documentation.d.ts 3.3 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112
  1. declare module BABYLON {
  2. /** Alias type for value that can be null */
  3. export type Nullable<T> = T | null;
  4. /**
  5. * Alias type for number that are floats
  6. * @ignorenaming
  7. */
  8. export type float = number;
  9. /**
  10. * Alias type for number that are doubles.
  11. * @ignorenaming
  12. */
  13. export type double = number;
  14. /**
  15. * Alias type for number that are integer
  16. * @ignorenaming
  17. */
  18. export type int = number;
  19. /** Alias type for number array or Float32Array */
  20. export type FloatArray = number[] | Float32Array;
  21. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  22. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  23. /**
  24. * Alias for types that can be used by a Buffer or VertexBuffer.
  25. */
  26. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  27. /**
  28. * Alias type for primitive types
  29. * @ignorenaming
  30. */
  31. type Primitive = undefined | null | boolean | string | number | Function;
  32. /**
  33. * Type modifier to make all the properties of an object Readonly
  34. */
  35. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  36. /**
  37. * Type modifier to make all the properties of an object Readonly recursively
  38. */
  39. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  40. /**
  41. * Type modifier to make object properties readonly.
  42. */
  43. export type DeepImmutableObject<T> = {
  44. readonly [K in keyof T]: DeepImmutable<T[K]>;
  45. };
  46. /** @hidden */
  47. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  48. }
  49. }
  50. declare module BABYLON {
  51. /**
  52. * A class serves as a medium between the observable and its observers
  53. */
  54. export class EventState {
  55. /**
  56. * Create a new EventState
  57. * @param mask defines the mask associated with this state
  58. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  59. * @param target defines the original target of the state
  60. * @param currentTarget defines the current target of the state
  61. */
  62. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  63. /**
  64. * Initialize the current event state
  65. * @param mask defines the mask associated with this state
  66. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  67. * @param target defines the original target of the state
  68. * @param currentTarget defines the current target of the state
  69. * @returns the current event state
  70. */
  71. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  72. /**
  73. * An Observer can set this property to true to prevent subsequent observers of being notified
  74. */
  75. skipNextObservers: boolean;
  76. /**
  77. * Get the mask value that were used to trigger the event corresponding to this EventState object
  78. */
  79. mask: number;
  80. /**
  81. * The object that originally notified the event
  82. */
  83. target?: any;
  84. /**
  85. * The current object in the bubbling phase
  86. */
  87. currentTarget?: any;
  88. /**
  89. * This will be populated with the return value of the last function that was executed.
  90. * If it is the first function in the callback chain it will be the event data.
  91. */
  92. lastReturnValue?: any;
  93. }
  94. /**
  95. * Represent an Observer registered to a given Observable object.
  96. */
  97. export class Observer<T> {
  98. /**
  99. * Defines the callback to call when the observer is notified
  100. */
  101. callback: (eventData: T, eventState: EventState) => void;
  102. /**
  103. * Defines the mask of the observer (used to filter notifications)
  104. */
  105. mask: number;
  106. /**
  107. * Defines the current scope used to restore the JS context
  108. */
  109. scope: any;
  110. /** @hidden */
  111. _willBeUnregistered: boolean;
  112. /**
  113. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  114. */
  115. unregisterOnNextCall: boolean;
  116. /**
  117. * Creates a new observer
  118. * @param callback defines the callback to call when the observer is notified
  119. * @param mask defines the mask of the observer (used to filter notifications)
  120. * @param scope defines the current scope used to restore the JS context
  121. */
  122. constructor(
  123. /**
  124. * Defines the callback to call when the observer is notified
  125. */
  126. callback: (eventData: T, eventState: EventState) => void,
  127. /**
  128. * Defines the mask of the observer (used to filter notifications)
  129. */
  130. mask: number,
  131. /**
  132. * Defines the current scope used to restore the JS context
  133. */
  134. scope?: any);
  135. }
  136. /**
  137. * Represent a list of observers registered to multiple Observables object.
  138. */
  139. export class MultiObserver<T> {
  140. private _observers;
  141. private _observables;
  142. /**
  143. * Release associated resources
  144. */
  145. dispose(): void;
  146. /**
  147. * Raise a callback when one of the observable will notify
  148. * @param observables defines a list of observables to watch
  149. * @param callback defines the callback to call on notification
  150. * @param mask defines the mask used to filter notifications
  151. * @param scope defines the current scope used to restore the JS context
  152. * @returns the new MultiObserver
  153. */
  154. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  155. }
  156. /**
  157. * The Observable class is a simple implementation of the Observable pattern.
  158. *
  159. * There's one slight particularity though: a given Observable can notify its observer using a particular mask value, only the Observers registered with this mask value will be notified.
  160. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  161. * For instance you may have a given Observable that have four different types of notifications: Move (mask = 0x01), Stop (mask = 0x02), Turn Right (mask = 0X04), Turn Left (mask = 0X08).
  162. * A given observer can register itself with only Move and Stop (mask = 0x03), then it will only be notified when one of these two occurs and will never be for Turn Left/Right.
  163. */
  164. export class Observable<T> {
  165. private _observers;
  166. private _eventState;
  167. private _onObserverAdded;
  168. /**
  169. * Gets the list of observers
  170. */
  171. get observers(): Array<Observer<T>>;
  172. /**
  173. * Creates a new observable
  174. * @param onObserverAdded defines a callback to call when a new observer is added
  175. */
  176. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  177. /**
  178. * Create a new Observer with the specified callback
  179. * @param callback the callback that will be executed for that Observer
  180. * @param mask the mask used to filter observers
  181. * @param insertFirst if true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present.
  182. * @param scope optional scope for the callback to be called from
  183. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  184. * @returns the new observer created for the callback
  185. */
  186. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  187. /**
  188. * Create a new Observer with the specified callback and unregisters after the next notification
  189. * @param callback the callback that will be executed for that Observer
  190. * @returns the new observer created for the callback
  191. */
  192. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  193. /**
  194. * Remove an Observer from the Observable object
  195. * @param observer the instance of the Observer to remove
  196. * @returns false if it doesn't belong to this Observable
  197. */
  198. remove(observer: Nullable<Observer<T>>): boolean;
  199. /**
  200. * Remove a callback from the Observable object
  201. * @param callback the callback to remove
  202. * @param scope optional scope. If used only the callbacks with this scope will be removed
  203. * @returns false if it doesn't belong to this Observable
  204. */
  205. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  206. private _deferUnregister;
  207. private _remove;
  208. /**
  209. * Moves the observable to the top of the observer list making it get called first when notified
  210. * @param observer the observer to move
  211. */
  212. makeObserverTopPriority(observer: Observer<T>): void;
  213. /**
  214. * Moves the observable to the bottom of the observer list making it get called last when notified
  215. * @param observer the observer to move
  216. */
  217. makeObserverBottomPriority(observer: Observer<T>): void;
  218. /**
  219. * Notify all Observers by calling their respective callback with the given data
  220. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  221. * @param eventData defines the data to send to all observers
  222. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  223. * @param target defines the original target of the state
  224. * @param currentTarget defines the current target of the state
  225. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  226. */
  227. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  228. /**
  229. * Calling this will execute each callback, expecting it to be a promise or return a value.
  230. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  231. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  232. * and it is crucial that all callbacks will be executed.
  233. * The order of the callbacks is kept, callbacks are not executed parallel.
  234. *
  235. * @param eventData The data to be sent to each callback
  236. * @param mask is used to filter observers defaults to -1
  237. * @param target defines the callback target (see EventState)
  238. * @param currentTarget defines he current object in the bubbling phase
  239. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  240. */
  241. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  242. /**
  243. * Notify a specific observer
  244. * @param observer defines the observer to notify
  245. * @param eventData defines the data to be sent to each callback
  246. * @param mask is used to filter observers defaults to -1
  247. */
  248. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  249. /**
  250. * Gets a boolean indicating if the observable has at least one observer
  251. * @returns true is the Observable has at least one Observer registered
  252. */
  253. hasObservers(): boolean;
  254. /**
  255. * Clear the list of observers
  256. */
  257. clear(): void;
  258. /**
  259. * Clone the current observable
  260. * @returns a new observable
  261. */
  262. clone(): Observable<T>;
  263. /**
  264. * Does this observable handles observer registered with a given mask
  265. * @param mask defines the mask to be tested
  266. * @return whether or not one observer registered with the given mask is handeled
  267. **/
  268. hasSpecificMask(mask?: number): boolean;
  269. }
  270. }
  271. declare module BABYLON {
  272. /**
  273. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  274. * Babylon.js
  275. */
  276. export class DomManagement {
  277. /**
  278. * Checks if the window object exists
  279. * @returns true if the window object exists
  280. */
  281. static IsWindowObjectExist(): boolean;
  282. /**
  283. * Checks if the navigator object exists
  284. * @returns true if the navigator object exists
  285. */
  286. static IsNavigatorAvailable(): boolean;
  287. /**
  288. * Extracts text content from a DOM element hierarchy
  289. * @param element defines the root element
  290. * @returns a string
  291. */
  292. static GetDOMTextContent(element: HTMLElement): string;
  293. }
  294. }
  295. declare module BABYLON {
  296. /**
  297. * Logger used througouht the application to allow configuration of
  298. * the log level required for the messages.
  299. */
  300. export class Logger {
  301. /**
  302. * No log
  303. */
  304. static readonly NoneLogLevel: number;
  305. /**
  306. * Only message logs
  307. */
  308. static readonly MessageLogLevel: number;
  309. /**
  310. * Only warning logs
  311. */
  312. static readonly WarningLogLevel: number;
  313. /**
  314. * Only error logs
  315. */
  316. static readonly ErrorLogLevel: number;
  317. /**
  318. * All logs
  319. */
  320. static readonly AllLogLevel: number;
  321. private static _LogCache;
  322. /**
  323. * Gets a value indicating the number of loading errors
  324. * @ignorenaming
  325. */
  326. static errorsCount: number;
  327. /**
  328. * Callback called when a new log is added
  329. */
  330. static OnNewCacheEntry: (entry: string) => void;
  331. private static _AddLogEntry;
  332. private static _FormatMessage;
  333. private static _LogDisabled;
  334. private static _LogEnabled;
  335. private static _WarnDisabled;
  336. private static _WarnEnabled;
  337. private static _ErrorDisabled;
  338. private static _ErrorEnabled;
  339. /**
  340. * Log a message to the console
  341. */
  342. static Log: (message: string) => void;
  343. /**
  344. * Write a warning message to the console
  345. */
  346. static Warn: (message: string) => void;
  347. /**
  348. * Write an error message to the console
  349. */
  350. static Error: (message: string) => void;
  351. /**
  352. * Gets current log cache (list of logs)
  353. */
  354. static get LogCache(): string;
  355. /**
  356. * Clears the log cache
  357. */
  358. static ClearLogCache(): void;
  359. /**
  360. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  361. */
  362. static set LogLevels(level: number);
  363. }
  364. }
  365. declare module BABYLON {
  366. /** @hidden */
  367. export class _TypeStore {
  368. /** @hidden */
  369. static RegisteredTypes: {
  370. [key: string]: Object;
  371. };
  372. /** @hidden */
  373. static GetClass(fqdn: string): any;
  374. }
  375. }
  376. declare module BABYLON {
  377. /**
  378. * Helper to manipulate strings
  379. */
  380. export class StringTools {
  381. /**
  382. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  383. * @param str Source string
  384. * @param suffix Suffix to search for in the source string
  385. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  386. */
  387. static EndsWith(str: string, suffix: string): boolean;
  388. /**
  389. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  390. * @param str Source string
  391. * @param suffix Suffix to search for in the source string
  392. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  393. */
  394. static StartsWith(str: string, suffix: string): boolean;
  395. /**
  396. * Decodes a buffer into a string
  397. * @param buffer The buffer to decode
  398. * @returns The decoded string
  399. */
  400. static Decode(buffer: Uint8Array | Uint16Array): string;
  401. /**
  402. * Encode a buffer to a base64 string
  403. * @param buffer defines the buffer to encode
  404. * @returns the encoded string
  405. */
  406. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  407. }
  408. }
  409. declare module BABYLON {
  410. /**
  411. * Class containing a set of static utilities functions for deep copy.
  412. */
  413. export class DeepCopier {
  414. /**
  415. * Tries to copy an object by duplicating every property
  416. * @param source defines the source object
  417. * @param destination defines the target object
  418. * @param doNotCopyList defines a list of properties to avoid
  419. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  420. */
  421. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  422. }
  423. }
  424. declare module BABYLON {
  425. /**
  426. * Class containing a set of static utilities functions for precision date
  427. */
  428. export class PrecisionDate {
  429. /**
  430. * Gets either window.performance.now() if supported or Date.now() else
  431. */
  432. static get Now(): number;
  433. }
  434. }
  435. declare module BABYLON {
  436. /** @hidden */
  437. export class _DevTools {
  438. static WarnImport(name: string): string;
  439. }
  440. }
  441. declare module BABYLON {
  442. /**
  443. * Interface used to define the mechanism to get data from the network
  444. */
  445. export interface IWebRequest {
  446. /**
  447. * Returns client's response url
  448. */
  449. responseURL: string;
  450. /**
  451. * Returns client's status
  452. */
  453. status: number;
  454. /**
  455. * Returns client's status as a text
  456. */
  457. statusText: string;
  458. }
  459. }
  460. declare module BABYLON {
  461. /**
  462. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  463. */
  464. export class WebRequest implements IWebRequest {
  465. private _xhr;
  466. /**
  467. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  468. * i.e. when loading files, where the server/service expects an Authorization header
  469. */
  470. static CustomRequestHeaders: {
  471. [key: string]: string;
  472. };
  473. /**
  474. * Add callback functions in this array to update all the requests before they get sent to the network
  475. */
  476. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  477. private _injectCustomRequestHeaders;
  478. /**
  479. * Gets or sets a function to be called when loading progress changes
  480. */
  481. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  482. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  483. /**
  484. * Returns client's state
  485. */
  486. get readyState(): number;
  487. /**
  488. * Returns client's status
  489. */
  490. get status(): number;
  491. /**
  492. * Returns client's status as a text
  493. */
  494. get statusText(): string;
  495. /**
  496. * Returns client's response
  497. */
  498. get response(): any;
  499. /**
  500. * Returns client's response url
  501. */
  502. get responseURL(): string;
  503. /**
  504. * Returns client's response as text
  505. */
  506. get responseText(): string;
  507. /**
  508. * Gets or sets the expected response type
  509. */
  510. get responseType(): XMLHttpRequestResponseType;
  511. set responseType(value: XMLHttpRequestResponseType);
  512. /** @hidden */
  513. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  514. /** @hidden */
  515. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  516. /**
  517. * Cancels any network activity
  518. */
  519. abort(): void;
  520. /**
  521. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  522. * @param body defines an optional request body
  523. */
  524. send(body?: Document | BodyInit | null): void;
  525. /**
  526. * Sets the request method, request URL
  527. * @param method defines the method to use (GET, POST, etc..)
  528. * @param url defines the url to connect with
  529. */
  530. open(method: string, url: string): void;
  531. /**
  532. * Sets the value of a request header.
  533. * @param name The name of the header whose value is to be set
  534. * @param value The value to set as the body of the header
  535. */
  536. setRequestHeader(name: string, value: string): void;
  537. /**
  538. * Get the string containing the text of a particular header's value.
  539. * @param name The name of the header
  540. * @returns The string containing the text of the given header name
  541. */
  542. getResponseHeader(name: string): Nullable<string>;
  543. }
  544. }
  545. declare module BABYLON {
  546. /**
  547. * File request interface
  548. */
  549. export interface IFileRequest {
  550. /**
  551. * Raised when the request is complete (success or error).
  552. */
  553. onCompleteObservable: Observable<IFileRequest>;
  554. /**
  555. * Aborts the request for a file.
  556. */
  557. abort: () => void;
  558. }
  559. }
  560. declare module BABYLON {
  561. /**
  562. * Define options used to create a render target texture
  563. */
  564. export class RenderTargetCreationOptions {
  565. /**
  566. * Specifies is mipmaps must be generated
  567. */
  568. generateMipMaps?: boolean;
  569. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  570. generateDepthBuffer?: boolean;
  571. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  572. generateStencilBuffer?: boolean;
  573. /** Defines texture type (int by default) */
  574. type?: number;
  575. /** Defines sampling mode (trilinear by default) */
  576. samplingMode?: number;
  577. /** Defines format (RGBA by default) */
  578. format?: number;
  579. }
  580. }
  581. declare module BABYLON {
  582. /** Defines the cross module used constants to avoid circular dependncies */
  583. export class Constants {
  584. /** Defines that alpha blending is disabled */
  585. static readonly ALPHA_DISABLE: number;
  586. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  587. static readonly ALPHA_ADD: number;
  588. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  589. static readonly ALPHA_COMBINE: number;
  590. /** Defines that alpha blending is DEST - SRC * DEST */
  591. static readonly ALPHA_SUBTRACT: number;
  592. /** Defines that alpha blending is SRC * DEST */
  593. static readonly ALPHA_MULTIPLY: number;
  594. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  595. static readonly ALPHA_MAXIMIZED: number;
  596. /** Defines that alpha blending is SRC + DEST */
  597. static readonly ALPHA_ONEONE: number;
  598. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  599. static readonly ALPHA_PREMULTIPLIED: number;
  600. /**
  601. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  602. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  603. */
  604. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  605. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  606. static readonly ALPHA_INTERPOLATE: number;
  607. /**
  608. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  609. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  610. */
  611. static readonly ALPHA_SCREENMODE: number;
  612. /**
  613. * Defines that alpha blending is SRC + DST
  614. * Alpha will be set to SRC ALPHA + DST ALPHA
  615. */
  616. static readonly ALPHA_ONEONE_ONEONE: number;
  617. /**
  618. * Defines that alpha blending is SRC * DST ALPHA + DST
  619. * Alpha will be set to 0
  620. */
  621. static readonly ALPHA_ALPHATOCOLOR: number;
  622. /**
  623. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  624. */
  625. static readonly ALPHA_REVERSEONEMINUS: number;
  626. /**
  627. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  628. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  629. */
  630. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  631. /**
  632. * Defines that alpha blending is SRC + DST
  633. * Alpha will be set to SRC ALPHA
  634. */
  635. static readonly ALPHA_ONEONE_ONEZERO: number;
  636. /**
  637. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  638. * Alpha will be set to DST ALPHA
  639. */
  640. static readonly ALPHA_EXCLUSION: number;
  641. /** Defines that alpha blending equation a SUM */
  642. static readonly ALPHA_EQUATION_ADD: number;
  643. /** Defines that alpha blending equation a SUBSTRACTION */
  644. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  645. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  646. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  647. /** Defines that alpha blending equation a MAX operation */
  648. static readonly ALPHA_EQUATION_MAX: number;
  649. /** Defines that alpha blending equation a MIN operation */
  650. static readonly ALPHA_EQUATION_MIN: number;
  651. /**
  652. * Defines that alpha blending equation a DARKEN operation:
  653. * It takes the min of the src and sums the alpha channels.
  654. */
  655. static readonly ALPHA_EQUATION_DARKEN: number;
  656. /** Defines that the ressource is not delayed*/
  657. static readonly DELAYLOADSTATE_NONE: number;
  658. /** Defines that the ressource was successfully delay loaded */
  659. static readonly DELAYLOADSTATE_LOADED: number;
  660. /** Defines that the ressource is currently delay loading */
  661. static readonly DELAYLOADSTATE_LOADING: number;
  662. /** Defines that the ressource is delayed and has not started loading */
  663. static readonly DELAYLOADSTATE_NOTLOADED: number;
  664. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  665. static readonly NEVER: number;
  666. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  667. static readonly ALWAYS: number;
  668. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  669. static readonly LESS: number;
  670. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  671. static readonly EQUAL: number;
  672. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than or equal to the stored value */
  673. static readonly LEQUAL: number;
  674. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  675. static readonly GREATER: number;
  676. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than or equal to the stored value */
  677. static readonly GEQUAL: number;
  678. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is not equal to the stored value */
  679. static readonly NOTEQUAL: number;
  680. /** Passed to stencilOperation to specify that stencil value must be kept */
  681. static readonly KEEP: number;
  682. /** Passed to stencilOperation to specify that stencil value must be replaced */
  683. static readonly REPLACE: number;
  684. /** Passed to stencilOperation to specify that stencil value must be incremented */
  685. static readonly INCR: number;
  686. /** Passed to stencilOperation to specify that stencil value must be decremented */
  687. static readonly DECR: number;
  688. /** Passed to stencilOperation to specify that stencil value must be inverted */
  689. static readonly INVERT: number;
  690. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  691. static readonly INCR_WRAP: number;
  692. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  693. static readonly DECR_WRAP: number;
  694. /** Texture is not repeating outside of 0..1 UVs */
  695. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  696. /** Texture is repeating outside of 0..1 UVs */
  697. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  698. /** Texture is repeating and mirrored */
  699. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  700. /** ALPHA */
  701. static readonly TEXTUREFORMAT_ALPHA: number;
  702. /** LUMINANCE */
  703. static readonly TEXTUREFORMAT_LUMINANCE: number;
  704. /** LUMINANCE_ALPHA */
  705. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  706. /** RGB */
  707. static readonly TEXTUREFORMAT_RGB: number;
  708. /** RGBA */
  709. static readonly TEXTUREFORMAT_RGBA: number;
  710. /** RED */
  711. static readonly TEXTUREFORMAT_RED: number;
  712. /** RED (2nd reference) */
  713. static readonly TEXTUREFORMAT_R: number;
  714. /** RG */
  715. static readonly TEXTUREFORMAT_RG: number;
  716. /** RED_INTEGER */
  717. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  718. /** RED_INTEGER (2nd reference) */
  719. static readonly TEXTUREFORMAT_R_INTEGER: number;
  720. /** RG_INTEGER */
  721. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  722. /** RGB_INTEGER */
  723. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  724. /** RGBA_INTEGER */
  725. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  726. /** UNSIGNED_BYTE */
  727. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  728. /** UNSIGNED_BYTE (2nd reference) */
  729. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  730. /** FLOAT */
  731. static readonly TEXTURETYPE_FLOAT: number;
  732. /** HALF_FLOAT */
  733. static readonly TEXTURETYPE_HALF_FLOAT: number;
  734. /** BYTE */
  735. static readonly TEXTURETYPE_BYTE: number;
  736. /** SHORT */
  737. static readonly TEXTURETYPE_SHORT: number;
  738. /** UNSIGNED_SHORT */
  739. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  740. /** INT */
  741. static readonly TEXTURETYPE_INT: number;
  742. /** UNSIGNED_INT */
  743. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  744. /** UNSIGNED_SHORT_4_4_4_4 */
  745. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  746. /** UNSIGNED_SHORT_5_5_5_1 */
  747. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  748. /** UNSIGNED_SHORT_5_6_5 */
  749. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  750. /** UNSIGNED_INT_2_10_10_10_REV */
  751. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  752. /** UNSIGNED_INT_24_8 */
  753. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  754. /** UNSIGNED_INT_10F_11F_11F_REV */
  755. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  756. /** UNSIGNED_INT_5_9_9_9_REV */
  757. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  758. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  759. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  760. /** nearest is mag = nearest and min = nearest and no mip */
  761. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  762. /** mag = nearest and min = nearest and mip = none */
  763. static readonly TEXTURE_NEAREST_NEAREST: number;
  764. /** Bilinear is mag = linear and min = linear and no mip */
  765. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  766. /** mag = linear and min = linear and mip = none */
  767. static readonly TEXTURE_LINEAR_LINEAR: number;
  768. /** Trilinear is mag = linear and min = linear and mip = linear */
  769. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  770. /** Trilinear is mag = linear and min = linear and mip = linear */
  771. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  772. /** mag = nearest and min = nearest and mip = nearest */
  773. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  774. /** mag = nearest and min = linear and mip = nearest */
  775. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  776. /** mag = nearest and min = linear and mip = linear */
  777. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  778. /** mag = nearest and min = linear and mip = none */
  779. static readonly TEXTURE_NEAREST_LINEAR: number;
  780. /** nearest is mag = nearest and min = nearest and mip = linear */
  781. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  782. /** mag = linear and min = nearest and mip = nearest */
  783. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  784. /** mag = linear and min = nearest and mip = linear */
  785. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  786. /** Bilinear is mag = linear and min = linear and mip = nearest */
  787. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  788. /** mag = linear and min = nearest and mip = none */
  789. static readonly TEXTURE_LINEAR_NEAREST: number;
  790. /** Explicit coordinates mode */
  791. static readonly TEXTURE_EXPLICIT_MODE: number;
  792. /** Spherical coordinates mode */
  793. static readonly TEXTURE_SPHERICAL_MODE: number;
  794. /** Planar coordinates mode */
  795. static readonly TEXTURE_PLANAR_MODE: number;
  796. /** Cubic coordinates mode */
  797. static readonly TEXTURE_CUBIC_MODE: number;
  798. /** Projection coordinates mode */
  799. static readonly TEXTURE_PROJECTION_MODE: number;
  800. /** Skybox coordinates mode */
  801. static readonly TEXTURE_SKYBOX_MODE: number;
  802. /** Inverse Cubic coordinates mode */
  803. static readonly TEXTURE_INVCUBIC_MODE: number;
  804. /** Equirectangular coordinates mode */
  805. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  806. /** Equirectangular Fixed coordinates mode */
  807. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  808. /** Equirectangular Fixed Mirrored coordinates mode */
  809. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  810. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  811. static readonly SCALEMODE_FLOOR: number;
  812. /** Defines that texture rescaling will look for the nearest power of 2 size */
  813. static readonly SCALEMODE_NEAREST: number;
  814. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  815. static readonly SCALEMODE_CEILING: number;
  816. /**
  817. * The dirty texture flag value
  818. */
  819. static readonly MATERIAL_TextureDirtyFlag: number;
  820. /**
  821. * The dirty light flag value
  822. */
  823. static readonly MATERIAL_LightDirtyFlag: number;
  824. /**
  825. * The dirty fresnel flag value
  826. */
  827. static readonly MATERIAL_FresnelDirtyFlag: number;
  828. /**
  829. * The dirty attribute flag value
  830. */
  831. static readonly MATERIAL_AttributesDirtyFlag: number;
  832. /**
  833. * The dirty misc flag value
  834. */
  835. static readonly MATERIAL_MiscDirtyFlag: number;
  836. /**
  837. * The all dirty flag value
  838. */
  839. static readonly MATERIAL_AllDirtyFlag: number;
  840. /**
  841. * Returns the triangle fill mode
  842. */
  843. static readonly MATERIAL_TriangleFillMode: number;
  844. /**
  845. * Returns the wireframe mode
  846. */
  847. static readonly MATERIAL_WireFrameFillMode: number;
  848. /**
  849. * Returns the point fill mode
  850. */
  851. static readonly MATERIAL_PointFillMode: number;
  852. /**
  853. * Returns the point list draw mode
  854. */
  855. static readonly MATERIAL_PointListDrawMode: number;
  856. /**
  857. * Returns the line list draw mode
  858. */
  859. static readonly MATERIAL_LineListDrawMode: number;
  860. /**
  861. * Returns the line loop draw mode
  862. */
  863. static readonly MATERIAL_LineLoopDrawMode: number;
  864. /**
  865. * Returns the line strip draw mode
  866. */
  867. static readonly MATERIAL_LineStripDrawMode: number;
  868. /**
  869. * Returns the triangle strip draw mode
  870. */
  871. static readonly MATERIAL_TriangleStripDrawMode: number;
  872. /**
  873. * Returns the triangle fan draw mode
  874. */
  875. static readonly MATERIAL_TriangleFanDrawMode: number;
  876. /**
  877. * Stores the clock-wise side orientation
  878. */
  879. static readonly MATERIAL_ClockWiseSideOrientation: number;
  880. /**
  881. * Stores the counter clock-wise side orientation
  882. */
  883. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  884. /**
  885. * Nothing
  886. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  887. */
  888. static readonly ACTION_NothingTrigger: number;
  889. /**
  890. * On pick
  891. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  892. */
  893. static readonly ACTION_OnPickTrigger: number;
  894. /**
  895. * On left pick
  896. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  897. */
  898. static readonly ACTION_OnLeftPickTrigger: number;
  899. /**
  900. * On right pick
  901. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  902. */
  903. static readonly ACTION_OnRightPickTrigger: number;
  904. /**
  905. * On center pick
  906. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  907. */
  908. static readonly ACTION_OnCenterPickTrigger: number;
  909. /**
  910. * On pick down
  911. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  912. */
  913. static readonly ACTION_OnPickDownTrigger: number;
  914. /**
  915. * On double pick
  916. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  917. */
  918. static readonly ACTION_OnDoublePickTrigger: number;
  919. /**
  920. * On pick up
  921. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  922. */
  923. static readonly ACTION_OnPickUpTrigger: number;
  924. /**
  925. * On pick out.
  926. * This trigger will only be raised if you also declared a OnPickDown
  927. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  928. */
  929. static readonly ACTION_OnPickOutTrigger: number;
  930. /**
  931. * On long press
  932. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  933. */
  934. static readonly ACTION_OnLongPressTrigger: number;
  935. /**
  936. * On pointer over
  937. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  938. */
  939. static readonly ACTION_OnPointerOverTrigger: number;
  940. /**
  941. * On pointer out
  942. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  943. */
  944. static readonly ACTION_OnPointerOutTrigger: number;
  945. /**
  946. * On every frame
  947. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  948. */
  949. static readonly ACTION_OnEveryFrameTrigger: number;
  950. /**
  951. * On intersection enter
  952. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  953. */
  954. static readonly ACTION_OnIntersectionEnterTrigger: number;
  955. /**
  956. * On intersection exit
  957. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  958. */
  959. static readonly ACTION_OnIntersectionExitTrigger: number;
  960. /**
  961. * On key down
  962. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  963. */
  964. static readonly ACTION_OnKeyDownTrigger: number;
  965. /**
  966. * On key up
  967. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  968. */
  969. static readonly ACTION_OnKeyUpTrigger: number;
  970. /**
  971. * Billboard mode will only apply to Y axis
  972. */
  973. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  974. /**
  975. * Billboard mode will apply to all axes
  976. */
  977. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  978. /**
  979. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  980. */
  981. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  982. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  983. * Test order :
  984. * Is the bounding sphere outside the frustum ?
  985. * If not, are the bounding box vertices outside the frustum ?
  986. * It not, then the cullable object is in the frustum.
  987. */
  988. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  989. /** Culling strategy : Bounding Sphere Only.
  990. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  991. * It's also less accurate than the standard because some not visible objects can still be selected.
  992. * Test : is the bounding sphere outside the frustum ?
  993. * If not, then the cullable object is in the frustum.
  994. */
  995. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  996. /** Culling strategy : Optimistic Inclusion.
  997. * This in an inclusion test first, then the standard exclusion test.
  998. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  999. * This could also be a little slower than the standard test when the tested object center is not the frustum but one of its bounding box vertex is still inside.
  1000. * Anyway, it's as accurate as the standard strategy.
  1001. * Test :
  1002. * Is the cullable object bounding sphere center in the frustum ?
  1003. * If not, apply the default culling strategy.
  1004. */
  1005. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  1006. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  1007. * This in an inclusion test first, then the bounding sphere only exclusion test.
  1008. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  1009. * This could also be a little slower than the BoundingSphereOnly strategy when the tested object center is not in the frustum but its bounding sphere still intersects it.
  1010. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  1011. * Test :
  1012. * Is the cullable object bounding sphere center in the frustum ?
  1013. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  1014. */
  1015. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  1016. /**
  1017. * No logging while loading
  1018. */
  1019. static readonly SCENELOADER_NO_LOGGING: number;
  1020. /**
  1021. * Minimal logging while loading
  1022. */
  1023. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  1024. /**
  1025. * Summary logging while loading
  1026. */
  1027. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  1028. /**
  1029. * Detailled logging while loading
  1030. */
  1031. static readonly SCENELOADER_DETAILED_LOGGING: number;
  1032. }
  1033. }
  1034. declare module BABYLON {
  1035. /**
  1036. * This represents the required contract to create a new type of texture loader.
  1037. */
  1038. export interface IInternalTextureLoader {
  1039. /**
  1040. * Defines wether the loader supports cascade loading the different faces.
  1041. */
  1042. supportCascades: boolean;
  1043. /**
  1044. * This returns if the loader support the current file information.
  1045. * @param extension defines the file extension of the file being loaded
  1046. * @param textureFormatInUse defines the current compressed format in use iun the engine
  1047. * @param fallback defines the fallback internal texture if any
  1048. * @param isBase64 defines whether the texture is encoded as a base64
  1049. * @param isBuffer defines whether the texture data are stored as a buffer
  1050. * @returns true if the loader can load the specified file
  1051. */
  1052. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  1053. /**
  1054. * Transform the url before loading if required.
  1055. * @param rootUrl the url of the texture
  1056. * @param textureFormatInUse defines the current compressed format in use iun the engine
  1057. * @returns the transformed texture
  1058. */
  1059. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  1060. /**
  1061. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  1062. * @param rootUrl the url of the texture
  1063. * @param textureFormatInUse defines the current compressed format in use iun the engine
  1064. * @returns the fallback texture
  1065. */
  1066. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  1067. /**
  1068. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  1069. * @param data contains the texture data
  1070. * @param texture defines the BabylonJS internal texture
  1071. * @param createPolynomials will be true if polynomials have been requested
  1072. * @param onLoad defines the callback to trigger once the texture is ready
  1073. * @param onError defines the callback to trigger in case of error
  1074. */
  1075. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  1076. /**
  1077. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  1078. * @param data contains the texture data
  1079. * @param texture defines the BabylonJS internal texture
  1080. * @param callback defines the method to call once ready to upload
  1081. */
  1082. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  1083. }
  1084. }
  1085. declare module BABYLON {
  1086. /**
  1087. * Class used to store and describe the pipeline context associated with an effect
  1088. */
  1089. export interface IPipelineContext {
  1090. /**
  1091. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1092. */
  1093. isAsync: boolean;
  1094. /**
  1095. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1096. */
  1097. isReady: boolean;
  1098. /** @hidden */
  1099. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1100. }
  1101. }
  1102. declare module BABYLON {
  1103. /**
  1104. * Class used to store gfx data (like WebGLBuffer)
  1105. */
  1106. export class DataBuffer {
  1107. /**
  1108. * Gets or sets the number of objects referencing this buffer
  1109. */
  1110. references: number;
  1111. /** Gets or sets the size of the underlying buffer */
  1112. capacity: number;
  1113. /**
  1114. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1115. */
  1116. is32Bits: boolean;
  1117. /**
  1118. * Gets the underlying buffer
  1119. */
  1120. get underlyingResource(): any;
  1121. }
  1122. }
  1123. declare module BABYLON {
  1124. /** @hidden */
  1125. export interface IShaderProcessor {
  1126. attributeProcessor?: (attribute: string) => string;
  1127. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  1128. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  1129. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  1130. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  1131. lineProcessor?: (line: string, isFragment: boolean) => string;
  1132. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1133. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1134. }
  1135. }
  1136. declare module BABYLON {
  1137. /** @hidden */
  1138. export interface ProcessingOptions {
  1139. defines: string[];
  1140. indexParameters: any;
  1141. isFragment: boolean;
  1142. shouldUseHighPrecisionShader: boolean;
  1143. supportsUniformBuffers: boolean;
  1144. shadersRepository: string;
  1145. includesShadersStore: {
  1146. [key: string]: string;
  1147. };
  1148. processor?: IShaderProcessor;
  1149. version: string;
  1150. platformName: string;
  1151. lookForClosingBracketForUniformBuffer?: boolean;
  1152. }
  1153. }
  1154. declare module BABYLON {
  1155. /** @hidden */
  1156. export class ShaderCodeNode {
  1157. line: string;
  1158. children: ShaderCodeNode[];
  1159. additionalDefineKey?: string;
  1160. additionalDefineValue?: string;
  1161. isValid(preprocessors: {
  1162. [key: string]: string;
  1163. }): boolean;
  1164. process(preprocessors: {
  1165. [key: string]: string;
  1166. }, options: ProcessingOptions): string;
  1167. }
  1168. }
  1169. declare module BABYLON {
  1170. /** @hidden */
  1171. export class ShaderCodeCursor {
  1172. private _lines;
  1173. lineIndex: number;
  1174. get currentLine(): string;
  1175. get canRead(): boolean;
  1176. set lines(value: string[]);
  1177. }
  1178. }
  1179. declare module BABYLON {
  1180. /** @hidden */
  1181. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1182. process(preprocessors: {
  1183. [key: string]: string;
  1184. }, options: ProcessingOptions): string;
  1185. }
  1186. }
  1187. declare module BABYLON {
  1188. /** @hidden */
  1189. export class ShaderDefineExpression {
  1190. isTrue(preprocessors: {
  1191. [key: string]: string;
  1192. }): boolean;
  1193. }
  1194. }
  1195. declare module BABYLON {
  1196. /** @hidden */
  1197. export class ShaderCodeTestNode extends ShaderCodeNode {
  1198. testExpression: ShaderDefineExpression;
  1199. isValid(preprocessors: {
  1200. [key: string]: string;
  1201. }): boolean;
  1202. }
  1203. }
  1204. declare module BABYLON {
  1205. /** @hidden */
  1206. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1207. define: string;
  1208. not: boolean;
  1209. constructor(define: string, not?: boolean);
  1210. isTrue(preprocessors: {
  1211. [key: string]: string;
  1212. }): boolean;
  1213. }
  1214. }
  1215. declare module BABYLON {
  1216. /** @hidden */
  1217. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1218. leftOperand: ShaderDefineExpression;
  1219. rightOperand: ShaderDefineExpression;
  1220. isTrue(preprocessors: {
  1221. [key: string]: string;
  1222. }): boolean;
  1223. }
  1224. }
  1225. declare module BABYLON {
  1226. /** @hidden */
  1227. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1228. leftOperand: ShaderDefineExpression;
  1229. rightOperand: ShaderDefineExpression;
  1230. isTrue(preprocessors: {
  1231. [key: string]: string;
  1232. }): boolean;
  1233. }
  1234. }
  1235. declare module BABYLON {
  1236. /** @hidden */
  1237. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1238. define: string;
  1239. operand: string;
  1240. testValue: string;
  1241. constructor(define: string, operand: string, testValue: string);
  1242. isTrue(preprocessors: {
  1243. [key: string]: string;
  1244. }): boolean;
  1245. }
  1246. }
  1247. declare module BABYLON {
  1248. /**
  1249. * Class used to enable access to offline support
  1250. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1251. */
  1252. export interface IOfflineProvider {
  1253. /**
  1254. * Gets a boolean indicating if scene must be saved in the database
  1255. */
  1256. enableSceneOffline: boolean;
  1257. /**
  1258. * Gets a boolean indicating if textures must be saved in the database
  1259. */
  1260. enableTexturesOffline: boolean;
  1261. /**
  1262. * Open the offline support and make it available
  1263. * @param successCallback defines the callback to call on success
  1264. * @param errorCallback defines the callback to call on error
  1265. */
  1266. open(successCallback: () => void, errorCallback: () => void): void;
  1267. /**
  1268. * Loads an image from the offline support
  1269. * @param url defines the url to load from
  1270. * @param image defines the target DOM image
  1271. */
  1272. loadImage(url: string, image: HTMLImageElement): void;
  1273. /**
  1274. * Loads a file from offline support
  1275. * @param url defines the URL to load from
  1276. * @param sceneLoaded defines a callback to call on success
  1277. * @param progressCallBack defines a callback to call when progress changed
  1278. * @param errorCallback defines a callback to call on error
  1279. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1280. */
  1281. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1282. }
  1283. }
  1284. declare module BABYLON {
  1285. /**
  1286. * Class used to help managing file picking and drag'n'drop
  1287. * File Storage
  1288. */
  1289. export class FilesInputStore {
  1290. /**
  1291. * List of files ready to be loaded
  1292. */
  1293. static FilesToLoad: {
  1294. [key: string]: File;
  1295. };
  1296. }
  1297. }
  1298. declare module BABYLON {
  1299. /**
  1300. * Class used to define a retry strategy when error happens while loading assets
  1301. */
  1302. export class RetryStrategy {
  1303. /**
  1304. * Function used to defines an exponential back off strategy
  1305. * @param maxRetries defines the maximum number of retries (3 by default)
  1306. * @param baseInterval defines the interval between retries
  1307. * @returns the strategy function to use
  1308. */
  1309. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1310. }
  1311. }
  1312. declare module BABYLON {
  1313. /**
  1314. * @ignore
  1315. * Application error to support additional information when loading a file
  1316. */
  1317. export abstract class BaseError extends Error {
  1318. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  1319. }
  1320. }
  1321. declare module BABYLON {
  1322. /** @ignore */
  1323. export class LoadFileError extends BaseError {
  1324. request?: WebRequest;
  1325. file?: File;
  1326. /**
  1327. * Creates a new LoadFileError
  1328. * @param message defines the message of the error
  1329. * @param request defines the optional web request
  1330. * @param file defines the optional file
  1331. */
  1332. constructor(message: string, object?: WebRequest | File);
  1333. }
  1334. /** @ignore */
  1335. export class RequestFileError extends BaseError {
  1336. request: WebRequest;
  1337. /**
  1338. * Creates a new LoadFileError
  1339. * @param message defines the message of the error
  1340. * @param request defines the optional web request
  1341. */
  1342. constructor(message: string, request: WebRequest);
  1343. }
  1344. /** @ignore */
  1345. export class ReadFileError extends BaseError {
  1346. file: File;
  1347. /**
  1348. * Creates a new ReadFileError
  1349. * @param message defines the message of the error
  1350. * @param file defines the optional file
  1351. */
  1352. constructor(message: string, file: File);
  1353. }
  1354. /**
  1355. * @hidden
  1356. */
  1357. export class FileTools {
  1358. /**
  1359. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1360. */
  1361. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1362. /**
  1363. * Gets or sets the base URL to use to load assets
  1364. */
  1365. static BaseUrl: string;
  1366. /**
  1367. * Default behaviour for cors in the application.
  1368. * It can be a string if the expected behavior is identical in the entire app.
  1369. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1370. */
  1371. static CorsBehavior: string | ((url: string | string[]) => string);
  1372. /**
  1373. * Gets or sets a function used to pre-process url before using them to load assets
  1374. */
  1375. static PreprocessUrl: (url: string) => string;
  1376. /**
  1377. * Removes unwanted characters from an url
  1378. * @param url defines the url to clean
  1379. * @returns the cleaned url
  1380. */
  1381. private static _CleanUrl;
  1382. /**
  1383. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1384. * @param url define the url we are trying
  1385. * @param element define the dom element where to configure the cors policy
  1386. */
  1387. static SetCorsBehavior(url: string | string[], element: {
  1388. crossOrigin: string | null;
  1389. }): void;
  1390. /**
  1391. * Loads an image as an HTMLImageElement.
  1392. * @param input url string, ArrayBuffer, or Blob to load
  1393. * @param onLoad callback called when the image successfully loads
  1394. * @param onError callback called when the image fails to load
  1395. * @param offlineProvider offline provider for caching
  1396. * @param mimeType optional mime type
  1397. * @returns the HTMLImageElement of the loaded image
  1398. */
  1399. static LoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  1400. /**
  1401. * Reads a file from a File object
  1402. * @param file defines the file to load
  1403. * @param onSuccess defines the callback to call when data is loaded
  1404. * @param onProgress defines the callback to call during loading process
  1405. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1406. * @param onError defines the callback to call when an error occurs
  1407. * @returns a file request object
  1408. */
  1409. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  1410. /**
  1411. * Loads a file from a url
  1412. * @param url url to load
  1413. * @param onSuccess callback called when the file successfully loads
  1414. * @param onProgress callback called while file is loading (if the server supports this mode)
  1415. * @param offlineProvider defines the offline provider for caching
  1416. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1417. * @param onError callback called when the file fails to load
  1418. * @returns a file request object
  1419. */
  1420. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  1421. /**
  1422. * Loads a file
  1423. * @param url url to load
  1424. * @param onSuccess callback called when the file successfully loads
  1425. * @param onProgress callback called while file is loading (if the server supports this mode)
  1426. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1427. * @param onError callback called when the file fails to load
  1428. * @param onOpened callback called when the web request is opened
  1429. * @returns a file request object
  1430. */
  1431. static RequestFile(url: string, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, onProgress?: (event: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  1432. /**
  1433. * Checks if the loaded document was accessed via `file:`-Protocol.
  1434. * @returns boolean
  1435. */
  1436. static IsFileURL(): boolean;
  1437. }
  1438. }
  1439. declare module BABYLON {
  1440. /** @hidden */
  1441. export class ShaderProcessor {
  1442. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  1443. private static _ProcessPrecision;
  1444. private static _ExtractOperation;
  1445. private static _BuildSubExpression;
  1446. private static _BuildExpression;
  1447. private static _MoveCursorWithinIf;
  1448. private static _MoveCursor;
  1449. private static _EvaluatePreProcessors;
  1450. private static _PreparePreProcessors;
  1451. private static _ProcessShaderConversion;
  1452. private static _ProcessIncludes;
  1453. /**
  1454. * Loads a file from a url
  1455. * @param url url to load
  1456. * @param onSuccess callback called when the file successfully loads
  1457. * @param onProgress callback called while file is loading (if the server supports this mode)
  1458. * @param offlineProvider defines the offline provider for caching
  1459. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1460. * @param onError callback called when the file fails to load
  1461. * @returns a file request object
  1462. * @hidden
  1463. */
  1464. static _FileToolsLoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  1465. }
  1466. }
  1467. declare module BABYLON {
  1468. /**
  1469. * @hidden
  1470. */
  1471. export interface IColor4Like {
  1472. r: float;
  1473. g: float;
  1474. b: float;
  1475. a: float;
  1476. }
  1477. /**
  1478. * @hidden
  1479. */
  1480. export interface IColor3Like {
  1481. r: float;
  1482. g: float;
  1483. b: float;
  1484. }
  1485. /**
  1486. * @hidden
  1487. */
  1488. export interface IVector4Like {
  1489. x: float;
  1490. y: float;
  1491. z: float;
  1492. w: float;
  1493. }
  1494. /**
  1495. * @hidden
  1496. */
  1497. export interface IVector3Like {
  1498. x: float;
  1499. y: float;
  1500. z: float;
  1501. }
  1502. /**
  1503. * @hidden
  1504. */
  1505. export interface IVector2Like {
  1506. x: float;
  1507. y: float;
  1508. }
  1509. /**
  1510. * @hidden
  1511. */
  1512. export interface IMatrixLike {
  1513. toArray(): DeepImmutable<Float32Array>;
  1514. updateFlag: int;
  1515. }
  1516. /**
  1517. * @hidden
  1518. */
  1519. export interface IViewportLike {
  1520. x: float;
  1521. y: float;
  1522. width: float;
  1523. height: float;
  1524. }
  1525. /**
  1526. * @hidden
  1527. */
  1528. export interface IPlaneLike {
  1529. normal: IVector3Like;
  1530. d: float;
  1531. normalize(): void;
  1532. }
  1533. }
  1534. declare module BABYLON {
  1535. /**
  1536. * Interface used to define common properties for effect fallbacks
  1537. */
  1538. export interface IEffectFallbacks {
  1539. /**
  1540. * Removes the defines that should be removed when falling back.
  1541. * @param currentDefines defines the current define statements for the shader.
  1542. * @param effect defines the current effect we try to compile
  1543. * @returns The resulting defines with defines of the current rank removed.
  1544. */
  1545. reduce(currentDefines: string, effect: Effect): string;
  1546. /**
  1547. * Removes the fallback from the bound mesh.
  1548. */
  1549. unBindMesh(): void;
  1550. /**
  1551. * Checks to see if more fallbacks are still availible.
  1552. */
  1553. hasMoreFallbacks: boolean;
  1554. }
  1555. }
  1556. declare module BABYLON {
  1557. /**
  1558. * Class used to evalaute queries containing `and` and `or` operators
  1559. */
  1560. export class AndOrNotEvaluator {
  1561. /**
  1562. * Evaluate a query
  1563. * @param query defines the query to evaluate
  1564. * @param evaluateCallback defines the callback used to filter result
  1565. * @returns true if the query matches
  1566. */
  1567. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  1568. private static _HandleParenthesisContent;
  1569. private static _SimplifyNegation;
  1570. }
  1571. }
  1572. declare module BABYLON {
  1573. /**
  1574. * Class used to store custom tags
  1575. */
  1576. export class Tags {
  1577. /**
  1578. * Adds support for tags on the given object
  1579. * @param obj defines the object to use
  1580. */
  1581. static EnableFor(obj: any): void;
  1582. /**
  1583. * Removes tags support
  1584. * @param obj defines the object to use
  1585. */
  1586. static DisableFor(obj: any): void;
  1587. /**
  1588. * Gets a boolean indicating if the given object has tags
  1589. * @param obj defines the object to use
  1590. * @returns a boolean
  1591. */
  1592. static HasTags(obj: any): boolean;
  1593. /**
  1594. * Gets the tags available on a given object
  1595. * @param obj defines the object to use
  1596. * @param asString defines if the tags must be returned as a string instead of an array of strings
  1597. * @returns the tags
  1598. */
  1599. static GetTags(obj: any, asString?: boolean): any;
  1600. /**
  1601. * Adds tags to an object
  1602. * @param obj defines the object to use
  1603. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  1604. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  1605. */
  1606. static AddTagsTo(obj: any, tagsString: string): void;
  1607. /**
  1608. * @hidden
  1609. */
  1610. static _AddTagTo(obj: any, tag: string): void;
  1611. /**
  1612. * Removes specific tags from a specific object
  1613. * @param obj defines the object to use
  1614. * @param tagsString defines the tags to remove
  1615. */
  1616. static RemoveTagsFrom(obj: any, tagsString: string): void;
  1617. /**
  1618. * @hidden
  1619. */
  1620. static _RemoveTagFrom(obj: any, tag: string): void;
  1621. /**
  1622. * Defines if tags hosted on an object match a given query
  1623. * @param obj defines the object to use
  1624. * @param tagsQuery defines the tag query
  1625. * @returns a boolean
  1626. */
  1627. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  1628. }
  1629. }
  1630. declare module BABYLON {
  1631. /**
  1632. * Scalar computation library
  1633. */
  1634. export class Scalar {
  1635. /**
  1636. * Two pi constants convenient for computation.
  1637. */
  1638. static TwoPi: number;
  1639. /**
  1640. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1641. * @param a number
  1642. * @param b number
  1643. * @param epsilon (default = 1.401298E-45)
  1644. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1645. */
  1646. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1647. /**
  1648. * Returns a string : the upper case translation of the number i to hexadecimal.
  1649. * @param i number
  1650. * @returns the upper case translation of the number i to hexadecimal.
  1651. */
  1652. static ToHex(i: number): string;
  1653. /**
  1654. * Returns -1 if value is negative and +1 is value is positive.
  1655. * @param value the value
  1656. * @returns the value itself if it's equal to zero.
  1657. */
  1658. static Sign(value: number): number;
  1659. /**
  1660. * Returns the value itself if it's between min and max.
  1661. * Returns min if the value is lower than min.
  1662. * Returns max if the value is greater than max.
  1663. * @param value the value to clmap
  1664. * @param min the min value to clamp to (default: 0)
  1665. * @param max the max value to clamp to (default: 1)
  1666. * @returns the clamped value
  1667. */
  1668. static Clamp(value: number, min?: number, max?: number): number;
  1669. /**
  1670. * the log2 of value.
  1671. * @param value the value to compute log2 of
  1672. * @returns the log2 of value.
  1673. */
  1674. static Log2(value: number): number;
  1675. /**
  1676. * Loops the value, so that it is never larger than length and never smaller than 0.
  1677. *
  1678. * This is similar to the modulo operator but it works with floating point numbers.
  1679. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1680. * With t = 5 and length = 2.5, the result would be 0.0.
  1681. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1682. * @param value the value
  1683. * @param length the length
  1684. * @returns the looped value
  1685. */
  1686. static Repeat(value: number, length: number): number;
  1687. /**
  1688. * Normalize the value between 0.0 and 1.0 using min and max values
  1689. * @param value value to normalize
  1690. * @param min max to normalize between
  1691. * @param max min to normalize between
  1692. * @returns the normalized value
  1693. */
  1694. static Normalize(value: number, min: number, max: number): number;
  1695. /**
  1696. * Denormalize the value from 0.0 and 1.0 using min and max values
  1697. * @param normalized value to denormalize
  1698. * @param min max to denormalize between
  1699. * @param max min to denormalize between
  1700. * @returns the denormalized value
  1701. */
  1702. static Denormalize(normalized: number, min: number, max: number): number;
  1703. /**
  1704. * Calculates the shortest difference between two given angles given in degrees.
  1705. * @param current current angle in degrees
  1706. * @param target target angle in degrees
  1707. * @returns the delta
  1708. */
  1709. static DeltaAngle(current: number, target: number): number;
  1710. /**
  1711. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1712. * @param tx value
  1713. * @param length length
  1714. * @returns The returned value will move back and forth between 0 and length
  1715. */
  1716. static PingPong(tx: number, length: number): number;
  1717. /**
  1718. * Interpolates between min and max with smoothing at the limits.
  1719. *
  1720. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1721. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1722. * @param from from
  1723. * @param to to
  1724. * @param tx value
  1725. * @returns the smooth stepped value
  1726. */
  1727. static SmoothStep(from: number, to: number, tx: number): number;
  1728. /**
  1729. * Moves a value current towards target.
  1730. *
  1731. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1732. * Negative values of maxDelta pushes the value away from target.
  1733. * @param current current value
  1734. * @param target target value
  1735. * @param maxDelta max distance to move
  1736. * @returns resulting value
  1737. */
  1738. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1739. /**
  1740. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1741. *
  1742. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1743. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1744. * @param current current value
  1745. * @param target target value
  1746. * @param maxDelta max distance to move
  1747. * @returns resulting angle
  1748. */
  1749. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1750. /**
  1751. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1752. * @param start start value
  1753. * @param end target value
  1754. * @param amount amount to lerp between
  1755. * @returns the lerped value
  1756. */
  1757. static Lerp(start: number, end: number, amount: number): number;
  1758. /**
  1759. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1760. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1761. * @param start start value
  1762. * @param end target value
  1763. * @param amount amount to lerp between
  1764. * @returns the lerped value
  1765. */
  1766. static LerpAngle(start: number, end: number, amount: number): number;
  1767. /**
  1768. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1769. * @param a start value
  1770. * @param b target value
  1771. * @param value value between a and b
  1772. * @returns the inverseLerp value
  1773. */
  1774. static InverseLerp(a: number, b: number, value: number): number;
  1775. /**
  1776. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1777. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1778. * @param value1 spline value
  1779. * @param tangent1 spline value
  1780. * @param value2 spline value
  1781. * @param tangent2 spline value
  1782. * @param amount input value
  1783. * @returns hermite result
  1784. */
  1785. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1786. /**
  1787. * Returns a random float number between and min and max values
  1788. * @param min min value of random
  1789. * @param max max value of random
  1790. * @returns random value
  1791. */
  1792. static RandomRange(min: number, max: number): number;
  1793. /**
  1794. * This function returns percentage of a number in a given range.
  1795. *
  1796. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1797. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1798. * @param number to convert to percentage
  1799. * @param min min range
  1800. * @param max max range
  1801. * @returns the percentage
  1802. */
  1803. static RangeToPercent(number: number, min: number, max: number): number;
  1804. /**
  1805. * This function returns number that corresponds to the percentage in a given range.
  1806. *
  1807. * PercentToRange(0.34,0,100) will return 34.
  1808. * @param percent to convert to number
  1809. * @param min min range
  1810. * @param max max range
  1811. * @returns the number
  1812. */
  1813. static PercentToRange(percent: number, min: number, max: number): number;
  1814. /**
  1815. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1816. * @param angle The angle to normalize in radian.
  1817. * @return The converted angle.
  1818. */
  1819. static NormalizeRadians(angle: number): number;
  1820. }
  1821. }
  1822. declare module BABYLON {
  1823. /**
  1824. * Constant used to convert a value to gamma space
  1825. * @ignorenaming
  1826. */
  1827. export const ToGammaSpace: number;
  1828. /**
  1829. * Constant used to convert a value to linear space
  1830. * @ignorenaming
  1831. */
  1832. export const ToLinearSpace = 2.2;
  1833. /**
  1834. * Constant used to define the minimal number value in Babylon.js
  1835. * @ignorenaming
  1836. */
  1837. let Epsilon: number;
  1838. }
  1839. declare module BABYLON {
  1840. /**
  1841. * Class used to represent a viewport on screen
  1842. */
  1843. export class Viewport {
  1844. /** viewport left coordinate */
  1845. x: number;
  1846. /** viewport top coordinate */
  1847. y: number;
  1848. /**viewport width */
  1849. width: number;
  1850. /** viewport height */
  1851. height: number;
  1852. /**
  1853. * Creates a Viewport object located at (x, y) and sized (width, height)
  1854. * @param x defines viewport left coordinate
  1855. * @param y defines viewport top coordinate
  1856. * @param width defines the viewport width
  1857. * @param height defines the viewport height
  1858. */
  1859. constructor(
  1860. /** viewport left coordinate */
  1861. x: number,
  1862. /** viewport top coordinate */
  1863. y: number,
  1864. /**viewport width */
  1865. width: number,
  1866. /** viewport height */
  1867. height: number);
  1868. /**
  1869. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1870. * @param renderWidth defines the rendering width
  1871. * @param renderHeight defines the rendering height
  1872. * @returns a new Viewport
  1873. */
  1874. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1875. /**
  1876. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1877. * @param renderWidth defines the rendering width
  1878. * @param renderHeight defines the rendering height
  1879. * @param ref defines the target viewport
  1880. * @returns the current viewport
  1881. */
  1882. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1883. /**
  1884. * Returns a new Viewport copied from the current one
  1885. * @returns a new Viewport
  1886. */
  1887. clone(): Viewport;
  1888. }
  1889. }
  1890. declare module BABYLON {
  1891. /**
  1892. * Class containing a set of static utilities functions for arrays.
  1893. */
  1894. export class ArrayTools {
  1895. /**
  1896. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1897. * @param size the number of element to construct and put in the array
  1898. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1899. * @returns a new array filled with new objects
  1900. */
  1901. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1902. }
  1903. }
  1904. declare module BABYLON {
  1905. /**
  1906. * Class representing a vector containing 2 coordinates
  1907. */
  1908. export class Vector2 {
  1909. /** defines the first coordinate */
  1910. x: number;
  1911. /** defines the second coordinate */
  1912. y: number;
  1913. /**
  1914. * Creates a new Vector2 from the given x and y coordinates
  1915. * @param x defines the first coordinate
  1916. * @param y defines the second coordinate
  1917. */
  1918. constructor(
  1919. /** defines the first coordinate */
  1920. x?: number,
  1921. /** defines the second coordinate */
  1922. y?: number);
  1923. /**
  1924. * Gets a string with the Vector2 coordinates
  1925. * @returns a string with the Vector2 coordinates
  1926. */
  1927. toString(): string;
  1928. /**
  1929. * Gets class name
  1930. * @returns the string "Vector2"
  1931. */
  1932. getClassName(): string;
  1933. /**
  1934. * Gets current vector hash code
  1935. * @returns the Vector2 hash code as a number
  1936. */
  1937. getHashCode(): number;
  1938. /**
  1939. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  1940. * @param array defines the source array
  1941. * @param index defines the offset in source array
  1942. * @returns the current Vector2
  1943. */
  1944. toArray(array: FloatArray, index?: number): Vector2;
  1945. /**
  1946. * Copy the current vector to an array
  1947. * @returns a new array with 2 elements: the Vector2 coordinates.
  1948. */
  1949. asArray(): number[];
  1950. /**
  1951. * Sets the Vector2 coordinates with the given Vector2 coordinates
  1952. * @param source defines the source Vector2
  1953. * @returns the current updated Vector2
  1954. */
  1955. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  1956. /**
  1957. * Sets the Vector2 coordinates with the given floats
  1958. * @param x defines the first coordinate
  1959. * @param y defines the second coordinate
  1960. * @returns the current updated Vector2
  1961. */
  1962. copyFromFloats(x: number, y: number): Vector2;
  1963. /**
  1964. * Sets the Vector2 coordinates with the given floats
  1965. * @param x defines the first coordinate
  1966. * @param y defines the second coordinate
  1967. * @returns the current updated Vector2
  1968. */
  1969. set(x: number, y: number): Vector2;
  1970. /**
  1971. * Add another vector with the current one
  1972. * @param otherVector defines the other vector
  1973. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  1974. */
  1975. add(otherVector: DeepImmutable<Vector2>): Vector2;
  1976. /**
  1977. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  1978. * @param otherVector defines the other vector
  1979. * @param result defines the target vector
  1980. * @returns the unmodified current Vector2
  1981. */
  1982. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1983. /**
  1984. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  1985. * @param otherVector defines the other vector
  1986. * @returns the current updated Vector2
  1987. */
  1988. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1989. /**
  1990. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  1991. * @param otherVector defines the other vector
  1992. * @returns a new Vector2
  1993. */
  1994. addVector3(otherVector: Vector3): Vector2;
  1995. /**
  1996. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  1997. * @param otherVector defines the other vector
  1998. * @returns a new Vector2
  1999. */
  2000. subtract(otherVector: Vector2): Vector2;
  2001. /**
  2002. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  2003. * @param otherVector defines the other vector
  2004. * @param result defines the target vector
  2005. * @returns the unmodified current Vector2
  2006. */
  2007. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2008. /**
  2009. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2010. * @param otherVector defines the other vector
  2011. * @returns the current updated Vector2
  2012. */
  2013. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2014. /**
  2015. * Multiplies in place the current Vector2 coordinates by the given ones
  2016. * @param otherVector defines the other vector
  2017. * @returns the current updated Vector2
  2018. */
  2019. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2020. /**
  2021. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2022. * @param otherVector defines the other vector
  2023. * @returns a new Vector2
  2024. */
  2025. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2026. /**
  2027. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2028. * @param otherVector defines the other vector
  2029. * @param result defines the target vector
  2030. * @returns the unmodified current Vector2
  2031. */
  2032. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2033. /**
  2034. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2035. * @param x defines the first coordinate
  2036. * @param y defines the second coordinate
  2037. * @returns a new Vector2
  2038. */
  2039. multiplyByFloats(x: number, y: number): Vector2;
  2040. /**
  2041. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2042. * @param otherVector defines the other vector
  2043. * @returns a new Vector2
  2044. */
  2045. divide(otherVector: Vector2): Vector2;
  2046. /**
  2047. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2048. * @param otherVector defines the other vector
  2049. * @param result defines the target vector
  2050. * @returns the unmodified current Vector2
  2051. */
  2052. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2053. /**
  2054. * Divides the current Vector2 coordinates by the given ones
  2055. * @param otherVector defines the other vector
  2056. * @returns the current updated Vector2
  2057. */
  2058. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2059. /**
  2060. * Gets a new Vector2 with current Vector2 negated coordinates
  2061. * @returns a new Vector2
  2062. */
  2063. negate(): Vector2;
  2064. /**
  2065. * Negate this vector in place
  2066. * @returns this
  2067. */
  2068. negateInPlace(): Vector2;
  2069. /**
  2070. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  2071. * @param result defines the Vector3 object where to store the result
  2072. * @returns the current Vector2
  2073. */
  2074. negateToRef(result: Vector2): Vector2;
  2075. /**
  2076. * Multiply the Vector2 coordinates by scale
  2077. * @param scale defines the scaling factor
  2078. * @returns the current updated Vector2
  2079. */
  2080. scaleInPlace(scale: number): Vector2;
  2081. /**
  2082. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2083. * @param scale defines the scaling factor
  2084. * @returns a new Vector2
  2085. */
  2086. scale(scale: number): Vector2;
  2087. /**
  2088. * Scale the current Vector2 values by a factor to a given Vector2
  2089. * @param scale defines the scale factor
  2090. * @param result defines the Vector2 object where to store the result
  2091. * @returns the unmodified current Vector2
  2092. */
  2093. scaleToRef(scale: number, result: Vector2): Vector2;
  2094. /**
  2095. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2096. * @param scale defines the scale factor
  2097. * @param result defines the Vector2 object where to store the result
  2098. * @returns the unmodified current Vector2
  2099. */
  2100. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2101. /**
  2102. * Gets a boolean if two vectors are equals
  2103. * @param otherVector defines the other vector
  2104. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2105. */
  2106. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2107. /**
  2108. * Gets a boolean if two vectors are equals (using an epsilon value)
  2109. * @param otherVector defines the other vector
  2110. * @param epsilon defines the minimal distance to consider equality
  2111. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2112. */
  2113. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2114. /**
  2115. * Gets a new Vector2 from current Vector2 floored values
  2116. * @returns a new Vector2
  2117. */
  2118. floor(): Vector2;
  2119. /**
  2120. * Gets a new Vector2 from current Vector2 floored values
  2121. * @returns a new Vector2
  2122. */
  2123. fract(): Vector2;
  2124. /**
  2125. * Gets the length of the vector
  2126. * @returns the vector length (float)
  2127. */
  2128. length(): number;
  2129. /**
  2130. * Gets the vector squared length
  2131. * @returns the vector squared length (float)
  2132. */
  2133. lengthSquared(): number;
  2134. /**
  2135. * Normalize the vector
  2136. * @returns the current updated Vector2
  2137. */
  2138. normalize(): Vector2;
  2139. /**
  2140. * Gets a new Vector2 copied from the Vector2
  2141. * @returns a new Vector2
  2142. */
  2143. clone(): Vector2;
  2144. /**
  2145. * Gets a new Vector2(0, 0)
  2146. * @returns a new Vector2
  2147. */
  2148. static Zero(): Vector2;
  2149. /**
  2150. * Gets a new Vector2(1, 1)
  2151. * @returns a new Vector2
  2152. */
  2153. static One(): Vector2;
  2154. /**
  2155. * Gets a new Vector2 set from the given index element of the given array
  2156. * @param array defines the data source
  2157. * @param offset defines the offset in the data source
  2158. * @returns a new Vector2
  2159. */
  2160. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2161. /**
  2162. * Sets "result" from the given index element of the given array
  2163. * @param array defines the data source
  2164. * @param offset defines the offset in the data source
  2165. * @param result defines the target vector
  2166. */
  2167. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2168. /**
  2169. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2170. * @param value1 defines 1st point of control
  2171. * @param value2 defines 2nd point of control
  2172. * @param value3 defines 3rd point of control
  2173. * @param value4 defines 4th point of control
  2174. * @param amount defines the interpolation factor
  2175. * @returns a new Vector2
  2176. */
  2177. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2178. /**
  2179. * Returns a new Vector2 set with same the coordinates than "value" ones if the vector "value" is in the square defined by "min" and "max".
  2180. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2181. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2182. * @param value defines the value to clamp
  2183. * @param min defines the lower limit
  2184. * @param max defines the upper limit
  2185. * @returns a new Vector2
  2186. */
  2187. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2188. /**
  2189. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2190. * @param value1 defines the 1st control point
  2191. * @param tangent1 defines the outgoing tangent
  2192. * @param value2 defines the 2nd control point
  2193. * @param tangent2 defines the incoming tangent
  2194. * @param amount defines the interpolation factor
  2195. * @returns a new Vector2
  2196. */
  2197. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2198. /**
  2199. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2200. * @param start defines the start vector
  2201. * @param end defines the end vector
  2202. * @param amount defines the interpolation factor
  2203. * @returns a new Vector2
  2204. */
  2205. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2206. /**
  2207. * Gets the dot product of the vector "left" and the vector "right"
  2208. * @param left defines first vector
  2209. * @param right defines second vector
  2210. * @returns the dot product (float)
  2211. */
  2212. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2213. /**
  2214. * Returns a new Vector2 equal to the normalized given vector
  2215. * @param vector defines the vector to normalize
  2216. * @returns a new Vector2
  2217. */
  2218. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2219. /**
  2220. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2221. * @param left defines 1st vector
  2222. * @param right defines 2nd vector
  2223. * @returns a new Vector2
  2224. */
  2225. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2226. /**
  2227. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2228. * @param left defines 1st vector
  2229. * @param right defines 2nd vector
  2230. * @returns a new Vector2
  2231. */
  2232. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2233. /**
  2234. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2235. * @param vector defines the vector to transform
  2236. * @param transformation defines the matrix to apply
  2237. * @returns a new Vector2
  2238. */
  2239. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2240. /**
  2241. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2242. * @param vector defines the vector to transform
  2243. * @param transformation defines the matrix to apply
  2244. * @param result defines the target vector
  2245. */
  2246. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2247. /**
  2248. * Determines if a given vector is included in a triangle
  2249. * @param p defines the vector to test
  2250. * @param p0 defines 1st triangle point
  2251. * @param p1 defines 2nd triangle point
  2252. * @param p2 defines 3rd triangle point
  2253. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2254. */
  2255. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2256. /**
  2257. * Gets the distance between the vectors "value1" and "value2"
  2258. * @param value1 defines first vector
  2259. * @param value2 defines second vector
  2260. * @returns the distance between vectors
  2261. */
  2262. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2263. /**
  2264. * Returns the squared distance between the vectors "value1" and "value2"
  2265. * @param value1 defines first vector
  2266. * @param value2 defines second vector
  2267. * @returns the squared distance between vectors
  2268. */
  2269. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2270. /**
  2271. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2272. * @param value1 defines first vector
  2273. * @param value2 defines second vector
  2274. * @returns a new Vector2
  2275. */
  2276. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2277. /**
  2278. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2279. * @param p defines the middle point
  2280. * @param segA defines one point of the segment
  2281. * @param segB defines the other point of the segment
  2282. * @returns the shortest distance
  2283. */
  2284. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2285. }
  2286. /**
  2287. * Class used to store (x,y,z) vector representation
  2288. * A Vector3 is the main object used in 3D geometry
  2289. * It can represent etiher the coordinates of a point the space, either a direction
  2290. * Reminder: js uses a left handed forward facing system
  2291. */
  2292. export class Vector3 {
  2293. /**
  2294. * Defines the first coordinates (on X axis)
  2295. */
  2296. x: number;
  2297. /**
  2298. * Defines the second coordinates (on Y axis)
  2299. */
  2300. y: number;
  2301. /**
  2302. * Defines the third coordinates (on Z axis)
  2303. */
  2304. z: number;
  2305. private static _UpReadOnly;
  2306. private static _ZeroReadOnly;
  2307. /**
  2308. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2309. * @param x defines the first coordinates (on X axis)
  2310. * @param y defines the second coordinates (on Y axis)
  2311. * @param z defines the third coordinates (on Z axis)
  2312. */
  2313. constructor(
  2314. /**
  2315. * Defines the first coordinates (on X axis)
  2316. */
  2317. x?: number,
  2318. /**
  2319. * Defines the second coordinates (on Y axis)
  2320. */
  2321. y?: number,
  2322. /**
  2323. * Defines the third coordinates (on Z axis)
  2324. */
  2325. z?: number);
  2326. /**
  2327. * Creates a string representation of the Vector3
  2328. * @returns a string with the Vector3 coordinates.
  2329. */
  2330. toString(): string;
  2331. /**
  2332. * Gets the class name
  2333. * @returns the string "Vector3"
  2334. */
  2335. getClassName(): string;
  2336. /**
  2337. * Creates the Vector3 hash code
  2338. * @returns a number which tends to be unique between Vector3 instances
  2339. */
  2340. getHashCode(): number;
  2341. /**
  2342. * Creates an array containing three elements : the coordinates of the Vector3
  2343. * @returns a new array of numbers
  2344. */
  2345. asArray(): number[];
  2346. /**
  2347. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2348. * @param array defines the destination array
  2349. * @param index defines the offset in the destination array
  2350. * @returns the current Vector3
  2351. */
  2352. toArray(array: FloatArray, index?: number): Vector3;
  2353. /**
  2354. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2355. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2356. */
  2357. toQuaternion(): Quaternion;
  2358. /**
  2359. * Adds the given vector to the current Vector3
  2360. * @param otherVector defines the second operand
  2361. * @returns the current updated Vector3
  2362. */
  2363. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2364. /**
  2365. * Adds the given coordinates to the current Vector3
  2366. * @param x defines the x coordinate of the operand
  2367. * @param y defines the y coordinate of the operand
  2368. * @param z defines the z coordinate of the operand
  2369. * @returns the current updated Vector3
  2370. */
  2371. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2372. /**
  2373. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2374. * @param otherVector defines the second operand
  2375. * @returns the resulting Vector3
  2376. */
  2377. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2378. /**
  2379. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2380. * @param otherVector defines the second operand
  2381. * @param result defines the Vector3 object where to store the result
  2382. * @returns the current Vector3
  2383. */
  2384. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2385. /**
  2386. * Subtract the given vector from the current Vector3
  2387. * @param otherVector defines the second operand
  2388. * @returns the current updated Vector3
  2389. */
  2390. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2391. /**
  2392. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2393. * @param otherVector defines the second operand
  2394. * @returns the resulting Vector3
  2395. */
  2396. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2397. /**
  2398. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2399. * @param otherVector defines the second operand
  2400. * @param result defines the Vector3 object where to store the result
  2401. * @returns the current Vector3
  2402. */
  2403. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2404. /**
  2405. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2406. * @param x defines the x coordinate of the operand
  2407. * @param y defines the y coordinate of the operand
  2408. * @param z defines the z coordinate of the operand
  2409. * @returns the resulting Vector3
  2410. */
  2411. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2412. /**
  2413. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2414. * @param x defines the x coordinate of the operand
  2415. * @param y defines the y coordinate of the operand
  2416. * @param z defines the z coordinate of the operand
  2417. * @param result defines the Vector3 object where to store the result
  2418. * @returns the current Vector3
  2419. */
  2420. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2421. /**
  2422. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2423. * @returns a new Vector3
  2424. */
  2425. negate(): Vector3;
  2426. /**
  2427. * Negate this vector in place
  2428. * @returns this
  2429. */
  2430. negateInPlace(): Vector3;
  2431. /**
  2432. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  2433. * @param result defines the Vector3 object where to store the result
  2434. * @returns the current Vector3
  2435. */
  2436. negateToRef(result: Vector3): Vector3;
  2437. /**
  2438. * Multiplies the Vector3 coordinates by the float "scale"
  2439. * @param scale defines the multiplier factor
  2440. * @returns the current updated Vector3
  2441. */
  2442. scaleInPlace(scale: number): Vector3;
  2443. /**
  2444. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2445. * @param scale defines the multiplier factor
  2446. * @returns a new Vector3
  2447. */
  2448. scale(scale: number): Vector3;
  2449. /**
  2450. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  2451. * @param scale defines the multiplier factor
  2452. * @param result defines the Vector3 object where to store the result
  2453. * @returns the current Vector3
  2454. */
  2455. scaleToRef(scale: number, result: Vector3): Vector3;
  2456. /**
  2457. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  2458. * @param scale defines the scale factor
  2459. * @param result defines the Vector3 object where to store the result
  2460. * @returns the unmodified current Vector3
  2461. */
  2462. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  2463. /**
  2464. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  2465. * @param otherVector defines the second operand
  2466. * @returns true if both vectors are equals
  2467. */
  2468. equals(otherVector: DeepImmutable<Vector3>): boolean;
  2469. /**
  2470. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  2471. * @param otherVector defines the second operand
  2472. * @param epsilon defines the minimal distance to define values as equals
  2473. * @returns true if both vectors are distant less than epsilon
  2474. */
  2475. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  2476. /**
  2477. * Returns true if the current Vector3 coordinates equals the given floats
  2478. * @param x defines the x coordinate of the operand
  2479. * @param y defines the y coordinate of the operand
  2480. * @param z defines the z coordinate of the operand
  2481. * @returns true if both vectors are equals
  2482. */
  2483. equalsToFloats(x: number, y: number, z: number): boolean;
  2484. /**
  2485. * Multiplies the current Vector3 coordinates by the given ones
  2486. * @param otherVector defines the second operand
  2487. * @returns the current updated Vector3
  2488. */
  2489. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2490. /**
  2491. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  2492. * @param otherVector defines the second operand
  2493. * @returns the new Vector3
  2494. */
  2495. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  2496. /**
  2497. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  2498. * @param otherVector defines the second operand
  2499. * @param result defines the Vector3 object where to store the result
  2500. * @returns the current Vector3
  2501. */
  2502. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2503. /**
  2504. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  2505. * @param x defines the x coordinate of the operand
  2506. * @param y defines the y coordinate of the operand
  2507. * @param z defines the z coordinate of the operand
  2508. * @returns the new Vector3
  2509. */
  2510. multiplyByFloats(x: number, y: number, z: number): Vector3;
  2511. /**
  2512. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  2513. * @param otherVector defines the second operand
  2514. * @returns the new Vector3
  2515. */
  2516. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  2517. /**
  2518. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  2519. * @param otherVector defines the second operand
  2520. * @param result defines the Vector3 object where to store the result
  2521. * @returns the current Vector3
  2522. */
  2523. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2524. /**
  2525. * Divides the current Vector3 coordinates by the given ones.
  2526. * @param otherVector defines the second operand
  2527. * @returns the current updated Vector3
  2528. */
  2529. divideInPlace(otherVector: Vector3): Vector3;
  2530. /**
  2531. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  2532. * @param other defines the second operand
  2533. * @returns the current updated Vector3
  2534. */
  2535. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2536. /**
  2537. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2538. * @param other defines the second operand
  2539. * @returns the current updated Vector3
  2540. */
  2541. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2542. /**
  2543. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2544. * @param x defines the x coordinate of the operand
  2545. * @param y defines the y coordinate of the operand
  2546. * @param z defines the z coordinate of the operand
  2547. * @returns the current updated Vector3
  2548. */
  2549. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2550. /**
  2551. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2552. * @param x defines the x coordinate of the operand
  2553. * @param y defines the y coordinate of the operand
  2554. * @param z defines the z coordinate of the operand
  2555. * @returns the current updated Vector3
  2556. */
  2557. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2558. /**
  2559. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2560. * Check if is non uniform within a certain amount of decimal places to account for this
  2561. * @param epsilon the amount the values can differ
  2562. * @returns if the the vector is non uniform to a certain number of decimal places
  2563. */
  2564. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2565. /**
  2566. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2567. */
  2568. get isNonUniform(): boolean;
  2569. /**
  2570. * Gets a new Vector3 from current Vector3 floored values
  2571. * @returns a new Vector3
  2572. */
  2573. floor(): Vector3;
  2574. /**
  2575. * Gets a new Vector3 from current Vector3 floored values
  2576. * @returns a new Vector3
  2577. */
  2578. fract(): Vector3;
  2579. /**
  2580. * Gets the length of the Vector3
  2581. * @returns the length of the Vector3
  2582. */
  2583. length(): number;
  2584. /**
  2585. * Gets the squared length of the Vector3
  2586. * @returns squared length of the Vector3
  2587. */
  2588. lengthSquared(): number;
  2589. /**
  2590. * Normalize the current Vector3.
  2591. * Please note that this is an in place operation.
  2592. * @returns the current updated Vector3
  2593. */
  2594. normalize(): Vector3;
  2595. /**
  2596. * Reorders the x y z properties of the vector in place
  2597. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2598. * @returns the current updated vector
  2599. */
  2600. reorderInPlace(order: string): this;
  2601. /**
  2602. * Rotates the vector around 0,0,0 by a quaternion
  2603. * @param quaternion the rotation quaternion
  2604. * @param result vector to store the result
  2605. * @returns the resulting vector
  2606. */
  2607. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2608. /**
  2609. * Rotates a vector around a given point
  2610. * @param quaternion the rotation quaternion
  2611. * @param point the point to rotate around
  2612. * @param result vector to store the result
  2613. * @returns the resulting vector
  2614. */
  2615. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2616. /**
  2617. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2618. * The cross product is then orthogonal to both current and "other"
  2619. * @param other defines the right operand
  2620. * @returns the cross product
  2621. */
  2622. cross(other: Vector3): Vector3;
  2623. /**
  2624. * Normalize the current Vector3 with the given input length.
  2625. * Please note that this is an in place operation.
  2626. * @param len the length of the vector
  2627. * @returns the current updated Vector3
  2628. */
  2629. normalizeFromLength(len: number): Vector3;
  2630. /**
  2631. * Normalize the current Vector3 to a new vector
  2632. * @returns the new Vector3
  2633. */
  2634. normalizeToNew(): Vector3;
  2635. /**
  2636. * Normalize the current Vector3 to the reference
  2637. * @param reference define the Vector3 to update
  2638. * @returns the updated Vector3
  2639. */
  2640. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  2641. /**
  2642. * Creates a new Vector3 copied from the current Vector3
  2643. * @returns the new Vector3
  2644. */
  2645. clone(): Vector3;
  2646. /**
  2647. * Copies the given vector coordinates to the current Vector3 ones
  2648. * @param source defines the source Vector3
  2649. * @returns the current updated Vector3
  2650. */
  2651. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2652. /**
  2653. * Copies the given floats to the current Vector3 coordinates
  2654. * @param x defines the x coordinate of the operand
  2655. * @param y defines the y coordinate of the operand
  2656. * @param z defines the z coordinate of the operand
  2657. * @returns the current updated Vector3
  2658. */
  2659. copyFromFloats(x: number, y: number, z: number): Vector3;
  2660. /**
  2661. * Copies the given floats to the current Vector3 coordinates
  2662. * @param x defines the x coordinate of the operand
  2663. * @param y defines the y coordinate of the operand
  2664. * @param z defines the z coordinate of the operand
  2665. * @returns the current updated Vector3
  2666. */
  2667. set(x: number, y: number, z: number): Vector3;
  2668. /**
  2669. * Copies the given float to the current Vector3 coordinates
  2670. * @param v defines the x, y and z coordinates of the operand
  2671. * @returns the current updated Vector3
  2672. */
  2673. setAll(v: number): Vector3;
  2674. /**
  2675. * Get the clip factor between two vectors
  2676. * @param vector0 defines the first operand
  2677. * @param vector1 defines the second operand
  2678. * @param axis defines the axis to use
  2679. * @param size defines the size along the axis
  2680. * @returns the clip factor
  2681. */
  2682. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2683. /**
  2684. * Get angle between two vectors
  2685. * @param vector0 angle between vector0 and vector1
  2686. * @param vector1 angle between vector0 and vector1
  2687. * @param normal direction of the normal
  2688. * @return the angle between vector0 and vector1
  2689. */
  2690. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2691. /**
  2692. * Returns a new Vector3 set from the index "offset" of the given array
  2693. * @param array defines the source array
  2694. * @param offset defines the offset in the source array
  2695. * @returns the new Vector3
  2696. */
  2697. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2698. /**
  2699. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2700. * @param array defines the source array
  2701. * @param offset defines the offset in the source array
  2702. * @returns the new Vector3
  2703. * @deprecated Please use FromArray instead.
  2704. */
  2705. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2706. /**
  2707. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2708. * @param array defines the source array
  2709. * @param offset defines the offset in the source array
  2710. * @param result defines the Vector3 where to store the result
  2711. */
  2712. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2713. /**
  2714. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2715. * @param array defines the source array
  2716. * @param offset defines the offset in the source array
  2717. * @param result defines the Vector3 where to store the result
  2718. * @deprecated Please use FromArrayToRef instead.
  2719. */
  2720. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2721. /**
  2722. * Sets the given vector "result" with the given floats.
  2723. * @param x defines the x coordinate of the source
  2724. * @param y defines the y coordinate of the source
  2725. * @param z defines the z coordinate of the source
  2726. * @param result defines the Vector3 where to store the result
  2727. */
  2728. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2729. /**
  2730. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2731. * @returns a new empty Vector3
  2732. */
  2733. static Zero(): Vector3;
  2734. /**
  2735. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2736. * @returns a new unit Vector3
  2737. */
  2738. static One(): Vector3;
  2739. /**
  2740. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2741. * @returns a new up Vector3
  2742. */
  2743. static Up(): Vector3;
  2744. /**
  2745. * Gets a up Vector3 that must not be updated
  2746. */
  2747. static get UpReadOnly(): DeepImmutable<Vector3>;
  2748. /**
  2749. * Gets a zero Vector3 that must not be updated
  2750. */
  2751. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  2752. /**
  2753. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2754. * @returns a new down Vector3
  2755. */
  2756. static Down(): Vector3;
  2757. /**
  2758. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2759. * @returns a new forward Vector3
  2760. */
  2761. static Forward(): Vector3;
  2762. /**
  2763. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2764. * @returns a new forward Vector3
  2765. */
  2766. static Backward(): Vector3;
  2767. /**
  2768. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2769. * @returns a new right Vector3
  2770. */
  2771. static Right(): Vector3;
  2772. /**
  2773. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2774. * @returns a new left Vector3
  2775. */
  2776. static Left(): Vector3;
  2777. /**
  2778. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2779. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2780. * @param vector defines the Vector3 to transform
  2781. * @param transformation defines the transformation matrix
  2782. * @returns the transformed Vector3
  2783. */
  2784. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2785. /**
  2786. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2787. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2788. * @param vector defines the Vector3 to transform
  2789. * @param transformation defines the transformation matrix
  2790. * @param result defines the Vector3 where to store the result
  2791. */
  2792. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2793. /**
  2794. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2795. * This method computes tranformed coordinates only, not transformed direction vectors
  2796. * @param x define the x coordinate of the source vector
  2797. * @param y define the y coordinate of the source vector
  2798. * @param z define the z coordinate of the source vector
  2799. * @param transformation defines the transformation matrix
  2800. * @param result defines the Vector3 where to store the result
  2801. */
  2802. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2803. /**
  2804. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2805. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2806. * @param vector defines the Vector3 to transform
  2807. * @param transformation defines the transformation matrix
  2808. * @returns the new Vector3
  2809. */
  2810. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2811. /**
  2812. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  2813. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2814. * @param vector defines the Vector3 to transform
  2815. * @param transformation defines the transformation matrix
  2816. * @param result defines the Vector3 where to store the result
  2817. */
  2818. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2819. /**
  2820. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  2821. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2822. * @param x define the x coordinate of the source vector
  2823. * @param y define the y coordinate of the source vector
  2824. * @param z define the z coordinate of the source vector
  2825. * @param transformation defines the transformation matrix
  2826. * @param result defines the Vector3 where to store the result
  2827. */
  2828. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2829. /**
  2830. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  2831. * @param value1 defines the first control point
  2832. * @param value2 defines the second control point
  2833. * @param value3 defines the third control point
  2834. * @param value4 defines the fourth control point
  2835. * @param amount defines the amount on the spline to use
  2836. * @returns the new Vector3
  2837. */
  2838. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  2839. /**
  2840. * Returns a new Vector3 set with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  2841. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2842. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2843. * @param value defines the current value
  2844. * @param min defines the lower range value
  2845. * @param max defines the upper range value
  2846. * @returns the new Vector3
  2847. */
  2848. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  2849. /**
  2850. * Sets the given vector "result" with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  2851. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2852. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2853. * @param value defines the current value
  2854. * @param min defines the lower range value
  2855. * @param max defines the upper range value
  2856. * @param result defines the Vector3 where to store the result
  2857. */
  2858. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  2859. /**
  2860. * Checks if a given vector is inside a specific range
  2861. * @param v defines the vector to test
  2862. * @param min defines the minimum range
  2863. * @param max defines the maximum range
  2864. */
  2865. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  2866. /**
  2867. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  2868. * @param value1 defines the first control point
  2869. * @param tangent1 defines the first tangent vector
  2870. * @param value2 defines the second control point
  2871. * @param tangent2 defines the second tangent vector
  2872. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  2873. * @returns the new Vector3
  2874. */
  2875. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  2876. /**
  2877. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  2878. * @param start defines the start value
  2879. * @param end defines the end value
  2880. * @param amount max defines amount between both (between 0 and 1)
  2881. * @returns the new Vector3
  2882. */
  2883. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  2884. /**
  2885. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  2886. * @param start defines the start value
  2887. * @param end defines the end value
  2888. * @param amount max defines amount between both (between 0 and 1)
  2889. * @param result defines the Vector3 where to store the result
  2890. */
  2891. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  2892. /**
  2893. * Returns the dot product (float) between the vectors "left" and "right"
  2894. * @param left defines the left operand
  2895. * @param right defines the right operand
  2896. * @returns the dot product
  2897. */
  2898. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  2899. /**
  2900. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  2901. * The cross product is then orthogonal to both "left" and "right"
  2902. * @param left defines the left operand
  2903. * @param right defines the right operand
  2904. * @returns the cross product
  2905. */
  2906. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2907. /**
  2908. * Sets the given vector "result" with the cross product of "left" and "right"
  2909. * The cross product is then orthogonal to both "left" and "right"
  2910. * @param left defines the left operand
  2911. * @param right defines the right operand
  2912. * @param result defines the Vector3 where to store the result
  2913. */
  2914. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  2915. /**
  2916. * Returns a new Vector3 as the normalization of the given vector
  2917. * @param vector defines the Vector3 to normalize
  2918. * @returns the new Vector3
  2919. */
  2920. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  2921. /**
  2922. * Sets the given vector "result" with the normalization of the given first vector
  2923. * @param vector defines the Vector3 to normalize
  2924. * @param result defines the Vector3 where to store the result
  2925. */
  2926. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  2927. /**
  2928. * Project a Vector3 onto screen space
  2929. * @param vector defines the Vector3 to project
  2930. * @param world defines the world matrix to use
  2931. * @param transform defines the transform (view x projection) matrix to use
  2932. * @param viewport defines the screen viewport to use
  2933. * @returns the new Vector3
  2934. */
  2935. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  2936. /** @hidden */
  2937. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  2938. /**
  2939. * Unproject from screen space to object space
  2940. * @param source defines the screen space Vector3 to use
  2941. * @param viewportWidth defines the current width of the viewport
  2942. * @param viewportHeight defines the current height of the viewport
  2943. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2944. * @param transform defines the transform (view x projection) matrix to use
  2945. * @returns the new Vector3
  2946. */
  2947. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  2948. /**
  2949. * Unproject from screen space to object space
  2950. * @param source defines the screen space Vector3 to use
  2951. * @param viewportWidth defines the current width of the viewport
  2952. * @param viewportHeight defines the current height of the viewport
  2953. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2954. * @param view defines the view matrix to use
  2955. * @param projection defines the projection matrix to use
  2956. * @returns the new Vector3
  2957. */
  2958. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  2959. /**
  2960. * Unproject from screen space to object space
  2961. * @param source defines the screen space Vector3 to use
  2962. * @param viewportWidth defines the current width of the viewport
  2963. * @param viewportHeight defines the current height of the viewport
  2964. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2965. * @param view defines the view matrix to use
  2966. * @param projection defines the projection matrix to use
  2967. * @param result defines the Vector3 where to store the result
  2968. */
  2969. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2970. /**
  2971. * Unproject from screen space to object space
  2972. * @param sourceX defines the screen space x coordinate to use
  2973. * @param sourceY defines the screen space y coordinate to use
  2974. * @param sourceZ defines the screen space z coordinate to use
  2975. * @param viewportWidth defines the current width of the viewport
  2976. * @param viewportHeight defines the current height of the viewport
  2977. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2978. * @param view defines the view matrix to use
  2979. * @param projection defines the projection matrix to use
  2980. * @param result defines the Vector3 where to store the result
  2981. */
  2982. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2983. /**
  2984. * Gets the minimal coordinate values between two Vector3
  2985. * @param left defines the first operand
  2986. * @param right defines the second operand
  2987. * @returns the new Vector3
  2988. */
  2989. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2990. /**
  2991. * Gets the maximal coordinate values between two Vector3
  2992. * @param left defines the first operand
  2993. * @param right defines the second operand
  2994. * @returns the new Vector3
  2995. */
  2996. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2997. /**
  2998. * Returns the distance between the vectors "value1" and "value2"
  2999. * @param value1 defines the first operand
  3000. * @param value2 defines the second operand
  3001. * @returns the distance
  3002. */
  3003. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3004. /**
  3005. * Returns the squared distance between the vectors "value1" and "value2"
  3006. * @param value1 defines the first operand
  3007. * @param value2 defines the second operand
  3008. * @returns the squared distance
  3009. */
  3010. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3011. /**
  3012. * Returns a new Vector3 located at the center between "value1" and "value2"
  3013. * @param value1 defines the first operand
  3014. * @param value2 defines the second operand
  3015. * @returns the new Vector3
  3016. */
  3017. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3018. /**
  3019. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3020. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3021. * to something in order to rotate it from its local system to the given target system
  3022. * Note: axis1, axis2 and axis3 are normalized during this operation
  3023. * @param axis1 defines the first axis
  3024. * @param axis2 defines the second axis
  3025. * @param axis3 defines the third axis
  3026. * @returns a new Vector3
  3027. */
  3028. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3029. /**
  3030. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3031. * @param axis1 defines the first axis
  3032. * @param axis2 defines the second axis
  3033. * @param axis3 defines the third axis
  3034. * @param ref defines the Vector3 where to store the result
  3035. */
  3036. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3037. }
  3038. /**
  3039. * Vector4 class created for EulerAngle class conversion to Quaternion
  3040. */
  3041. export class Vector4 {
  3042. /** x value of the vector */
  3043. x: number;
  3044. /** y value of the vector */
  3045. y: number;
  3046. /** z value of the vector */
  3047. z: number;
  3048. /** w value of the vector */
  3049. w: number;
  3050. /**
  3051. * Creates a Vector4 object from the given floats.
  3052. * @param x x value of the vector
  3053. * @param y y value of the vector
  3054. * @param z z value of the vector
  3055. * @param w w value of the vector
  3056. */
  3057. constructor(
  3058. /** x value of the vector */
  3059. x: number,
  3060. /** y value of the vector */
  3061. y: number,
  3062. /** z value of the vector */
  3063. z: number,
  3064. /** w value of the vector */
  3065. w: number);
  3066. /**
  3067. * Returns the string with the Vector4 coordinates.
  3068. * @returns a string containing all the vector values
  3069. */
  3070. toString(): string;
  3071. /**
  3072. * Returns the string "Vector4".
  3073. * @returns "Vector4"
  3074. */
  3075. getClassName(): string;
  3076. /**
  3077. * Returns the Vector4 hash code.
  3078. * @returns a unique hash code
  3079. */
  3080. getHashCode(): number;
  3081. /**
  3082. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3083. * @returns the resulting array
  3084. */
  3085. asArray(): number[];
  3086. /**
  3087. * Populates the given array from the given index with the Vector4 coordinates.
  3088. * @param array array to populate
  3089. * @param index index of the array to start at (default: 0)
  3090. * @returns the Vector4.
  3091. */
  3092. toArray(array: FloatArray, index?: number): Vector4;
  3093. /**
  3094. * Adds the given vector to the current Vector4.
  3095. * @param otherVector the vector to add
  3096. * @returns the updated Vector4.
  3097. */
  3098. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3099. /**
  3100. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3101. * @param otherVector the vector to add
  3102. * @returns the resulting vector
  3103. */
  3104. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3105. /**
  3106. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3107. * @param otherVector the vector to add
  3108. * @param result the vector to store the result
  3109. * @returns the current Vector4.
  3110. */
  3111. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3112. /**
  3113. * Subtract in place the given vector from the current Vector4.
  3114. * @param otherVector the vector to subtract
  3115. * @returns the updated Vector4.
  3116. */
  3117. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3118. /**
  3119. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3120. * @param otherVector the vector to add
  3121. * @returns the new vector with the result
  3122. */
  3123. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3124. /**
  3125. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3126. * @param otherVector the vector to subtract
  3127. * @param result the vector to store the result
  3128. * @returns the current Vector4.
  3129. */
  3130. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3131. /**
  3132. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3133. */
  3134. /**
  3135. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3136. * @param x value to subtract
  3137. * @param y value to subtract
  3138. * @param z value to subtract
  3139. * @param w value to subtract
  3140. * @returns new vector containing the result
  3141. */
  3142. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3143. /**
  3144. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3145. * @param x value to subtract
  3146. * @param y value to subtract
  3147. * @param z value to subtract
  3148. * @param w value to subtract
  3149. * @param result the vector to store the result in
  3150. * @returns the current Vector4.
  3151. */
  3152. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3153. /**
  3154. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3155. * @returns a new vector with the negated values
  3156. */
  3157. negate(): Vector4;
  3158. /**
  3159. * Negate this vector in place
  3160. * @returns this
  3161. */
  3162. negateInPlace(): Vector4;
  3163. /**
  3164. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  3165. * @param result defines the Vector3 object where to store the result
  3166. * @returns the current Vector4
  3167. */
  3168. negateToRef(result: Vector4): Vector4;
  3169. /**
  3170. * Multiplies the current Vector4 coordinates by scale (float).
  3171. * @param scale the number to scale with
  3172. * @returns the updated Vector4.
  3173. */
  3174. scaleInPlace(scale: number): Vector4;
  3175. /**
  3176. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3177. * @param scale the number to scale with
  3178. * @returns a new vector with the result
  3179. */
  3180. scale(scale: number): Vector4;
  3181. /**
  3182. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3183. * @param scale the number to scale with
  3184. * @param result a vector to store the result in
  3185. * @returns the current Vector4.
  3186. */
  3187. scaleToRef(scale: number, result: Vector4): Vector4;
  3188. /**
  3189. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3190. * @param scale defines the scale factor
  3191. * @param result defines the Vector4 object where to store the result
  3192. * @returns the unmodified current Vector4
  3193. */
  3194. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3195. /**
  3196. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3197. * @param otherVector the vector to compare against
  3198. * @returns true if they are equal
  3199. */
  3200. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3201. /**
  3202. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3203. * @param otherVector vector to compare against
  3204. * @param epsilon (Default: very small number)
  3205. * @returns true if they are equal
  3206. */
  3207. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3208. /**
  3209. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3210. * @param x x value to compare against
  3211. * @param y y value to compare against
  3212. * @param z z value to compare against
  3213. * @param w w value to compare against
  3214. * @returns true if equal
  3215. */
  3216. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3217. /**
  3218. * Multiplies in place the current Vector4 by the given one.
  3219. * @param otherVector vector to multiple with
  3220. * @returns the updated Vector4.
  3221. */
  3222. multiplyInPlace(otherVector: Vector4): Vector4;
  3223. /**
  3224. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3225. * @param otherVector vector to multiple with
  3226. * @returns resulting new vector
  3227. */
  3228. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3229. /**
  3230. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3231. * @param otherVector vector to multiple with
  3232. * @param result vector to store the result
  3233. * @returns the current Vector4.
  3234. */
  3235. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3236. /**
  3237. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3238. * @param x x value multiply with
  3239. * @param y y value multiply with
  3240. * @param z z value multiply with
  3241. * @param w w value multiply with
  3242. * @returns resulting new vector
  3243. */
  3244. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3245. /**
  3246. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3247. * @param otherVector vector to devide with
  3248. * @returns resulting new vector
  3249. */
  3250. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3251. /**
  3252. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3253. * @param otherVector vector to devide with
  3254. * @param result vector to store the result
  3255. * @returns the current Vector4.
  3256. */
  3257. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3258. /**
  3259. * Divides the current Vector3 coordinates by the given ones.
  3260. * @param otherVector vector to devide with
  3261. * @returns the updated Vector3.
  3262. */
  3263. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3264. /**
  3265. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3266. * @param other defines the second operand
  3267. * @returns the current updated Vector4
  3268. */
  3269. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3270. /**
  3271. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3272. * @param other defines the second operand
  3273. * @returns the current updated Vector4
  3274. */
  3275. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3276. /**
  3277. * Gets a new Vector4 from current Vector4 floored values
  3278. * @returns a new Vector4
  3279. */
  3280. floor(): Vector4;
  3281. /**
  3282. * Gets a new Vector4 from current Vector3 floored values
  3283. * @returns a new Vector4
  3284. */
  3285. fract(): Vector4;
  3286. /**
  3287. * Returns the Vector4 length (float).
  3288. * @returns the length
  3289. */
  3290. length(): number;
  3291. /**
  3292. * Returns the Vector4 squared length (float).
  3293. * @returns the length squared
  3294. */
  3295. lengthSquared(): number;
  3296. /**
  3297. * Normalizes in place the Vector4.
  3298. * @returns the updated Vector4.
  3299. */
  3300. normalize(): Vector4;
  3301. /**
  3302. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3303. * @returns this converted to a new vector3
  3304. */
  3305. toVector3(): Vector3;
  3306. /**
  3307. * Returns a new Vector4 copied from the current one.
  3308. * @returns the new cloned vector
  3309. */
  3310. clone(): Vector4;
  3311. /**
  3312. * Updates the current Vector4 with the given one coordinates.
  3313. * @param source the source vector to copy from
  3314. * @returns the updated Vector4.
  3315. */
  3316. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3317. /**
  3318. * Updates the current Vector4 coordinates with the given floats.
  3319. * @param x float to copy from
  3320. * @param y float to copy from
  3321. * @param z float to copy from
  3322. * @param w float to copy from
  3323. * @returns the updated Vector4.
  3324. */
  3325. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3326. /**
  3327. * Updates the current Vector4 coordinates with the given floats.
  3328. * @param x float to set from
  3329. * @param y float to set from
  3330. * @param z float to set from
  3331. * @param w float to set from
  3332. * @returns the updated Vector4.
  3333. */
  3334. set(x: number, y: number, z: number, w: number): Vector4;
  3335. /**
  3336. * Copies the given float to the current Vector3 coordinates
  3337. * @param v defines the x, y, z and w coordinates of the operand
  3338. * @returns the current updated Vector3
  3339. */
  3340. setAll(v: number): Vector4;
  3341. /**
  3342. * Returns a new Vector4 set from the starting index of the given array.
  3343. * @param array the array to pull values from
  3344. * @param offset the offset into the array to start at
  3345. * @returns the new vector
  3346. */
  3347. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3348. /**
  3349. * Updates the given vector "result" from the starting index of the given array.
  3350. * @param array the array to pull values from
  3351. * @param offset the offset into the array to start at
  3352. * @param result the vector to store the result in
  3353. */
  3354. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3355. /**
  3356. * Updates the given vector "result" from the starting index of the given Float32Array.
  3357. * @param array the array to pull values from
  3358. * @param offset the offset into the array to start at
  3359. * @param result the vector to store the result in
  3360. */
  3361. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3362. /**
  3363. * Updates the given vector "result" coordinates from the given floats.
  3364. * @param x float to set from
  3365. * @param y float to set from
  3366. * @param z float to set from
  3367. * @param w float to set from
  3368. * @param result the vector to the floats in
  3369. */
  3370. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3371. /**
  3372. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3373. * @returns the new vector
  3374. */
  3375. static Zero(): Vector4;
  3376. /**
  3377. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3378. * @returns the new vector
  3379. */
  3380. static One(): Vector4;
  3381. /**
  3382. * Returns a new normalized Vector4 from the given one.
  3383. * @param vector the vector to normalize
  3384. * @returns the vector
  3385. */
  3386. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3387. /**
  3388. * Updates the given vector "result" from the normalization of the given one.
  3389. * @param vector the vector to normalize
  3390. * @param result the vector to store the result in
  3391. */
  3392. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3393. /**
  3394. * Returns a vector with the minimum values from the left and right vectors
  3395. * @param left left vector to minimize
  3396. * @param right right vector to minimize
  3397. * @returns a new vector with the minimum of the left and right vector values
  3398. */
  3399. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3400. /**
  3401. * Returns a vector with the maximum values from the left and right vectors
  3402. * @param left left vector to maximize
  3403. * @param right right vector to maximize
  3404. * @returns a new vector with the maximum of the left and right vector values
  3405. */
  3406. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3407. /**
  3408. * Returns the distance (float) between the vectors "value1" and "value2".
  3409. * @param value1 value to calulate the distance between
  3410. * @param value2 value to calulate the distance between
  3411. * @return the distance between the two vectors
  3412. */
  3413. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3414. /**
  3415. * Returns the squared distance (float) between the vectors "value1" and "value2".
  3416. * @param value1 value to calulate the distance between
  3417. * @param value2 value to calulate the distance between
  3418. * @return the distance between the two vectors squared
  3419. */
  3420. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3421. /**
  3422. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3423. * @param value1 value to calulate the center between
  3424. * @param value2 value to calulate the center between
  3425. * @return the center between the two vectors
  3426. */
  3427. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3428. /**
  3429. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3430. * This methods computes transformed normalized direction vectors only.
  3431. * @param vector the vector to transform
  3432. * @param transformation the transformation matrix to apply
  3433. * @returns the new vector
  3434. */
  3435. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3436. /**
  3437. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  3438. * This methods computes transformed normalized direction vectors only.
  3439. * @param vector the vector to transform
  3440. * @param transformation the transformation matrix to apply
  3441. * @param result the vector to store the result in
  3442. */
  3443. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3444. /**
  3445. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3446. * This methods computes transformed normalized direction vectors only.
  3447. * @param x value to transform
  3448. * @param y value to transform
  3449. * @param z value to transform
  3450. * @param w value to transform
  3451. * @param transformation the transformation matrix to apply
  3452. * @param result the vector to store the results in
  3453. */
  3454. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3455. /**
  3456. * Creates a new Vector4 from a Vector3
  3457. * @param source defines the source data
  3458. * @param w defines the 4th component (default is 0)
  3459. * @returns a new Vector4
  3460. */
  3461. static FromVector3(source: Vector3, w?: number): Vector4;
  3462. }
  3463. /**
  3464. * Class used to store quaternion data
  3465. * @see https://en.wikipedia.org/wiki/Quaternion
  3466. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  3467. */
  3468. export class Quaternion {
  3469. /** defines the first component (0 by default) */
  3470. x: number;
  3471. /** defines the second component (0 by default) */
  3472. y: number;
  3473. /** defines the third component (0 by default) */
  3474. z: number;
  3475. /** defines the fourth component (1.0 by default) */
  3476. w: number;
  3477. /**
  3478. * Creates a new Quaternion from the given floats
  3479. * @param x defines the first component (0 by default)
  3480. * @param y defines the second component (0 by default)
  3481. * @param z defines the third component (0 by default)
  3482. * @param w defines the fourth component (1.0 by default)
  3483. */
  3484. constructor(
  3485. /** defines the first component (0 by default) */
  3486. x?: number,
  3487. /** defines the second component (0 by default) */
  3488. y?: number,
  3489. /** defines the third component (0 by default) */
  3490. z?: number,
  3491. /** defines the fourth component (1.0 by default) */
  3492. w?: number);
  3493. /**
  3494. * Gets a string representation for the current quaternion
  3495. * @returns a string with the Quaternion coordinates
  3496. */
  3497. toString(): string;
  3498. /**
  3499. * Gets the class name of the quaternion
  3500. * @returns the string "Quaternion"
  3501. */
  3502. getClassName(): string;
  3503. /**
  3504. * Gets a hash code for this quaternion
  3505. * @returns the quaternion hash code
  3506. */
  3507. getHashCode(): number;
  3508. /**
  3509. * Copy the quaternion to an array
  3510. * @returns a new array populated with 4 elements from the quaternion coordinates
  3511. */
  3512. asArray(): number[];
  3513. /**
  3514. * Check if two quaternions are equals
  3515. * @param otherQuaternion defines the second operand
  3516. * @return true if the current quaternion and the given one coordinates are strictly equals
  3517. */
  3518. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3519. /**
  3520. * Gets a boolean if two quaternions are equals (using an epsilon value)
  3521. * @param otherQuaternion defines the other quaternion
  3522. * @param epsilon defines the minimal distance to consider equality
  3523. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  3524. */
  3525. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  3526. /**
  3527. * Clone the current quaternion
  3528. * @returns a new quaternion copied from the current one
  3529. */
  3530. clone(): Quaternion;
  3531. /**
  3532. * Copy a quaternion to the current one
  3533. * @param other defines the other quaternion
  3534. * @returns the updated current quaternion
  3535. */
  3536. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3537. /**
  3538. * Updates the current quaternion with the given float coordinates
  3539. * @param x defines the x coordinate
  3540. * @param y defines the y coordinate
  3541. * @param z defines the z coordinate
  3542. * @param w defines the w coordinate
  3543. * @returns the updated current quaternion
  3544. */
  3545. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3546. /**
  3547. * Updates the current quaternion from the given float coordinates
  3548. * @param x defines the x coordinate
  3549. * @param y defines the y coordinate
  3550. * @param z defines the z coordinate
  3551. * @param w defines the w coordinate
  3552. * @returns the updated current quaternion
  3553. */
  3554. set(x: number, y: number, z: number, w: number): Quaternion;
  3555. /**
  3556. * Adds two quaternions
  3557. * @param other defines the second operand
  3558. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3559. */
  3560. add(other: DeepImmutable<Quaternion>): Quaternion;
  3561. /**
  3562. * Add a quaternion to the current one
  3563. * @param other defines the quaternion to add
  3564. * @returns the current quaternion
  3565. */
  3566. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3567. /**
  3568. * Subtract two quaternions
  3569. * @param other defines the second operand
  3570. * @returns a new quaternion as the subtraction result of the given one from the current one
  3571. */
  3572. subtract(other: Quaternion): Quaternion;
  3573. /**
  3574. * Multiplies the current quaternion by a scale factor
  3575. * @param value defines the scale factor
  3576. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3577. */
  3578. scale(value: number): Quaternion;
  3579. /**
  3580. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3581. * @param scale defines the scale factor
  3582. * @param result defines the Quaternion object where to store the result
  3583. * @returns the unmodified current quaternion
  3584. */
  3585. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3586. /**
  3587. * Multiplies in place the current quaternion by a scale factor
  3588. * @param value defines the scale factor
  3589. * @returns the current modified quaternion
  3590. */
  3591. scaleInPlace(value: number): Quaternion;
  3592. /**
  3593. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3594. * @param scale defines the scale factor
  3595. * @param result defines the Quaternion object where to store the result
  3596. * @returns the unmodified current quaternion
  3597. */
  3598. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3599. /**
  3600. * Multiplies two quaternions
  3601. * @param q1 defines the second operand
  3602. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3603. */
  3604. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3605. /**
  3606. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3607. * @param q1 defines the second operand
  3608. * @param result defines the target quaternion
  3609. * @returns the current quaternion
  3610. */
  3611. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3612. /**
  3613. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3614. * @param q1 defines the second operand
  3615. * @returns the currentupdated quaternion
  3616. */
  3617. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3618. /**
  3619. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3620. * @param ref defines the target quaternion
  3621. * @returns the current quaternion
  3622. */
  3623. conjugateToRef(ref: Quaternion): Quaternion;
  3624. /**
  3625. * Conjugates in place (1-q) the current quaternion
  3626. * @returns the current updated quaternion
  3627. */
  3628. conjugateInPlace(): Quaternion;
  3629. /**
  3630. * Conjugates in place (1-q) the current quaternion
  3631. * @returns a new quaternion
  3632. */
  3633. conjugate(): Quaternion;
  3634. /**
  3635. * Gets length of current quaternion
  3636. * @returns the quaternion length (float)
  3637. */
  3638. length(): number;
  3639. /**
  3640. * Normalize in place the current quaternion
  3641. * @returns the current updated quaternion
  3642. */
  3643. normalize(): Quaternion;
  3644. /**
  3645. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3646. * @param order is a reserved parameter and is ignore for now
  3647. * @returns a new Vector3 containing the Euler angles
  3648. */
  3649. toEulerAngles(order?: string): Vector3;
  3650. /**
  3651. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3652. * @param result defines the vector which will be filled with the Euler angles
  3653. * @param order is a reserved parameter and is ignore for now
  3654. * @returns the current unchanged quaternion
  3655. */
  3656. toEulerAnglesToRef(result: Vector3): Quaternion;
  3657. /**
  3658. * Updates the given rotation matrix with the current quaternion values
  3659. * @param result defines the target matrix
  3660. * @returns the current unchanged quaternion
  3661. */
  3662. toRotationMatrix(result: Matrix): Quaternion;
  3663. /**
  3664. * Updates the current quaternion from the given rotation matrix values
  3665. * @param matrix defines the source matrix
  3666. * @returns the current updated quaternion
  3667. */
  3668. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3669. /**
  3670. * Creates a new quaternion from a rotation matrix
  3671. * @param matrix defines the source matrix
  3672. * @returns a new quaternion created from the given rotation matrix values
  3673. */
  3674. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3675. /**
  3676. * Updates the given quaternion with the given rotation matrix values
  3677. * @param matrix defines the source matrix
  3678. * @param result defines the target quaternion
  3679. */
  3680. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3681. /**
  3682. * Returns the dot product (float) between the quaternions "left" and "right"
  3683. * @param left defines the left operand
  3684. * @param right defines the right operand
  3685. * @returns the dot product
  3686. */
  3687. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3688. /**
  3689. * Checks if the two quaternions are close to each other
  3690. * @param quat0 defines the first quaternion to check
  3691. * @param quat1 defines the second quaternion to check
  3692. * @returns true if the two quaternions are close to each other
  3693. */
  3694. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3695. /**
  3696. * Creates an empty quaternion
  3697. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3698. */
  3699. static Zero(): Quaternion;
  3700. /**
  3701. * Inverse a given quaternion
  3702. * @param q defines the source quaternion
  3703. * @returns a new quaternion as the inverted current quaternion
  3704. */
  3705. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3706. /**
  3707. * Inverse a given quaternion
  3708. * @param q defines the source quaternion
  3709. * @param result the quaternion the result will be stored in
  3710. * @returns the result quaternion
  3711. */
  3712. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3713. /**
  3714. * Creates an identity quaternion
  3715. * @returns the identity quaternion
  3716. */
  3717. static Identity(): Quaternion;
  3718. /**
  3719. * Gets a boolean indicating if the given quaternion is identity
  3720. * @param quaternion defines the quaternion to check
  3721. * @returns true if the quaternion is identity
  3722. */
  3723. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3724. /**
  3725. * Creates a quaternion from a rotation around an axis
  3726. * @param axis defines the axis to use
  3727. * @param angle defines the angle to use
  3728. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3729. */
  3730. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3731. /**
  3732. * Creates a rotation around an axis and stores it into the given quaternion
  3733. * @param axis defines the axis to use
  3734. * @param angle defines the angle to use
  3735. * @param result defines the target quaternion
  3736. * @returns the target quaternion
  3737. */
  3738. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3739. /**
  3740. * Creates a new quaternion from data stored into an array
  3741. * @param array defines the data source
  3742. * @param offset defines the offset in the source array where the data starts
  3743. * @returns a new quaternion
  3744. */
  3745. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3746. /**
  3747. * Create a quaternion from Euler rotation angles
  3748. * @param x Pitch
  3749. * @param y Yaw
  3750. * @param z Roll
  3751. * @returns the new Quaternion
  3752. */
  3753. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3754. /**
  3755. * Updates a quaternion from Euler rotation angles
  3756. * @param x Pitch
  3757. * @param y Yaw
  3758. * @param z Roll
  3759. * @param result the quaternion to store the result
  3760. * @returns the updated quaternion
  3761. */
  3762. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3763. /**
  3764. * Create a quaternion from Euler rotation vector
  3765. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3766. * @returns the new Quaternion
  3767. */
  3768. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3769. /**
  3770. * Updates a quaternion from Euler rotation vector
  3771. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3772. * @param result the quaternion to store the result
  3773. * @returns the updated quaternion
  3774. */
  3775. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3776. /**
  3777. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3778. * @param yaw defines the rotation around Y axis
  3779. * @param pitch defines the rotation around X axis
  3780. * @param roll defines the rotation around Z axis
  3781. * @returns the new quaternion
  3782. */
  3783. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3784. /**
  3785. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  3786. * @param yaw defines the rotation around Y axis
  3787. * @param pitch defines the rotation around X axis
  3788. * @param roll defines the rotation around Z axis
  3789. * @param result defines the target quaternion
  3790. */
  3791. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  3792. /**
  3793. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  3794. * @param alpha defines the rotation around first axis
  3795. * @param beta defines the rotation around second axis
  3796. * @param gamma defines the rotation around third axis
  3797. * @returns the new quaternion
  3798. */
  3799. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  3800. /**
  3801. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  3802. * @param alpha defines the rotation around first axis
  3803. * @param beta defines the rotation around second axis
  3804. * @param gamma defines the rotation around third axis
  3805. * @param result defines the target quaternion
  3806. */
  3807. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  3808. /**
  3809. * Creates a new quaternion containing the rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation)
  3810. * @param axis1 defines the first axis
  3811. * @param axis2 defines the second axis
  3812. * @param axis3 defines the third axis
  3813. * @returns the new quaternion
  3814. */
  3815. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  3816. /**
  3817. * Creates a rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation) and stores it in the target quaternion
  3818. * @param axis1 defines the first axis
  3819. * @param axis2 defines the second axis
  3820. * @param axis3 defines the third axis
  3821. * @param ref defines the target quaternion
  3822. */
  3823. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  3824. /**
  3825. * Interpolates between two quaternions
  3826. * @param left defines first quaternion
  3827. * @param right defines second quaternion
  3828. * @param amount defines the gradient to use
  3829. * @returns the new interpolated quaternion
  3830. */
  3831. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3832. /**
  3833. * Interpolates between two quaternions and stores it into a target quaternion
  3834. * @param left defines first quaternion
  3835. * @param right defines second quaternion
  3836. * @param amount defines the gradient to use
  3837. * @param result defines the target quaternion
  3838. */
  3839. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  3840. /**
  3841. * Interpolate between two quaternions using Hermite interpolation
  3842. * @param value1 defines first quaternion
  3843. * @param tangent1 defines the incoming tangent
  3844. * @param value2 defines second quaternion
  3845. * @param tangent2 defines the outgoing tangent
  3846. * @param amount defines the target quaternion
  3847. * @returns the new interpolated quaternion
  3848. */
  3849. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3850. }
  3851. /**
  3852. * Class used to store matrix data (4x4)
  3853. */
  3854. export class Matrix {
  3855. private static _updateFlagSeed;
  3856. private static _identityReadOnly;
  3857. private _isIdentity;
  3858. private _isIdentityDirty;
  3859. private _isIdentity3x2;
  3860. private _isIdentity3x2Dirty;
  3861. /**
  3862. * Gets the update flag of the matrix which is an unique number for the matrix.
  3863. * It will be incremented every time the matrix data change.
  3864. * You can use it to speed the comparison between two versions of the same matrix.
  3865. */
  3866. updateFlag: number;
  3867. private readonly _m;
  3868. /**
  3869. * Gets the internal data of the matrix
  3870. */
  3871. get m(): DeepImmutable<Float32Array>;
  3872. /** @hidden */
  3873. _markAsUpdated(): void;
  3874. /** @hidden */
  3875. private _updateIdentityStatus;
  3876. /**
  3877. * Creates an empty matrix (filled with zeros)
  3878. */
  3879. constructor();
  3880. /**
  3881. * Check if the current matrix is identity
  3882. * @returns true is the matrix is the identity matrix
  3883. */
  3884. isIdentity(): boolean;
  3885. /**
  3886. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  3887. * @returns true is the matrix is the identity matrix
  3888. */
  3889. isIdentityAs3x2(): boolean;
  3890. /**
  3891. * Gets the determinant of the matrix
  3892. * @returns the matrix determinant
  3893. */
  3894. determinant(): number;
  3895. /**
  3896. * Returns the matrix as a Float32Array
  3897. * @returns the matrix underlying array
  3898. */
  3899. toArray(): DeepImmutable<Float32Array>;
  3900. /**
  3901. * Returns the matrix as a Float32Array
  3902. * @returns the matrix underlying array.
  3903. */
  3904. asArray(): DeepImmutable<Float32Array>;
  3905. /**
  3906. * Inverts the current matrix in place
  3907. * @returns the current inverted matrix
  3908. */
  3909. invert(): Matrix;
  3910. /**
  3911. * Sets all the matrix elements to zero
  3912. * @returns the current matrix
  3913. */
  3914. reset(): Matrix;
  3915. /**
  3916. * Adds the current matrix with a second one
  3917. * @param other defines the matrix to add
  3918. * @returns a new matrix as the addition of the current matrix and the given one
  3919. */
  3920. add(other: DeepImmutable<Matrix>): Matrix;
  3921. /**
  3922. * Sets the given matrix "result" to the addition of the current matrix and the given one
  3923. * @param other defines the matrix to add
  3924. * @param result defines the target matrix
  3925. * @returns the current matrix
  3926. */
  3927. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3928. /**
  3929. * Adds in place the given matrix to the current matrix
  3930. * @param other defines the second operand
  3931. * @returns the current updated matrix
  3932. */
  3933. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  3934. /**
  3935. * Sets the given matrix to the current inverted Matrix
  3936. * @param other defines the target matrix
  3937. * @returns the unmodified current matrix
  3938. */
  3939. invertToRef(other: Matrix): Matrix;
  3940. /**
  3941. * add a value at the specified position in the current Matrix
  3942. * @param index the index of the value within the matrix. between 0 and 15.
  3943. * @param value the value to be added
  3944. * @returns the current updated matrix
  3945. */
  3946. addAtIndex(index: number, value: number): Matrix;
  3947. /**
  3948. * mutiply the specified position in the current Matrix by a value
  3949. * @param index the index of the value within the matrix. between 0 and 15.
  3950. * @param value the value to be added
  3951. * @returns the current updated matrix
  3952. */
  3953. multiplyAtIndex(index: number, value: number): Matrix;
  3954. /**
  3955. * Inserts the translation vector (using 3 floats) in the current matrix
  3956. * @param x defines the 1st component of the translation
  3957. * @param y defines the 2nd component of the translation
  3958. * @param z defines the 3rd component of the translation
  3959. * @returns the current updated matrix
  3960. */
  3961. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3962. /**
  3963. * Adds the translation vector (using 3 floats) in the current matrix
  3964. * @param x defines the 1st component of the translation
  3965. * @param y defines the 2nd component of the translation
  3966. * @param z defines the 3rd component of the translation
  3967. * @returns the current updated matrix
  3968. */
  3969. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3970. /**
  3971. * Inserts the translation vector in the current matrix
  3972. * @param vector3 defines the translation to insert
  3973. * @returns the current updated matrix
  3974. */
  3975. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  3976. /**
  3977. * Gets the translation value of the current matrix
  3978. * @returns a new Vector3 as the extracted translation from the matrix
  3979. */
  3980. getTranslation(): Vector3;
  3981. /**
  3982. * Fill a Vector3 with the extracted translation from the matrix
  3983. * @param result defines the Vector3 where to store the translation
  3984. * @returns the current matrix
  3985. */
  3986. getTranslationToRef(result: Vector3): Matrix;
  3987. /**
  3988. * Remove rotation and scaling part from the matrix
  3989. * @returns the updated matrix
  3990. */
  3991. removeRotationAndScaling(): Matrix;
  3992. /**
  3993. * Multiply two matrices
  3994. * @param other defines the second operand
  3995. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  3996. */
  3997. multiply(other: DeepImmutable<Matrix>): Matrix;
  3998. /**
  3999. * Copy the current matrix from the given one
  4000. * @param other defines the source matrix
  4001. * @returns the current updated matrix
  4002. */
  4003. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  4004. /**
  4005. * Populates the given array from the starting index with the current matrix values
  4006. * @param array defines the target array
  4007. * @param offset defines the offset in the target array where to start storing values
  4008. * @returns the current matrix
  4009. */
  4010. copyToArray(array: Float32Array, offset?: number): Matrix;
  4011. /**
  4012. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  4013. * @param other defines the second operand
  4014. * @param result defines the matrix where to store the multiplication
  4015. * @returns the current matrix
  4016. */
  4017. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4018. /**
  4019. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  4020. * @param other defines the second operand
  4021. * @param result defines the array where to store the multiplication
  4022. * @param offset defines the offset in the target array where to start storing values
  4023. * @returns the current matrix
  4024. */
  4025. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  4026. /**
  4027. * Check equality between this matrix and a second one
  4028. * @param value defines the second matrix to compare
  4029. * @returns true is the current matrix and the given one values are strictly equal
  4030. */
  4031. equals(value: DeepImmutable<Matrix>): boolean;
  4032. /**
  4033. * Clone the current matrix
  4034. * @returns a new matrix from the current matrix
  4035. */
  4036. clone(): Matrix;
  4037. /**
  4038. * Returns the name of the current matrix class
  4039. * @returns the string "Matrix"
  4040. */
  4041. getClassName(): string;
  4042. /**
  4043. * Gets the hash code of the current matrix
  4044. * @returns the hash code
  4045. */
  4046. getHashCode(): number;
  4047. /**
  4048. * Decomposes the current Matrix into a translation, rotation and scaling components
  4049. * @param scale defines the scale vector3 given as a reference to update
  4050. * @param rotation defines the rotation quaternion given as a reference to update
  4051. * @param translation defines the translation vector3 given as a reference to update
  4052. * @returns true if operation was successful
  4053. */
  4054. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4055. /**
  4056. * Gets specific row of the matrix
  4057. * @param index defines the number of the row to get
  4058. * @returns the index-th row of the current matrix as a new Vector4
  4059. */
  4060. getRow(index: number): Nullable<Vector4>;
  4061. /**
  4062. * Sets the index-th row of the current matrix to the vector4 values
  4063. * @param index defines the number of the row to set
  4064. * @param row defines the target vector4
  4065. * @returns the updated current matrix
  4066. */
  4067. setRow(index: number, row: Vector4): Matrix;
  4068. /**
  4069. * Compute the transpose of the matrix
  4070. * @returns the new transposed matrix
  4071. */
  4072. transpose(): Matrix;
  4073. /**
  4074. * Compute the transpose of the matrix and store it in a given matrix
  4075. * @param result defines the target matrix
  4076. * @returns the current matrix
  4077. */
  4078. transposeToRef(result: Matrix): Matrix;
  4079. /**
  4080. * Sets the index-th row of the current matrix with the given 4 x float values
  4081. * @param index defines the row index
  4082. * @param x defines the x component to set
  4083. * @param y defines the y component to set
  4084. * @param z defines the z component to set
  4085. * @param w defines the w component to set
  4086. * @returns the updated current matrix
  4087. */
  4088. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4089. /**
  4090. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4091. * @param scale defines the scale factor
  4092. * @returns a new matrix
  4093. */
  4094. scale(scale: number): Matrix;
  4095. /**
  4096. * Scale the current matrix values by a factor to a given result matrix
  4097. * @param scale defines the scale factor
  4098. * @param result defines the matrix to store the result
  4099. * @returns the current matrix
  4100. */
  4101. scaleToRef(scale: number, result: Matrix): Matrix;
  4102. /**
  4103. * Scale the current matrix values by a factor and add the result to a given matrix
  4104. * @param scale defines the scale factor
  4105. * @param result defines the Matrix to store the result
  4106. * @returns the current matrix
  4107. */
  4108. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4109. /**
  4110. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4111. * @param ref matrix to store the result
  4112. */
  4113. toNormalMatrix(ref: Matrix): void;
  4114. /**
  4115. * Gets only rotation part of the current matrix
  4116. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4117. */
  4118. getRotationMatrix(): Matrix;
  4119. /**
  4120. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4121. * @param result defines the target matrix to store data to
  4122. * @returns the current matrix
  4123. */
  4124. getRotationMatrixToRef(result: Matrix): Matrix;
  4125. /**
  4126. * Toggles model matrix from being right handed to left handed in place and vice versa
  4127. */
  4128. toggleModelMatrixHandInPlace(): void;
  4129. /**
  4130. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4131. */
  4132. toggleProjectionMatrixHandInPlace(): void;
  4133. /**
  4134. * Creates a matrix from an array
  4135. * @param array defines the source array
  4136. * @param offset defines an offset in the source array
  4137. * @returns a new Matrix set from the starting index of the given array
  4138. */
  4139. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4140. /**
  4141. * Copy the content of an array into a given matrix
  4142. * @param array defines the source array
  4143. * @param offset defines an offset in the source array
  4144. * @param result defines the target matrix
  4145. */
  4146. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4147. /**
  4148. * Stores an array into a matrix after having multiplied each component by a given factor
  4149. * @param array defines the source array
  4150. * @param offset defines the offset in the source array
  4151. * @param scale defines the scaling factor
  4152. * @param result defines the target matrix
  4153. */
  4154. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  4155. /**
  4156. * Gets an identity matrix that must not be updated
  4157. */
  4158. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  4159. /**
  4160. * Stores a list of values (16) inside a given matrix
  4161. * @param initialM11 defines 1st value of 1st row
  4162. * @param initialM12 defines 2nd value of 1st row
  4163. * @param initialM13 defines 3rd value of 1st row
  4164. * @param initialM14 defines 4th value of 1st row
  4165. * @param initialM21 defines 1st value of 2nd row
  4166. * @param initialM22 defines 2nd value of 2nd row
  4167. * @param initialM23 defines 3rd value of 2nd row
  4168. * @param initialM24 defines 4th value of 2nd row
  4169. * @param initialM31 defines 1st value of 3rd row
  4170. * @param initialM32 defines 2nd value of 3rd row
  4171. * @param initialM33 defines 3rd value of 3rd row
  4172. * @param initialM34 defines 4th value of 3rd row
  4173. * @param initialM41 defines 1st value of 4th row
  4174. * @param initialM42 defines 2nd value of 4th row
  4175. * @param initialM43 defines 3rd value of 4th row
  4176. * @param initialM44 defines 4th value of 4th row
  4177. * @param result defines the target matrix
  4178. */
  4179. static FromValuesToRef(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number, result: Matrix): void;
  4180. /**
  4181. * Creates new matrix from a list of values (16)
  4182. * @param initialM11 defines 1st value of 1st row
  4183. * @param initialM12 defines 2nd value of 1st row
  4184. * @param initialM13 defines 3rd value of 1st row
  4185. * @param initialM14 defines 4th value of 1st row
  4186. * @param initialM21 defines 1st value of 2nd row
  4187. * @param initialM22 defines 2nd value of 2nd row
  4188. * @param initialM23 defines 3rd value of 2nd row
  4189. * @param initialM24 defines 4th value of 2nd row
  4190. * @param initialM31 defines 1st value of 3rd row
  4191. * @param initialM32 defines 2nd value of 3rd row
  4192. * @param initialM33 defines 3rd value of 3rd row
  4193. * @param initialM34 defines 4th value of 3rd row
  4194. * @param initialM41 defines 1st value of 4th row
  4195. * @param initialM42 defines 2nd value of 4th row
  4196. * @param initialM43 defines 3rd value of 4th row
  4197. * @param initialM44 defines 4th value of 4th row
  4198. * @returns the new matrix
  4199. */
  4200. static FromValues(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number): Matrix;
  4201. /**
  4202. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4203. * @param scale defines the scale vector3
  4204. * @param rotation defines the rotation quaternion
  4205. * @param translation defines the translation vector3
  4206. * @returns a new matrix
  4207. */
  4208. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4209. /**
  4210. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4211. * @param scale defines the scale vector3
  4212. * @param rotation defines the rotation quaternion
  4213. * @param translation defines the translation vector3
  4214. * @param result defines the target matrix
  4215. */
  4216. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4217. /**
  4218. * Creates a new identity matrix
  4219. * @returns a new identity matrix
  4220. */
  4221. static Identity(): Matrix;
  4222. /**
  4223. * Creates a new identity matrix and stores the result in a given matrix
  4224. * @param result defines the target matrix
  4225. */
  4226. static IdentityToRef(result: Matrix): void;
  4227. /**
  4228. * Creates a new zero matrix
  4229. * @returns a new zero matrix
  4230. */
  4231. static Zero(): Matrix;
  4232. /**
  4233. * Creates a new rotation matrix for "angle" radians around the X axis
  4234. * @param angle defines the angle (in radians) to use
  4235. * @return the new matrix
  4236. */
  4237. static RotationX(angle: number): Matrix;
  4238. /**
  4239. * Creates a new matrix as the invert of a given matrix
  4240. * @param source defines the source matrix
  4241. * @returns the new matrix
  4242. */
  4243. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4244. /**
  4245. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4246. * @param angle defines the angle (in radians) to use
  4247. * @param result defines the target matrix
  4248. */
  4249. static RotationXToRef(angle: number, result: Matrix): void;
  4250. /**
  4251. * Creates a new rotation matrix for "angle" radians around the Y axis
  4252. * @param angle defines the angle (in radians) to use
  4253. * @return the new matrix
  4254. */
  4255. static RotationY(angle: number): Matrix;
  4256. /**
  4257. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4258. * @param angle defines the angle (in radians) to use
  4259. * @param result defines the target matrix
  4260. */
  4261. static RotationYToRef(angle: number, result: Matrix): void;
  4262. /**
  4263. * Creates a new rotation matrix for "angle" radians around the Z axis
  4264. * @param angle defines the angle (in radians) to use
  4265. * @return the new matrix
  4266. */
  4267. static RotationZ(angle: number): Matrix;
  4268. /**
  4269. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4270. * @param angle defines the angle (in radians) to use
  4271. * @param result defines the target matrix
  4272. */
  4273. static RotationZToRef(angle: number, result: Matrix): void;
  4274. /**
  4275. * Creates a new rotation matrix for "angle" radians around the given axis
  4276. * @param axis defines the axis to use
  4277. * @param angle defines the angle (in radians) to use
  4278. * @return the new matrix
  4279. */
  4280. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4281. /**
  4282. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4283. * @param axis defines the axis to use
  4284. * @param angle defines the angle (in radians) to use
  4285. * @param result defines the target matrix
  4286. */
  4287. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4288. /**
  4289. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4290. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4291. * @param from defines the vector to align
  4292. * @param to defines the vector to align to
  4293. * @param result defines the target matrix
  4294. */
  4295. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4296. /**
  4297. * Creates a rotation matrix
  4298. * @param yaw defines the yaw angle in radians (Y axis)
  4299. * @param pitch defines the pitch angle in radians (X axis)
  4300. * @param roll defines the roll angle in radians (X axis)
  4301. * @returns the new rotation matrix
  4302. */
  4303. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4304. /**
  4305. * Creates a rotation matrix and stores it in a given matrix
  4306. * @param yaw defines the yaw angle in radians (Y axis)
  4307. * @param pitch defines the pitch angle in radians (X axis)
  4308. * @param roll defines the roll angle in radians (X axis)
  4309. * @param result defines the target matrix
  4310. */
  4311. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4312. /**
  4313. * Creates a scaling matrix
  4314. * @param x defines the scale factor on X axis
  4315. * @param y defines the scale factor on Y axis
  4316. * @param z defines the scale factor on Z axis
  4317. * @returns the new matrix
  4318. */
  4319. static Scaling(x: number, y: number, z: number): Matrix;
  4320. /**
  4321. * Creates a scaling matrix and stores it in a given matrix
  4322. * @param x defines the scale factor on X axis
  4323. * @param y defines the scale factor on Y axis
  4324. * @param z defines the scale factor on Z axis
  4325. * @param result defines the target matrix
  4326. */
  4327. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4328. /**
  4329. * Creates a translation matrix
  4330. * @param x defines the translation on X axis
  4331. * @param y defines the translation on Y axis
  4332. * @param z defines the translationon Z axis
  4333. * @returns the new matrix
  4334. */
  4335. static Translation(x: number, y: number, z: number): Matrix;
  4336. /**
  4337. * Creates a translation matrix and stores it in a given matrix
  4338. * @param x defines the translation on X axis
  4339. * @param y defines the translation on Y axis
  4340. * @param z defines the translationon Z axis
  4341. * @param result defines the target matrix
  4342. */
  4343. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4344. /**
  4345. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4346. * @param startValue defines the start value
  4347. * @param endValue defines the end value
  4348. * @param gradient defines the gradient factor
  4349. * @returns the new matrix
  4350. */
  4351. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4352. /**
  4353. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4354. * @param startValue defines the start value
  4355. * @param endValue defines the end value
  4356. * @param gradient defines the gradient factor
  4357. * @param result defines the Matrix object where to store data
  4358. */
  4359. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4360. /**
  4361. * Builds a new matrix whose values are computed by:
  4362. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4363. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4364. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4365. * @param startValue defines the first matrix
  4366. * @param endValue defines the second matrix
  4367. * @param gradient defines the gradient between the two matrices
  4368. * @returns the new matrix
  4369. */
  4370. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4371. /**
  4372. * Update a matrix to values which are computed by:
  4373. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4374. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4375. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4376. * @param startValue defines the first matrix
  4377. * @param endValue defines the second matrix
  4378. * @param gradient defines the gradient between the two matrices
  4379. * @param result defines the target matrix
  4380. */
  4381. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4382. /**
  4383. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  4384. * This function works in left handed mode
  4385. * @param eye defines the final position of the entity
  4386. * @param target defines where the entity should look at
  4387. * @param up defines the up vector for the entity
  4388. * @returns the new matrix
  4389. */
  4390. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4391. /**
  4392. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  4393. * This function works in left handed mode
  4394. * @param eye defines the final position of the entity
  4395. * @param target defines where the entity should look at
  4396. * @param up defines the up vector for the entity
  4397. * @param result defines the target matrix
  4398. */
  4399. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4400. /**
  4401. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  4402. * This function works in right handed mode
  4403. * @param eye defines the final position of the entity
  4404. * @param target defines where the entity should look at
  4405. * @param up defines the up vector for the entity
  4406. * @returns the new matrix
  4407. */
  4408. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4409. /**
  4410. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  4411. * This function works in right handed mode
  4412. * @param eye defines the final position of the entity
  4413. * @param target defines where the entity should look at
  4414. * @param up defines the up vector for the entity
  4415. * @param result defines the target matrix
  4416. */
  4417. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4418. /**
  4419. * Create a left-handed orthographic projection matrix
  4420. * @param width defines the viewport width
  4421. * @param height defines the viewport height
  4422. * @param znear defines the near clip plane
  4423. * @param zfar defines the far clip plane
  4424. * @returns a new matrix as a left-handed orthographic projection matrix
  4425. */
  4426. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4427. /**
  4428. * Store a left-handed orthographic projection to a given matrix
  4429. * @param width defines the viewport width
  4430. * @param height defines the viewport height
  4431. * @param znear defines the near clip plane
  4432. * @param zfar defines the far clip plane
  4433. * @param result defines the target matrix
  4434. */
  4435. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  4436. /**
  4437. * Create a left-handed orthographic projection matrix
  4438. * @param left defines the viewport left coordinate
  4439. * @param right defines the viewport right coordinate
  4440. * @param bottom defines the viewport bottom coordinate
  4441. * @param top defines the viewport top coordinate
  4442. * @param znear defines the near clip plane
  4443. * @param zfar defines the far clip plane
  4444. * @returns a new matrix as a left-handed orthographic projection matrix
  4445. */
  4446. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4447. /**
  4448. * Stores a left-handed orthographic projection into a given matrix
  4449. * @param left defines the viewport left coordinate
  4450. * @param right defines the viewport right coordinate
  4451. * @param bottom defines the viewport bottom coordinate
  4452. * @param top defines the viewport top coordinate
  4453. * @param znear defines the near clip plane
  4454. * @param zfar defines the far clip plane
  4455. * @param result defines the target matrix
  4456. */
  4457. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4458. /**
  4459. * Creates a right-handed orthographic projection matrix
  4460. * @param left defines the viewport left coordinate
  4461. * @param right defines the viewport right coordinate
  4462. * @param bottom defines the viewport bottom coordinate
  4463. * @param top defines the viewport top coordinate
  4464. * @param znear defines the near clip plane
  4465. * @param zfar defines the far clip plane
  4466. * @returns a new matrix as a right-handed orthographic projection matrix
  4467. */
  4468. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4469. /**
  4470. * Stores a right-handed orthographic projection into a given matrix
  4471. * @param left defines the viewport left coordinate
  4472. * @param right defines the viewport right coordinate
  4473. * @param bottom defines the viewport bottom coordinate
  4474. * @param top defines the viewport top coordinate
  4475. * @param znear defines the near clip plane
  4476. * @param zfar defines the far clip plane
  4477. * @param result defines the target matrix
  4478. */
  4479. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4480. /**
  4481. * Creates a left-handed perspective projection matrix
  4482. * @param width defines the viewport width
  4483. * @param height defines the viewport height
  4484. * @param znear defines the near clip plane
  4485. * @param zfar defines the far clip plane
  4486. * @returns a new matrix as a left-handed perspective projection matrix
  4487. */
  4488. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4489. /**
  4490. * Creates a left-handed perspective projection matrix
  4491. * @param fov defines the horizontal field of view
  4492. * @param aspect defines the aspect ratio
  4493. * @param znear defines the near clip plane
  4494. * @param zfar defines the far clip plane
  4495. * @returns a new matrix as a left-handed perspective projection matrix
  4496. */
  4497. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4498. /**
  4499. * Stores a left-handed perspective projection into a given matrix
  4500. * @param fov defines the horizontal field of view
  4501. * @param aspect defines the aspect ratio
  4502. * @param znear defines the near clip plane
  4503. * @param zfar defines the far clip plane
  4504. * @param result defines the target matrix
  4505. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4506. */
  4507. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4508. /**
  4509. * Stores a left-handed perspective projection into a given matrix with depth reversed
  4510. * @param fov defines the horizontal field of view
  4511. * @param aspect defines the aspect ratio
  4512. * @param znear defines the near clip plane
  4513. * @param zfar not used as infinity is used as far clip
  4514. * @param result defines the target matrix
  4515. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4516. */
  4517. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4518. /**
  4519. * Creates a right-handed perspective projection matrix
  4520. * @param fov defines the horizontal field of view
  4521. * @param aspect defines the aspect ratio
  4522. * @param znear defines the near clip plane
  4523. * @param zfar defines the far clip plane
  4524. * @returns a new matrix as a right-handed perspective projection matrix
  4525. */
  4526. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4527. /**
  4528. * Stores a right-handed perspective projection into a given matrix
  4529. * @param fov defines the horizontal field of view
  4530. * @param aspect defines the aspect ratio
  4531. * @param znear defines the near clip plane
  4532. * @param zfar defines the far clip plane
  4533. * @param result defines the target matrix
  4534. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4535. */
  4536. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4537. /**
  4538. * Stores a right-handed perspective projection into a given matrix
  4539. * @param fov defines the horizontal field of view
  4540. * @param aspect defines the aspect ratio
  4541. * @param znear defines the near clip plane
  4542. * @param zfar not used as infinity is used as far clip
  4543. * @param result defines the target matrix
  4544. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4545. */
  4546. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4547. /**
  4548. * Stores a perspective projection for WebVR info a given matrix
  4549. * @param fov defines the field of view
  4550. * @param znear defines the near clip plane
  4551. * @param zfar defines the far clip plane
  4552. * @param result defines the target matrix
  4553. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4554. */
  4555. static PerspectiveFovWebVRToRef(fov: {
  4556. upDegrees: number;
  4557. downDegrees: number;
  4558. leftDegrees: number;
  4559. rightDegrees: number;
  4560. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4561. /**
  4562. * Computes a complete transformation matrix
  4563. * @param viewport defines the viewport to use
  4564. * @param world defines the world matrix
  4565. * @param view defines the view matrix
  4566. * @param projection defines the projection matrix
  4567. * @param zmin defines the near clip plane
  4568. * @param zmax defines the far clip plane
  4569. * @returns the transformation matrix
  4570. */
  4571. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4572. /**
  4573. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4574. * @param matrix defines the matrix to use
  4575. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4576. */
  4577. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  4578. /**
  4579. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4580. * @param matrix defines the matrix to use
  4581. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4582. */
  4583. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  4584. /**
  4585. * Compute the transpose of a given matrix
  4586. * @param matrix defines the matrix to transpose
  4587. * @returns the new matrix
  4588. */
  4589. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4590. /**
  4591. * Compute the transpose of a matrix and store it in a target matrix
  4592. * @param matrix defines the matrix to transpose
  4593. * @param result defines the target matrix
  4594. */
  4595. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4596. /**
  4597. * Computes a reflection matrix from a plane
  4598. * @param plane defines the reflection plane
  4599. * @returns a new matrix
  4600. */
  4601. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4602. /**
  4603. * Computes a reflection matrix from a plane
  4604. * @param plane defines the reflection plane
  4605. * @param result defines the target matrix
  4606. */
  4607. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4608. /**
  4609. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4610. * @param xaxis defines the value of the 1st axis
  4611. * @param yaxis defines the value of the 2nd axis
  4612. * @param zaxis defines the value of the 3rd axis
  4613. * @param result defines the target matrix
  4614. */
  4615. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4616. /**
  4617. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4618. * @param quat defines the quaternion to use
  4619. * @param result defines the target matrix
  4620. */
  4621. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4622. }
  4623. /**
  4624. * @hidden
  4625. */
  4626. export class TmpVectors {
  4627. static Vector2: Vector2[];
  4628. static Vector3: Vector3[];
  4629. static Vector4: Vector4[];
  4630. static Quaternion: Quaternion[];
  4631. static Matrix: Matrix[];
  4632. }
  4633. }
  4634. declare module BABYLON {
  4635. /**
  4636. * Defines potential orientation for back face culling
  4637. */
  4638. export enum Orientation {
  4639. /**
  4640. * Clockwise
  4641. */
  4642. CW = 0,
  4643. /** Counter clockwise */
  4644. CCW = 1
  4645. }
  4646. /** Class used to represent a Bezier curve */
  4647. export class BezierCurve {
  4648. /**
  4649. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4650. * @param t defines the time
  4651. * @param x1 defines the left coordinate on X axis
  4652. * @param y1 defines the left coordinate on Y axis
  4653. * @param x2 defines the right coordinate on X axis
  4654. * @param y2 defines the right coordinate on Y axis
  4655. * @returns the interpolated value
  4656. */
  4657. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4658. }
  4659. /**
  4660. * Defines angle representation
  4661. */
  4662. export class Angle {
  4663. private _radians;
  4664. /**
  4665. * Creates an Angle object of "radians" radians (float).
  4666. * @param radians the angle in radians
  4667. */
  4668. constructor(radians: number);
  4669. /**
  4670. * Get value in degrees
  4671. * @returns the Angle value in degrees (float)
  4672. */
  4673. degrees(): number;
  4674. /**
  4675. * Get value in radians
  4676. * @returns the Angle value in radians (float)
  4677. */
  4678. radians(): number;
  4679. /**
  4680. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  4681. * @param a defines first vector
  4682. * @param b defines second vector
  4683. * @returns a new Angle
  4684. */
  4685. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4686. /**
  4687. * Gets a new Angle object from the given float in radians
  4688. * @param radians defines the angle value in radians
  4689. * @returns a new Angle
  4690. */
  4691. static FromRadians(radians: number): Angle;
  4692. /**
  4693. * Gets a new Angle object from the given float in degrees
  4694. * @param degrees defines the angle value in degrees
  4695. * @returns a new Angle
  4696. */
  4697. static FromDegrees(degrees: number): Angle;
  4698. }
  4699. /**
  4700. * This represents an arc in a 2d space.
  4701. */
  4702. export class Arc2 {
  4703. /** Defines the start point of the arc */
  4704. startPoint: Vector2;
  4705. /** Defines the mid point of the arc */
  4706. midPoint: Vector2;
  4707. /** Defines the end point of the arc */
  4708. endPoint: Vector2;
  4709. /**
  4710. * Defines the center point of the arc.
  4711. */
  4712. centerPoint: Vector2;
  4713. /**
  4714. * Defines the radius of the arc.
  4715. */
  4716. radius: number;
  4717. /**
  4718. * Defines the angle of the arc (from mid point to end point).
  4719. */
  4720. angle: Angle;
  4721. /**
  4722. * Defines the start angle of the arc (from start point to middle point).
  4723. */
  4724. startAngle: Angle;
  4725. /**
  4726. * Defines the orientation of the arc (clock wise/counter clock wise).
  4727. */
  4728. orientation: Orientation;
  4729. /**
  4730. * Creates an Arc object from the three given points : start, middle and end.
  4731. * @param startPoint Defines the start point of the arc
  4732. * @param midPoint Defines the midlle point of the arc
  4733. * @param endPoint Defines the end point of the arc
  4734. */
  4735. constructor(
  4736. /** Defines the start point of the arc */
  4737. startPoint: Vector2,
  4738. /** Defines the mid point of the arc */
  4739. midPoint: Vector2,
  4740. /** Defines the end point of the arc */
  4741. endPoint: Vector2);
  4742. }
  4743. /**
  4744. * Represents a 2D path made up of multiple 2D points
  4745. */
  4746. export class Path2 {
  4747. private _points;
  4748. private _length;
  4749. /**
  4750. * If the path start and end point are the same
  4751. */
  4752. closed: boolean;
  4753. /**
  4754. * Creates a Path2 object from the starting 2D coordinates x and y.
  4755. * @param x the starting points x value
  4756. * @param y the starting points y value
  4757. */
  4758. constructor(x: number, y: number);
  4759. /**
  4760. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  4761. * @param x the added points x value
  4762. * @param y the added points y value
  4763. * @returns the updated Path2.
  4764. */
  4765. addLineTo(x: number, y: number): Path2;
  4766. /**
  4767. * Adds _numberOfSegments_ segments according to the arc definition (middle point coordinates, end point coordinates, the arc start point being the current Path2 last point) to the current Path2.
  4768. * @param midX middle point x value
  4769. * @param midY middle point y value
  4770. * @param endX end point x value
  4771. * @param endY end point y value
  4772. * @param numberOfSegments (default: 36)
  4773. * @returns the updated Path2.
  4774. */
  4775. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  4776. /**
  4777. * Closes the Path2.
  4778. * @returns the Path2.
  4779. */
  4780. close(): Path2;
  4781. /**
  4782. * Gets the sum of the distance between each sequential point in the path
  4783. * @returns the Path2 total length (float).
  4784. */
  4785. length(): number;
  4786. /**
  4787. * Gets the points which construct the path
  4788. * @returns the Path2 internal array of points.
  4789. */
  4790. getPoints(): Vector2[];
  4791. /**
  4792. * Retreives the point at the distance aways from the starting point
  4793. * @param normalizedLengthPosition the length along the path to retreive the point from
  4794. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  4795. */
  4796. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  4797. /**
  4798. * Creates a new path starting from an x and y position
  4799. * @param x starting x value
  4800. * @param y starting y value
  4801. * @returns a new Path2 starting at the coordinates (x, y).
  4802. */
  4803. static StartingAt(x: number, y: number): Path2;
  4804. }
  4805. /**
  4806. * Represents a 3D path made up of multiple 3D points
  4807. */
  4808. export class Path3D {
  4809. /**
  4810. * an array of Vector3, the curve axis of the Path3D
  4811. */
  4812. path: Vector3[];
  4813. private _curve;
  4814. private _distances;
  4815. private _tangents;
  4816. private _normals;
  4817. private _binormals;
  4818. private _raw;
  4819. private _alignTangentsWithPath;
  4820. private readonly _pointAtData;
  4821. /**
  4822. * new Path3D(path, normal, raw)
  4823. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  4824. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  4825. * @param path an array of Vector3, the curve axis of the Path3D
  4826. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  4827. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  4828. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  4829. */
  4830. constructor(
  4831. /**
  4832. * an array of Vector3, the curve axis of the Path3D
  4833. */
  4834. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  4835. /**
  4836. * Returns the Path3D array of successive Vector3 designing its curve.
  4837. * @returns the Path3D array of successive Vector3 designing its curve.
  4838. */
  4839. getCurve(): Vector3[];
  4840. /**
  4841. * Returns the Path3D array of successive Vector3 designing its curve.
  4842. * @returns the Path3D array of successive Vector3 designing its curve.
  4843. */
  4844. getPoints(): Vector3[];
  4845. /**
  4846. * @returns the computed length (float) of the path.
  4847. */
  4848. length(): number;
  4849. /**
  4850. * Returns an array populated with tangent vectors on each Path3D curve point.
  4851. * @returns an array populated with tangent vectors on each Path3D curve point.
  4852. */
  4853. getTangents(): Vector3[];
  4854. /**
  4855. * Returns an array populated with normal vectors on each Path3D curve point.
  4856. * @returns an array populated with normal vectors on each Path3D curve point.
  4857. */
  4858. getNormals(): Vector3[];
  4859. /**
  4860. * Returns an array populated with binormal vectors on each Path3D curve point.
  4861. * @returns an array populated with binormal vectors on each Path3D curve point.
  4862. */
  4863. getBinormals(): Vector3[];
  4864. /**
  4865. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  4866. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  4867. */
  4868. getDistances(): number[];
  4869. /**
  4870. * Returns an interpolated point along this path
  4871. * @param position the position of the point along this path, from 0.0 to 1.0
  4872. * @returns a new Vector3 as the point
  4873. */
  4874. getPointAt(position: number): Vector3;
  4875. /**
  4876. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  4877. * @param position the position of the point along this path, from 0.0 to 1.0
  4878. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  4879. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  4880. */
  4881. getTangentAt(position: number, interpolated?: boolean): Vector3;
  4882. /**
  4883. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  4884. * @param position the position of the point along this path, from 0.0 to 1.0
  4885. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  4886. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  4887. */
  4888. getNormalAt(position: number, interpolated?: boolean): Vector3;
  4889. /**
  4890. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  4891. * @param position the position of the point along this path, from 0.0 to 1.0
  4892. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  4893. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  4894. */
  4895. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  4896. /**
  4897. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  4898. * @param position the position of the point along this path, from 0.0 to 1.0
  4899. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  4900. */
  4901. getDistanceAt(position: number): number;
  4902. /**
  4903. * Returns the array index of the previous point of an interpolated point along this path
  4904. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  4905. * @returns the array index
  4906. */
  4907. getPreviousPointIndexAt(position: number): number;
  4908. /**
  4909. * Returns the position of an interpolated point relative to the two path points it lies between, from 0.0 (point A) to 1.0 (point B)
  4910. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  4911. * @returns the sub position
  4912. */
  4913. getSubPositionAt(position: number): number;
  4914. /**
  4915. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  4916. * @param target the vector of which to get the closest position to
  4917. * @returns the position of the closest virtual point on this path to the target vector
  4918. */
  4919. getClosestPositionTo(target: Vector3): number;
  4920. /**
  4921. * Returns a sub path (slice) of this path
  4922. * @param start the position of the fist path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  4923. * @param end the position of the last path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  4924. * @returns a sub path (slice) of this path
  4925. */
  4926. slice(start?: number, end?: number): Path3D;
  4927. /**
  4928. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  4929. * @param path path which all values are copied into the curves points
  4930. * @param firstNormal which should be projected onto the curve
  4931. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  4932. * @returns the same object updated.
  4933. */
  4934. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  4935. private _compute;
  4936. private _getFirstNonNullVector;
  4937. private _getLastNonNullVector;
  4938. private _normalVector;
  4939. /**
  4940. * Updates the point at data for an interpolated point along this curve
  4941. * @param position the position of the point along this curve, from 0.0 to 1.0
  4942. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  4943. * @returns the (updated) point at data
  4944. */
  4945. private _updatePointAtData;
  4946. /**
  4947. * Updates the point at data from the specified parameters
  4948. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  4949. * @param point the interpolated point
  4950. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  4951. */
  4952. private _setPointAtData;
  4953. /**
  4954. * Updates the point at interpolation matrix for the tangents, normals and binormals
  4955. */
  4956. private _updateInterpolationMatrix;
  4957. }
  4958. /**
  4959. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4960. * A Curve3 is designed from a series of successive Vector3.
  4961. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  4962. */
  4963. export class Curve3 {
  4964. private _points;
  4965. private _length;
  4966. /**
  4967. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  4968. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  4969. * @param v1 (Vector3) the control point
  4970. * @param v2 (Vector3) the end point of the Quadratic Bezier
  4971. * @param nbPoints (integer) the wanted number of points in the curve
  4972. * @returns the created Curve3
  4973. */
  4974. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4975. /**
  4976. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  4977. * @param v0 (Vector3) the origin point of the Cubic Bezier
  4978. * @param v1 (Vector3) the first control point
  4979. * @param v2 (Vector3) the second control point
  4980. * @param v3 (Vector3) the end point of the Cubic Bezier
  4981. * @param nbPoints (integer) the wanted number of points in the curve
  4982. * @returns the created Curve3
  4983. */
  4984. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4985. /**
  4986. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  4987. * @param p1 (Vector3) the origin point of the Hermite Spline
  4988. * @param t1 (Vector3) the tangent vector at the origin point
  4989. * @param p2 (Vector3) the end point of the Hermite Spline
  4990. * @param t2 (Vector3) the tangent vector at the end point
  4991. * @param nbPoints (integer) the wanted number of points in the curve
  4992. * @returns the created Curve3
  4993. */
  4994. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4995. /**
  4996. * Returns a Curve3 object along a CatmullRom Spline curve :
  4997. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  4998. * @param nbPoints (integer) the wanted number of points between each curve control points
  4999. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  5000. * @returns the created Curve3
  5001. */
  5002. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  5003. /**
  5004. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5005. * A Curve3 is designed from a series of successive Vector3.
  5006. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  5007. * @param points points which make up the curve
  5008. */
  5009. constructor(points: Vector3[]);
  5010. /**
  5011. * @returns the Curve3 stored array of successive Vector3
  5012. */
  5013. getPoints(): Vector3[];
  5014. /**
  5015. * @returns the computed length (float) of the curve.
  5016. */
  5017. length(): number;
  5018. /**
  5019. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5020. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5021. * curveA and curveB keep unchanged.
  5022. * @param curve the curve to continue from this curve
  5023. * @returns the newly constructed curve
  5024. */
  5025. continue(curve: DeepImmutable<Curve3>): Curve3;
  5026. private _computeLength;
  5027. }
  5028. }
  5029. declare module BABYLON {
  5030. /**
  5031. * This represents the main contract an easing function should follow.
  5032. * Easing functions are used throughout the animation system.
  5033. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5034. */
  5035. export interface IEasingFunction {
  5036. /**
  5037. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5038. * of the easing function.
  5039. * The link below provides some of the most common examples of easing functions.
  5040. * @see https://easings.net/
  5041. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5042. * @returns the corresponding value on the curve defined by the easing function
  5043. */
  5044. ease(gradient: number): number;
  5045. }
  5046. /**
  5047. * Base class used for every default easing function.
  5048. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5049. */
  5050. export class EasingFunction implements IEasingFunction {
  5051. /**
  5052. * Interpolation follows the mathematical formula associated with the easing function.
  5053. */
  5054. static readonly EASINGMODE_EASEIN: number;
  5055. /**
  5056. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5057. */
  5058. static readonly EASINGMODE_EASEOUT: number;
  5059. /**
  5060. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5061. */
  5062. static readonly EASINGMODE_EASEINOUT: number;
  5063. private _easingMode;
  5064. /**
  5065. * Sets the easing mode of the current function.
  5066. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5067. */
  5068. setEasingMode(easingMode: number): void;
  5069. /**
  5070. * Gets the current easing mode.
  5071. * @returns the easing mode
  5072. */
  5073. getEasingMode(): number;
  5074. /**
  5075. * @hidden
  5076. */
  5077. easeInCore(gradient: number): number;
  5078. /**
  5079. * Given an input gradient between 0 and 1, this returns the corresponding value
  5080. * of the easing function.
  5081. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5082. * @returns the corresponding value on the curve defined by the easing function
  5083. */
  5084. ease(gradient: number): number;
  5085. }
  5086. /**
  5087. * Easing function with a circle shape (see link below).
  5088. * @see https://easings.net/#easeInCirc
  5089. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5090. */
  5091. export class CircleEase extends EasingFunction implements IEasingFunction {
  5092. /** @hidden */
  5093. easeInCore(gradient: number): number;
  5094. }
  5095. /**
  5096. * Easing function with a ease back shape (see link below).
  5097. * @see https://easings.net/#easeInBack
  5098. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5099. */
  5100. export class BackEase extends EasingFunction implements IEasingFunction {
  5101. /** Defines the amplitude of the function */
  5102. amplitude: number;
  5103. /**
  5104. * Instantiates a back ease easing
  5105. * @see https://easings.net/#easeInBack
  5106. * @param amplitude Defines the amplitude of the function
  5107. */
  5108. constructor(
  5109. /** Defines the amplitude of the function */
  5110. amplitude?: number);
  5111. /** @hidden */
  5112. easeInCore(gradient: number): number;
  5113. }
  5114. /**
  5115. * Easing function with a bouncing shape (see link below).
  5116. * @see https://easings.net/#easeInBounce
  5117. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5118. */
  5119. export class BounceEase extends EasingFunction implements IEasingFunction {
  5120. /** Defines the number of bounces */
  5121. bounces: number;
  5122. /** Defines the amplitude of the bounce */
  5123. bounciness: number;
  5124. /**
  5125. * Instantiates a bounce easing
  5126. * @see https://easings.net/#easeInBounce
  5127. * @param bounces Defines the number of bounces
  5128. * @param bounciness Defines the amplitude of the bounce
  5129. */
  5130. constructor(
  5131. /** Defines the number of bounces */
  5132. bounces?: number,
  5133. /** Defines the amplitude of the bounce */
  5134. bounciness?: number);
  5135. /** @hidden */
  5136. easeInCore(gradient: number): number;
  5137. }
  5138. /**
  5139. * Easing function with a power of 3 shape (see link below).
  5140. * @see https://easings.net/#easeInCubic
  5141. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5142. */
  5143. export class CubicEase extends EasingFunction implements IEasingFunction {
  5144. /** @hidden */
  5145. easeInCore(gradient: number): number;
  5146. }
  5147. /**
  5148. * Easing function with an elastic shape (see link below).
  5149. * @see https://easings.net/#easeInElastic
  5150. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5151. */
  5152. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5153. /** Defines the number of oscillations*/
  5154. oscillations: number;
  5155. /** Defines the amplitude of the oscillations*/
  5156. springiness: number;
  5157. /**
  5158. * Instantiates an elastic easing function
  5159. * @see https://easings.net/#easeInElastic
  5160. * @param oscillations Defines the number of oscillations
  5161. * @param springiness Defines the amplitude of the oscillations
  5162. */
  5163. constructor(
  5164. /** Defines the number of oscillations*/
  5165. oscillations?: number,
  5166. /** Defines the amplitude of the oscillations*/
  5167. springiness?: number);
  5168. /** @hidden */
  5169. easeInCore(gradient: number): number;
  5170. }
  5171. /**
  5172. * Easing function with an exponential shape (see link below).
  5173. * @see https://easings.net/#easeInExpo
  5174. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5175. */
  5176. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5177. /** Defines the exponent of the function */
  5178. exponent: number;
  5179. /**
  5180. * Instantiates an exponential easing function
  5181. * @see https://easings.net/#easeInExpo
  5182. * @param exponent Defines the exponent of the function
  5183. */
  5184. constructor(
  5185. /** Defines the exponent of the function */
  5186. exponent?: number);
  5187. /** @hidden */
  5188. easeInCore(gradient: number): number;
  5189. }
  5190. /**
  5191. * Easing function with a power shape (see link below).
  5192. * @see https://easings.net/#easeInQuad
  5193. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5194. */
  5195. export class PowerEase extends EasingFunction implements IEasingFunction {
  5196. /** Defines the power of the function */
  5197. power: number;
  5198. /**
  5199. * Instantiates an power base easing function
  5200. * @see https://easings.net/#easeInQuad
  5201. * @param power Defines the power of the function
  5202. */
  5203. constructor(
  5204. /** Defines the power of the function */
  5205. power?: number);
  5206. /** @hidden */
  5207. easeInCore(gradient: number): number;
  5208. }
  5209. /**
  5210. * Easing function with a power of 2 shape (see link below).
  5211. * @see https://easings.net/#easeInQuad
  5212. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5213. */
  5214. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5215. /** @hidden */
  5216. easeInCore(gradient: number): number;
  5217. }
  5218. /**
  5219. * Easing function with a power of 4 shape (see link below).
  5220. * @see https://easings.net/#easeInQuart
  5221. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5222. */
  5223. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5224. /** @hidden */
  5225. easeInCore(gradient: number): number;
  5226. }
  5227. /**
  5228. * Easing function with a power of 5 shape (see link below).
  5229. * @see https://easings.net/#easeInQuint
  5230. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5231. */
  5232. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5233. /** @hidden */
  5234. easeInCore(gradient: number): number;
  5235. }
  5236. /**
  5237. * Easing function with a sin shape (see link below).
  5238. * @see https://easings.net/#easeInSine
  5239. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5240. */
  5241. export class SineEase extends EasingFunction implements IEasingFunction {
  5242. /** @hidden */
  5243. easeInCore(gradient: number): number;
  5244. }
  5245. /**
  5246. * Easing function with a bezier shape (see link below).
  5247. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5248. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5249. */
  5250. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5251. /** Defines the x component of the start tangent in the bezier curve */
  5252. x1: number;
  5253. /** Defines the y component of the start tangent in the bezier curve */
  5254. y1: number;
  5255. /** Defines the x component of the end tangent in the bezier curve */
  5256. x2: number;
  5257. /** Defines the y component of the end tangent in the bezier curve */
  5258. y2: number;
  5259. /**
  5260. * Instantiates a bezier function
  5261. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5262. * @param x1 Defines the x component of the start tangent in the bezier curve
  5263. * @param y1 Defines the y component of the start tangent in the bezier curve
  5264. * @param x2 Defines the x component of the end tangent in the bezier curve
  5265. * @param y2 Defines the y component of the end tangent in the bezier curve
  5266. */
  5267. constructor(
  5268. /** Defines the x component of the start tangent in the bezier curve */
  5269. x1?: number,
  5270. /** Defines the y component of the start tangent in the bezier curve */
  5271. y1?: number,
  5272. /** Defines the x component of the end tangent in the bezier curve */
  5273. x2?: number,
  5274. /** Defines the y component of the end tangent in the bezier curve */
  5275. y2?: number);
  5276. /** @hidden */
  5277. easeInCore(gradient: number): number;
  5278. }
  5279. }
  5280. declare module BABYLON {
  5281. /**
  5282. * Class used to hold a RBG color
  5283. */
  5284. export class Color3 {
  5285. /**
  5286. * Defines the red component (between 0 and 1, default is 0)
  5287. */
  5288. r: number;
  5289. /**
  5290. * Defines the green component (between 0 and 1, default is 0)
  5291. */
  5292. g: number;
  5293. /**
  5294. * Defines the blue component (between 0 and 1, default is 0)
  5295. */
  5296. b: number;
  5297. /**
  5298. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5299. * @param r defines the red component (between 0 and 1, default is 0)
  5300. * @param g defines the green component (between 0 and 1, default is 0)
  5301. * @param b defines the blue component (between 0 and 1, default is 0)
  5302. */
  5303. constructor(
  5304. /**
  5305. * Defines the red component (between 0 and 1, default is 0)
  5306. */
  5307. r?: number,
  5308. /**
  5309. * Defines the green component (between 0 and 1, default is 0)
  5310. */
  5311. g?: number,
  5312. /**
  5313. * Defines the blue component (between 0 and 1, default is 0)
  5314. */
  5315. b?: number);
  5316. /**
  5317. * Creates a string with the Color3 current values
  5318. * @returns the string representation of the Color3 object
  5319. */
  5320. toString(): string;
  5321. /**
  5322. * Returns the string "Color3"
  5323. * @returns "Color3"
  5324. */
  5325. getClassName(): string;
  5326. /**
  5327. * Compute the Color3 hash code
  5328. * @returns an unique number that can be used to hash Color3 objects
  5329. */
  5330. getHashCode(): number;
  5331. /**
  5332. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5333. * @param array defines the array where to store the r,g,b components
  5334. * @param index defines an optional index in the target array to define where to start storing values
  5335. * @returns the current Color3 object
  5336. */
  5337. toArray(array: FloatArray, index?: number): Color3;
  5338. /**
  5339. * Returns a new Color4 object from the current Color3 and the given alpha
  5340. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5341. * @returns a new Color4 object
  5342. */
  5343. toColor4(alpha?: number): Color4;
  5344. /**
  5345. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5346. * @returns the new array
  5347. */
  5348. asArray(): number[];
  5349. /**
  5350. * Returns the luminance value
  5351. * @returns a float value
  5352. */
  5353. toLuminance(): number;
  5354. /**
  5355. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5356. * @param otherColor defines the second operand
  5357. * @returns the new Color3 object
  5358. */
  5359. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5360. /**
  5361. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5362. * @param otherColor defines the second operand
  5363. * @param result defines the Color3 object where to store the result
  5364. * @returns the current Color3
  5365. */
  5366. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5367. /**
  5368. * Determines equality between Color3 objects
  5369. * @param otherColor defines the second operand
  5370. * @returns true if the rgb values are equal to the given ones
  5371. */
  5372. equals(otherColor: DeepImmutable<Color3>): boolean;
  5373. /**
  5374. * Determines equality between the current Color3 object and a set of r,b,g values
  5375. * @param r defines the red component to check
  5376. * @param g defines the green component to check
  5377. * @param b defines the blue component to check
  5378. * @returns true if the rgb values are equal to the given ones
  5379. */
  5380. equalsFloats(r: number, g: number, b: number): boolean;
  5381. /**
  5382. * Multiplies in place each rgb value by scale
  5383. * @param scale defines the scaling factor
  5384. * @returns the updated Color3
  5385. */
  5386. scale(scale: number): Color3;
  5387. /**
  5388. * Multiplies the rgb values by scale and stores the result into "result"
  5389. * @param scale defines the scaling factor
  5390. * @param result defines the Color3 object where to store the result
  5391. * @returns the unmodified current Color3
  5392. */
  5393. scaleToRef(scale: number, result: Color3): Color3;
  5394. /**
  5395. * Scale the current Color3 values by a factor and add the result to a given Color3
  5396. * @param scale defines the scale factor
  5397. * @param result defines color to store the result into
  5398. * @returns the unmodified current Color3
  5399. */
  5400. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5401. /**
  5402. * Clamps the rgb values by the min and max values and stores the result into "result"
  5403. * @param min defines minimum clamping value (default is 0)
  5404. * @param max defines maximum clamping value (default is 1)
  5405. * @param result defines color to store the result into
  5406. * @returns the original Color3
  5407. */
  5408. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5409. /**
  5410. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5411. * @param otherColor defines the second operand
  5412. * @returns the new Color3
  5413. */
  5414. add(otherColor: DeepImmutable<Color3>): Color3;
  5415. /**
  5416. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5417. * @param otherColor defines the second operand
  5418. * @param result defines Color3 object to store the result into
  5419. * @returns the unmodified current Color3
  5420. */
  5421. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5422. /**
  5423. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5424. * @param otherColor defines the second operand
  5425. * @returns the new Color3
  5426. */
  5427. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5428. /**
  5429. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5430. * @param otherColor defines the second operand
  5431. * @param result defines Color3 object to store the result into
  5432. * @returns the unmodified current Color3
  5433. */
  5434. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5435. /**
  5436. * Copy the current object
  5437. * @returns a new Color3 copied the current one
  5438. */
  5439. clone(): Color3;
  5440. /**
  5441. * Copies the rgb values from the source in the current Color3
  5442. * @param source defines the source Color3 object
  5443. * @returns the updated Color3 object
  5444. */
  5445. copyFrom(source: DeepImmutable<Color3>): Color3;
  5446. /**
  5447. * Updates the Color3 rgb values from the given floats
  5448. * @param r defines the red component to read from
  5449. * @param g defines the green component to read from
  5450. * @param b defines the blue component to read from
  5451. * @returns the current Color3 object
  5452. */
  5453. copyFromFloats(r: number, g: number, b: number): Color3;
  5454. /**
  5455. * Updates the Color3 rgb values from the given floats
  5456. * @param r defines the red component to read from
  5457. * @param g defines the green component to read from
  5458. * @param b defines the blue component to read from
  5459. * @returns the current Color3 object
  5460. */
  5461. set(r: number, g: number, b: number): Color3;
  5462. /**
  5463. * Compute the Color3 hexadecimal code as a string
  5464. * @returns a string containing the hexadecimal representation of the Color3 object
  5465. */
  5466. toHexString(): string;
  5467. /**
  5468. * Computes a new Color3 converted from the current one to linear space
  5469. * @returns a new Color3 object
  5470. */
  5471. toLinearSpace(): Color3;
  5472. /**
  5473. * Converts current color in rgb space to HSV values
  5474. * @returns a new color3 representing the HSV values
  5475. */
  5476. toHSV(): Color3;
  5477. /**
  5478. * Converts current color in rgb space to HSV values
  5479. * @param result defines the Color3 where to store the HSV values
  5480. */
  5481. toHSVToRef(result: Color3): void;
  5482. /**
  5483. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5484. * @param convertedColor defines the Color3 object where to store the linear space version
  5485. * @returns the unmodified Color3
  5486. */
  5487. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5488. /**
  5489. * Computes a new Color3 converted from the current one to gamma space
  5490. * @returns a new Color3 object
  5491. */
  5492. toGammaSpace(): Color3;
  5493. /**
  5494. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5495. * @param convertedColor defines the Color3 object where to store the gamma space version
  5496. * @returns the unmodified Color3
  5497. */
  5498. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5499. private static _BlackReadOnly;
  5500. /**
  5501. * Convert Hue, saturation and value to a Color3 (RGB)
  5502. * @param hue defines the hue
  5503. * @param saturation defines the saturation
  5504. * @param value defines the value
  5505. * @param result defines the Color3 where to store the RGB values
  5506. */
  5507. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5508. /**
  5509. * Creates a new Color3 from the string containing valid hexadecimal values
  5510. * @param hex defines a string containing valid hexadecimal values
  5511. * @returns a new Color3 object
  5512. */
  5513. static FromHexString(hex: string): Color3;
  5514. /**
  5515. * Creates a new Color3 from the starting index of the given array
  5516. * @param array defines the source array
  5517. * @param offset defines an offset in the source array
  5518. * @returns a new Color3 object
  5519. */
  5520. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5521. /**
  5522. * Creates a new Color3 from integer values (< 256)
  5523. * @param r defines the red component to read from (value between 0 and 255)
  5524. * @param g defines the green component to read from (value between 0 and 255)
  5525. * @param b defines the blue component to read from (value between 0 and 255)
  5526. * @returns a new Color3 object
  5527. */
  5528. static FromInts(r: number, g: number, b: number): Color3;
  5529. /**
  5530. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5531. * @param start defines the start Color3 value
  5532. * @param end defines the end Color3 value
  5533. * @param amount defines the gradient value between start and end
  5534. * @returns a new Color3 object
  5535. */
  5536. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5537. /**
  5538. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5539. * @param left defines the start value
  5540. * @param right defines the end value
  5541. * @param amount defines the gradient factor
  5542. * @param result defines the Color3 object where to store the result
  5543. */
  5544. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5545. /**
  5546. * Returns a Color3 value containing a red color
  5547. * @returns a new Color3 object
  5548. */
  5549. static Red(): Color3;
  5550. /**
  5551. * Returns a Color3 value containing a green color
  5552. * @returns a new Color3 object
  5553. */
  5554. static Green(): Color3;
  5555. /**
  5556. * Returns a Color3 value containing a blue color
  5557. * @returns a new Color3 object
  5558. */
  5559. static Blue(): Color3;
  5560. /**
  5561. * Returns a Color3 value containing a black color
  5562. * @returns a new Color3 object
  5563. */
  5564. static Black(): Color3;
  5565. /**
  5566. * Gets a Color3 value containing a black color that must not be updated
  5567. */
  5568. static get BlackReadOnly(): DeepImmutable<Color3>;
  5569. /**
  5570. * Returns a Color3 value containing a white color
  5571. * @returns a new Color3 object
  5572. */
  5573. static White(): Color3;
  5574. /**
  5575. * Returns a Color3 value containing a purple color
  5576. * @returns a new Color3 object
  5577. */
  5578. static Purple(): Color3;
  5579. /**
  5580. * Returns a Color3 value containing a magenta color
  5581. * @returns a new Color3 object
  5582. */
  5583. static Magenta(): Color3;
  5584. /**
  5585. * Returns a Color3 value containing a yellow color
  5586. * @returns a new Color3 object
  5587. */
  5588. static Yellow(): Color3;
  5589. /**
  5590. * Returns a Color3 value containing a gray color
  5591. * @returns a new Color3 object
  5592. */
  5593. static Gray(): Color3;
  5594. /**
  5595. * Returns a Color3 value containing a teal color
  5596. * @returns a new Color3 object
  5597. */
  5598. static Teal(): Color3;
  5599. /**
  5600. * Returns a Color3 value containing a random color
  5601. * @returns a new Color3 object
  5602. */
  5603. static Random(): Color3;
  5604. }
  5605. /**
  5606. * Class used to hold a RBGA color
  5607. */
  5608. export class Color4 {
  5609. /**
  5610. * Defines the red component (between 0 and 1, default is 0)
  5611. */
  5612. r: number;
  5613. /**
  5614. * Defines the green component (between 0 and 1, default is 0)
  5615. */
  5616. g: number;
  5617. /**
  5618. * Defines the blue component (between 0 and 1, default is 0)
  5619. */
  5620. b: number;
  5621. /**
  5622. * Defines the alpha component (between 0 and 1, default is 1)
  5623. */
  5624. a: number;
  5625. /**
  5626. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5627. * @param r defines the red component (between 0 and 1, default is 0)
  5628. * @param g defines the green component (between 0 and 1, default is 0)
  5629. * @param b defines the blue component (between 0 and 1, default is 0)
  5630. * @param a defines the alpha component (between 0 and 1, default is 1)
  5631. */
  5632. constructor(
  5633. /**
  5634. * Defines the red component (between 0 and 1, default is 0)
  5635. */
  5636. r?: number,
  5637. /**
  5638. * Defines the green component (between 0 and 1, default is 0)
  5639. */
  5640. g?: number,
  5641. /**
  5642. * Defines the blue component (between 0 and 1, default is 0)
  5643. */
  5644. b?: number,
  5645. /**
  5646. * Defines the alpha component (between 0 and 1, default is 1)
  5647. */
  5648. a?: number);
  5649. /**
  5650. * Adds in place the given Color4 values to the current Color4 object
  5651. * @param right defines the second operand
  5652. * @returns the current updated Color4 object
  5653. */
  5654. addInPlace(right: DeepImmutable<Color4>): Color4;
  5655. /**
  5656. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5657. * @returns the new array
  5658. */
  5659. asArray(): number[];
  5660. /**
  5661. * Stores from the starting index in the given array the Color4 successive values
  5662. * @param array defines the array where to store the r,g,b components
  5663. * @param index defines an optional index in the target array to define where to start storing values
  5664. * @returns the current Color4 object
  5665. */
  5666. toArray(array: number[], index?: number): Color4;
  5667. /**
  5668. * Determines equality between Color4 objects
  5669. * @param otherColor defines the second operand
  5670. * @returns true if the rgba values are equal to the given ones
  5671. */
  5672. equals(otherColor: DeepImmutable<Color4>): boolean;
  5673. /**
  5674. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5675. * @param right defines the second operand
  5676. * @returns a new Color4 object
  5677. */
  5678. add(right: DeepImmutable<Color4>): Color4;
  5679. /**
  5680. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5681. * @param right defines the second operand
  5682. * @returns a new Color4 object
  5683. */
  5684. subtract(right: DeepImmutable<Color4>): Color4;
  5685. /**
  5686. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5687. * @param right defines the second operand
  5688. * @param result defines the Color4 object where to store the result
  5689. * @returns the current Color4 object
  5690. */
  5691. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5692. /**
  5693. * Creates a new Color4 with the current Color4 values multiplied by scale
  5694. * @param scale defines the scaling factor to apply
  5695. * @returns a new Color4 object
  5696. */
  5697. scale(scale: number): Color4;
  5698. /**
  5699. * Multiplies the current Color4 values by scale and stores the result in "result"
  5700. * @param scale defines the scaling factor to apply
  5701. * @param result defines the Color4 object where to store the result
  5702. * @returns the current unmodified Color4
  5703. */
  5704. scaleToRef(scale: number, result: Color4): Color4;
  5705. /**
  5706. * Scale the current Color4 values by a factor and add the result to a given Color4
  5707. * @param scale defines the scale factor
  5708. * @param result defines the Color4 object where to store the result
  5709. * @returns the unmodified current Color4
  5710. */
  5711. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5712. /**
  5713. * Clamps the rgb values by the min and max values and stores the result into "result"
  5714. * @param min defines minimum clamping value (default is 0)
  5715. * @param max defines maximum clamping value (default is 1)
  5716. * @param result defines color to store the result into.
  5717. * @returns the cuurent Color4
  5718. */
  5719. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5720. /**
  5721. * Multipy an Color4 value by another and return a new Color4 object
  5722. * @param color defines the Color4 value to multiply by
  5723. * @returns a new Color4 object
  5724. */
  5725. multiply(color: Color4): Color4;
  5726. /**
  5727. * Multipy a Color4 value by another and push the result in a reference value
  5728. * @param color defines the Color4 value to multiply by
  5729. * @param result defines the Color4 to fill the result in
  5730. * @returns the result Color4
  5731. */
  5732. multiplyToRef(color: Color4, result: Color4): Color4;
  5733. /**
  5734. * Creates a string with the Color4 current values
  5735. * @returns the string representation of the Color4 object
  5736. */
  5737. toString(): string;
  5738. /**
  5739. * Returns the string "Color4"
  5740. * @returns "Color4"
  5741. */
  5742. getClassName(): string;
  5743. /**
  5744. * Compute the Color4 hash code
  5745. * @returns an unique number that can be used to hash Color4 objects
  5746. */
  5747. getHashCode(): number;
  5748. /**
  5749. * Creates a new Color4 copied from the current one
  5750. * @returns a new Color4 object
  5751. */
  5752. clone(): Color4;
  5753. /**
  5754. * Copies the given Color4 values into the current one
  5755. * @param source defines the source Color4 object
  5756. * @returns the current updated Color4 object
  5757. */
  5758. copyFrom(source: Color4): Color4;
  5759. /**
  5760. * Copies the given float values into the current one
  5761. * @param r defines the red component to read from
  5762. * @param g defines the green component to read from
  5763. * @param b defines the blue component to read from
  5764. * @param a defines the alpha component to read from
  5765. * @returns the current updated Color4 object
  5766. */
  5767. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5768. /**
  5769. * Copies the given float values into the current one
  5770. * @param r defines the red component to read from
  5771. * @param g defines the green component to read from
  5772. * @param b defines the blue component to read from
  5773. * @param a defines the alpha component to read from
  5774. * @returns the current updated Color4 object
  5775. */
  5776. set(r: number, g: number, b: number, a: number): Color4;
  5777. /**
  5778. * Compute the Color4 hexadecimal code as a string
  5779. * @returns a string containing the hexadecimal representation of the Color4 object
  5780. */
  5781. toHexString(): string;
  5782. /**
  5783. * Computes a new Color4 converted from the current one to linear space
  5784. * @returns a new Color4 object
  5785. */
  5786. toLinearSpace(): Color4;
  5787. /**
  5788. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  5789. * @param convertedColor defines the Color4 object where to store the linear space version
  5790. * @returns the unmodified Color4
  5791. */
  5792. toLinearSpaceToRef(convertedColor: Color4): Color4;
  5793. /**
  5794. * Computes a new Color4 converted from the current one to gamma space
  5795. * @returns a new Color4 object
  5796. */
  5797. toGammaSpace(): Color4;
  5798. /**
  5799. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  5800. * @param convertedColor defines the Color4 object where to store the gamma space version
  5801. * @returns the unmodified Color4
  5802. */
  5803. toGammaSpaceToRef(convertedColor: Color4): Color4;
  5804. /**
  5805. * Creates a new Color4 from the string containing valid hexadecimal values
  5806. * @param hex defines a string containing valid hexadecimal values
  5807. * @returns a new Color4 object
  5808. */
  5809. static FromHexString(hex: string): Color4;
  5810. /**
  5811. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5812. * @param left defines the start value
  5813. * @param right defines the end value
  5814. * @param amount defines the gradient factor
  5815. * @returns a new Color4 object
  5816. */
  5817. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  5818. /**
  5819. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5820. * @param left defines the start value
  5821. * @param right defines the end value
  5822. * @param amount defines the gradient factor
  5823. * @param result defines the Color4 object where to store data
  5824. */
  5825. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  5826. /**
  5827. * Creates a new Color4 from a Color3 and an alpha value
  5828. * @param color3 defines the source Color3 to read from
  5829. * @param alpha defines the alpha component (1.0 by default)
  5830. * @returns a new Color4 object
  5831. */
  5832. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  5833. /**
  5834. * Creates a new Color4 from the starting index element of the given array
  5835. * @param array defines the source array to read from
  5836. * @param offset defines the offset in the source array
  5837. * @returns a new Color4 object
  5838. */
  5839. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5840. /**
  5841. * Creates a new Color3 from integer values (< 256)
  5842. * @param r defines the red component to read from (value between 0 and 255)
  5843. * @param g defines the green component to read from (value between 0 and 255)
  5844. * @param b defines the blue component to read from (value between 0 and 255)
  5845. * @param a defines the alpha component to read from (value between 0 and 255)
  5846. * @returns a new Color3 object
  5847. */
  5848. static FromInts(r: number, g: number, b: number, a: number): Color4;
  5849. /**
  5850. * Check the content of a given array and convert it to an array containing RGBA data
  5851. * If the original array was already containing count * 4 values then it is returned directly
  5852. * @param colors defines the array to check
  5853. * @param count defines the number of RGBA data to expect
  5854. * @returns an array containing count * 4 values (RGBA)
  5855. */
  5856. static CheckColors4(colors: number[], count: number): number[];
  5857. }
  5858. /**
  5859. * @hidden
  5860. */
  5861. export class TmpColors {
  5862. static Color3: Color3[];
  5863. static Color4: Color4[];
  5864. }
  5865. }
  5866. declare module BABYLON {
  5867. /**
  5868. * Defines an interface which represents an animation key frame
  5869. */
  5870. export interface IAnimationKey {
  5871. /**
  5872. * Frame of the key frame
  5873. */
  5874. frame: number;
  5875. /**
  5876. * Value at the specifies key frame
  5877. */
  5878. value: any;
  5879. /**
  5880. * The input tangent for the cubic hermite spline
  5881. */
  5882. inTangent?: any;
  5883. /**
  5884. * The output tangent for the cubic hermite spline
  5885. */
  5886. outTangent?: any;
  5887. /**
  5888. * The animation interpolation type
  5889. */
  5890. interpolation?: AnimationKeyInterpolation;
  5891. }
  5892. /**
  5893. * Enum for the animation key frame interpolation type
  5894. */
  5895. export enum AnimationKeyInterpolation {
  5896. /**
  5897. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  5898. */
  5899. STEP = 1
  5900. }
  5901. }
  5902. declare module BABYLON {
  5903. /**
  5904. * Represents the range of an animation
  5905. */
  5906. export class AnimationRange {
  5907. /**The name of the animation range**/
  5908. name: string;
  5909. /**The starting frame of the animation */
  5910. from: number;
  5911. /**The ending frame of the animation*/
  5912. to: number;
  5913. /**
  5914. * Initializes the range of an animation
  5915. * @param name The name of the animation range
  5916. * @param from The starting frame of the animation
  5917. * @param to The ending frame of the animation
  5918. */
  5919. constructor(
  5920. /**The name of the animation range**/
  5921. name: string,
  5922. /**The starting frame of the animation */
  5923. from: number,
  5924. /**The ending frame of the animation*/
  5925. to: number);
  5926. /**
  5927. * Makes a copy of the animation range
  5928. * @returns A copy of the animation range
  5929. */
  5930. clone(): AnimationRange;
  5931. }
  5932. }
  5933. declare module BABYLON {
  5934. /**
  5935. * Composed of a frame, and an action function
  5936. */
  5937. export class AnimationEvent {
  5938. /** The frame for which the event is triggered **/
  5939. frame: number;
  5940. /** The event to perform when triggered **/
  5941. action: (currentFrame: number) => void;
  5942. /** Specifies if the event should be triggered only once**/
  5943. onlyOnce?: boolean | undefined;
  5944. /**
  5945. * Specifies if the animation event is done
  5946. */
  5947. isDone: boolean;
  5948. /**
  5949. * Initializes the animation event
  5950. * @param frame The frame for which the event is triggered
  5951. * @param action The event to perform when triggered
  5952. * @param onlyOnce Specifies if the event should be triggered only once
  5953. */
  5954. constructor(
  5955. /** The frame for which the event is triggered **/
  5956. frame: number,
  5957. /** The event to perform when triggered **/
  5958. action: (currentFrame: number) => void,
  5959. /** Specifies if the event should be triggered only once**/
  5960. onlyOnce?: boolean | undefined);
  5961. /** @hidden */
  5962. _clone(): AnimationEvent;
  5963. }
  5964. }
  5965. declare module BABYLON {
  5966. /**
  5967. * Interface used to define a behavior
  5968. */
  5969. export interface Behavior<T> {
  5970. /** gets or sets behavior's name */
  5971. name: string;
  5972. /**
  5973. * Function called when the behavior needs to be initialized (after attaching it to a target)
  5974. */
  5975. init(): void;
  5976. /**
  5977. * Called when the behavior is attached to a target
  5978. * @param target defines the target where the behavior is attached to
  5979. */
  5980. attach(target: T): void;
  5981. /**
  5982. * Called when the behavior is detached from its target
  5983. */
  5984. detach(): void;
  5985. }
  5986. /**
  5987. * Interface implemented by classes supporting behaviors
  5988. */
  5989. export interface IBehaviorAware<T> {
  5990. /**
  5991. * Attach a behavior
  5992. * @param behavior defines the behavior to attach
  5993. * @returns the current host
  5994. */
  5995. addBehavior(behavior: Behavior<T>): T;
  5996. /**
  5997. * Remove a behavior from the current object
  5998. * @param behavior defines the behavior to detach
  5999. * @returns the current host
  6000. */
  6001. removeBehavior(behavior: Behavior<T>): T;
  6002. /**
  6003. * Gets a behavior using its name to search
  6004. * @param name defines the name to search
  6005. * @returns the behavior or null if not found
  6006. */
  6007. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6008. }
  6009. }
  6010. declare module BABYLON {
  6011. /**
  6012. * Defines an array and its length.
  6013. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6014. */
  6015. export interface ISmartArrayLike<T> {
  6016. /**
  6017. * The data of the array.
  6018. */
  6019. data: Array<T>;
  6020. /**
  6021. * The active length of the array.
  6022. */
  6023. length: number;
  6024. }
  6025. /**
  6026. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6027. */
  6028. export class SmartArray<T> implements ISmartArrayLike<T> {
  6029. /**
  6030. * The full set of data from the array.
  6031. */
  6032. data: Array<T>;
  6033. /**
  6034. * The active length of the array.
  6035. */
  6036. length: number;
  6037. protected _id: number;
  6038. /**
  6039. * Instantiates a Smart Array.
  6040. * @param capacity defines the default capacity of the array.
  6041. */
  6042. constructor(capacity: number);
  6043. /**
  6044. * Pushes a value at the end of the active data.
  6045. * @param value defines the object to push in the array.
  6046. */
  6047. push(value: T): void;
  6048. /**
  6049. * Iterates over the active data and apply the lambda to them.
  6050. * @param func defines the action to apply on each value.
  6051. */
  6052. forEach(func: (content: T) => void): void;
  6053. /**
  6054. * Sorts the full sets of data.
  6055. * @param compareFn defines the comparison function to apply.
  6056. */
  6057. sort(compareFn: (a: T, b: T) => number): void;
  6058. /**
  6059. * Resets the active data to an empty array.
  6060. */
  6061. reset(): void;
  6062. /**
  6063. * Releases all the data from the array as well as the array.
  6064. */
  6065. dispose(): void;
  6066. /**
  6067. * Concats the active data with a given array.
  6068. * @param array defines the data to concatenate with.
  6069. */
  6070. concat(array: any): void;
  6071. /**
  6072. * Returns the position of a value in the active data.
  6073. * @param value defines the value to find the index for
  6074. * @returns the index if found in the active data otherwise -1
  6075. */
  6076. indexOf(value: T): number;
  6077. /**
  6078. * Returns whether an element is part of the active data.
  6079. * @param value defines the value to look for
  6080. * @returns true if found in the active data otherwise false
  6081. */
  6082. contains(value: T): boolean;
  6083. private static _GlobalId;
  6084. }
  6085. /**
  6086. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6087. * The data in this array can only be present once
  6088. */
  6089. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6090. private _duplicateId;
  6091. /**
  6092. * Pushes a value at the end of the active data.
  6093. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6094. * @param value defines the object to push in the array.
  6095. */
  6096. push(value: T): void;
  6097. /**
  6098. * Pushes a value at the end of the active data.
  6099. * If the data is already present, it won t be added again
  6100. * @param value defines the object to push in the array.
  6101. * @returns true if added false if it was already present
  6102. */
  6103. pushNoDuplicate(value: T): boolean;
  6104. /**
  6105. * Resets the active data to an empty array.
  6106. */
  6107. reset(): void;
  6108. /**
  6109. * Concats the active data with a given array.
  6110. * This ensures no dupplicate will be present in the result.
  6111. * @param array defines the data to concatenate with.
  6112. */
  6113. concatWithNoDuplicate(array: any): void;
  6114. }
  6115. }
  6116. declare module BABYLON {
  6117. /**
  6118. * @ignore
  6119. * This is a list of all the different input types that are available in the application.
  6120. * Fo instance: ArcRotateCameraGamepadInput...
  6121. */
  6122. export var CameraInputTypes: {};
  6123. /**
  6124. * This is the contract to implement in order to create a new input class.
  6125. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6126. */
  6127. export interface ICameraInput<TCamera extends Camera> {
  6128. /**
  6129. * Defines the camera the input is attached to.
  6130. */
  6131. camera: Nullable<TCamera>;
  6132. /**
  6133. * Gets the class name of the current intput.
  6134. * @returns the class name
  6135. */
  6136. getClassName(): string;
  6137. /**
  6138. * Get the friendly name associated with the input class.
  6139. * @returns the input friendly name
  6140. */
  6141. getSimpleName(): string;
  6142. /**
  6143. * Attach the input controls to a specific dom element to get the input from.
  6144. * @param element Defines the element the controls should be listened from
  6145. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6146. */
  6147. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6148. /**
  6149. * Detach the current controls from the specified dom element.
  6150. * @param element Defines the element to stop listening the inputs from
  6151. */
  6152. detachControl(element: Nullable<HTMLElement>): void;
  6153. /**
  6154. * Update the current camera state depending on the inputs that have been used this frame.
  6155. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6156. */
  6157. checkInputs?: () => void;
  6158. }
  6159. /**
  6160. * Represents a map of input types to input instance or input index to input instance.
  6161. */
  6162. export interface CameraInputsMap<TCamera extends Camera> {
  6163. /**
  6164. * Accessor to the input by input type.
  6165. */
  6166. [name: string]: ICameraInput<TCamera>;
  6167. /**
  6168. * Accessor to the input by input index.
  6169. */
  6170. [idx: number]: ICameraInput<TCamera>;
  6171. }
  6172. /**
  6173. * This represents the input manager used within a camera.
  6174. * It helps dealing with all the different kind of input attached to a camera.
  6175. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6176. */
  6177. export class CameraInputsManager<TCamera extends Camera> {
  6178. /**
  6179. * Defines the list of inputs attahed to the camera.
  6180. */
  6181. attached: CameraInputsMap<TCamera>;
  6182. /**
  6183. * Defines the dom element the camera is collecting inputs from.
  6184. * This is null if the controls have not been attached.
  6185. */
  6186. attachedElement: Nullable<HTMLElement>;
  6187. /**
  6188. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6189. */
  6190. noPreventDefault: boolean;
  6191. /**
  6192. * Defined the camera the input manager belongs to.
  6193. */
  6194. camera: TCamera;
  6195. /**
  6196. * Update the current camera state depending on the inputs that have been used this frame.
  6197. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6198. */
  6199. checkInputs: () => void;
  6200. /**
  6201. * Instantiate a new Camera Input Manager.
  6202. * @param camera Defines the camera the input manager blongs to
  6203. */
  6204. constructor(camera: TCamera);
  6205. /**
  6206. * Add an input method to a camera
  6207. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6208. * @param input camera input method
  6209. */
  6210. add(input: ICameraInput<TCamera>): void;
  6211. /**
  6212. * Remove a specific input method from a camera
  6213. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6214. * @param inputToRemove camera input method
  6215. */
  6216. remove(inputToRemove: ICameraInput<TCamera>): void;
  6217. /**
  6218. * Remove a specific input type from a camera
  6219. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6220. * @param inputType the type of the input to remove
  6221. */
  6222. removeByType(inputType: string): void;
  6223. private _addCheckInputs;
  6224. /**
  6225. * Attach the input controls to the currently attached dom element to listen the events from.
  6226. * @param input Defines the input to attach
  6227. */
  6228. attachInput(input: ICameraInput<TCamera>): void;
  6229. /**
  6230. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6231. * @param element Defines the dom element to collect the events from
  6232. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6233. */
  6234. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6235. /**
  6236. * Detach the current manager inputs controls from a specific dom element.
  6237. * @param element Defines the dom element to collect the events from
  6238. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6239. */
  6240. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6241. /**
  6242. * Rebuild the dynamic inputCheck function from the current list of
  6243. * defined inputs in the manager.
  6244. */
  6245. rebuildInputCheck(): void;
  6246. /**
  6247. * Remove all attached input methods from a camera
  6248. */
  6249. clear(): void;
  6250. /**
  6251. * Serialize the current input manager attached to a camera.
  6252. * This ensures than once parsed,
  6253. * the input associated to the camera will be identical to the current ones
  6254. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6255. */
  6256. serialize(serializedCamera: any): void;
  6257. /**
  6258. * Parses an input manager serialized JSON to restore the previous list of inputs
  6259. * and states associated to a camera.
  6260. * @param parsedCamera Defines the JSON to parse
  6261. */
  6262. parse(parsedCamera: any): void;
  6263. }
  6264. }
  6265. declare module BABYLON {
  6266. /**
  6267. * Class used to store data that will be store in GPU memory
  6268. */
  6269. export class Buffer {
  6270. private _engine;
  6271. private _buffer;
  6272. /** @hidden */
  6273. _data: Nullable<DataArray>;
  6274. private _updatable;
  6275. private _instanced;
  6276. private _divisor;
  6277. /**
  6278. * Gets the byte stride.
  6279. */
  6280. readonly byteStride: number;
  6281. /**
  6282. * Constructor
  6283. * @param engine the engine
  6284. * @param data the data to use for this buffer
  6285. * @param updatable whether the data is updatable
  6286. * @param stride the stride (optional)
  6287. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6288. * @param instanced whether the buffer is instanced (optional)
  6289. * @param useBytes set to true if the stride in in bytes (optional)
  6290. * @param divisor sets an optional divisor for instances (1 by default)
  6291. */
  6292. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6293. /**
  6294. * Create a new VertexBuffer based on the current buffer
  6295. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6296. * @param offset defines offset in the buffer (0 by default)
  6297. * @param size defines the size in floats of attributes (position is 3 for instance)
  6298. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6299. * @param instanced defines if the vertex buffer contains indexed data
  6300. * @param useBytes defines if the offset and stride are in bytes *
  6301. * @param divisor sets an optional divisor for instances (1 by default)
  6302. * @returns the new vertex buffer
  6303. */
  6304. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6305. /**
  6306. * Gets a boolean indicating if the Buffer is updatable?
  6307. * @returns true if the buffer is updatable
  6308. */
  6309. isUpdatable(): boolean;
  6310. /**
  6311. * Gets current buffer's data
  6312. * @returns a DataArray or null
  6313. */
  6314. getData(): Nullable<DataArray>;
  6315. /**
  6316. * Gets underlying native buffer
  6317. * @returns underlying native buffer
  6318. */
  6319. getBuffer(): Nullable<DataBuffer>;
  6320. /**
  6321. * Gets the stride in float32 units (i.e. byte stride / 4).
  6322. * May not be an integer if the byte stride is not divisible by 4.
  6323. * @returns the stride in float32 units
  6324. * @deprecated Please use byteStride instead.
  6325. */
  6326. getStrideSize(): number;
  6327. /**
  6328. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6329. * @param data defines the data to store
  6330. */
  6331. create(data?: Nullable<DataArray>): void;
  6332. /** @hidden */
  6333. _rebuild(): void;
  6334. /**
  6335. * Update current buffer data
  6336. * @param data defines the data to store
  6337. */
  6338. update(data: DataArray): void;
  6339. /**
  6340. * Updates the data directly.
  6341. * @param data the new data
  6342. * @param offset the new offset
  6343. * @param vertexCount the vertex count (optional)
  6344. * @param useBytes set to true if the offset is in bytes
  6345. */
  6346. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6347. /**
  6348. * Release all resources
  6349. */
  6350. dispose(): void;
  6351. }
  6352. /**
  6353. * Specialized buffer used to store vertex data
  6354. */
  6355. export class VertexBuffer {
  6356. /** @hidden */
  6357. _buffer: Buffer;
  6358. private _kind;
  6359. private _size;
  6360. private _ownsBuffer;
  6361. private _instanced;
  6362. private _instanceDivisor;
  6363. /**
  6364. * The byte type.
  6365. */
  6366. static readonly BYTE: number;
  6367. /**
  6368. * The unsigned byte type.
  6369. */
  6370. static readonly UNSIGNED_BYTE: number;
  6371. /**
  6372. * The short type.
  6373. */
  6374. static readonly SHORT: number;
  6375. /**
  6376. * The unsigned short type.
  6377. */
  6378. static readonly UNSIGNED_SHORT: number;
  6379. /**
  6380. * The integer type.
  6381. */
  6382. static readonly INT: number;
  6383. /**
  6384. * The unsigned integer type.
  6385. */
  6386. static readonly UNSIGNED_INT: number;
  6387. /**
  6388. * The float type.
  6389. */
  6390. static readonly FLOAT: number;
  6391. /**
  6392. * Gets or sets the instance divisor when in instanced mode
  6393. */
  6394. get instanceDivisor(): number;
  6395. set instanceDivisor(value: number);
  6396. /**
  6397. * Gets the byte stride.
  6398. */
  6399. readonly byteStride: number;
  6400. /**
  6401. * Gets the byte offset.
  6402. */
  6403. readonly byteOffset: number;
  6404. /**
  6405. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6406. */
  6407. readonly normalized: boolean;
  6408. /**
  6409. * Gets the data type of each component in the array.
  6410. */
  6411. readonly type: number;
  6412. /**
  6413. * Constructor
  6414. * @param engine the engine
  6415. * @param data the data to use for this vertex buffer
  6416. * @param kind the vertex buffer kind
  6417. * @param updatable whether the data is updatable
  6418. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6419. * @param stride the stride (optional)
  6420. * @param instanced whether the buffer is instanced (optional)
  6421. * @param offset the offset of the data (optional)
  6422. * @param size the number of components (optional)
  6423. * @param type the type of the component (optional)
  6424. * @param normalized whether the data contains normalized data (optional)
  6425. * @param useBytes set to true if stride and offset are in bytes (optional)
  6426. * @param divisor defines the instance divisor to use (1 by default)
  6427. */
  6428. constructor(engine: any, data: DataArray | Buffer, kind: string, updatable: boolean, postponeInternalCreation?: boolean, stride?: number, instanced?: boolean, offset?: number, size?: number, type?: number, normalized?: boolean, useBytes?: boolean, divisor?: number);
  6429. /** @hidden */
  6430. _rebuild(): void;
  6431. /**
  6432. * Returns the kind of the VertexBuffer (string)
  6433. * @returns a string
  6434. */
  6435. getKind(): string;
  6436. /**
  6437. * Gets a boolean indicating if the VertexBuffer is updatable?
  6438. * @returns true if the buffer is updatable
  6439. */
  6440. isUpdatable(): boolean;
  6441. /**
  6442. * Gets current buffer's data
  6443. * @returns a DataArray or null
  6444. */
  6445. getData(): Nullable<DataArray>;
  6446. /**
  6447. * Gets underlying native buffer
  6448. * @returns underlying native buffer
  6449. */
  6450. getBuffer(): Nullable<DataBuffer>;
  6451. /**
  6452. * Gets the stride in float32 units (i.e. byte stride / 4).
  6453. * May not be an integer if the byte stride is not divisible by 4.
  6454. * @returns the stride in float32 units
  6455. * @deprecated Please use byteStride instead.
  6456. */
  6457. getStrideSize(): number;
  6458. /**
  6459. * Returns the offset as a multiple of the type byte length.
  6460. * @returns the offset in bytes
  6461. * @deprecated Please use byteOffset instead.
  6462. */
  6463. getOffset(): number;
  6464. /**
  6465. * Returns the number of components per vertex attribute (integer)
  6466. * @returns the size in float
  6467. */
  6468. getSize(): number;
  6469. /**
  6470. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6471. * @returns true if this buffer is instanced
  6472. */
  6473. getIsInstanced(): boolean;
  6474. /**
  6475. * Returns the instancing divisor, zero for non-instanced (integer).
  6476. * @returns a number
  6477. */
  6478. getInstanceDivisor(): number;
  6479. /**
  6480. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6481. * @param data defines the data to store
  6482. */
  6483. create(data?: DataArray): void;
  6484. /**
  6485. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6486. * This function will create a new buffer if the current one is not updatable
  6487. * @param data defines the data to store
  6488. */
  6489. update(data: DataArray): void;
  6490. /**
  6491. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6492. * Returns the directly updated WebGLBuffer.
  6493. * @param data the new data
  6494. * @param offset the new offset
  6495. * @param useBytes set to true if the offset is in bytes
  6496. */
  6497. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6498. /**
  6499. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6500. */
  6501. dispose(): void;
  6502. /**
  6503. * Enumerates each value of this vertex buffer as numbers.
  6504. * @param count the number of values to enumerate
  6505. * @param callback the callback function called for each value
  6506. */
  6507. forEach(count: number, callback: (value: number, index: number) => void): void;
  6508. /**
  6509. * Positions
  6510. */
  6511. static readonly PositionKind: string;
  6512. /**
  6513. * Normals
  6514. */
  6515. static readonly NormalKind: string;
  6516. /**
  6517. * Tangents
  6518. */
  6519. static readonly TangentKind: string;
  6520. /**
  6521. * Texture coordinates
  6522. */
  6523. static readonly UVKind: string;
  6524. /**
  6525. * Texture coordinates 2
  6526. */
  6527. static readonly UV2Kind: string;
  6528. /**
  6529. * Texture coordinates 3
  6530. */
  6531. static readonly UV3Kind: string;
  6532. /**
  6533. * Texture coordinates 4
  6534. */
  6535. static readonly UV4Kind: string;
  6536. /**
  6537. * Texture coordinates 5
  6538. */
  6539. static readonly UV5Kind: string;
  6540. /**
  6541. * Texture coordinates 6
  6542. */
  6543. static readonly UV6Kind: string;
  6544. /**
  6545. * Colors
  6546. */
  6547. static readonly ColorKind: string;
  6548. /**
  6549. * Matrix indices (for bones)
  6550. */
  6551. static readonly MatricesIndicesKind: string;
  6552. /**
  6553. * Matrix weights (for bones)
  6554. */
  6555. static readonly MatricesWeightsKind: string;
  6556. /**
  6557. * Additional matrix indices (for bones)
  6558. */
  6559. static readonly MatricesIndicesExtraKind: string;
  6560. /**
  6561. * Additional matrix weights (for bones)
  6562. */
  6563. static readonly MatricesWeightsExtraKind: string;
  6564. /**
  6565. * Deduces the stride given a kind.
  6566. * @param kind The kind string to deduce
  6567. * @returns The deduced stride
  6568. */
  6569. static DeduceStride(kind: string): number;
  6570. /**
  6571. * Gets the byte length of the given type.
  6572. * @param type the type
  6573. * @returns the number of bytes
  6574. */
  6575. static GetTypeByteLength(type: number): number;
  6576. /**
  6577. * Enumerates each value of the given parameters as numbers.
  6578. * @param data the data to enumerate
  6579. * @param byteOffset the byte offset of the data
  6580. * @param byteStride the byte stride of the data
  6581. * @param componentCount the number of components per element
  6582. * @param componentType the type of the component
  6583. * @param count the number of values to enumerate
  6584. * @param normalized whether the data is normalized
  6585. * @param callback the callback function called for each value
  6586. */
  6587. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6588. private static _GetFloatValue;
  6589. }
  6590. }
  6591. declare module BABYLON {
  6592. /**
  6593. * @hidden
  6594. */
  6595. export class IntersectionInfo {
  6596. bu: Nullable<number>;
  6597. bv: Nullable<number>;
  6598. distance: number;
  6599. faceId: number;
  6600. subMeshId: number;
  6601. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6602. }
  6603. }
  6604. declare module BABYLON {
  6605. /**
  6606. * Represens a plane by the equation ax + by + cz + d = 0
  6607. */
  6608. export class Plane {
  6609. private static _TmpMatrix;
  6610. /**
  6611. * Normal of the plane (a,b,c)
  6612. */
  6613. normal: Vector3;
  6614. /**
  6615. * d component of the plane
  6616. */
  6617. d: number;
  6618. /**
  6619. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  6620. * @param a a component of the plane
  6621. * @param b b component of the plane
  6622. * @param c c component of the plane
  6623. * @param d d component of the plane
  6624. */
  6625. constructor(a: number, b: number, c: number, d: number);
  6626. /**
  6627. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  6628. */
  6629. asArray(): number[];
  6630. /**
  6631. * @returns a new plane copied from the current Plane.
  6632. */
  6633. clone(): Plane;
  6634. /**
  6635. * @returns the string "Plane".
  6636. */
  6637. getClassName(): string;
  6638. /**
  6639. * @returns the Plane hash code.
  6640. */
  6641. getHashCode(): number;
  6642. /**
  6643. * Normalize the current Plane in place.
  6644. * @returns the updated Plane.
  6645. */
  6646. normalize(): Plane;
  6647. /**
  6648. * Applies a transformation the plane and returns the result
  6649. * @param transformation the transformation matrix to be applied to the plane
  6650. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  6651. */
  6652. transform(transformation: DeepImmutable<Matrix>): Plane;
  6653. /**
  6654. * Calcualtte the dot product between the point and the plane normal
  6655. * @param point point to calculate the dot product with
  6656. * @returns the dot product (float) of the point coordinates and the plane normal.
  6657. */
  6658. dotCoordinate(point: DeepImmutable<Vector3>): number;
  6659. /**
  6660. * Updates the current Plane from the plane defined by the three given points.
  6661. * @param point1 one of the points used to contruct the plane
  6662. * @param point2 one of the points used to contruct the plane
  6663. * @param point3 one of the points used to contruct the plane
  6664. * @returns the updated Plane.
  6665. */
  6666. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6667. /**
  6668. * Checks if the plane is facing a given direction
  6669. * @param direction the direction to check if the plane is facing
  6670. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  6671. * @returns True is the vector "direction" is the same side than the plane normal.
  6672. */
  6673. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  6674. /**
  6675. * Calculates the distance to a point
  6676. * @param point point to calculate distance to
  6677. * @returns the signed distance (float) from the given point to the Plane.
  6678. */
  6679. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  6680. /**
  6681. * Creates a plane from an array
  6682. * @param array the array to create a plane from
  6683. * @returns a new Plane from the given array.
  6684. */
  6685. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  6686. /**
  6687. * Creates a plane from three points
  6688. * @param point1 point used to create the plane
  6689. * @param point2 point used to create the plane
  6690. * @param point3 point used to create the plane
  6691. * @returns a new Plane defined by the three given points.
  6692. */
  6693. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6694. /**
  6695. * Creates a plane from an origin point and a normal
  6696. * @param origin origin of the plane to be constructed
  6697. * @param normal normal of the plane to be constructed
  6698. * @returns a new Plane the normal vector to this plane at the given origin point.
  6699. * Note : the vector "normal" is updated because normalized.
  6700. */
  6701. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  6702. /**
  6703. * Calculates the distance from a plane and a point
  6704. * @param origin origin of the plane to be constructed
  6705. * @param normal normal of the plane to be constructed
  6706. * @param point point to calculate distance to
  6707. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  6708. */
  6709. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  6710. }
  6711. }
  6712. declare module BABYLON {
  6713. /**
  6714. * Class used to store bounding sphere information
  6715. */
  6716. export class BoundingSphere {
  6717. /**
  6718. * Gets the center of the bounding sphere in local space
  6719. */
  6720. readonly center: Vector3;
  6721. /**
  6722. * Radius of the bounding sphere in local space
  6723. */
  6724. radius: number;
  6725. /**
  6726. * Gets the center of the bounding sphere in world space
  6727. */
  6728. readonly centerWorld: Vector3;
  6729. /**
  6730. * Radius of the bounding sphere in world space
  6731. */
  6732. radiusWorld: number;
  6733. /**
  6734. * Gets the minimum vector in local space
  6735. */
  6736. readonly minimum: Vector3;
  6737. /**
  6738. * Gets the maximum vector in local space
  6739. */
  6740. readonly maximum: Vector3;
  6741. private _worldMatrix;
  6742. private static readonly TmpVector3;
  6743. /**
  6744. * Creates a new bounding sphere
  6745. * @param min defines the minimum vector (in local space)
  6746. * @param max defines the maximum vector (in local space)
  6747. * @param worldMatrix defines the new world matrix
  6748. */
  6749. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6750. /**
  6751. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6752. * @param min defines the new minimum vector (in local space)
  6753. * @param max defines the new maximum vector (in local space)
  6754. * @param worldMatrix defines the new world matrix
  6755. */
  6756. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6757. /**
  6758. * Scale the current bounding sphere by applying a scale factor
  6759. * @param factor defines the scale factor to apply
  6760. * @returns the current bounding box
  6761. */
  6762. scale(factor: number): BoundingSphere;
  6763. /**
  6764. * Gets the world matrix of the bounding box
  6765. * @returns a matrix
  6766. */
  6767. getWorldMatrix(): DeepImmutable<Matrix>;
  6768. /** @hidden */
  6769. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6770. /**
  6771. * Tests if the bounding sphere is intersecting the frustum planes
  6772. * @param frustumPlanes defines the frustum planes to test
  6773. * @returns true if there is an intersection
  6774. */
  6775. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6776. /**
  6777. * Tests if the bounding sphere center is in between the frustum planes.
  6778. * Used for optimistic fast inclusion.
  6779. * @param frustumPlanes defines the frustum planes to test
  6780. * @returns true if the sphere center is in between the frustum planes
  6781. */
  6782. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6783. /**
  6784. * Tests if a point is inside the bounding sphere
  6785. * @param point defines the point to test
  6786. * @returns true if the point is inside the bounding sphere
  6787. */
  6788. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6789. /**
  6790. * Checks if two sphere intersct
  6791. * @param sphere0 sphere 0
  6792. * @param sphere1 sphere 1
  6793. * @returns true if the speres intersect
  6794. */
  6795. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6796. }
  6797. }
  6798. declare module BABYLON {
  6799. /**
  6800. * Class used to store bounding box information
  6801. */
  6802. export class BoundingBox implements ICullable {
  6803. /**
  6804. * Gets the 8 vectors representing the bounding box in local space
  6805. */
  6806. readonly vectors: Vector3[];
  6807. /**
  6808. * Gets the center of the bounding box in local space
  6809. */
  6810. readonly center: Vector3;
  6811. /**
  6812. * Gets the center of the bounding box in world space
  6813. */
  6814. readonly centerWorld: Vector3;
  6815. /**
  6816. * Gets the extend size in local space
  6817. */
  6818. readonly extendSize: Vector3;
  6819. /**
  6820. * Gets the extend size in world space
  6821. */
  6822. readonly extendSizeWorld: Vector3;
  6823. /**
  6824. * Gets the OBB (object bounding box) directions
  6825. */
  6826. readonly directions: Vector3[];
  6827. /**
  6828. * Gets the 8 vectors representing the bounding box in world space
  6829. */
  6830. readonly vectorsWorld: Vector3[];
  6831. /**
  6832. * Gets the minimum vector in world space
  6833. */
  6834. readonly minimumWorld: Vector3;
  6835. /**
  6836. * Gets the maximum vector in world space
  6837. */
  6838. readonly maximumWorld: Vector3;
  6839. /**
  6840. * Gets the minimum vector in local space
  6841. */
  6842. readonly minimum: Vector3;
  6843. /**
  6844. * Gets the maximum vector in local space
  6845. */
  6846. readonly maximum: Vector3;
  6847. private _worldMatrix;
  6848. private static readonly TmpVector3;
  6849. /**
  6850. * @hidden
  6851. */
  6852. _tag: number;
  6853. /**
  6854. * Creates a new bounding box
  6855. * @param min defines the minimum vector (in local space)
  6856. * @param max defines the maximum vector (in local space)
  6857. * @param worldMatrix defines the new world matrix
  6858. */
  6859. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6860. /**
  6861. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6862. * @param min defines the new minimum vector (in local space)
  6863. * @param max defines the new maximum vector (in local space)
  6864. * @param worldMatrix defines the new world matrix
  6865. */
  6866. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6867. /**
  6868. * Scale the current bounding box by applying a scale factor
  6869. * @param factor defines the scale factor to apply
  6870. * @returns the current bounding box
  6871. */
  6872. scale(factor: number): BoundingBox;
  6873. /**
  6874. * Gets the world matrix of the bounding box
  6875. * @returns a matrix
  6876. */
  6877. getWorldMatrix(): DeepImmutable<Matrix>;
  6878. /** @hidden */
  6879. _update(world: DeepImmutable<Matrix>): void;
  6880. /**
  6881. * Tests if the bounding box is intersecting the frustum planes
  6882. * @param frustumPlanes defines the frustum planes to test
  6883. * @returns true if there is an intersection
  6884. */
  6885. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6886. /**
  6887. * Tests if the bounding box is entirely inside the frustum planes
  6888. * @param frustumPlanes defines the frustum planes to test
  6889. * @returns true if there is an inclusion
  6890. */
  6891. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6892. /**
  6893. * Tests if a point is inside the bounding box
  6894. * @param point defines the point to test
  6895. * @returns true if the point is inside the bounding box
  6896. */
  6897. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6898. /**
  6899. * Tests if the bounding box intersects with a bounding sphere
  6900. * @param sphere defines the sphere to test
  6901. * @returns true if there is an intersection
  6902. */
  6903. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  6904. /**
  6905. * Tests if the bounding box intersects with a box defined by a min and max vectors
  6906. * @param min defines the min vector to use
  6907. * @param max defines the max vector to use
  6908. * @returns true if there is an intersection
  6909. */
  6910. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  6911. /**
  6912. * Tests if two bounding boxes are intersections
  6913. * @param box0 defines the first box to test
  6914. * @param box1 defines the second box to test
  6915. * @returns true if there is an intersection
  6916. */
  6917. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  6918. /**
  6919. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  6920. * @param minPoint defines the minimum vector of the bounding box
  6921. * @param maxPoint defines the maximum vector of the bounding box
  6922. * @param sphereCenter defines the sphere center
  6923. * @param sphereRadius defines the sphere radius
  6924. * @returns true if there is an intersection
  6925. */
  6926. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  6927. /**
  6928. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  6929. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6930. * @param frustumPlanes defines the frustum planes to test
  6931. * @return true if there is an inclusion
  6932. */
  6933. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6934. /**
  6935. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  6936. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6937. * @param frustumPlanes defines the frustum planes to test
  6938. * @return true if there is an intersection
  6939. */
  6940. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6941. }
  6942. }
  6943. declare module BABYLON {
  6944. /** @hidden */
  6945. export class Collider {
  6946. /** Define if a collision was found */
  6947. collisionFound: boolean;
  6948. /**
  6949. * Define last intersection point in local space
  6950. */
  6951. intersectionPoint: Vector3;
  6952. /**
  6953. * Define last collided mesh
  6954. */
  6955. collidedMesh: Nullable<AbstractMesh>;
  6956. private _collisionPoint;
  6957. private _planeIntersectionPoint;
  6958. private _tempVector;
  6959. private _tempVector2;
  6960. private _tempVector3;
  6961. private _tempVector4;
  6962. private _edge;
  6963. private _baseToVertex;
  6964. private _destinationPoint;
  6965. private _slidePlaneNormal;
  6966. private _displacementVector;
  6967. /** @hidden */
  6968. _radius: Vector3;
  6969. /** @hidden */
  6970. _retry: number;
  6971. private _velocity;
  6972. private _basePoint;
  6973. private _epsilon;
  6974. /** @hidden */
  6975. _velocityWorldLength: number;
  6976. /** @hidden */
  6977. _basePointWorld: Vector3;
  6978. private _velocityWorld;
  6979. private _normalizedVelocity;
  6980. /** @hidden */
  6981. _initialVelocity: Vector3;
  6982. /** @hidden */
  6983. _initialPosition: Vector3;
  6984. private _nearestDistance;
  6985. private _collisionMask;
  6986. get collisionMask(): number;
  6987. set collisionMask(mask: number);
  6988. /**
  6989. * Gets the plane normal used to compute the sliding response (in local space)
  6990. */
  6991. get slidePlaneNormal(): Vector3;
  6992. /** @hidden */
  6993. _initialize(source: Vector3, dir: Vector3, e: number): void;
  6994. /** @hidden */
  6995. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  6996. /** @hidden */
  6997. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  6998. /** @hidden */
  6999. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7000. /** @hidden */
  7001. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7002. /** @hidden */
  7003. _getResponse(pos: Vector3, vel: Vector3): void;
  7004. }
  7005. }
  7006. declare module BABYLON {
  7007. /**
  7008. * Interface for cullable objects
  7009. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7010. */
  7011. export interface ICullable {
  7012. /**
  7013. * Checks if the object or part of the object is in the frustum
  7014. * @param frustumPlanes Camera near/planes
  7015. * @returns true if the object is in frustum otherwise false
  7016. */
  7017. isInFrustum(frustumPlanes: Plane[]): boolean;
  7018. /**
  7019. * Checks if a cullable object (mesh...) is in the camera frustum
  7020. * Unlike isInFrustum this cheks the full bounding box
  7021. * @param frustumPlanes Camera near/planes
  7022. * @returns true if the object is in frustum otherwise false
  7023. */
  7024. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7025. }
  7026. /**
  7027. * Info for a bounding data of a mesh
  7028. */
  7029. export class BoundingInfo implements ICullable {
  7030. /**
  7031. * Bounding box for the mesh
  7032. */
  7033. readonly boundingBox: BoundingBox;
  7034. /**
  7035. * Bounding sphere for the mesh
  7036. */
  7037. readonly boundingSphere: BoundingSphere;
  7038. private _isLocked;
  7039. private static readonly TmpVector3;
  7040. /**
  7041. * Constructs bounding info
  7042. * @param minimum min vector of the bounding box/sphere
  7043. * @param maximum max vector of the bounding box/sphere
  7044. * @param worldMatrix defines the new world matrix
  7045. */
  7046. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7047. /**
  7048. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7049. * @param min defines the new minimum vector (in local space)
  7050. * @param max defines the new maximum vector (in local space)
  7051. * @param worldMatrix defines the new world matrix
  7052. */
  7053. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7054. /**
  7055. * min vector of the bounding box/sphere
  7056. */
  7057. get minimum(): Vector3;
  7058. /**
  7059. * max vector of the bounding box/sphere
  7060. */
  7061. get maximum(): Vector3;
  7062. /**
  7063. * If the info is locked and won't be updated to avoid perf overhead
  7064. */
  7065. get isLocked(): boolean;
  7066. set isLocked(value: boolean);
  7067. /**
  7068. * Updates the bounding sphere and box
  7069. * @param world world matrix to be used to update
  7070. */
  7071. update(world: DeepImmutable<Matrix>): void;
  7072. /**
  7073. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7074. * @param center New center of the bounding info
  7075. * @param extend New extend of the bounding info
  7076. * @returns the current bounding info
  7077. */
  7078. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7079. /**
  7080. * Scale the current bounding info by applying a scale factor
  7081. * @param factor defines the scale factor to apply
  7082. * @returns the current bounding info
  7083. */
  7084. scale(factor: number): BoundingInfo;
  7085. /**
  7086. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7087. * @param frustumPlanes defines the frustum to test
  7088. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7089. * @returns true if the bounding info is in the frustum planes
  7090. */
  7091. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7092. /**
  7093. * Gets the world distance between the min and max points of the bounding box
  7094. */
  7095. get diagonalLength(): number;
  7096. /**
  7097. * Checks if a cullable object (mesh...) is in the camera frustum
  7098. * Unlike isInFrustum this cheks the full bounding box
  7099. * @param frustumPlanes Camera near/planes
  7100. * @returns true if the object is in frustum otherwise false
  7101. */
  7102. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7103. /** @hidden */
  7104. _checkCollision(collider: Collider): boolean;
  7105. /**
  7106. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7107. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7108. * @param point the point to check intersection with
  7109. * @returns if the point intersects
  7110. */
  7111. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7112. /**
  7113. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7114. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7115. * @param boundingInfo the bounding info to check intersection with
  7116. * @param precise if the intersection should be done using OBB
  7117. * @returns if the bounding info intersects
  7118. */
  7119. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7120. }
  7121. }
  7122. declare module BABYLON {
  7123. /**
  7124. * Extracts minimum and maximum values from a list of indexed positions
  7125. * @param positions defines the positions to use
  7126. * @param indices defines the indices to the positions
  7127. * @param indexStart defines the start index
  7128. * @param indexCount defines the end index
  7129. * @param bias defines bias value to add to the result
  7130. * @return minimum and maximum values
  7131. */
  7132. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7133. minimum: Vector3;
  7134. maximum: Vector3;
  7135. };
  7136. /**
  7137. * Extracts minimum and maximum values from a list of positions
  7138. * @param positions defines the positions to use
  7139. * @param start defines the start index in the positions array
  7140. * @param count defines the number of positions to handle
  7141. * @param bias defines bias value to add to the result
  7142. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7143. * @return minimum and maximum values
  7144. */
  7145. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7146. minimum: Vector3;
  7147. maximum: Vector3;
  7148. };
  7149. }
  7150. declare module BABYLON {
  7151. /** @hidden */
  7152. export class WebGLDataBuffer extends DataBuffer {
  7153. private _buffer;
  7154. constructor(resource: WebGLBuffer);
  7155. get underlyingResource(): any;
  7156. }
  7157. }
  7158. declare module BABYLON {
  7159. /** @hidden */
  7160. export class WebGLPipelineContext implements IPipelineContext {
  7161. engine: ThinEngine;
  7162. program: Nullable<WebGLProgram>;
  7163. context?: WebGLRenderingContext;
  7164. vertexShader?: WebGLShader;
  7165. fragmentShader?: WebGLShader;
  7166. isParallelCompiled: boolean;
  7167. onCompiled?: () => void;
  7168. transformFeedback?: WebGLTransformFeedback | null;
  7169. vertexCompilationError: Nullable<string>;
  7170. fragmentCompilationError: Nullable<string>;
  7171. programLinkError: Nullable<string>;
  7172. programValidationError: Nullable<string>;
  7173. get isAsync(): boolean;
  7174. get isReady(): boolean;
  7175. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7176. }
  7177. }
  7178. declare module BABYLON {
  7179. interface ThinEngine {
  7180. /**
  7181. * Create an uniform buffer
  7182. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7183. * @param elements defines the content of the uniform buffer
  7184. * @returns the webGL uniform buffer
  7185. */
  7186. createUniformBuffer(elements: FloatArray): DataBuffer;
  7187. /**
  7188. * Create a dynamic uniform buffer
  7189. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7190. * @param elements defines the content of the uniform buffer
  7191. * @returns the webGL uniform buffer
  7192. */
  7193. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7194. /**
  7195. * Update an existing uniform buffer
  7196. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7197. * @param uniformBuffer defines the target uniform buffer
  7198. * @param elements defines the content to update
  7199. * @param offset defines the offset in the uniform buffer where update should start
  7200. * @param count defines the size of the data to update
  7201. */
  7202. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7203. /**
  7204. * Bind an uniform buffer to the current webGL context
  7205. * @param buffer defines the buffer to bind
  7206. */
  7207. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7208. /**
  7209. * Bind a buffer to the current webGL context at a given location
  7210. * @param buffer defines the buffer to bind
  7211. * @param location defines the index where to bind the buffer
  7212. */
  7213. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7214. /**
  7215. * Bind a specific block at a given index in a specific shader program
  7216. * @param pipelineContext defines the pipeline context to use
  7217. * @param blockName defines the block name
  7218. * @param index defines the index where to bind the block
  7219. */
  7220. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7221. }
  7222. }
  7223. declare module BABYLON {
  7224. /**
  7225. * Uniform buffer objects.
  7226. *
  7227. * Handles blocks of uniform on the GPU.
  7228. *
  7229. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7230. *
  7231. * For more information, please refer to :
  7232. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7233. */
  7234. export class UniformBuffer {
  7235. private _engine;
  7236. private _buffer;
  7237. private _data;
  7238. private _bufferData;
  7239. private _dynamic?;
  7240. private _uniformLocations;
  7241. private _uniformSizes;
  7242. private _uniformLocationPointer;
  7243. private _needSync;
  7244. private _noUBO;
  7245. private _currentEffect;
  7246. /** @hidden */
  7247. _alreadyBound: boolean;
  7248. private static _MAX_UNIFORM_SIZE;
  7249. private static _tempBuffer;
  7250. /**
  7251. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7252. * This is dynamic to allow compat with webgl 1 and 2.
  7253. * You will need to pass the name of the uniform as well as the value.
  7254. */
  7255. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7256. /**
  7257. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7258. * This is dynamic to allow compat with webgl 1 and 2.
  7259. * You will need to pass the name of the uniform as well as the value.
  7260. */
  7261. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7262. /**
  7263. * Lambda to Update a single float in a uniform buffer.
  7264. * This is dynamic to allow compat with webgl 1 and 2.
  7265. * You will need to pass the name of the uniform as well as the value.
  7266. */
  7267. updateFloat: (name: string, x: number) => void;
  7268. /**
  7269. * Lambda to Update a vec2 of float in a uniform buffer.
  7270. * This is dynamic to allow compat with webgl 1 and 2.
  7271. * You will need to pass the name of the uniform as well as the value.
  7272. */
  7273. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7274. /**
  7275. * Lambda to Update a vec3 of float in a uniform buffer.
  7276. * This is dynamic to allow compat with webgl 1 and 2.
  7277. * You will need to pass the name of the uniform as well as the value.
  7278. */
  7279. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7280. /**
  7281. * Lambda to Update a vec4 of float in a uniform buffer.
  7282. * This is dynamic to allow compat with webgl 1 and 2.
  7283. * You will need to pass the name of the uniform as well as the value.
  7284. */
  7285. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7286. /**
  7287. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7288. * This is dynamic to allow compat with webgl 1 and 2.
  7289. * You will need to pass the name of the uniform as well as the value.
  7290. */
  7291. updateMatrix: (name: string, mat: Matrix) => void;
  7292. /**
  7293. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7294. * This is dynamic to allow compat with webgl 1 and 2.
  7295. * You will need to pass the name of the uniform as well as the value.
  7296. */
  7297. updateVector3: (name: string, vector: Vector3) => void;
  7298. /**
  7299. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7300. * This is dynamic to allow compat with webgl 1 and 2.
  7301. * You will need to pass the name of the uniform as well as the value.
  7302. */
  7303. updateVector4: (name: string, vector: Vector4) => void;
  7304. /**
  7305. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7306. * This is dynamic to allow compat with webgl 1 and 2.
  7307. * You will need to pass the name of the uniform as well as the value.
  7308. */
  7309. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7310. /**
  7311. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7312. * This is dynamic to allow compat with webgl 1 and 2.
  7313. * You will need to pass the name of the uniform as well as the value.
  7314. */
  7315. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7316. /**
  7317. * Instantiates a new Uniform buffer objects.
  7318. *
  7319. * Handles blocks of uniform on the GPU.
  7320. *
  7321. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7322. *
  7323. * For more information, please refer to :
  7324. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7325. * @param engine Define the engine the buffer is associated with
  7326. * @param data Define the data contained in the buffer
  7327. * @param dynamic Define if the buffer is updatable
  7328. */
  7329. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7330. /**
  7331. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7332. * or just falling back on setUniformXXX calls.
  7333. */
  7334. get useUbo(): boolean;
  7335. /**
  7336. * Indicates if the WebGL underlying uniform buffer is in sync
  7337. * with the javascript cache data.
  7338. */
  7339. get isSync(): boolean;
  7340. /**
  7341. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7342. * Also, a dynamic UniformBuffer will disable cache verification and always
  7343. * update the underlying WebGL uniform buffer to the GPU.
  7344. * @returns if Dynamic, otherwise false
  7345. */
  7346. isDynamic(): boolean;
  7347. /**
  7348. * The data cache on JS side.
  7349. * @returns the underlying data as a float array
  7350. */
  7351. getData(): Float32Array;
  7352. /**
  7353. * The underlying WebGL Uniform buffer.
  7354. * @returns the webgl buffer
  7355. */
  7356. getBuffer(): Nullable<DataBuffer>;
  7357. /**
  7358. * std140 layout specifies how to align data within an UBO structure.
  7359. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7360. * for specs.
  7361. */
  7362. private _fillAlignment;
  7363. /**
  7364. * Adds an uniform in the buffer.
  7365. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7366. * for the layout to be correct !
  7367. * @param name Name of the uniform, as used in the uniform block in the shader.
  7368. * @param size Data size, or data directly.
  7369. */
  7370. addUniform(name: string, size: number | number[]): void;
  7371. /**
  7372. * Adds a Matrix 4x4 to the uniform buffer.
  7373. * @param name Name of the uniform, as used in the uniform block in the shader.
  7374. * @param mat A 4x4 matrix.
  7375. */
  7376. addMatrix(name: string, mat: Matrix): void;
  7377. /**
  7378. * Adds a vec2 to the uniform buffer.
  7379. * @param name Name of the uniform, as used in the uniform block in the shader.
  7380. * @param x Define the x component value of the vec2
  7381. * @param y Define the y component value of the vec2
  7382. */
  7383. addFloat2(name: string, x: number, y: number): void;
  7384. /**
  7385. * Adds a vec3 to the uniform buffer.
  7386. * @param name Name of the uniform, as used in the uniform block in the shader.
  7387. * @param x Define the x component value of the vec3
  7388. * @param y Define the y component value of the vec3
  7389. * @param z Define the z component value of the vec3
  7390. */
  7391. addFloat3(name: string, x: number, y: number, z: number): void;
  7392. /**
  7393. * Adds a vec3 to the uniform buffer.
  7394. * @param name Name of the uniform, as used in the uniform block in the shader.
  7395. * @param color Define the vec3 from a Color
  7396. */
  7397. addColor3(name: string, color: Color3): void;
  7398. /**
  7399. * Adds a vec4 to the uniform buffer.
  7400. * @param name Name of the uniform, as used in the uniform block in the shader.
  7401. * @param color Define the rgb components from a Color
  7402. * @param alpha Define the a component of the vec4
  7403. */
  7404. addColor4(name: string, color: Color3, alpha: number): void;
  7405. /**
  7406. * Adds a vec3 to the uniform buffer.
  7407. * @param name Name of the uniform, as used in the uniform block in the shader.
  7408. * @param vector Define the vec3 components from a Vector
  7409. */
  7410. addVector3(name: string, vector: Vector3): void;
  7411. /**
  7412. * Adds a Matrix 3x3 to the uniform buffer.
  7413. * @param name Name of the uniform, as used in the uniform block in the shader.
  7414. */
  7415. addMatrix3x3(name: string): void;
  7416. /**
  7417. * Adds a Matrix 2x2 to the uniform buffer.
  7418. * @param name Name of the uniform, as used in the uniform block in the shader.
  7419. */
  7420. addMatrix2x2(name: string): void;
  7421. /**
  7422. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7423. */
  7424. create(): void;
  7425. /** @hidden */
  7426. _rebuild(): void;
  7427. /**
  7428. * Updates the WebGL Uniform Buffer on the GPU.
  7429. * If the `dynamic` flag is set to true, no cache comparison is done.
  7430. * Otherwise, the buffer will be updated only if the cache differs.
  7431. */
  7432. update(): void;
  7433. /**
  7434. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7435. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7436. * @param data Define the flattened data
  7437. * @param size Define the size of the data.
  7438. */
  7439. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7440. private _valueCache;
  7441. private _cacheMatrix;
  7442. private _updateMatrix3x3ForUniform;
  7443. private _updateMatrix3x3ForEffect;
  7444. private _updateMatrix2x2ForEffect;
  7445. private _updateMatrix2x2ForUniform;
  7446. private _updateFloatForEffect;
  7447. private _updateFloatForUniform;
  7448. private _updateFloat2ForEffect;
  7449. private _updateFloat2ForUniform;
  7450. private _updateFloat3ForEffect;
  7451. private _updateFloat3ForUniform;
  7452. private _updateFloat4ForEffect;
  7453. private _updateFloat4ForUniform;
  7454. private _updateMatrixForEffect;
  7455. private _updateMatrixForUniform;
  7456. private _updateVector3ForEffect;
  7457. private _updateVector3ForUniform;
  7458. private _updateVector4ForEffect;
  7459. private _updateVector4ForUniform;
  7460. private _updateColor3ForEffect;
  7461. private _updateColor3ForUniform;
  7462. private _updateColor4ForEffect;
  7463. private _updateColor4ForUniform;
  7464. /**
  7465. * Sets a sampler uniform on the effect.
  7466. * @param name Define the name of the sampler.
  7467. * @param texture Define the texture to set in the sampler
  7468. */
  7469. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7470. /**
  7471. * Directly updates the value of the uniform in the cache AND on the GPU.
  7472. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7473. * @param data Define the flattened data
  7474. */
  7475. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7476. /**
  7477. * Binds this uniform buffer to an effect.
  7478. * @param effect Define the effect to bind the buffer to
  7479. * @param name Name of the uniform block in the shader.
  7480. */
  7481. bindToEffect(effect: Effect, name: string): void;
  7482. /**
  7483. * Disposes the uniform buffer.
  7484. */
  7485. dispose(): void;
  7486. }
  7487. }
  7488. declare module BABYLON {
  7489. /**
  7490. * Enum that determines the text-wrapping mode to use.
  7491. */
  7492. export enum InspectableType {
  7493. /**
  7494. * Checkbox for booleans
  7495. */
  7496. Checkbox = 0,
  7497. /**
  7498. * Sliders for numbers
  7499. */
  7500. Slider = 1,
  7501. /**
  7502. * Vector3
  7503. */
  7504. Vector3 = 2,
  7505. /**
  7506. * Quaternions
  7507. */
  7508. Quaternion = 3,
  7509. /**
  7510. * Color3
  7511. */
  7512. Color3 = 4,
  7513. /**
  7514. * String
  7515. */
  7516. String = 5
  7517. }
  7518. /**
  7519. * Interface used to define custom inspectable properties.
  7520. * This interface is used by the inspector to display custom property grids
  7521. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7522. */
  7523. export interface IInspectable {
  7524. /**
  7525. * Gets the label to display
  7526. */
  7527. label: string;
  7528. /**
  7529. * Gets the name of the property to edit
  7530. */
  7531. propertyName: string;
  7532. /**
  7533. * Gets the type of the editor to use
  7534. */
  7535. type: InspectableType;
  7536. /**
  7537. * Gets the minimum value of the property when using in "slider" mode
  7538. */
  7539. min?: number;
  7540. /**
  7541. * Gets the maximum value of the property when using in "slider" mode
  7542. */
  7543. max?: number;
  7544. /**
  7545. * Gets the setp to use when using in "slider" mode
  7546. */
  7547. step?: number;
  7548. }
  7549. }
  7550. declare module BABYLON {
  7551. /**
  7552. * Class used to provide helper for timing
  7553. */
  7554. export class TimingTools {
  7555. /**
  7556. * Polyfill for setImmediate
  7557. * @param action defines the action to execute after the current execution block
  7558. */
  7559. static SetImmediate(action: () => void): void;
  7560. }
  7561. }
  7562. declare module BABYLON {
  7563. /**
  7564. * Class used to enable instatition of objects by class name
  7565. */
  7566. export class InstantiationTools {
  7567. /**
  7568. * Use this object to register external classes like custom textures or material
  7569. * to allow the laoders to instantiate them
  7570. */
  7571. static RegisteredExternalClasses: {
  7572. [key: string]: Object;
  7573. };
  7574. /**
  7575. * Tries to instantiate a new object from a given class name
  7576. * @param className defines the class name to instantiate
  7577. * @returns the new object or null if the system was not able to do the instantiation
  7578. */
  7579. static Instantiate(className: string): any;
  7580. }
  7581. }
  7582. declare module BABYLON {
  7583. /**
  7584. * Define options used to create a depth texture
  7585. */
  7586. export class DepthTextureCreationOptions {
  7587. /** Specifies whether or not a stencil should be allocated in the texture */
  7588. generateStencil?: boolean;
  7589. /** Specifies whether or not bilinear filtering is enable on the texture */
  7590. bilinearFiltering?: boolean;
  7591. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7592. comparisonFunction?: number;
  7593. /** Specifies if the created texture is a cube texture */
  7594. isCube?: boolean;
  7595. }
  7596. }
  7597. declare module BABYLON {
  7598. interface ThinEngine {
  7599. /**
  7600. * Creates a depth stencil cube texture.
  7601. * This is only available in WebGL 2.
  7602. * @param size The size of face edge in the cube texture.
  7603. * @param options The options defining the cube texture.
  7604. * @returns The cube texture
  7605. */
  7606. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7607. /**
  7608. * Creates a cube texture
  7609. * @param rootUrl defines the url where the files to load is located
  7610. * @param scene defines the current scene
  7611. * @param files defines the list of files to load (1 per face)
  7612. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7613. * @param onLoad defines an optional callback raised when the texture is loaded
  7614. * @param onError defines an optional callback raised if there is an issue to load the texture
  7615. * @param format defines the format of the data
  7616. * @param forcedExtension defines the extension to use to pick the right loader
  7617. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7618. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7619. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7620. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7621. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  7622. * @returns the cube texture as an InternalTexture
  7623. */
  7624. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean | undefined, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number, fallback: Nullable<InternalTexture>, excludeLoaders: Array<IInternalTextureLoader>): InternalTexture;
  7625. /**
  7626. * Creates a cube texture
  7627. * @param rootUrl defines the url where the files to load is located
  7628. * @param scene defines the current scene
  7629. * @param files defines the list of files to load (1 per face)
  7630. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7631. * @param onLoad defines an optional callback raised when the texture is loaded
  7632. * @param onError defines an optional callback raised if there is an issue to load the texture
  7633. * @param format defines the format of the data
  7634. * @param forcedExtension defines the extension to use to pick the right loader
  7635. * @returns the cube texture as an InternalTexture
  7636. */
  7637. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any): InternalTexture;
  7638. /**
  7639. * Creates a cube texture
  7640. * @param rootUrl defines the url where the files to load is located
  7641. * @param scene defines the current scene
  7642. * @param files defines the list of files to load (1 per face)
  7643. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7644. * @param onLoad defines an optional callback raised when the texture is loaded
  7645. * @param onError defines an optional callback raised if there is an issue to load the texture
  7646. * @param format defines the format of the data
  7647. * @param forcedExtension defines the extension to use to pick the right loader
  7648. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7649. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7650. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7651. * @returns the cube texture as an InternalTexture
  7652. */
  7653. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number): InternalTexture;
  7654. /** @hidden */
  7655. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7656. /** @hidden */
  7657. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7658. /** @hidden */
  7659. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7660. /** @hidden */
  7661. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7662. /**
  7663. * @hidden
  7664. */
  7665. _setCubeMapTextureParams(loadMipmap: boolean): void;
  7666. }
  7667. }
  7668. declare module BABYLON {
  7669. /**
  7670. * Class for creating a cube texture
  7671. */
  7672. export class CubeTexture extends BaseTexture {
  7673. private _delayedOnLoad;
  7674. /**
  7675. * Observable triggered once the texture has been loaded.
  7676. */
  7677. onLoadObservable: Observable<CubeTexture>;
  7678. /**
  7679. * The url of the texture
  7680. */
  7681. url: string;
  7682. /**
  7683. * Gets or sets the center of the bounding box associated with the cube texture.
  7684. * It must define where the camera used to render the texture was set
  7685. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7686. */
  7687. boundingBoxPosition: Vector3;
  7688. private _boundingBoxSize;
  7689. /**
  7690. * Gets or sets the size of the bounding box associated with the cube texture
  7691. * When defined, the cubemap will switch to local mode
  7692. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7693. * @example https://www.babylonjs-playground.com/#RNASML
  7694. */
  7695. set boundingBoxSize(value: Vector3);
  7696. /**
  7697. * Returns the bounding box size
  7698. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7699. */
  7700. get boundingBoxSize(): Vector3;
  7701. protected _rotationY: number;
  7702. /**
  7703. * Sets texture matrix rotation angle around Y axis in radians.
  7704. */
  7705. set rotationY(value: number);
  7706. /**
  7707. * Gets texture matrix rotation angle around Y axis radians.
  7708. */
  7709. get rotationY(): number;
  7710. /**
  7711. * Are mip maps generated for this texture or not.
  7712. */
  7713. get noMipmap(): boolean;
  7714. private _noMipmap;
  7715. private _files;
  7716. protected _forcedExtension: Nullable<string>;
  7717. private _extensions;
  7718. private _textureMatrix;
  7719. private _format;
  7720. private _createPolynomials;
  7721. /** @hidden */
  7722. _prefiltered: boolean;
  7723. /**
  7724. * Creates a cube texture from an array of image urls
  7725. * @param files defines an array of image urls
  7726. * @param scene defines the hosting scene
  7727. * @param noMipmap specifies if mip maps are not used
  7728. * @returns a cube texture
  7729. */
  7730. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7731. /**
  7732. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7733. * @param url defines the url of the prefiltered texture
  7734. * @param scene defines the scene the texture is attached to
  7735. * @param forcedExtension defines the extension of the file if different from the url
  7736. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7737. * @return the prefiltered texture
  7738. */
  7739. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7740. /**
  7741. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7742. * as prefiltered data.
  7743. * @param rootUrl defines the url of the texture or the root name of the six images
  7744. * @param scene defines the scene the texture is attached to
  7745. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7746. * @param noMipmap defines if mipmaps should be created or not
  7747. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7748. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7749. * @param onError defines a callback triggered in case of error during load
  7750. * @param format defines the internal format to use for the texture once loaded
  7751. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7752. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7753. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7754. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7755. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7756. * @return the cube texture
  7757. */
  7758. constructor(rootUrl: string, scene: Scene, extensions?: Nullable<string[]>, noMipmap?: boolean, files?: Nullable<string[]>, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, prefiltered?: boolean, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number);
  7759. /**
  7760. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7761. */
  7762. get isPrefiltered(): boolean;
  7763. /**
  7764. * Get the current class name of the texture useful for serialization or dynamic coding.
  7765. * @returns "CubeTexture"
  7766. */
  7767. getClassName(): string;
  7768. /**
  7769. * Update the url (and optional buffer) of this texture if url was null during construction.
  7770. * @param url the url of the texture
  7771. * @param forcedExtension defines the extension to use
  7772. * @param onLoad callback called when the texture is loaded (defaults to null)
  7773. * @param prefiltered Defines whether the updated texture is prefiltered or not
  7774. */
  7775. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  7776. /**
  7777. * Delays loading of the cube texture
  7778. * @param forcedExtension defines the extension to use
  7779. */
  7780. delayLoad(forcedExtension?: string): void;
  7781. /**
  7782. * Returns the reflection texture matrix
  7783. * @returns the reflection texture matrix
  7784. */
  7785. getReflectionTextureMatrix(): Matrix;
  7786. /**
  7787. * Sets the reflection texture matrix
  7788. * @param value Reflection texture matrix
  7789. */
  7790. setReflectionTextureMatrix(value: Matrix): void;
  7791. /**
  7792. * Parses text to create a cube texture
  7793. * @param parsedTexture define the serialized text to read from
  7794. * @param scene defines the hosting scene
  7795. * @param rootUrl defines the root url of the cube texture
  7796. * @returns a cube texture
  7797. */
  7798. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7799. /**
  7800. * Makes a clone, or deep copy, of the cube texture
  7801. * @returns a new cube texture
  7802. */
  7803. clone(): CubeTexture;
  7804. }
  7805. }
  7806. declare module BABYLON {
  7807. /**
  7808. * Manages the defines for the Material
  7809. */
  7810. export class MaterialDefines {
  7811. /** @hidden */
  7812. protected _keys: string[];
  7813. private _isDirty;
  7814. /** @hidden */
  7815. _renderId: number;
  7816. /** @hidden */
  7817. _areLightsDirty: boolean;
  7818. /** @hidden */
  7819. _areLightsDisposed: boolean;
  7820. /** @hidden */
  7821. _areAttributesDirty: boolean;
  7822. /** @hidden */
  7823. _areTexturesDirty: boolean;
  7824. /** @hidden */
  7825. _areFresnelDirty: boolean;
  7826. /** @hidden */
  7827. _areMiscDirty: boolean;
  7828. /** @hidden */
  7829. _areImageProcessingDirty: boolean;
  7830. /** @hidden */
  7831. _normals: boolean;
  7832. /** @hidden */
  7833. _uvs: boolean;
  7834. /** @hidden */
  7835. _needNormals: boolean;
  7836. /** @hidden */
  7837. _needUVs: boolean;
  7838. [id: string]: any;
  7839. /**
  7840. * Specifies if the material needs to be re-calculated
  7841. */
  7842. get isDirty(): boolean;
  7843. /**
  7844. * Marks the material to indicate that it has been re-calculated
  7845. */
  7846. markAsProcessed(): void;
  7847. /**
  7848. * Marks the material to indicate that it needs to be re-calculated
  7849. */
  7850. markAsUnprocessed(): void;
  7851. /**
  7852. * Marks the material to indicate all of its defines need to be re-calculated
  7853. */
  7854. markAllAsDirty(): void;
  7855. /**
  7856. * Marks the material to indicate that image processing needs to be re-calculated
  7857. */
  7858. markAsImageProcessingDirty(): void;
  7859. /**
  7860. * Marks the material to indicate the lights need to be re-calculated
  7861. * @param disposed Defines whether the light is dirty due to dispose or not
  7862. */
  7863. markAsLightDirty(disposed?: boolean): void;
  7864. /**
  7865. * Marks the attribute state as changed
  7866. */
  7867. markAsAttributesDirty(): void;
  7868. /**
  7869. * Marks the texture state as changed
  7870. */
  7871. markAsTexturesDirty(): void;
  7872. /**
  7873. * Marks the fresnel state as changed
  7874. */
  7875. markAsFresnelDirty(): void;
  7876. /**
  7877. * Marks the misc state as changed
  7878. */
  7879. markAsMiscDirty(): void;
  7880. /**
  7881. * Rebuilds the material defines
  7882. */
  7883. rebuild(): void;
  7884. /**
  7885. * Specifies if two material defines are equal
  7886. * @param other - A material define instance to compare to
  7887. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7888. */
  7889. isEqual(other: MaterialDefines): boolean;
  7890. /**
  7891. * Clones this instance's defines to another instance
  7892. * @param other - material defines to clone values to
  7893. */
  7894. cloneTo(other: MaterialDefines): void;
  7895. /**
  7896. * Resets the material define values
  7897. */
  7898. reset(): void;
  7899. /**
  7900. * Converts the material define values to a string
  7901. * @returns - String of material define information
  7902. */
  7903. toString(): string;
  7904. }
  7905. }
  7906. declare module BABYLON {
  7907. /**
  7908. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  7909. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  7910. * These are similar to controls found in many professional imaging or colorist software. The global controls are applied to the entire image. For advanced tuning, extra controls are provided to adjust the shadow, midtone and highlight areas of the image;
  7911. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  7912. */
  7913. export class ColorCurves {
  7914. private _dirty;
  7915. private _tempColor;
  7916. private _globalCurve;
  7917. private _highlightsCurve;
  7918. private _midtonesCurve;
  7919. private _shadowsCurve;
  7920. private _positiveCurve;
  7921. private _negativeCurve;
  7922. private _globalHue;
  7923. private _globalDensity;
  7924. private _globalSaturation;
  7925. private _globalExposure;
  7926. /**
  7927. * Gets the global Hue value.
  7928. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7929. */
  7930. get globalHue(): number;
  7931. /**
  7932. * Sets the global Hue value.
  7933. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7934. */
  7935. set globalHue(value: number);
  7936. /**
  7937. * Gets the global Density value.
  7938. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  7939. * Values less than zero provide a filter of opposite hue.
  7940. */
  7941. get globalDensity(): number;
  7942. /**
  7943. * Sets the global Density value.
  7944. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  7945. * Values less than zero provide a filter of opposite hue.
  7946. */
  7947. set globalDensity(value: number);
  7948. /**
  7949. * Gets the global Saturation value.
  7950. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7951. */
  7952. get globalSaturation(): number;
  7953. /**
  7954. * Sets the global Saturation value.
  7955. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7956. */
  7957. set globalSaturation(value: number);
  7958. /**
  7959. * Gets the global Exposure value.
  7960. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  7961. */
  7962. get globalExposure(): number;
  7963. /**
  7964. * Sets the global Exposure value.
  7965. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  7966. */
  7967. set globalExposure(value: number);
  7968. private _highlightsHue;
  7969. private _highlightsDensity;
  7970. private _highlightsSaturation;
  7971. private _highlightsExposure;
  7972. /**
  7973. * Gets the highlights Hue value.
  7974. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7975. */
  7976. get highlightsHue(): number;
  7977. /**
  7978. * Sets the highlights Hue value.
  7979. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7980. */
  7981. set highlightsHue(value: number);
  7982. /**
  7983. * Gets the highlights Density value.
  7984. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  7985. * Values less than zero provide a filter of opposite hue.
  7986. */
  7987. get highlightsDensity(): number;
  7988. /**
  7989. * Sets the highlights Density value.
  7990. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  7991. * Values less than zero provide a filter of opposite hue.
  7992. */
  7993. set highlightsDensity(value: number);
  7994. /**
  7995. * Gets the highlights Saturation value.
  7996. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7997. */
  7998. get highlightsSaturation(): number;
  7999. /**
  8000. * Sets the highlights Saturation value.
  8001. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8002. */
  8003. set highlightsSaturation(value: number);
  8004. /**
  8005. * Gets the highlights Exposure value.
  8006. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8007. */
  8008. get highlightsExposure(): number;
  8009. /**
  8010. * Sets the highlights Exposure value.
  8011. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8012. */
  8013. set highlightsExposure(value: number);
  8014. private _midtonesHue;
  8015. private _midtonesDensity;
  8016. private _midtonesSaturation;
  8017. private _midtonesExposure;
  8018. /**
  8019. * Gets the midtones Hue value.
  8020. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8021. */
  8022. get midtonesHue(): number;
  8023. /**
  8024. * Sets the midtones Hue value.
  8025. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8026. */
  8027. set midtonesHue(value: number);
  8028. /**
  8029. * Gets the midtones Density value.
  8030. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8031. * Values less than zero provide a filter of opposite hue.
  8032. */
  8033. get midtonesDensity(): number;
  8034. /**
  8035. * Sets the midtones Density value.
  8036. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8037. * Values less than zero provide a filter of opposite hue.
  8038. */
  8039. set midtonesDensity(value: number);
  8040. /**
  8041. * Gets the midtones Saturation value.
  8042. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8043. */
  8044. get midtonesSaturation(): number;
  8045. /**
  8046. * Sets the midtones Saturation value.
  8047. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8048. */
  8049. set midtonesSaturation(value: number);
  8050. /**
  8051. * Gets the midtones Exposure value.
  8052. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8053. */
  8054. get midtonesExposure(): number;
  8055. /**
  8056. * Sets the midtones Exposure value.
  8057. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8058. */
  8059. set midtonesExposure(value: number);
  8060. private _shadowsHue;
  8061. private _shadowsDensity;
  8062. private _shadowsSaturation;
  8063. private _shadowsExposure;
  8064. /**
  8065. * Gets the shadows Hue value.
  8066. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8067. */
  8068. get shadowsHue(): number;
  8069. /**
  8070. * Sets the shadows Hue value.
  8071. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8072. */
  8073. set shadowsHue(value: number);
  8074. /**
  8075. * Gets the shadows Density value.
  8076. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8077. * Values less than zero provide a filter of opposite hue.
  8078. */
  8079. get shadowsDensity(): number;
  8080. /**
  8081. * Sets the shadows Density value.
  8082. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8083. * Values less than zero provide a filter of opposite hue.
  8084. */
  8085. set shadowsDensity(value: number);
  8086. /**
  8087. * Gets the shadows Saturation value.
  8088. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8089. */
  8090. get shadowsSaturation(): number;
  8091. /**
  8092. * Sets the shadows Saturation value.
  8093. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8094. */
  8095. set shadowsSaturation(value: number);
  8096. /**
  8097. * Gets the shadows Exposure value.
  8098. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8099. */
  8100. get shadowsExposure(): number;
  8101. /**
  8102. * Sets the shadows Exposure value.
  8103. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8104. */
  8105. set shadowsExposure(value: number);
  8106. /**
  8107. * Returns the class name
  8108. * @returns The class name
  8109. */
  8110. getClassName(): string;
  8111. /**
  8112. * Binds the color curves to the shader.
  8113. * @param colorCurves The color curve to bind
  8114. * @param effect The effect to bind to
  8115. * @param positiveUniform The positive uniform shader parameter
  8116. * @param neutralUniform The neutral uniform shader parameter
  8117. * @param negativeUniform The negative uniform shader parameter
  8118. */
  8119. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8120. /**
  8121. * Prepare the list of uniforms associated with the ColorCurves effects.
  8122. * @param uniformsList The list of uniforms used in the effect
  8123. */
  8124. static PrepareUniforms(uniformsList: string[]): void;
  8125. /**
  8126. * Returns color grading data based on a hue, density, saturation and exposure value.
  8127. * @param filterHue The hue of the color filter.
  8128. * @param filterDensity The density of the color filter.
  8129. * @param saturation The saturation.
  8130. * @param exposure The exposure.
  8131. * @param result The result data container.
  8132. */
  8133. private getColorGradingDataToRef;
  8134. /**
  8135. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8136. * @param value The input slider value in range [-100,100].
  8137. * @returns Adjusted value.
  8138. */
  8139. private static applyColorGradingSliderNonlinear;
  8140. /**
  8141. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8142. * @param hue The hue (H) input.
  8143. * @param saturation The saturation (S) input.
  8144. * @param brightness The brightness (B) input.
  8145. * @result An RGBA color represented as Vector4.
  8146. */
  8147. private static fromHSBToRef;
  8148. /**
  8149. * Returns a value clamped between min and max
  8150. * @param value The value to clamp
  8151. * @param min The minimum of value
  8152. * @param max The maximum of value
  8153. * @returns The clamped value.
  8154. */
  8155. private static clamp;
  8156. /**
  8157. * Clones the current color curve instance.
  8158. * @return The cloned curves
  8159. */
  8160. clone(): ColorCurves;
  8161. /**
  8162. * Serializes the current color curve instance to a json representation.
  8163. * @return a JSON representation
  8164. */
  8165. serialize(): any;
  8166. /**
  8167. * Parses the color curve from a json representation.
  8168. * @param source the JSON source to parse
  8169. * @return The parsed curves
  8170. */
  8171. static Parse(source: any): ColorCurves;
  8172. }
  8173. }
  8174. declare module BABYLON {
  8175. /**
  8176. * Interface to follow in your material defines to integrate easily the
  8177. * Image proccessing functions.
  8178. * @hidden
  8179. */
  8180. export interface IImageProcessingConfigurationDefines {
  8181. IMAGEPROCESSING: boolean;
  8182. VIGNETTE: boolean;
  8183. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8184. VIGNETTEBLENDMODEOPAQUE: boolean;
  8185. TONEMAPPING: boolean;
  8186. TONEMAPPING_ACES: boolean;
  8187. CONTRAST: boolean;
  8188. EXPOSURE: boolean;
  8189. COLORCURVES: boolean;
  8190. COLORGRADING: boolean;
  8191. COLORGRADING3D: boolean;
  8192. SAMPLER3DGREENDEPTH: boolean;
  8193. SAMPLER3DBGRMAP: boolean;
  8194. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8195. }
  8196. /**
  8197. * @hidden
  8198. */
  8199. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8200. IMAGEPROCESSING: boolean;
  8201. VIGNETTE: boolean;
  8202. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8203. VIGNETTEBLENDMODEOPAQUE: boolean;
  8204. TONEMAPPING: boolean;
  8205. TONEMAPPING_ACES: boolean;
  8206. CONTRAST: boolean;
  8207. COLORCURVES: boolean;
  8208. COLORGRADING: boolean;
  8209. COLORGRADING3D: boolean;
  8210. SAMPLER3DGREENDEPTH: boolean;
  8211. SAMPLER3DBGRMAP: boolean;
  8212. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8213. EXPOSURE: boolean;
  8214. constructor();
  8215. }
  8216. /**
  8217. * This groups together the common properties used for image processing either in direct forward pass
  8218. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8219. * or not.
  8220. */
  8221. export class ImageProcessingConfiguration {
  8222. /**
  8223. * Default tone mapping applied in BabylonJS.
  8224. */
  8225. static readonly TONEMAPPING_STANDARD: number;
  8226. /**
  8227. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8228. * to other engines rendering to increase portability.
  8229. */
  8230. static readonly TONEMAPPING_ACES: number;
  8231. /**
  8232. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8233. */
  8234. colorCurves: Nullable<ColorCurves>;
  8235. private _colorCurvesEnabled;
  8236. /**
  8237. * Gets wether the color curves effect is enabled.
  8238. */
  8239. get colorCurvesEnabled(): boolean;
  8240. /**
  8241. * Sets wether the color curves effect is enabled.
  8242. */
  8243. set colorCurvesEnabled(value: boolean);
  8244. private _colorGradingTexture;
  8245. /**
  8246. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8247. */
  8248. get colorGradingTexture(): Nullable<BaseTexture>;
  8249. /**
  8250. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8251. */
  8252. set colorGradingTexture(value: Nullable<BaseTexture>);
  8253. private _colorGradingEnabled;
  8254. /**
  8255. * Gets wether the color grading effect is enabled.
  8256. */
  8257. get colorGradingEnabled(): boolean;
  8258. /**
  8259. * Sets wether the color grading effect is enabled.
  8260. */
  8261. set colorGradingEnabled(value: boolean);
  8262. private _colorGradingWithGreenDepth;
  8263. /**
  8264. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8265. */
  8266. get colorGradingWithGreenDepth(): boolean;
  8267. /**
  8268. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8269. */
  8270. set colorGradingWithGreenDepth(value: boolean);
  8271. private _colorGradingBGR;
  8272. /**
  8273. * Gets wether the color grading texture contains BGR values.
  8274. */
  8275. get colorGradingBGR(): boolean;
  8276. /**
  8277. * Sets wether the color grading texture contains BGR values.
  8278. */
  8279. set colorGradingBGR(value: boolean);
  8280. /** @hidden */
  8281. _exposure: number;
  8282. /**
  8283. * Gets the Exposure used in the effect.
  8284. */
  8285. get exposure(): number;
  8286. /**
  8287. * Sets the Exposure used in the effect.
  8288. */
  8289. set exposure(value: number);
  8290. private _toneMappingEnabled;
  8291. /**
  8292. * Gets wether the tone mapping effect is enabled.
  8293. */
  8294. get toneMappingEnabled(): boolean;
  8295. /**
  8296. * Sets wether the tone mapping effect is enabled.
  8297. */
  8298. set toneMappingEnabled(value: boolean);
  8299. private _toneMappingType;
  8300. /**
  8301. * Gets the type of tone mapping effect.
  8302. */
  8303. get toneMappingType(): number;
  8304. /**
  8305. * Sets the type of tone mapping effect used in BabylonJS.
  8306. */
  8307. set toneMappingType(value: number);
  8308. protected _contrast: number;
  8309. /**
  8310. * Gets the contrast used in the effect.
  8311. */
  8312. get contrast(): number;
  8313. /**
  8314. * Sets the contrast used in the effect.
  8315. */
  8316. set contrast(value: number);
  8317. /**
  8318. * Vignette stretch size.
  8319. */
  8320. vignetteStretch: number;
  8321. /**
  8322. * Vignette centre X Offset.
  8323. */
  8324. vignetteCentreX: number;
  8325. /**
  8326. * Vignette centre Y Offset.
  8327. */
  8328. vignetteCentreY: number;
  8329. /**
  8330. * Vignette weight or intensity of the vignette effect.
  8331. */
  8332. vignetteWeight: number;
  8333. /**
  8334. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8335. * if vignetteEnabled is set to true.
  8336. */
  8337. vignetteColor: Color4;
  8338. /**
  8339. * Camera field of view used by the Vignette effect.
  8340. */
  8341. vignetteCameraFov: number;
  8342. private _vignetteBlendMode;
  8343. /**
  8344. * Gets the vignette blend mode allowing different kind of effect.
  8345. */
  8346. get vignetteBlendMode(): number;
  8347. /**
  8348. * Sets the vignette blend mode allowing different kind of effect.
  8349. */
  8350. set vignetteBlendMode(value: number);
  8351. private _vignetteEnabled;
  8352. /**
  8353. * Gets wether the vignette effect is enabled.
  8354. */
  8355. get vignetteEnabled(): boolean;
  8356. /**
  8357. * Sets wether the vignette effect is enabled.
  8358. */
  8359. set vignetteEnabled(value: boolean);
  8360. private _applyByPostProcess;
  8361. /**
  8362. * Gets wether the image processing is applied through a post process or not.
  8363. */
  8364. get applyByPostProcess(): boolean;
  8365. /**
  8366. * Sets wether the image processing is applied through a post process or not.
  8367. */
  8368. set applyByPostProcess(value: boolean);
  8369. private _isEnabled;
  8370. /**
  8371. * Gets wether the image processing is enabled or not.
  8372. */
  8373. get isEnabled(): boolean;
  8374. /**
  8375. * Sets wether the image processing is enabled or not.
  8376. */
  8377. set isEnabled(value: boolean);
  8378. /**
  8379. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8380. */
  8381. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8382. /**
  8383. * Method called each time the image processing information changes requires to recompile the effect.
  8384. */
  8385. protected _updateParameters(): void;
  8386. /**
  8387. * Gets the current class name.
  8388. * @return "ImageProcessingConfiguration"
  8389. */
  8390. getClassName(): string;
  8391. /**
  8392. * Prepare the list of uniforms associated with the Image Processing effects.
  8393. * @param uniforms The list of uniforms used in the effect
  8394. * @param defines the list of defines currently in use
  8395. */
  8396. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8397. /**
  8398. * Prepare the list of samplers associated with the Image Processing effects.
  8399. * @param samplersList The list of uniforms used in the effect
  8400. * @param defines the list of defines currently in use
  8401. */
  8402. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8403. /**
  8404. * Prepare the list of defines associated to the shader.
  8405. * @param defines the list of defines to complete
  8406. * @param forPostProcess Define if we are currently in post process mode or not
  8407. */
  8408. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8409. /**
  8410. * Returns true if all the image processing information are ready.
  8411. * @returns True if ready, otherwise, false
  8412. */
  8413. isReady(): boolean;
  8414. /**
  8415. * Binds the image processing to the shader.
  8416. * @param effect The effect to bind to
  8417. * @param overrideAspectRatio Override the aspect ratio of the effect
  8418. */
  8419. bind(effect: Effect, overrideAspectRatio?: number): void;
  8420. /**
  8421. * Clones the current image processing instance.
  8422. * @return The cloned image processing
  8423. */
  8424. clone(): ImageProcessingConfiguration;
  8425. /**
  8426. * Serializes the current image processing instance to a json representation.
  8427. * @return a JSON representation
  8428. */
  8429. serialize(): any;
  8430. /**
  8431. * Parses the image processing from a json representation.
  8432. * @param source the JSON source to parse
  8433. * @return The parsed image processing
  8434. */
  8435. static Parse(source: any): ImageProcessingConfiguration;
  8436. private static _VIGNETTEMODE_MULTIPLY;
  8437. private static _VIGNETTEMODE_OPAQUE;
  8438. /**
  8439. * Used to apply the vignette as a mix with the pixel color.
  8440. */
  8441. static get VIGNETTEMODE_MULTIPLY(): number;
  8442. /**
  8443. * Used to apply the vignette as a replacement of the pixel color.
  8444. */
  8445. static get VIGNETTEMODE_OPAQUE(): number;
  8446. }
  8447. }
  8448. declare module BABYLON {
  8449. /** @hidden */
  8450. export var postprocessVertexShader: {
  8451. name: string;
  8452. shader: string;
  8453. };
  8454. }
  8455. declare module BABYLON {
  8456. interface ThinEngine {
  8457. /**
  8458. * Creates a new render target texture
  8459. * @param size defines the size of the texture
  8460. * @param options defines the options used to create the texture
  8461. * @returns a new render target texture stored in an InternalTexture
  8462. */
  8463. createRenderTargetTexture(size: number | {
  8464. width: number;
  8465. height: number;
  8466. layers?: number;
  8467. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8468. /**
  8469. * Creates a depth stencil texture.
  8470. * This is only available in WebGL 2 or with the depth texture extension available.
  8471. * @param size The size of face edge in the texture.
  8472. * @param options The options defining the texture.
  8473. * @returns The texture
  8474. */
  8475. createDepthStencilTexture(size: number | {
  8476. width: number;
  8477. height: number;
  8478. layers?: number;
  8479. }, options: DepthTextureCreationOptions): InternalTexture;
  8480. /** @hidden */
  8481. _createDepthStencilTexture(size: number | {
  8482. width: number;
  8483. height: number;
  8484. layers?: number;
  8485. }, options: DepthTextureCreationOptions): InternalTexture;
  8486. }
  8487. }
  8488. declare module BABYLON {
  8489. /** Defines supported spaces */
  8490. export enum Space {
  8491. /** Local (object) space */
  8492. LOCAL = 0,
  8493. /** World space */
  8494. WORLD = 1,
  8495. /** Bone space */
  8496. BONE = 2
  8497. }
  8498. /** Defines the 3 main axes */
  8499. export class Axis {
  8500. /** X axis */
  8501. static X: Vector3;
  8502. /** Y axis */
  8503. static Y: Vector3;
  8504. /** Z axis */
  8505. static Z: Vector3;
  8506. }
  8507. }
  8508. declare module BABYLON {
  8509. /**
  8510. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8511. * This is the base of the follow, arc rotate cameras and Free camera
  8512. * @see http://doc.babylonjs.com/features/cameras
  8513. */
  8514. export class TargetCamera extends Camera {
  8515. private static _RigCamTransformMatrix;
  8516. private static _TargetTransformMatrix;
  8517. private static _TargetFocalPoint;
  8518. /**
  8519. * Define the current direction the camera is moving to
  8520. */
  8521. cameraDirection: Vector3;
  8522. /**
  8523. * Define the current rotation the camera is rotating to
  8524. */
  8525. cameraRotation: Vector2;
  8526. /**
  8527. * When set, the up vector of the camera will be updated by the rotation of the camera
  8528. */
  8529. updateUpVectorFromRotation: boolean;
  8530. private _tmpQuaternion;
  8531. /**
  8532. * Define the current rotation of the camera
  8533. */
  8534. rotation: Vector3;
  8535. /**
  8536. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8537. */
  8538. rotationQuaternion: Quaternion;
  8539. /**
  8540. * Define the current speed of the camera
  8541. */
  8542. speed: number;
  8543. /**
  8544. * Add constraint to the camera to prevent it to move freely in all directions and
  8545. * around all axis.
  8546. */
  8547. noRotationConstraint: boolean;
  8548. /**
  8549. * Define the current target of the camera as an object or a position.
  8550. */
  8551. lockedTarget: any;
  8552. /** @hidden */
  8553. _currentTarget: Vector3;
  8554. /** @hidden */
  8555. _initialFocalDistance: number;
  8556. /** @hidden */
  8557. _viewMatrix: Matrix;
  8558. /** @hidden */
  8559. _camMatrix: Matrix;
  8560. /** @hidden */
  8561. _cameraTransformMatrix: Matrix;
  8562. /** @hidden */
  8563. _cameraRotationMatrix: Matrix;
  8564. /** @hidden */
  8565. _referencePoint: Vector3;
  8566. /** @hidden */
  8567. _transformedReferencePoint: Vector3;
  8568. protected _globalCurrentTarget: Vector3;
  8569. protected _globalCurrentUpVector: Vector3;
  8570. /** @hidden */
  8571. _reset: () => void;
  8572. private _defaultUp;
  8573. /**
  8574. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  8575. * This is the base of the follow, arc rotate cameras and Free camera
  8576. * @see http://doc.babylonjs.com/features/cameras
  8577. * @param name Defines the name of the camera in the scene
  8578. * @param position Defines the start position of the camera in the scene
  8579. * @param scene Defines the scene the camera belongs to
  8580. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8581. */
  8582. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8583. /**
  8584. * Gets the position in front of the camera at a given distance.
  8585. * @param distance The distance from the camera we want the position to be
  8586. * @returns the position
  8587. */
  8588. getFrontPosition(distance: number): Vector3;
  8589. /** @hidden */
  8590. _getLockedTargetPosition(): Nullable<Vector3>;
  8591. private _storedPosition;
  8592. private _storedRotation;
  8593. private _storedRotationQuaternion;
  8594. /**
  8595. * Store current camera state of the camera (fov, position, rotation, etc..)
  8596. * @returns the camera
  8597. */
  8598. storeState(): Camera;
  8599. /**
  8600. * Restored camera state. You must call storeState() first
  8601. * @returns whether it was successful or not
  8602. * @hidden
  8603. */
  8604. _restoreStateValues(): boolean;
  8605. /** @hidden */
  8606. _initCache(): void;
  8607. /** @hidden */
  8608. _updateCache(ignoreParentClass?: boolean): void;
  8609. /** @hidden */
  8610. _isSynchronizedViewMatrix(): boolean;
  8611. /** @hidden */
  8612. _computeLocalCameraSpeed(): number;
  8613. /**
  8614. * Defines the target the camera should look at.
  8615. * @param target Defines the new target as a Vector or a mesh
  8616. */
  8617. setTarget(target: Vector3): void;
  8618. /**
  8619. * Return the current target position of the camera. This value is expressed in local space.
  8620. * @returns the target position
  8621. */
  8622. getTarget(): Vector3;
  8623. /** @hidden */
  8624. _decideIfNeedsToMove(): boolean;
  8625. /** @hidden */
  8626. _updatePosition(): void;
  8627. /** @hidden */
  8628. _checkInputs(): void;
  8629. protected _updateCameraRotationMatrix(): void;
  8630. /**
  8631. * Update the up vector to apply the rotation of the camera (So if you changed the camera rotation.z this will let you update the up vector as well)
  8632. * @returns the current camera
  8633. */
  8634. private _rotateUpVectorWithCameraRotationMatrix;
  8635. private _cachedRotationZ;
  8636. private _cachedQuaternionRotationZ;
  8637. /** @hidden */
  8638. _getViewMatrix(): Matrix;
  8639. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8640. /**
  8641. * @hidden
  8642. */
  8643. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8644. /**
  8645. * @hidden
  8646. */
  8647. _updateRigCameras(): void;
  8648. private _getRigCamPositionAndTarget;
  8649. /**
  8650. * Gets the current object class name.
  8651. * @return the class name
  8652. */
  8653. getClassName(): string;
  8654. }
  8655. }
  8656. declare module BABYLON {
  8657. /**
  8658. * Gather the list of keyboard event types as constants.
  8659. */
  8660. export class KeyboardEventTypes {
  8661. /**
  8662. * The keydown event is fired when a key becomes active (pressed).
  8663. */
  8664. static readonly KEYDOWN: number;
  8665. /**
  8666. * The keyup event is fired when a key has been released.
  8667. */
  8668. static readonly KEYUP: number;
  8669. }
  8670. /**
  8671. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8672. */
  8673. export class KeyboardInfo {
  8674. /**
  8675. * Defines the type of event (KeyboardEventTypes)
  8676. */
  8677. type: number;
  8678. /**
  8679. * Defines the related dom event
  8680. */
  8681. event: KeyboardEvent;
  8682. /**
  8683. * Instantiates a new keyboard info.
  8684. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8685. * @param type Defines the type of event (KeyboardEventTypes)
  8686. * @param event Defines the related dom event
  8687. */
  8688. constructor(
  8689. /**
  8690. * Defines the type of event (KeyboardEventTypes)
  8691. */
  8692. type: number,
  8693. /**
  8694. * Defines the related dom event
  8695. */
  8696. event: KeyboardEvent);
  8697. }
  8698. /**
  8699. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8700. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8701. */
  8702. export class KeyboardInfoPre extends KeyboardInfo {
  8703. /**
  8704. * Defines the type of event (KeyboardEventTypes)
  8705. */
  8706. type: number;
  8707. /**
  8708. * Defines the related dom event
  8709. */
  8710. event: KeyboardEvent;
  8711. /**
  8712. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8713. */
  8714. skipOnPointerObservable: boolean;
  8715. /**
  8716. * Instantiates a new keyboard pre info.
  8717. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8718. * @param type Defines the type of event (KeyboardEventTypes)
  8719. * @param event Defines the related dom event
  8720. */
  8721. constructor(
  8722. /**
  8723. * Defines the type of event (KeyboardEventTypes)
  8724. */
  8725. type: number,
  8726. /**
  8727. * Defines the related dom event
  8728. */
  8729. event: KeyboardEvent);
  8730. }
  8731. }
  8732. declare module BABYLON {
  8733. /**
  8734. * Manage the keyboard inputs to control the movement of a free camera.
  8735. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8736. */
  8737. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8738. /**
  8739. * Defines the camera the input is attached to.
  8740. */
  8741. camera: FreeCamera;
  8742. /**
  8743. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8744. */
  8745. keysUp: number[];
  8746. /**
  8747. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8748. */
  8749. keysDown: number[];
  8750. /**
  8751. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8752. */
  8753. keysLeft: number[];
  8754. /**
  8755. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8756. */
  8757. keysRight: number[];
  8758. private _keys;
  8759. private _onCanvasBlurObserver;
  8760. private _onKeyboardObserver;
  8761. private _engine;
  8762. private _scene;
  8763. /**
  8764. * Attach the input controls to a specific dom element to get the input from.
  8765. * @param element Defines the element the controls should be listened from
  8766. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8767. */
  8768. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8769. /**
  8770. * Detach the current controls from the specified dom element.
  8771. * @param element Defines the element to stop listening the inputs from
  8772. */
  8773. detachControl(element: Nullable<HTMLElement>): void;
  8774. /**
  8775. * Update the current camera state depending on the inputs that have been used this frame.
  8776. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8777. */
  8778. checkInputs(): void;
  8779. /**
  8780. * Gets the class name of the current intput.
  8781. * @returns the class name
  8782. */
  8783. getClassName(): string;
  8784. /** @hidden */
  8785. _onLostFocus(): void;
  8786. /**
  8787. * Get the friendly name associated with the input class.
  8788. * @returns the input friendly name
  8789. */
  8790. getSimpleName(): string;
  8791. }
  8792. }
  8793. declare module BABYLON {
  8794. /**
  8795. * Interface describing all the common properties and methods a shadow light needs to implement.
  8796. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8797. * as well as binding the different shadow properties to the effects.
  8798. */
  8799. export interface IShadowLight extends Light {
  8800. /**
  8801. * The light id in the scene (used in scene.findLighById for instance)
  8802. */
  8803. id: string;
  8804. /**
  8805. * The position the shdow will be casted from.
  8806. */
  8807. position: Vector3;
  8808. /**
  8809. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8810. */
  8811. direction: Vector3;
  8812. /**
  8813. * The transformed position. Position of the light in world space taking parenting in account.
  8814. */
  8815. transformedPosition: Vector3;
  8816. /**
  8817. * The transformed direction. Direction of the light in world space taking parenting in account.
  8818. */
  8819. transformedDirection: Vector3;
  8820. /**
  8821. * The friendly name of the light in the scene.
  8822. */
  8823. name: string;
  8824. /**
  8825. * Defines the shadow projection clipping minimum z value.
  8826. */
  8827. shadowMinZ: number;
  8828. /**
  8829. * Defines the shadow projection clipping maximum z value.
  8830. */
  8831. shadowMaxZ: number;
  8832. /**
  8833. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8834. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8835. */
  8836. computeTransformedInformation(): boolean;
  8837. /**
  8838. * Gets the scene the light belongs to.
  8839. * @returns The scene
  8840. */
  8841. getScene(): Scene;
  8842. /**
  8843. * Callback defining a custom Projection Matrix Builder.
  8844. * This can be used to override the default projection matrix computation.
  8845. */
  8846. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8847. /**
  8848. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8849. * @param matrix The materix to updated with the projection information
  8850. * @param viewMatrix The transform matrix of the light
  8851. * @param renderList The list of mesh to render in the map
  8852. * @returns The current light
  8853. */
  8854. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8855. /**
  8856. * Gets the current depth scale used in ESM.
  8857. * @returns The scale
  8858. */
  8859. getDepthScale(): number;
  8860. /**
  8861. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8862. * @returns true if a cube texture needs to be use
  8863. */
  8864. needCube(): boolean;
  8865. /**
  8866. * Detects if the projection matrix requires to be recomputed this frame.
  8867. * @returns true if it requires to be recomputed otherwise, false.
  8868. */
  8869. needProjectionMatrixCompute(): boolean;
  8870. /**
  8871. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8872. */
  8873. forceProjectionMatrixCompute(): void;
  8874. /**
  8875. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8876. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8877. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8878. */
  8879. getShadowDirection(faceIndex?: number): Vector3;
  8880. /**
  8881. * Gets the minZ used for shadow according to both the scene and the light.
  8882. * @param activeCamera The camera we are returning the min for
  8883. * @returns the depth min z
  8884. */
  8885. getDepthMinZ(activeCamera: Camera): number;
  8886. /**
  8887. * Gets the maxZ used for shadow according to both the scene and the light.
  8888. * @param activeCamera The camera we are returning the max for
  8889. * @returns the depth max z
  8890. */
  8891. getDepthMaxZ(activeCamera: Camera): number;
  8892. }
  8893. /**
  8894. * Base implementation IShadowLight
  8895. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8896. */
  8897. export abstract class ShadowLight extends Light implements IShadowLight {
  8898. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8899. protected _position: Vector3;
  8900. protected _setPosition(value: Vector3): void;
  8901. /**
  8902. * Sets the position the shadow will be casted from. Also use as the light position for both
  8903. * point and spot lights.
  8904. */
  8905. get position(): Vector3;
  8906. /**
  8907. * Sets the position the shadow will be casted from. Also use as the light position for both
  8908. * point and spot lights.
  8909. */
  8910. set position(value: Vector3);
  8911. protected _direction: Vector3;
  8912. protected _setDirection(value: Vector3): void;
  8913. /**
  8914. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8915. * Also use as the light direction on spot and directional lights.
  8916. */
  8917. get direction(): Vector3;
  8918. /**
  8919. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8920. * Also use as the light direction on spot and directional lights.
  8921. */
  8922. set direction(value: Vector3);
  8923. protected _shadowMinZ: number;
  8924. /**
  8925. * Gets the shadow projection clipping minimum z value.
  8926. */
  8927. get shadowMinZ(): number;
  8928. /**
  8929. * Sets the shadow projection clipping minimum z value.
  8930. */
  8931. set shadowMinZ(value: number);
  8932. protected _shadowMaxZ: number;
  8933. /**
  8934. * Sets the shadow projection clipping maximum z value.
  8935. */
  8936. get shadowMaxZ(): number;
  8937. /**
  8938. * Gets the shadow projection clipping maximum z value.
  8939. */
  8940. set shadowMaxZ(value: number);
  8941. /**
  8942. * Callback defining a custom Projection Matrix Builder.
  8943. * This can be used to override the default projection matrix computation.
  8944. */
  8945. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8946. /**
  8947. * The transformed position. Position of the light in world space taking parenting in account.
  8948. */
  8949. transformedPosition: Vector3;
  8950. /**
  8951. * The transformed direction. Direction of the light in world space taking parenting in account.
  8952. */
  8953. transformedDirection: Vector3;
  8954. private _needProjectionMatrixCompute;
  8955. /**
  8956. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8957. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8958. */
  8959. computeTransformedInformation(): boolean;
  8960. /**
  8961. * Return the depth scale used for the shadow map.
  8962. * @returns the depth scale.
  8963. */
  8964. getDepthScale(): number;
  8965. /**
  8966. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8967. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8968. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8969. */
  8970. getShadowDirection(faceIndex?: number): Vector3;
  8971. /**
  8972. * Returns the ShadowLight absolute position in the World.
  8973. * @returns the position vector in world space
  8974. */
  8975. getAbsolutePosition(): Vector3;
  8976. /**
  8977. * Sets the ShadowLight direction toward the passed target.
  8978. * @param target The point to target in local space
  8979. * @returns the updated ShadowLight direction
  8980. */
  8981. setDirectionToTarget(target: Vector3): Vector3;
  8982. /**
  8983. * Returns the light rotation in euler definition.
  8984. * @returns the x y z rotation in local space.
  8985. */
  8986. getRotation(): Vector3;
  8987. /**
  8988. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8989. * @returns true if a cube texture needs to be use
  8990. */
  8991. needCube(): boolean;
  8992. /**
  8993. * Detects if the projection matrix requires to be recomputed this frame.
  8994. * @returns true if it requires to be recomputed otherwise, false.
  8995. */
  8996. needProjectionMatrixCompute(): boolean;
  8997. /**
  8998. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8999. */
  9000. forceProjectionMatrixCompute(): void;
  9001. /** @hidden */
  9002. _initCache(): void;
  9003. /** @hidden */
  9004. _isSynchronized(): boolean;
  9005. /**
  9006. * Computes the world matrix of the node
  9007. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9008. * @returns the world matrix
  9009. */
  9010. computeWorldMatrix(force?: boolean): Matrix;
  9011. /**
  9012. * Gets the minZ used for shadow according to both the scene and the light.
  9013. * @param activeCamera The camera we are returning the min for
  9014. * @returns the depth min z
  9015. */
  9016. getDepthMinZ(activeCamera: Camera): number;
  9017. /**
  9018. * Gets the maxZ used for shadow according to both the scene and the light.
  9019. * @param activeCamera The camera we are returning the max for
  9020. * @returns the depth max z
  9021. */
  9022. getDepthMaxZ(activeCamera: Camera): number;
  9023. /**
  9024. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9025. * @param matrix The materix to updated with the projection information
  9026. * @param viewMatrix The transform matrix of the light
  9027. * @param renderList The list of mesh to render in the map
  9028. * @returns The current light
  9029. */
  9030. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9031. }
  9032. }
  9033. declare module BABYLON {
  9034. /**
  9035. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  9036. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  9037. */
  9038. export class EffectFallbacks implements IEffectFallbacks {
  9039. private _defines;
  9040. private _currentRank;
  9041. private _maxRank;
  9042. private _mesh;
  9043. /**
  9044. * Removes the fallback from the bound mesh.
  9045. */
  9046. unBindMesh(): void;
  9047. /**
  9048. * Adds a fallback on the specified property.
  9049. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9050. * @param define The name of the define in the shader
  9051. */
  9052. addFallback(rank: number, define: string): void;
  9053. /**
  9054. * Sets the mesh to use CPU skinning when needing to fallback.
  9055. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9056. * @param mesh The mesh to use the fallbacks.
  9057. */
  9058. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  9059. /**
  9060. * Checks to see if more fallbacks are still availible.
  9061. */
  9062. get hasMoreFallbacks(): boolean;
  9063. /**
  9064. * Removes the defines that should be removed when falling back.
  9065. * @param currentDefines defines the current define statements for the shader.
  9066. * @param effect defines the current effect we try to compile
  9067. * @returns The resulting defines with defines of the current rank removed.
  9068. */
  9069. reduce(currentDefines: string, effect: Effect): string;
  9070. }
  9071. }
  9072. declare module BABYLON {
  9073. /**
  9074. * "Static Class" containing the most commonly used helper while dealing with material for
  9075. * rendering purpose.
  9076. *
  9077. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  9078. *
  9079. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  9080. */
  9081. export class MaterialHelper {
  9082. /**
  9083. * Bind the current view position to an effect.
  9084. * @param effect The effect to be bound
  9085. * @param scene The scene the eyes position is used from
  9086. */
  9087. static BindEyePosition(effect: Effect, scene: Scene): void;
  9088. /**
  9089. * Helps preparing the defines values about the UVs in used in the effect.
  9090. * UVs are shared as much as we can accross channels in the shaders.
  9091. * @param texture The texture we are preparing the UVs for
  9092. * @param defines The defines to update
  9093. * @param key The channel key "diffuse", "specular"... used in the shader
  9094. */
  9095. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  9096. /**
  9097. * Binds a texture matrix value to its corrsponding uniform
  9098. * @param texture The texture to bind the matrix for
  9099. * @param uniformBuffer The uniform buffer receivin the data
  9100. * @param key The channel key "diffuse", "specular"... used in the shader
  9101. */
  9102. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9103. /**
  9104. * Gets the current status of the fog (should it be enabled?)
  9105. * @param mesh defines the mesh to evaluate for fog support
  9106. * @param scene defines the hosting scene
  9107. * @returns true if fog must be enabled
  9108. */
  9109. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  9110. /**
  9111. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9112. * @param mesh defines the current mesh
  9113. * @param scene defines the current scene
  9114. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9115. * @param pointsCloud defines if point cloud rendering has to be turned on
  9116. * @param fogEnabled defines if fog has to be turned on
  9117. * @param alphaTest defines if alpha testing has to be turned on
  9118. * @param defines defines the current list of defines
  9119. */
  9120. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9121. /**
  9122. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9123. * @param scene defines the current scene
  9124. * @param engine defines the current engine
  9125. * @param defines specifies the list of active defines
  9126. * @param useInstances defines if instances have to be turned on
  9127. * @param useClipPlane defines if clip plane have to be turned on
  9128. */
  9129. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9130. /**
  9131. * Prepares the defines for bones
  9132. * @param mesh The mesh containing the geometry data we will draw
  9133. * @param defines The defines to update
  9134. */
  9135. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  9136. /**
  9137. * Prepares the defines for morph targets
  9138. * @param mesh The mesh containing the geometry data we will draw
  9139. * @param defines The defines to update
  9140. */
  9141. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  9142. /**
  9143. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9144. * @param mesh The mesh containing the geometry data we will draw
  9145. * @param defines The defines to update
  9146. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9147. * @param useBones Precise whether bones should be used or not (override mesh info)
  9148. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9149. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9150. * @returns false if defines are considered not dirty and have not been checked
  9151. */
  9152. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9153. /**
  9154. * Prepares the defines related to multiview
  9155. * @param scene The scene we are intending to draw
  9156. * @param defines The defines to update
  9157. */
  9158. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  9159. /**
  9160. * Prepares the defines related to the light information passed in parameter
  9161. * @param scene The scene we are intending to draw
  9162. * @param mesh The mesh the effect is compiling for
  9163. * @param light The light the effect is compiling for
  9164. * @param lightIndex The index of the light
  9165. * @param defines The defines to update
  9166. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9167. * @param state Defines the current state regarding what is needed (normals, etc...)
  9168. */
  9169. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  9170. needNormals: boolean;
  9171. needRebuild: boolean;
  9172. shadowEnabled: boolean;
  9173. specularEnabled: boolean;
  9174. lightmapMode: boolean;
  9175. }): void;
  9176. /**
  9177. * Prepares the defines related to the light information passed in parameter
  9178. * @param scene The scene we are intending to draw
  9179. * @param mesh The mesh the effect is compiling for
  9180. * @param defines The defines to update
  9181. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9182. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9183. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9184. * @returns true if normals will be required for the rest of the effect
  9185. */
  9186. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9187. /**
  9188. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  9189. * @param lightIndex defines the light index
  9190. * @param uniformsList The uniform list
  9191. * @param samplersList The sampler list
  9192. * @param projectedLightTexture defines if projected texture must be used
  9193. * @param uniformBuffersList defines an optional list of uniform buffers
  9194. */
  9195. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  9196. /**
  9197. * Prepares the uniforms and samplers list to be used in the effect
  9198. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9199. * @param samplersList The sampler list
  9200. * @param defines The defines helping in the list generation
  9201. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9202. */
  9203. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9204. /**
  9205. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9206. * @param defines The defines to update while falling back
  9207. * @param fallbacks The authorized effect fallbacks
  9208. * @param maxSimultaneousLights The maximum number of lights allowed
  9209. * @param rank the current rank of the Effect
  9210. * @returns The newly affected rank
  9211. */
  9212. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9213. private static _TmpMorphInfluencers;
  9214. /**
  9215. * Prepares the list of attributes required for morph targets according to the effect defines.
  9216. * @param attribs The current list of supported attribs
  9217. * @param mesh The mesh to prepare the morph targets attributes for
  9218. * @param influencers The number of influencers
  9219. */
  9220. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  9221. /**
  9222. * Prepares the list of attributes required for morph targets according to the effect defines.
  9223. * @param attribs The current list of supported attribs
  9224. * @param mesh The mesh to prepare the morph targets attributes for
  9225. * @param defines The current Defines of the effect
  9226. */
  9227. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9228. /**
  9229. * Prepares the list of attributes required for bones according to the effect defines.
  9230. * @param attribs The current list of supported attribs
  9231. * @param mesh The mesh to prepare the bones attributes for
  9232. * @param defines The current Defines of the effect
  9233. * @param fallbacks The current efffect fallback strategy
  9234. */
  9235. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9236. /**
  9237. * Check and prepare the list of attributes required for instances according to the effect defines.
  9238. * @param attribs The current list of supported attribs
  9239. * @param defines The current MaterialDefines of the effect
  9240. */
  9241. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  9242. /**
  9243. * Add the list of attributes required for instances to the attribs array.
  9244. * @param attribs The current list of supported attribs
  9245. */
  9246. static PushAttributesForInstances(attribs: string[]): void;
  9247. /**
  9248. * Binds the light information to the effect.
  9249. * @param light The light containing the generator
  9250. * @param effect The effect we are binding the data to
  9251. * @param lightIndex The light index in the effect used to render
  9252. */
  9253. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9254. /**
  9255. * Binds the lights information from the scene to the effect for the given mesh.
  9256. * @param light Light to bind
  9257. * @param lightIndex Light index
  9258. * @param scene The scene where the light belongs to
  9259. * @param effect The effect we are binding the data to
  9260. * @param useSpecular Defines if specular is supported
  9261. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9262. */
  9263. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  9264. /**
  9265. * Binds the lights information from the scene to the effect for the given mesh.
  9266. * @param scene The scene the lights belongs to
  9267. * @param mesh The mesh we are binding the information to render
  9268. * @param effect The effect we are binding the data to
  9269. * @param defines The generated defines for the effect
  9270. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9271. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9272. */
  9273. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  9274. private static _tempFogColor;
  9275. /**
  9276. * Binds the fog information from the scene to the effect for the given mesh.
  9277. * @param scene The scene the lights belongs to
  9278. * @param mesh The mesh we are binding the information to render
  9279. * @param effect The effect we are binding the data to
  9280. * @param linearSpace Defines if the fog effect is applied in linear space
  9281. */
  9282. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9283. /**
  9284. * Binds the bones information from the mesh to the effect.
  9285. * @param mesh The mesh we are binding the information to render
  9286. * @param effect The effect we are binding the data to
  9287. */
  9288. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9289. /**
  9290. * Binds the morph targets information from the mesh to the effect.
  9291. * @param abstractMesh The mesh we are binding the information to render
  9292. * @param effect The effect we are binding the data to
  9293. */
  9294. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9295. /**
  9296. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9297. * @param defines The generated defines used in the effect
  9298. * @param effect The effect we are binding the data to
  9299. * @param scene The scene we are willing to render with logarithmic scale for
  9300. */
  9301. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9302. /**
  9303. * Binds the clip plane information from the scene to the effect.
  9304. * @param scene The scene the clip plane information are extracted from
  9305. * @param effect The effect we are binding the data to
  9306. */
  9307. static BindClipPlane(effect: Effect, scene: Scene): void;
  9308. }
  9309. }
  9310. declare module BABYLON {
  9311. /** @hidden */
  9312. export var packingFunctions: {
  9313. name: string;
  9314. shader: string;
  9315. };
  9316. }
  9317. declare module BABYLON {
  9318. /** @hidden */
  9319. export var clipPlaneFragmentDeclaration: {
  9320. name: string;
  9321. shader: string;
  9322. };
  9323. }
  9324. declare module BABYLON {
  9325. /** @hidden */
  9326. export var clipPlaneFragment: {
  9327. name: string;
  9328. shader: string;
  9329. };
  9330. }
  9331. declare module BABYLON {
  9332. /** @hidden */
  9333. export var shadowMapPixelShader: {
  9334. name: string;
  9335. shader: string;
  9336. };
  9337. }
  9338. declare module BABYLON {
  9339. /** @hidden */
  9340. export var bonesDeclaration: {
  9341. name: string;
  9342. shader: string;
  9343. };
  9344. }
  9345. declare module BABYLON {
  9346. /** @hidden */
  9347. export var morphTargetsVertexGlobalDeclaration: {
  9348. name: string;
  9349. shader: string;
  9350. };
  9351. }
  9352. declare module BABYLON {
  9353. /** @hidden */
  9354. export var morphTargetsVertexDeclaration: {
  9355. name: string;
  9356. shader: string;
  9357. };
  9358. }
  9359. declare module BABYLON {
  9360. /** @hidden */
  9361. export var instancesDeclaration: {
  9362. name: string;
  9363. shader: string;
  9364. };
  9365. }
  9366. declare module BABYLON {
  9367. /** @hidden */
  9368. export var helperFunctions: {
  9369. name: string;
  9370. shader: string;
  9371. };
  9372. }
  9373. declare module BABYLON {
  9374. /** @hidden */
  9375. export var clipPlaneVertexDeclaration: {
  9376. name: string;
  9377. shader: string;
  9378. };
  9379. }
  9380. declare module BABYLON {
  9381. /** @hidden */
  9382. export var morphTargetsVertex: {
  9383. name: string;
  9384. shader: string;
  9385. };
  9386. }
  9387. declare module BABYLON {
  9388. /** @hidden */
  9389. export var instancesVertex: {
  9390. name: string;
  9391. shader: string;
  9392. };
  9393. }
  9394. declare module BABYLON {
  9395. /** @hidden */
  9396. export var bonesVertex: {
  9397. name: string;
  9398. shader: string;
  9399. };
  9400. }
  9401. declare module BABYLON {
  9402. /** @hidden */
  9403. export var clipPlaneVertex: {
  9404. name: string;
  9405. shader: string;
  9406. };
  9407. }
  9408. declare module BABYLON {
  9409. /** @hidden */
  9410. export var shadowMapVertexShader: {
  9411. name: string;
  9412. shader: string;
  9413. };
  9414. }
  9415. declare module BABYLON {
  9416. /** @hidden */
  9417. export var depthBoxBlurPixelShader: {
  9418. name: string;
  9419. shader: string;
  9420. };
  9421. }
  9422. declare module BABYLON {
  9423. /**
  9424. * Class representing a ray with position and direction
  9425. */
  9426. export class Ray {
  9427. /** origin point */
  9428. origin: Vector3;
  9429. /** direction */
  9430. direction: Vector3;
  9431. /** length of the ray */
  9432. length: number;
  9433. private static readonly TmpVector3;
  9434. private _tmpRay;
  9435. /**
  9436. * Creates a new ray
  9437. * @param origin origin point
  9438. * @param direction direction
  9439. * @param length length of the ray
  9440. */
  9441. constructor(
  9442. /** origin point */
  9443. origin: Vector3,
  9444. /** direction */
  9445. direction: Vector3,
  9446. /** length of the ray */
  9447. length?: number);
  9448. /**
  9449. * Checks if the ray intersects a box
  9450. * @param minimum bound of the box
  9451. * @param maximum bound of the box
  9452. * @param intersectionTreshold extra extend to be added to the box in all direction
  9453. * @returns if the box was hit
  9454. */
  9455. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  9456. /**
  9457. * Checks if the ray intersects a box
  9458. * @param box the bounding box to check
  9459. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  9460. * @returns if the box was hit
  9461. */
  9462. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  9463. /**
  9464. * If the ray hits a sphere
  9465. * @param sphere the bounding sphere to check
  9466. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  9467. * @returns true if it hits the sphere
  9468. */
  9469. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  9470. /**
  9471. * If the ray hits a triange
  9472. * @param vertex0 triangle vertex
  9473. * @param vertex1 triangle vertex
  9474. * @param vertex2 triangle vertex
  9475. * @returns intersection information if hit
  9476. */
  9477. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  9478. /**
  9479. * Checks if ray intersects a plane
  9480. * @param plane the plane to check
  9481. * @returns the distance away it was hit
  9482. */
  9483. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  9484. /**
  9485. * Calculate the intercept of a ray on a given axis
  9486. * @param axis to check 'x' | 'y' | 'z'
  9487. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  9488. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  9489. */
  9490. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  9491. /**
  9492. * Checks if ray intersects a mesh
  9493. * @param mesh the mesh to check
  9494. * @param fastCheck if only the bounding box should checked
  9495. * @returns picking info of the intersecton
  9496. */
  9497. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  9498. /**
  9499. * Checks if ray intersects a mesh
  9500. * @param meshes the meshes to check
  9501. * @param fastCheck if only the bounding box should checked
  9502. * @param results array to store result in
  9503. * @returns Array of picking infos
  9504. */
  9505. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  9506. private _comparePickingInfo;
  9507. private static smallnum;
  9508. private static rayl;
  9509. /**
  9510. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  9511. * @param sega the first point of the segment to test the intersection against
  9512. * @param segb the second point of the segment to test the intersection against
  9513. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  9514. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  9515. */
  9516. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  9517. /**
  9518. * Update the ray from viewport position
  9519. * @param x position
  9520. * @param y y position
  9521. * @param viewportWidth viewport width
  9522. * @param viewportHeight viewport height
  9523. * @param world world matrix
  9524. * @param view view matrix
  9525. * @param projection projection matrix
  9526. * @returns this ray updated
  9527. */
  9528. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  9529. /**
  9530. * Creates a ray with origin and direction of 0,0,0
  9531. * @returns the new ray
  9532. */
  9533. static Zero(): Ray;
  9534. /**
  9535. * Creates a new ray from screen space and viewport
  9536. * @param x position
  9537. * @param y y position
  9538. * @param viewportWidth viewport width
  9539. * @param viewportHeight viewport height
  9540. * @param world world matrix
  9541. * @param view view matrix
  9542. * @param projection projection matrix
  9543. * @returns new ray
  9544. */
  9545. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  9546. /**
  9547. * Function will create a new transformed ray starting from origin and ending at the end point. Ray's length will be set, and ray will be
  9548. * transformed to the given world matrix.
  9549. * @param origin The origin point
  9550. * @param end The end point
  9551. * @param world a matrix to transform the ray to. Default is the identity matrix.
  9552. * @returns the new ray
  9553. */
  9554. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  9555. /**
  9556. * Transforms a ray by a matrix
  9557. * @param ray ray to transform
  9558. * @param matrix matrix to apply
  9559. * @returns the resulting new ray
  9560. */
  9561. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  9562. /**
  9563. * Transforms a ray by a matrix
  9564. * @param ray ray to transform
  9565. * @param matrix matrix to apply
  9566. * @param result ray to store result in
  9567. */
  9568. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  9569. /**
  9570. * Unproject a ray from screen space to object space
  9571. * @param sourceX defines the screen space x coordinate to use
  9572. * @param sourceY defines the screen space y coordinate to use
  9573. * @param viewportWidth defines the current width of the viewport
  9574. * @param viewportHeight defines the current height of the viewport
  9575. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  9576. * @param view defines the view matrix to use
  9577. * @param projection defines the projection matrix to use
  9578. */
  9579. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  9580. }
  9581. /**
  9582. * Type used to define predicate used to select faces when a mesh intersection is detected
  9583. */
  9584. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  9585. interface Scene {
  9586. /** @hidden */
  9587. _tempPickingRay: Nullable<Ray>;
  9588. /** @hidden */
  9589. _cachedRayForTransform: Ray;
  9590. /** @hidden */
  9591. _pickWithRayInverseMatrix: Matrix;
  9592. /** @hidden */
  9593. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  9594. /** @hidden */
  9595. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  9596. }
  9597. }
  9598. declare module BABYLON {
  9599. /**
  9600. * Groups all the scene component constants in one place to ease maintenance.
  9601. * @hidden
  9602. */
  9603. export class SceneComponentConstants {
  9604. static readonly NAME_EFFECTLAYER: string;
  9605. static readonly NAME_LAYER: string;
  9606. static readonly NAME_LENSFLARESYSTEM: string;
  9607. static readonly NAME_BOUNDINGBOXRENDERER: string;
  9608. static readonly NAME_PARTICLESYSTEM: string;
  9609. static readonly NAME_GAMEPAD: string;
  9610. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  9611. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  9612. static readonly NAME_DEPTHRENDERER: string;
  9613. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  9614. static readonly NAME_SPRITE: string;
  9615. static readonly NAME_OUTLINERENDERER: string;
  9616. static readonly NAME_PROCEDURALTEXTURE: string;
  9617. static readonly NAME_SHADOWGENERATOR: string;
  9618. static readonly NAME_OCTREE: string;
  9619. static readonly NAME_PHYSICSENGINE: string;
  9620. static readonly NAME_AUDIO: string;
  9621. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  9622. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  9623. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  9624. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  9625. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  9626. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  9627. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  9628. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  9629. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  9630. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  9631. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  9632. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  9633. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  9634. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  9635. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  9636. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  9637. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  9638. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  9639. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  9640. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  9641. static readonly STEP_AFTERRENDER_AUDIO: number;
  9642. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  9643. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  9644. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  9645. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  9646. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  9647. static readonly STEP_POINTERMOVE_SPRITE: number;
  9648. static readonly STEP_POINTERDOWN_SPRITE: number;
  9649. static readonly STEP_POINTERUP_SPRITE: number;
  9650. }
  9651. /**
  9652. * This represents a scene component.
  9653. *
  9654. * This is used to decouple the dependency the scene is having on the different workloads like
  9655. * layers, post processes...
  9656. */
  9657. export interface ISceneComponent {
  9658. /**
  9659. * The name of the component. Each component must have a unique name.
  9660. */
  9661. name: string;
  9662. /**
  9663. * The scene the component belongs to.
  9664. */
  9665. scene: Scene;
  9666. /**
  9667. * Register the component to one instance of a scene.
  9668. */
  9669. register(): void;
  9670. /**
  9671. * Rebuilds the elements related to this component in case of
  9672. * context lost for instance.
  9673. */
  9674. rebuild(): void;
  9675. /**
  9676. * Disposes the component and the associated ressources.
  9677. */
  9678. dispose(): void;
  9679. }
  9680. /**
  9681. * This represents a SERIALIZABLE scene component.
  9682. *
  9683. * This extends Scene Component to add Serialization methods on top.
  9684. */
  9685. export interface ISceneSerializableComponent extends ISceneComponent {
  9686. /**
  9687. * Adds all the elements from the container to the scene
  9688. * @param container the container holding the elements
  9689. */
  9690. addFromContainer(container: AbstractScene): void;
  9691. /**
  9692. * Removes all the elements in the container from the scene
  9693. * @param container contains the elements to remove
  9694. * @param dispose if the removed element should be disposed (default: false)
  9695. */
  9696. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  9697. /**
  9698. * Serializes the component data to the specified json object
  9699. * @param serializationObject The object to serialize to
  9700. */
  9701. serialize(serializationObject: any): void;
  9702. }
  9703. /**
  9704. * Strong typing of a Mesh related stage step action
  9705. */
  9706. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  9707. /**
  9708. * Strong typing of a Evaluate Sub Mesh related stage step action
  9709. */
  9710. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  9711. /**
  9712. * Strong typing of a Active Mesh related stage step action
  9713. */
  9714. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  9715. /**
  9716. * Strong typing of a Camera related stage step action
  9717. */
  9718. export type CameraStageAction = (camera: Camera) => void;
  9719. /**
  9720. * Strong typing of a Camera Frame buffer related stage step action
  9721. */
  9722. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  9723. /**
  9724. * Strong typing of a Render Target related stage step action
  9725. */
  9726. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  9727. /**
  9728. * Strong typing of a RenderingGroup related stage step action
  9729. */
  9730. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  9731. /**
  9732. * Strong typing of a Mesh Render related stage step action
  9733. */
  9734. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  9735. /**
  9736. * Strong typing of a simple stage step action
  9737. */
  9738. export type SimpleStageAction = () => void;
  9739. /**
  9740. * Strong typing of a render target action.
  9741. */
  9742. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  9743. /**
  9744. * Strong typing of a pointer move action.
  9745. */
  9746. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  9747. /**
  9748. * Strong typing of a pointer up/down action.
  9749. */
  9750. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  9751. /**
  9752. * Representation of a stage in the scene (Basically a list of ordered steps)
  9753. * @hidden
  9754. */
  9755. export class Stage<T extends Function> extends Array<{
  9756. index: number;
  9757. component: ISceneComponent;
  9758. action: T;
  9759. }> {
  9760. /**
  9761. * Hide ctor from the rest of the world.
  9762. * @param items The items to add.
  9763. */
  9764. private constructor();
  9765. /**
  9766. * Creates a new Stage.
  9767. * @returns A new instance of a Stage
  9768. */
  9769. static Create<T extends Function>(): Stage<T>;
  9770. /**
  9771. * Registers a step in an ordered way in the targeted stage.
  9772. * @param index Defines the position to register the step in
  9773. * @param component Defines the component attached to the step
  9774. * @param action Defines the action to launch during the step
  9775. */
  9776. registerStep(index: number, component: ISceneComponent, action: T): void;
  9777. /**
  9778. * Clears all the steps from the stage.
  9779. */
  9780. clear(): void;
  9781. }
  9782. }
  9783. declare module BABYLON {
  9784. interface Scene {
  9785. /** @hidden */
  9786. _pointerOverSprite: Nullable<Sprite>;
  9787. /** @hidden */
  9788. _pickedDownSprite: Nullable<Sprite>;
  9789. /** @hidden */
  9790. _tempSpritePickingRay: Nullable<Ray>;
  9791. /**
  9792. * All of the sprite managers added to this scene
  9793. * @see http://doc.babylonjs.com/babylon101/sprites
  9794. */
  9795. spriteManagers: Array<ISpriteManager>;
  9796. /**
  9797. * An event triggered when sprites rendering is about to start
  9798. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  9799. */
  9800. onBeforeSpritesRenderingObservable: Observable<Scene>;
  9801. /**
  9802. * An event triggered when sprites rendering is done
  9803. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  9804. */
  9805. onAfterSpritesRenderingObservable: Observable<Scene>;
  9806. /** @hidden */
  9807. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  9808. /** Launch a ray to try to pick a sprite in the scene
  9809. * @param x position on screen
  9810. * @param y position on screen
  9811. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  9812. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  9813. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  9814. * @returns a PickingInfo
  9815. */
  9816. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  9817. /** Use the given ray to pick a sprite in the scene
  9818. * @param ray The ray (in world space) to use to pick meshes
  9819. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  9820. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  9821. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  9822. * @returns a PickingInfo
  9823. */
  9824. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  9825. /** @hidden */
  9826. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  9827. /** Launch a ray to try to pick sprites in the scene
  9828. * @param x position on screen
  9829. * @param y position on screen
  9830. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  9831. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  9832. * @returns a PickingInfo array
  9833. */
  9834. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  9835. /** Use the given ray to pick sprites in the scene
  9836. * @param ray The ray (in world space) to use to pick meshes
  9837. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  9838. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  9839. * @returns a PickingInfo array
  9840. */
  9841. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  9842. /**
  9843. * Force the sprite under the pointer
  9844. * @param sprite defines the sprite to use
  9845. */
  9846. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  9847. /**
  9848. * Gets the sprite under the pointer
  9849. * @returns a Sprite or null if no sprite is under the pointer
  9850. */
  9851. getPointerOverSprite(): Nullable<Sprite>;
  9852. }
  9853. /**
  9854. * Defines the sprite scene component responsible to manage sprites
  9855. * in a given scene.
  9856. */
  9857. export class SpriteSceneComponent implements ISceneComponent {
  9858. /**
  9859. * The component name helpfull to identify the component in the list of scene components.
  9860. */
  9861. readonly name: string;
  9862. /**
  9863. * The scene the component belongs to.
  9864. */
  9865. scene: Scene;
  9866. /** @hidden */
  9867. private _spritePredicate;
  9868. /**
  9869. * Creates a new instance of the component for the given scene
  9870. * @param scene Defines the scene to register the component in
  9871. */
  9872. constructor(scene: Scene);
  9873. /**
  9874. * Registers the component in a given scene
  9875. */
  9876. register(): void;
  9877. /**
  9878. * Rebuilds the elements related to this component in case of
  9879. * context lost for instance.
  9880. */
  9881. rebuild(): void;
  9882. /**
  9883. * Disposes the component and the associated ressources.
  9884. */
  9885. dispose(): void;
  9886. private _pickSpriteButKeepRay;
  9887. private _pointerMove;
  9888. private _pointerDown;
  9889. private _pointerUp;
  9890. }
  9891. }
  9892. declare module BABYLON {
  9893. /** @hidden */
  9894. export var fogFragmentDeclaration: {
  9895. name: string;
  9896. shader: string;
  9897. };
  9898. }
  9899. declare module BABYLON {
  9900. /** @hidden */
  9901. export var fogFragment: {
  9902. name: string;
  9903. shader: string;
  9904. };
  9905. }
  9906. declare module BABYLON {
  9907. /** @hidden */
  9908. export var spritesPixelShader: {
  9909. name: string;
  9910. shader: string;
  9911. };
  9912. }
  9913. declare module BABYLON {
  9914. /** @hidden */
  9915. export var fogVertexDeclaration: {
  9916. name: string;
  9917. shader: string;
  9918. };
  9919. }
  9920. declare module BABYLON {
  9921. /** @hidden */
  9922. export var spritesVertexShader: {
  9923. name: string;
  9924. shader: string;
  9925. };
  9926. }
  9927. declare module BABYLON {
  9928. /**
  9929. * Defines the minimum interface to fullfil in order to be a sprite manager.
  9930. */
  9931. export interface ISpriteManager extends IDisposable {
  9932. /**
  9933. * Restricts the camera to viewing objects with the same layerMask.
  9934. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  9935. */
  9936. layerMask: number;
  9937. /**
  9938. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  9939. */
  9940. isPickable: boolean;
  9941. /**
  9942. * Specifies the rendering group id for this mesh (0 by default)
  9943. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  9944. */
  9945. renderingGroupId: number;
  9946. /**
  9947. * Defines the list of sprites managed by the manager.
  9948. */
  9949. sprites: Array<Sprite>;
  9950. /**
  9951. * Tests the intersection of a sprite with a specific ray.
  9952. * @param ray The ray we are sending to test the collision
  9953. * @param camera The camera space we are sending rays in
  9954. * @param predicate A predicate allowing excluding sprites from the list of object to test
  9955. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  9956. * @returns picking info or null.
  9957. */
  9958. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  9959. /**
  9960. * Intersects the sprites with a ray
  9961. * @param ray defines the ray to intersect with
  9962. * @param camera defines the current active camera
  9963. * @param predicate defines a predicate used to select candidate sprites
  9964. * @returns null if no hit or a PickingInfo array
  9965. */
  9966. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  9967. /**
  9968. * Renders the list of sprites on screen.
  9969. */
  9970. render(): void;
  9971. }
  9972. /**
  9973. * Class used to manage multiple sprites on the same spritesheet
  9974. * @see http://doc.babylonjs.com/babylon101/sprites
  9975. */
  9976. export class SpriteManager implements ISpriteManager {
  9977. /** defines the manager's name */
  9978. name: string;
  9979. /** Gets the list of sprites */
  9980. sprites: Sprite[];
  9981. /** Gets or sets the rendering group id (0 by default) */
  9982. renderingGroupId: number;
  9983. /** Gets or sets camera layer mask */
  9984. layerMask: number;
  9985. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  9986. fogEnabled: boolean;
  9987. /** Gets or sets a boolean indicating if the sprites are pickable */
  9988. isPickable: boolean;
  9989. /** Defines the default width of a cell in the spritesheet */
  9990. cellWidth: number;
  9991. /** Defines the default height of a cell in the spritesheet */
  9992. cellHeight: number;
  9993. /** Associative array from JSON sprite data file */
  9994. private _cellData;
  9995. /** Array of sprite names from JSON sprite data file */
  9996. private _spriteMap;
  9997. /** True when packed cell data from JSON file is ready*/
  9998. private _packedAndReady;
  9999. /**
  10000. * An event triggered when the manager is disposed.
  10001. */
  10002. onDisposeObservable: Observable<SpriteManager>;
  10003. private _onDisposeObserver;
  10004. /**
  10005. * Callback called when the manager is disposed
  10006. */
  10007. set onDispose(callback: () => void);
  10008. private _capacity;
  10009. private _fromPacked;
  10010. private _spriteTexture;
  10011. private _epsilon;
  10012. private _scene;
  10013. private _vertexData;
  10014. private _buffer;
  10015. private _vertexBuffers;
  10016. private _indexBuffer;
  10017. private _effectBase;
  10018. private _effectFog;
  10019. /**
  10020. * Gets or sets the spritesheet texture
  10021. */
  10022. get texture(): Texture;
  10023. set texture(value: Texture);
  10024. /**
  10025. * Creates a new sprite manager
  10026. * @param name defines the manager's name
  10027. * @param imgUrl defines the sprite sheet url
  10028. * @param capacity defines the maximum allowed number of sprites
  10029. * @param cellSize defines the size of a sprite cell
  10030. * @param scene defines the hosting scene
  10031. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  10032. * @param samplingMode defines the smapling mode to use with spritesheet
  10033. * @param fromPacked set to false; do not alter
  10034. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  10035. */
  10036. constructor(
  10037. /** defines the manager's name */
  10038. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  10039. private _makePacked;
  10040. private _appendSpriteVertex;
  10041. /**
  10042. * Intersects the sprites with a ray
  10043. * @param ray defines the ray to intersect with
  10044. * @param camera defines the current active camera
  10045. * @param predicate defines a predicate used to select candidate sprites
  10046. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  10047. * @returns null if no hit or a PickingInfo
  10048. */
  10049. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  10050. /**
  10051. * Intersects the sprites with a ray
  10052. * @param ray defines the ray to intersect with
  10053. * @param camera defines the current active camera
  10054. * @param predicate defines a predicate used to select candidate sprites
  10055. * @returns null if no hit or a PickingInfo array
  10056. */
  10057. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  10058. /**
  10059. * Render all child sprites
  10060. */
  10061. render(): void;
  10062. /**
  10063. * Release associated resources
  10064. */
  10065. dispose(): void;
  10066. }
  10067. }
  10068. declare module BABYLON {
  10069. /** Interface used by value gradients (color, factor, ...) */
  10070. export interface IValueGradient {
  10071. /**
  10072. * Gets or sets the gradient value (between 0 and 1)
  10073. */
  10074. gradient: number;
  10075. }
  10076. /** Class used to store color4 gradient */
  10077. export class ColorGradient implements IValueGradient {
  10078. /**
  10079. * Gets or sets the gradient value (between 0 and 1)
  10080. */
  10081. gradient: number;
  10082. /**
  10083. * Gets or sets first associated color
  10084. */
  10085. color1: Color4;
  10086. /**
  10087. * Gets or sets second associated color
  10088. */
  10089. color2?: Color4;
  10090. /**
  10091. * Will get a color picked randomly between color1 and color2.
  10092. * If color2 is undefined then color1 will be used
  10093. * @param result defines the target Color4 to store the result in
  10094. */
  10095. getColorToRef(result: Color4): void;
  10096. }
  10097. /** Class used to store color 3 gradient */
  10098. export class Color3Gradient implements IValueGradient {
  10099. /**
  10100. * Gets or sets the gradient value (between 0 and 1)
  10101. */
  10102. gradient: number;
  10103. /**
  10104. * Gets or sets the associated color
  10105. */
  10106. color: Color3;
  10107. }
  10108. /** Class used to store factor gradient */
  10109. export class FactorGradient implements IValueGradient {
  10110. /**
  10111. * Gets or sets the gradient value (between 0 and 1)
  10112. */
  10113. gradient: number;
  10114. /**
  10115. * Gets or sets first associated factor
  10116. */
  10117. factor1: number;
  10118. /**
  10119. * Gets or sets second associated factor
  10120. */
  10121. factor2?: number;
  10122. /**
  10123. * Will get a number picked randomly between factor1 and factor2.
  10124. * If factor2 is undefined then factor1 will be used
  10125. * @returns the picked number
  10126. */
  10127. getFactor(): number;
  10128. }
  10129. /**
  10130. * Helper used to simplify some generic gradient tasks
  10131. */
  10132. export class GradientHelper {
  10133. /**
  10134. * Gets the current gradient from an array of IValueGradient
  10135. * @param ratio defines the current ratio to get
  10136. * @param gradients defines the array of IValueGradient
  10137. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  10138. */
  10139. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  10140. }
  10141. }
  10142. declare module BABYLON {
  10143. /**
  10144. * Interface for the size containing width and height
  10145. */
  10146. export interface ISize {
  10147. /**
  10148. * Width
  10149. */
  10150. width: number;
  10151. /**
  10152. * Heighht
  10153. */
  10154. height: number;
  10155. }
  10156. /**
  10157. * Size containing widht and height
  10158. */
  10159. export class Size implements ISize {
  10160. /**
  10161. * Width
  10162. */
  10163. width: number;
  10164. /**
  10165. * Height
  10166. */
  10167. height: number;
  10168. /**
  10169. * Creates a Size object from the given width and height (floats).
  10170. * @param width width of the new size
  10171. * @param height height of the new size
  10172. */
  10173. constructor(width: number, height: number);
  10174. /**
  10175. * Returns a string with the Size width and height
  10176. * @returns a string with the Size width and height
  10177. */
  10178. toString(): string;
  10179. /**
  10180. * "Size"
  10181. * @returns the string "Size"
  10182. */
  10183. getClassName(): string;
  10184. /**
  10185. * Returns the Size hash code.
  10186. * @returns a hash code for a unique width and height
  10187. */
  10188. getHashCode(): number;
  10189. /**
  10190. * Updates the current size from the given one.
  10191. * @param src the given size
  10192. */
  10193. copyFrom(src: Size): void;
  10194. /**
  10195. * Updates in place the current Size from the given floats.
  10196. * @param width width of the new size
  10197. * @param height height of the new size
  10198. * @returns the updated Size.
  10199. */
  10200. copyFromFloats(width: number, height: number): Size;
  10201. /**
  10202. * Updates in place the current Size from the given floats.
  10203. * @param width width to set
  10204. * @param height height to set
  10205. * @returns the updated Size.
  10206. */
  10207. set(width: number, height: number): Size;
  10208. /**
  10209. * Multiplies the width and height by numbers
  10210. * @param w factor to multiple the width by
  10211. * @param h factor to multiple the height by
  10212. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  10213. */
  10214. multiplyByFloats(w: number, h: number): Size;
  10215. /**
  10216. * Clones the size
  10217. * @returns a new Size copied from the given one.
  10218. */
  10219. clone(): Size;
  10220. /**
  10221. * True if the current Size and the given one width and height are strictly equal.
  10222. * @param other the other size to compare against
  10223. * @returns True if the current Size and the given one width and height are strictly equal.
  10224. */
  10225. equals(other: Size): boolean;
  10226. /**
  10227. * The surface of the Size : width * height (float).
  10228. */
  10229. get surface(): number;
  10230. /**
  10231. * Create a new size of zero
  10232. * @returns a new Size set to (0.0, 0.0)
  10233. */
  10234. static Zero(): Size;
  10235. /**
  10236. * Sums the width and height of two sizes
  10237. * @param otherSize size to add to this size
  10238. * @returns a new Size set as the addition result of the current Size and the given one.
  10239. */
  10240. add(otherSize: Size): Size;
  10241. /**
  10242. * Subtracts the width and height of two
  10243. * @param otherSize size to subtract to this size
  10244. * @returns a new Size set as the subtraction result of the given one from the current Size.
  10245. */
  10246. subtract(otherSize: Size): Size;
  10247. /**
  10248. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  10249. * @param start starting size to lerp between
  10250. * @param end end size to lerp between
  10251. * @param amount amount to lerp between the start and end values
  10252. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  10253. */
  10254. static Lerp(start: Size, end: Size, amount: number): Size;
  10255. }
  10256. }
  10257. declare module BABYLON {
  10258. interface ThinEngine {
  10259. /**
  10260. * Creates a dynamic texture
  10261. * @param width defines the width of the texture
  10262. * @param height defines the height of the texture
  10263. * @param generateMipMaps defines if the engine should generate the mip levels
  10264. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  10265. * @returns the dynamic texture inside an InternalTexture
  10266. */
  10267. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  10268. /**
  10269. * Update the content of a dynamic texture
  10270. * @param texture defines the texture to update
  10271. * @param canvas defines the canvas containing the source
  10272. * @param invertY defines if data must be stored with Y axis inverted
  10273. * @param premulAlpha defines if alpha is stored as premultiplied
  10274. * @param format defines the format of the data
  10275. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  10276. */
  10277. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  10278. }
  10279. }
  10280. declare module BABYLON {
  10281. /**
  10282. * Helper class used to generate a canvas to manipulate images
  10283. */
  10284. export class CanvasGenerator {
  10285. /**
  10286. * Create a new canvas (or offscreen canvas depending on the context)
  10287. * @param width defines the expected width
  10288. * @param height defines the expected height
  10289. * @return a new canvas or offscreen canvas
  10290. */
  10291. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  10292. }
  10293. }
  10294. declare module BABYLON {
  10295. /**
  10296. * A class extending Texture allowing drawing on a texture
  10297. * @see http://doc.babylonjs.com/how_to/dynamictexture
  10298. */
  10299. export class DynamicTexture extends Texture {
  10300. private _generateMipMaps;
  10301. private _canvas;
  10302. private _context;
  10303. private _engine;
  10304. /**
  10305. * Creates a DynamicTexture
  10306. * @param name defines the name of the texture
  10307. * @param options provides 3 alternatives for width and height of texture, a canvas, object with width and height properties, number for both width and height
  10308. * @param scene defines the scene where you want the texture
  10309. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  10310. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  10311. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  10312. */
  10313. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  10314. /**
  10315. * Get the current class name of the texture useful for serialization or dynamic coding.
  10316. * @returns "DynamicTexture"
  10317. */
  10318. getClassName(): string;
  10319. /**
  10320. * Gets the current state of canRescale
  10321. */
  10322. get canRescale(): boolean;
  10323. private _recreate;
  10324. /**
  10325. * Scales the texture
  10326. * @param ratio the scale factor to apply to both width and height
  10327. */
  10328. scale(ratio: number): void;
  10329. /**
  10330. * Resizes the texture
  10331. * @param width the new width
  10332. * @param height the new height
  10333. */
  10334. scaleTo(width: number, height: number): void;
  10335. /**
  10336. * Gets the context of the canvas used by the texture
  10337. * @returns the canvas context of the dynamic texture
  10338. */
  10339. getContext(): CanvasRenderingContext2D;
  10340. /**
  10341. * Clears the texture
  10342. */
  10343. clear(): void;
  10344. /**
  10345. * Updates the texture
  10346. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  10347. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  10348. */
  10349. update(invertY?: boolean, premulAlpha?: boolean): void;
  10350. /**
  10351. * Draws text onto the texture
  10352. * @param text defines the text to be drawn
  10353. * @param x defines the placement of the text from the left
  10354. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  10355. * @param font defines the font to be used with font-style, font-size, font-name
  10356. * @param color defines the color used for the text
  10357. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  10358. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  10359. * @param update defines whether texture is immediately update (default is true)
  10360. */
  10361. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  10362. /**
  10363. * Clones the texture
  10364. * @returns the clone of the texture.
  10365. */
  10366. clone(): DynamicTexture;
  10367. /**
  10368. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  10369. * @returns a serialized dynamic texture object
  10370. */
  10371. serialize(): any;
  10372. /** @hidden */
  10373. _rebuild(): void;
  10374. }
  10375. }
  10376. declare module BABYLON {
  10377. interface Engine {
  10378. /**
  10379. * Creates a raw texture
  10380. * @param data defines the data to store in the texture
  10381. * @param width defines the width of the texture
  10382. * @param height defines the height of the texture
  10383. * @param format defines the format of the data
  10384. * @param generateMipMaps defines if the engine should generate the mip levels
  10385. * @param invertY defines if data must be stored with Y axis inverted
  10386. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  10387. * @param compression defines the compression used (null by default)
  10388. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10389. * @returns the raw texture inside an InternalTexture
  10390. */
  10391. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  10392. /**
  10393. * Update a raw texture
  10394. * @param texture defines the texture to update
  10395. * @param data defines the data to store in the texture
  10396. * @param format defines the format of the data
  10397. * @param invertY defines if data must be stored with Y axis inverted
  10398. */
  10399. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  10400. /**
  10401. * Update a raw texture
  10402. * @param texture defines the texture to update
  10403. * @param data defines the data to store in the texture
  10404. * @param format defines the format of the data
  10405. * @param invertY defines if data must be stored with Y axis inverted
  10406. * @param compression defines the compression used (null by default)
  10407. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10408. */
  10409. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  10410. /**
  10411. * Creates a new raw cube texture
  10412. * @param data defines the array of data to use to create each face
  10413. * @param size defines the size of the textures
  10414. * @param format defines the format of the data
  10415. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  10416. * @param generateMipMaps defines if the engine should generate the mip levels
  10417. * @param invertY defines if data must be stored with Y axis inverted
  10418. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10419. * @param compression defines the compression used (null by default)
  10420. * @returns the cube texture as an InternalTexture
  10421. */
  10422. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  10423. /**
  10424. * Update a raw cube texture
  10425. * @param texture defines the texture to udpdate
  10426. * @param data defines the data to store
  10427. * @param format defines the data format
  10428. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10429. * @param invertY defines if data must be stored with Y axis inverted
  10430. */
  10431. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  10432. /**
  10433. * Update a raw cube texture
  10434. * @param texture defines the texture to udpdate
  10435. * @param data defines the data to store
  10436. * @param format defines the data format
  10437. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10438. * @param invertY defines if data must be stored with Y axis inverted
  10439. * @param compression defines the compression used (null by default)
  10440. */
  10441. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  10442. /**
  10443. * Update a raw cube texture
  10444. * @param texture defines the texture to udpdate
  10445. * @param data defines the data to store
  10446. * @param format defines the data format
  10447. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10448. * @param invertY defines if data must be stored with Y axis inverted
  10449. * @param compression defines the compression used (null by default)
  10450. * @param level defines which level of the texture to update
  10451. */
  10452. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  10453. /**
  10454. * Creates a new raw cube texture from a specified url
  10455. * @param url defines the url where the data is located
  10456. * @param scene defines the current scene
  10457. * @param size defines the size of the textures
  10458. * @param format defines the format of the data
  10459. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  10460. * @param noMipmap defines if the engine should avoid generating the mip levels
  10461. * @param callback defines a callback used to extract texture data from loaded data
  10462. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  10463. * @param onLoad defines a callback called when texture is loaded
  10464. * @param onError defines a callback called if there is an error
  10465. * @returns the cube texture as an InternalTexture
  10466. */
  10467. createRawCubeTextureFromUrl(url: string, scene: Scene, size: number, format: number, type: number, noMipmap: boolean, callback: (ArrayBuffer: ArrayBuffer) => Nullable<ArrayBufferView[]>, mipmapGenerator: Nullable<((faces: ArrayBufferView[]) => ArrayBufferView[][])>, onLoad: Nullable<() => void>, onError: Nullable<(message?: string, exception?: any) => void>): InternalTexture;
  10468. /**
  10469. * Creates a new raw cube texture from a specified url
  10470. * @param url defines the url where the data is located
  10471. * @param scene defines the current scene
  10472. * @param size defines the size of the textures
  10473. * @param format defines the format of the data
  10474. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  10475. * @param noMipmap defines if the engine should avoid generating the mip levels
  10476. * @param callback defines a callback used to extract texture data from loaded data
  10477. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  10478. * @param onLoad defines a callback called when texture is loaded
  10479. * @param onError defines a callback called if there is an error
  10480. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10481. * @param invertY defines if data must be stored with Y axis inverted
  10482. * @returns the cube texture as an InternalTexture
  10483. */
  10484. createRawCubeTextureFromUrl(url: string, scene: Scene, size: number, format: number, type: number, noMipmap: boolean, callback: (ArrayBuffer: ArrayBuffer) => Nullable<ArrayBufferView[]>, mipmapGenerator: Nullable<((faces: ArrayBufferView[]) => ArrayBufferView[][])>, onLoad: Nullable<() => void>, onError: Nullable<(message?: string, exception?: any) => void>, samplingMode: number, invertY: boolean): InternalTexture;
  10485. /**
  10486. * Creates a new raw 3D texture
  10487. * @param data defines the data used to create the texture
  10488. * @param width defines the width of the texture
  10489. * @param height defines the height of the texture
  10490. * @param depth defines the depth of the texture
  10491. * @param format defines the format of the texture
  10492. * @param generateMipMaps defines if the engine must generate mip levels
  10493. * @param invertY defines if data must be stored with Y axis inverted
  10494. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10495. * @param compression defines the compressed used (can be null)
  10496. * @param textureType defines the compressed used (can be null)
  10497. * @returns a new raw 3D texture (stored in an InternalTexture)
  10498. */
  10499. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  10500. /**
  10501. * Update a raw 3D texture
  10502. * @param texture defines the texture to update
  10503. * @param data defines the data to store
  10504. * @param format defines the data format
  10505. * @param invertY defines if data must be stored with Y axis inverted
  10506. */
  10507. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  10508. /**
  10509. * Update a raw 3D texture
  10510. * @param texture defines the texture to update
  10511. * @param data defines the data to store
  10512. * @param format defines the data format
  10513. * @param invertY defines if data must be stored with Y axis inverted
  10514. * @param compression defines the used compression (can be null)
  10515. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  10516. */
  10517. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  10518. /**
  10519. * Creates a new raw 2D array texture
  10520. * @param data defines the data used to create the texture
  10521. * @param width defines the width of the texture
  10522. * @param height defines the height of the texture
  10523. * @param depth defines the number of layers of the texture
  10524. * @param format defines the format of the texture
  10525. * @param generateMipMaps defines if the engine must generate mip levels
  10526. * @param invertY defines if data must be stored with Y axis inverted
  10527. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10528. * @param compression defines the compressed used (can be null)
  10529. * @param textureType defines the compressed used (can be null)
  10530. * @returns a new raw 2D array texture (stored in an InternalTexture)
  10531. */
  10532. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  10533. /**
  10534. * Update a raw 2D array texture
  10535. * @param texture defines the texture to update
  10536. * @param data defines the data to store
  10537. * @param format defines the data format
  10538. * @param invertY defines if data must be stored with Y axis inverted
  10539. */
  10540. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  10541. /**
  10542. * Update a raw 2D array texture
  10543. * @param texture defines the texture to update
  10544. * @param data defines the data to store
  10545. * @param format defines the data format
  10546. * @param invertY defines if data must be stored with Y axis inverted
  10547. * @param compression defines the used compression (can be null)
  10548. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  10549. */
  10550. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  10551. }
  10552. }
  10553. declare module BABYLON {
  10554. /**
  10555. * Raw texture can help creating a texture directly from an array of data.
  10556. * This can be super useful if you either get the data from an uncompressed source or
  10557. * if you wish to create your texture pixel by pixel.
  10558. */
  10559. export class RawTexture extends Texture {
  10560. /**
  10561. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  10562. */
  10563. format: number;
  10564. private _engine;
  10565. /**
  10566. * Instantiates a new RawTexture.
  10567. * Raw texture can help creating a texture directly from an array of data.
  10568. * This can be super useful if you either get the data from an uncompressed source or
  10569. * if you wish to create your texture pixel by pixel.
  10570. * @param data define the array of data to use to create the texture
  10571. * @param width define the width of the texture
  10572. * @param height define the height of the texture
  10573. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  10574. * @param scene define the scene the texture belongs to
  10575. * @param generateMipMaps define whether mip maps should be generated or not
  10576. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10577. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10578. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10579. */
  10580. constructor(data: ArrayBufferView, width: number, height: number,
  10581. /**
  10582. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  10583. */
  10584. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  10585. /**
  10586. * Updates the texture underlying data.
  10587. * @param data Define the new data of the texture
  10588. */
  10589. update(data: ArrayBufferView): void;
  10590. /**
  10591. * Creates a luminance texture from some data.
  10592. * @param data Define the texture data
  10593. * @param width Define the width of the texture
  10594. * @param height Define the height of the texture
  10595. * @param scene Define the scene the texture belongs to
  10596. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10597. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10598. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10599. * @returns the luminance texture
  10600. */
  10601. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  10602. /**
  10603. * Creates a luminance alpha texture from some data.
  10604. * @param data Define the texture data
  10605. * @param width Define the width of the texture
  10606. * @param height Define the height of the texture
  10607. * @param scene Define the scene the texture belongs to
  10608. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10609. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10610. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10611. * @returns the luminance alpha texture
  10612. */
  10613. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  10614. /**
  10615. * Creates an alpha texture from some data.
  10616. * @param data Define the texture data
  10617. * @param width Define the width of the texture
  10618. * @param height Define the height of the texture
  10619. * @param scene Define the scene the texture belongs to
  10620. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10621. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10622. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10623. * @returns the alpha texture
  10624. */
  10625. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  10626. /**
  10627. * Creates a RGB texture from some data.
  10628. * @param data Define the texture data
  10629. * @param width Define the width of the texture
  10630. * @param height Define the height of the texture
  10631. * @param scene Define the scene the texture belongs to
  10632. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10633. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10634. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10635. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10636. * @returns the RGB alpha texture
  10637. */
  10638. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  10639. /**
  10640. * Creates a RGBA texture from some data.
  10641. * @param data Define the texture data
  10642. * @param width Define the width of the texture
  10643. * @param height Define the height of the texture
  10644. * @param scene Define the scene the texture belongs to
  10645. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10646. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10647. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10648. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10649. * @returns the RGBA texture
  10650. */
  10651. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  10652. /**
  10653. * Creates a R texture from some data.
  10654. * @param data Define the texture data
  10655. * @param width Define the width of the texture
  10656. * @param height Define the height of the texture
  10657. * @param scene Define the scene the texture belongs to
  10658. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10659. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10660. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10661. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10662. * @returns the R texture
  10663. */
  10664. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  10665. }
  10666. }
  10667. declare module BABYLON {
  10668. interface AbstractScene {
  10669. /**
  10670. * The list of procedural textures added to the scene
  10671. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  10672. */
  10673. proceduralTextures: Array<ProceduralTexture>;
  10674. }
  10675. /**
  10676. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  10677. * in a given scene.
  10678. */
  10679. export class ProceduralTextureSceneComponent implements ISceneComponent {
  10680. /**
  10681. * The component name helpfull to identify the component in the list of scene components.
  10682. */
  10683. readonly name: string;
  10684. /**
  10685. * The scene the component belongs to.
  10686. */
  10687. scene: Scene;
  10688. /**
  10689. * Creates a new instance of the component for the given scene
  10690. * @param scene Defines the scene to register the component in
  10691. */
  10692. constructor(scene: Scene);
  10693. /**
  10694. * Registers the component in a given scene
  10695. */
  10696. register(): void;
  10697. /**
  10698. * Rebuilds the elements related to this component in case of
  10699. * context lost for instance.
  10700. */
  10701. rebuild(): void;
  10702. /**
  10703. * Disposes the component and the associated ressources.
  10704. */
  10705. dispose(): void;
  10706. private _beforeClear;
  10707. }
  10708. }
  10709. declare module BABYLON {
  10710. interface ThinEngine {
  10711. /**
  10712. * Creates a new render target cube texture
  10713. * @param size defines the size of the texture
  10714. * @param options defines the options used to create the texture
  10715. * @returns a new render target cube texture stored in an InternalTexture
  10716. */
  10717. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  10718. }
  10719. }
  10720. declare module BABYLON {
  10721. /** @hidden */
  10722. export var proceduralVertexShader: {
  10723. name: string;
  10724. shader: string;
  10725. };
  10726. }
  10727. declare module BABYLON {
  10728. /**
  10729. * Procedural texturing is a way to programmatically create a texture. There are 2 types of procedural textures: code-only, and code that references some classic 2D images, sometimes calmpler' images.
  10730. * This is the base class of any Procedural texture and contains most of the shareable code.
  10731. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  10732. */
  10733. export class ProceduralTexture extends Texture {
  10734. isCube: boolean;
  10735. /**
  10736. * Define if the texture is enabled or not (disabled texture will not render)
  10737. */
  10738. isEnabled: boolean;
  10739. /**
  10740. * Define if the texture must be cleared before rendering (default is true)
  10741. */
  10742. autoClear: boolean;
  10743. /**
  10744. * Callback called when the texture is generated
  10745. */
  10746. onGenerated: () => void;
  10747. /**
  10748. * Event raised when the texture is generated
  10749. */
  10750. onGeneratedObservable: Observable<ProceduralTexture>;
  10751. /** @hidden */
  10752. _generateMipMaps: boolean;
  10753. /** @hidden **/
  10754. _effect: Effect;
  10755. /** @hidden */
  10756. _textures: {
  10757. [key: string]: Texture;
  10758. };
  10759. private _size;
  10760. private _currentRefreshId;
  10761. private _frameId;
  10762. private _refreshRate;
  10763. private _vertexBuffers;
  10764. private _indexBuffer;
  10765. private _uniforms;
  10766. private _samplers;
  10767. private _fragment;
  10768. private _floats;
  10769. private _ints;
  10770. private _floatsArrays;
  10771. private _colors3;
  10772. private _colors4;
  10773. private _vectors2;
  10774. private _vectors3;
  10775. private _matrices;
  10776. private _fallbackTexture;
  10777. private _fallbackTextureUsed;
  10778. private _engine;
  10779. private _cachedDefines;
  10780. private _contentUpdateId;
  10781. private _contentData;
  10782. /**
  10783. * Instantiates a new procedural texture.
  10784. * Procedural texturing is a way to programmatically create a texture. There are 2 types of procedural textures: code-only, and code that references some classic 2D images, sometimes called 'refMaps' or 'sampler' images.
  10785. * This is the base class of any Procedural texture and contains most of the shareable code.
  10786. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  10787. * @param name Define the name of the texture
  10788. * @param size Define the size of the texture to create
  10789. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  10790. * @param scene Define the scene the texture belongs to
  10791. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  10792. * @param generateMipMaps Define if the texture should creates mip maps or not
  10793. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  10794. */
  10795. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  10796. /**
  10797. * The effect that is created when initializing the post process.
  10798. * @returns The created effect corresponding the the postprocess.
  10799. */
  10800. getEffect(): Effect;
  10801. /**
  10802. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  10803. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  10804. */
  10805. getContent(): Nullable<ArrayBufferView>;
  10806. private _createIndexBuffer;
  10807. /** @hidden */
  10808. _rebuild(): void;
  10809. /**
  10810. * Resets the texture in order to recreate its associated resources.
  10811. * This can be called in case of context loss
  10812. */
  10813. reset(): void;
  10814. protected _getDefines(): string;
  10815. /**
  10816. * Is the texture ready to be used ? (rendered at least once)
  10817. * @returns true if ready, otherwise, false.
  10818. */
  10819. isReady(): boolean;
  10820. /**
  10821. * Resets the refresh counter of the texture and start bak from scratch.
  10822. * Could be useful to regenerate the texture if it is setup to render only once.
  10823. */
  10824. resetRefreshCounter(): void;
  10825. /**
  10826. * Set the fragment shader to use in order to render the texture.
  10827. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  10828. */
  10829. setFragment(fragment: any): void;
  10830. /**
  10831. * Define the refresh rate of the texture or the rendering frequency.
  10832. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  10833. */
  10834. get refreshRate(): number;
  10835. set refreshRate(value: number);
  10836. /** @hidden */
  10837. _shouldRender(): boolean;
  10838. /**
  10839. * Get the size the texture is rendering at.
  10840. * @returns the size (texture is always squared)
  10841. */
  10842. getRenderSize(): number;
  10843. /**
  10844. * Resize the texture to new value.
  10845. * @param size Define the new size the texture should have
  10846. * @param generateMipMaps Define whether the new texture should create mip maps
  10847. */
  10848. resize(size: number, generateMipMaps: boolean): void;
  10849. private _checkUniform;
  10850. /**
  10851. * Set a texture in the shader program used to render.
  10852. * @param name Define the name of the uniform samplers as defined in the shader
  10853. * @param texture Define the texture to bind to this sampler
  10854. * @return the texture itself allowing "fluent" like uniform updates
  10855. */
  10856. setTexture(name: string, texture: Texture): ProceduralTexture;
  10857. /**
  10858. * Set a float in the shader.
  10859. * @param name Define the name of the uniform as defined in the shader
  10860. * @param value Define the value to give to the uniform
  10861. * @return the texture itself allowing "fluent" like uniform updates
  10862. */
  10863. setFloat(name: string, value: number): ProceduralTexture;
  10864. /**
  10865. * Set a int in the shader.
  10866. * @param name Define the name of the uniform as defined in the shader
  10867. * @param value Define the value to give to the uniform
  10868. * @return the texture itself allowing "fluent" like uniform updates
  10869. */
  10870. setInt(name: string, value: number): ProceduralTexture;
  10871. /**
  10872. * Set an array of floats in the shader.
  10873. * @param name Define the name of the uniform as defined in the shader
  10874. * @param value Define the value to give to the uniform
  10875. * @return the texture itself allowing "fluent" like uniform updates
  10876. */
  10877. setFloats(name: string, value: number[]): ProceduralTexture;
  10878. /**
  10879. * Set a vec3 in the shader from a Color3.
  10880. * @param name Define the name of the uniform as defined in the shader
  10881. * @param value Define the value to give to the uniform
  10882. * @return the texture itself allowing "fluent" like uniform updates
  10883. */
  10884. setColor3(name: string, value: Color3): ProceduralTexture;
  10885. /**
  10886. * Set a vec4 in the shader from a Color4.
  10887. * @param name Define the name of the uniform as defined in the shader
  10888. * @param value Define the value to give to the uniform
  10889. * @return the texture itself allowing "fluent" like uniform updates
  10890. */
  10891. setColor4(name: string, value: Color4): ProceduralTexture;
  10892. /**
  10893. * Set a vec2 in the shader from a Vector2.
  10894. * @param name Define the name of the uniform as defined in the shader
  10895. * @param value Define the value to give to the uniform
  10896. * @return the texture itself allowing "fluent" like uniform updates
  10897. */
  10898. setVector2(name: string, value: Vector2): ProceduralTexture;
  10899. /**
  10900. * Set a vec3 in the shader from a Vector3.
  10901. * @param name Define the name of the uniform as defined in the shader
  10902. * @param value Define the value to give to the uniform
  10903. * @return the texture itself allowing "fluent" like uniform updates
  10904. */
  10905. setVector3(name: string, value: Vector3): ProceduralTexture;
  10906. /**
  10907. * Set a mat4 in the shader from a MAtrix.
  10908. * @param name Define the name of the uniform as defined in the shader
  10909. * @param value Define the value to give to the uniform
  10910. * @return the texture itself allowing "fluent" like uniform updates
  10911. */
  10912. setMatrix(name: string, value: Matrix): ProceduralTexture;
  10913. /**
  10914. * Render the texture to its associated render target.
  10915. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  10916. */
  10917. render(useCameraPostProcess?: boolean): void;
  10918. /**
  10919. * Clone the texture.
  10920. * @returns the cloned texture
  10921. */
  10922. clone(): ProceduralTexture;
  10923. /**
  10924. * Dispose the texture and release its asoociated resources.
  10925. */
  10926. dispose(): void;
  10927. }
  10928. }
  10929. declare module BABYLON {
  10930. /**
  10931. * This represents the base class for particle system in Babylon.
  10932. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  10933. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  10934. * @example https://doc.babylonjs.com/babylon101/particles
  10935. */
  10936. export class BaseParticleSystem {
  10937. /**
  10938. * Source color is added to the destination color without alpha affecting the result
  10939. */
  10940. static BLENDMODE_ONEONE: number;
  10941. /**
  10942. * Blend current color and particle color using particle’s alpha
  10943. */
  10944. static BLENDMODE_STANDARD: number;
  10945. /**
  10946. * Add current color and particle color multiplied by particle’s alpha
  10947. */
  10948. static BLENDMODE_ADD: number;
  10949. /**
  10950. * Multiply current color with particle color
  10951. */
  10952. static BLENDMODE_MULTIPLY: number;
  10953. /**
  10954. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  10955. */
  10956. static BLENDMODE_MULTIPLYADD: number;
  10957. /**
  10958. * List of animations used by the particle system.
  10959. */
  10960. animations: Animation[];
  10961. /**
  10962. * The id of the Particle system.
  10963. */
  10964. id: string;
  10965. /**
  10966. * The friendly name of the Particle system.
  10967. */
  10968. name: string;
  10969. /**
  10970. * The rendering group used by the Particle system to chose when to render.
  10971. */
  10972. renderingGroupId: number;
  10973. /**
  10974. * The emitter represents the Mesh or position we are attaching the particle system to.
  10975. */
  10976. emitter: Nullable<AbstractMesh | Vector3>;
  10977. /**
  10978. * The maximum number of particles to emit per frame
  10979. */
  10980. emitRate: number;
  10981. /**
  10982. * If you want to launch only a few particles at once, that can be done, as well.
  10983. */
  10984. manualEmitCount: number;
  10985. /**
  10986. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  10987. */
  10988. updateSpeed: number;
  10989. /**
  10990. * The amount of time the particle system is running (depends of the overall update speed).
  10991. */
  10992. targetStopDuration: number;
  10993. /**
  10994. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  10995. */
  10996. disposeOnStop: boolean;
  10997. /**
  10998. * Minimum power of emitting particles.
  10999. */
  11000. minEmitPower: number;
  11001. /**
  11002. * Maximum power of emitting particles.
  11003. */
  11004. maxEmitPower: number;
  11005. /**
  11006. * Minimum life time of emitting particles.
  11007. */
  11008. minLifeTime: number;
  11009. /**
  11010. * Maximum life time of emitting particles.
  11011. */
  11012. maxLifeTime: number;
  11013. /**
  11014. * Minimum Size of emitting particles.
  11015. */
  11016. minSize: number;
  11017. /**
  11018. * Maximum Size of emitting particles.
  11019. */
  11020. maxSize: number;
  11021. /**
  11022. * Minimum scale of emitting particles on X axis.
  11023. */
  11024. minScaleX: number;
  11025. /**
  11026. * Maximum scale of emitting particles on X axis.
  11027. */
  11028. maxScaleX: number;
  11029. /**
  11030. * Minimum scale of emitting particles on Y axis.
  11031. */
  11032. minScaleY: number;
  11033. /**
  11034. * Maximum scale of emitting particles on Y axis.
  11035. */
  11036. maxScaleY: number;
  11037. /**
  11038. * Gets or sets the minimal initial rotation in radians.
  11039. */
  11040. minInitialRotation: number;
  11041. /**
  11042. * Gets or sets the maximal initial rotation in radians.
  11043. */
  11044. maxInitialRotation: number;
  11045. /**
  11046. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  11047. */
  11048. minAngularSpeed: number;
  11049. /**
  11050. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  11051. */
  11052. maxAngularSpeed: number;
  11053. /**
  11054. * The texture used to render each particle. (this can be a spritesheet)
  11055. */
  11056. particleTexture: Nullable<Texture>;
  11057. /**
  11058. * The layer mask we are rendering the particles through.
  11059. */
  11060. layerMask: number;
  11061. /**
  11062. * This can help using your own shader to render the particle system.
  11063. * The according effect will be created
  11064. */
  11065. customShader: any;
  11066. /**
  11067. * By default particle system starts as soon as they are created. This prevents the
  11068. * automatic start to happen and let you decide when to start emitting particles.
  11069. */
  11070. preventAutoStart: boolean;
  11071. private _noiseTexture;
  11072. /**
  11073. * Gets or sets a texture used to add random noise to particle positions
  11074. */
  11075. get noiseTexture(): Nullable<ProceduralTexture>;
  11076. set noiseTexture(value: Nullable<ProceduralTexture>);
  11077. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  11078. noiseStrength: Vector3;
  11079. /**
  11080. * Callback triggered when the particle animation is ending.
  11081. */
  11082. onAnimationEnd: Nullable<() => void>;
  11083. /**
  11084. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  11085. */
  11086. blendMode: number;
  11087. /**
  11088. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  11089. * to override the particles.
  11090. */
  11091. forceDepthWrite: boolean;
  11092. /** Gets or sets a value indicating how many cycles (or frames) must be executed before first rendering (this value has to be set before starting the system). Default is 0 */
  11093. preWarmCycles: number;
  11094. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  11095. preWarmStepOffset: number;
  11096. /**
  11097. * If using a spritesheet (isAnimationSheetEnabled) defines the speed of the sprite loop (default is 1 meaning the animation will play once during the entire particle lifetime)
  11098. */
  11099. spriteCellChangeSpeed: number;
  11100. /**
  11101. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  11102. */
  11103. startSpriteCellID: number;
  11104. /**
  11105. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  11106. */
  11107. endSpriteCellID: number;
  11108. /**
  11109. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  11110. */
  11111. spriteCellWidth: number;
  11112. /**
  11113. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  11114. */
  11115. spriteCellHeight: number;
  11116. /**
  11117. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  11118. */
  11119. spriteRandomStartCell: boolean;
  11120. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  11121. translationPivot: Vector2;
  11122. /** @hidden */
  11123. protected _isAnimationSheetEnabled: boolean;
  11124. /**
  11125. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  11126. */
  11127. beginAnimationOnStart: boolean;
  11128. /**
  11129. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  11130. */
  11131. beginAnimationFrom: number;
  11132. /**
  11133. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  11134. */
  11135. beginAnimationTo: number;
  11136. /**
  11137. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  11138. */
  11139. beginAnimationLoop: boolean;
  11140. /**
  11141. * Gets or sets a world offset applied to all particles
  11142. */
  11143. worldOffset: Vector3;
  11144. /**
  11145. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  11146. */
  11147. get isAnimationSheetEnabled(): boolean;
  11148. set isAnimationSheetEnabled(value: boolean);
  11149. /**
  11150. * Get hosting scene
  11151. * @returns the scene
  11152. */
  11153. getScene(): Scene;
  11154. /**
  11155. * You can use gravity if you want to give an orientation to your particles.
  11156. */
  11157. gravity: Vector3;
  11158. protected _colorGradients: Nullable<Array<ColorGradient>>;
  11159. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  11160. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  11161. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  11162. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  11163. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  11164. protected _dragGradients: Nullable<Array<FactorGradient>>;
  11165. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  11166. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  11167. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  11168. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  11169. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  11170. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  11171. /**
  11172. * Defines the delay in milliseconds before starting the system (0 by default)
  11173. */
  11174. startDelay: number;
  11175. /**
  11176. * Gets the current list of drag gradients.
  11177. * You must use addDragGradient and removeDragGradient to udpate this list
  11178. * @returns the list of drag gradients
  11179. */
  11180. getDragGradients(): Nullable<Array<FactorGradient>>;
  11181. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  11182. limitVelocityDamping: number;
  11183. /**
  11184. * Gets the current list of limit velocity gradients.
  11185. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  11186. * @returns the list of limit velocity gradients
  11187. */
  11188. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  11189. /**
  11190. * Gets the current list of color gradients.
  11191. * You must use addColorGradient and removeColorGradient to udpate this list
  11192. * @returns the list of color gradients
  11193. */
  11194. getColorGradients(): Nullable<Array<ColorGradient>>;
  11195. /**
  11196. * Gets the current list of size gradients.
  11197. * You must use addSizeGradient and removeSizeGradient to udpate this list
  11198. * @returns the list of size gradients
  11199. */
  11200. getSizeGradients(): Nullable<Array<FactorGradient>>;
  11201. /**
  11202. * Gets the current list of color remap gradients.
  11203. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  11204. * @returns the list of color remap gradients
  11205. */
  11206. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  11207. /**
  11208. * Gets the current list of alpha remap gradients.
  11209. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  11210. * @returns the list of alpha remap gradients
  11211. */
  11212. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  11213. /**
  11214. * Gets the current list of life time gradients.
  11215. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  11216. * @returns the list of life time gradients
  11217. */
  11218. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  11219. /**
  11220. * Gets the current list of angular speed gradients.
  11221. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  11222. * @returns the list of angular speed gradients
  11223. */
  11224. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  11225. /**
  11226. * Gets the current list of velocity gradients.
  11227. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  11228. * @returns the list of velocity gradients
  11229. */
  11230. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  11231. /**
  11232. * Gets the current list of start size gradients.
  11233. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  11234. * @returns the list of start size gradients
  11235. */
  11236. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  11237. /**
  11238. * Gets the current list of emit rate gradients.
  11239. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  11240. * @returns the list of emit rate gradients
  11241. */
  11242. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  11243. /**
  11244. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  11245. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11246. */
  11247. get direction1(): Vector3;
  11248. set direction1(value: Vector3);
  11249. /**
  11250. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  11251. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11252. */
  11253. get direction2(): Vector3;
  11254. set direction2(value: Vector3);
  11255. /**
  11256. * Minimum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
  11257. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11258. */
  11259. get minEmitBox(): Vector3;
  11260. set minEmitBox(value: Vector3);
  11261. /**
  11262. * Maximum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
  11263. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11264. */
  11265. get maxEmitBox(): Vector3;
  11266. set maxEmitBox(value: Vector3);
  11267. /**
  11268. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  11269. */
  11270. color1: Color4;
  11271. /**
  11272. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  11273. */
  11274. color2: Color4;
  11275. /**
  11276. * Color the particle will have at the end of its lifetime
  11277. */
  11278. colorDead: Color4;
  11279. /**
  11280. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  11281. */
  11282. textureMask: Color4;
  11283. /**
  11284. * The particle emitter type defines the emitter used by the particle system.
  11285. * It can be for example box, sphere, or cone...
  11286. */
  11287. particleEmitterType: IParticleEmitterType;
  11288. /** @hidden */
  11289. _isSubEmitter: boolean;
  11290. /**
  11291. * Gets or sets the billboard mode to use when isBillboardBased = true.
  11292. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  11293. */
  11294. billboardMode: number;
  11295. protected _isBillboardBased: boolean;
  11296. /**
  11297. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  11298. */
  11299. get isBillboardBased(): boolean;
  11300. set isBillboardBased(value: boolean);
  11301. /**
  11302. * The scene the particle system belongs to.
  11303. */
  11304. protected _scene: Scene;
  11305. /**
  11306. * Local cache of defines for image processing.
  11307. */
  11308. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  11309. /**
  11310. * Default configuration related to image processing available in the standard Material.
  11311. */
  11312. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  11313. /**
  11314. * Gets the image processing configuration used either in this material.
  11315. */
  11316. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  11317. /**
  11318. * Sets the Default image processing configuration used either in the this material.
  11319. *
  11320. * If sets to null, the scene one is in use.
  11321. */
  11322. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  11323. /**
  11324. * Attaches a new image processing configuration to the Standard Material.
  11325. * @param configuration
  11326. */
  11327. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  11328. /** @hidden */
  11329. protected _reset(): void;
  11330. /** @hidden */
  11331. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  11332. /**
  11333. * Instantiates a particle system.
  11334. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  11335. * @param name The name of the particle system
  11336. */
  11337. constructor(name: string);
  11338. /**
  11339. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  11340. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  11341. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  11342. * @returns the emitter
  11343. */
  11344. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  11345. /**
  11346. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  11347. * @param radius The radius of the hemisphere to emit from
  11348. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  11349. * @returns the emitter
  11350. */
  11351. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  11352. /**
  11353. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  11354. * @param radius The radius of the sphere to emit from
  11355. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  11356. * @returns the emitter
  11357. */
  11358. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  11359. /**
  11360. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  11361. * @param radius The radius of the sphere to emit from
  11362. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  11363. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  11364. * @returns the emitter
  11365. */
  11366. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  11367. /**
  11368. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  11369. * @param radius The radius of the emission cylinder
  11370. * @param height The height of the emission cylinder
  11371. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  11372. * @param directionRandomizer How much to randomize the particle direction [0-1]
  11373. * @returns the emitter
  11374. */
  11375. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  11376. /**
  11377. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  11378. * @param radius The radius of the cylinder to emit from
  11379. * @param height The height of the emission cylinder
  11380. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  11381. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  11382. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  11383. * @returns the emitter
  11384. */
  11385. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  11386. /**
  11387. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  11388. * @param radius The radius of the cone to emit from
  11389. * @param angle The base angle of the cone
  11390. * @returns the emitter
  11391. */
  11392. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  11393. /**
  11394. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  11395. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  11396. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  11397. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  11398. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  11399. * @returns the emitter
  11400. */
  11401. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  11402. }
  11403. }
  11404. declare module BABYLON {
  11405. /**
  11406. * Type of sub emitter
  11407. */
  11408. export enum SubEmitterType {
  11409. /**
  11410. * Attached to the particle over it's lifetime
  11411. */
  11412. ATTACHED = 0,
  11413. /**
  11414. * Created when the particle dies
  11415. */
  11416. END = 1
  11417. }
  11418. /**
  11419. * Sub emitter class used to emit particles from an existing particle
  11420. */
  11421. export class SubEmitter {
  11422. /**
  11423. * the particle system to be used by the sub emitter
  11424. */
  11425. particleSystem: ParticleSystem;
  11426. /**
  11427. * Type of the submitter (Default: END)
  11428. */
  11429. type: SubEmitterType;
  11430. /**
  11431. * If the particle should inherit the direction from the particle it's attached to. (+Y will face the direction the particle is moving) (Default: false)
  11432. * Note: This only is supported when using an emitter of type Mesh
  11433. */
  11434. inheritDirection: boolean;
  11435. /**
  11436. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  11437. */
  11438. inheritedVelocityAmount: number;
  11439. /**
  11440. * Creates a sub emitter
  11441. * @param particleSystem the particle system to be used by the sub emitter
  11442. */
  11443. constructor(
  11444. /**
  11445. * the particle system to be used by the sub emitter
  11446. */
  11447. particleSystem: ParticleSystem);
  11448. /**
  11449. * Clones the sub emitter
  11450. * @returns the cloned sub emitter
  11451. */
  11452. clone(): SubEmitter;
  11453. /**
  11454. * Serialize current object to a JSON object
  11455. * @returns the serialized object
  11456. */
  11457. serialize(): any;
  11458. /** @hidden */
  11459. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  11460. /**
  11461. * Creates a new SubEmitter from a serialized JSON version
  11462. * @param serializationObject defines the JSON object to read from
  11463. * @param scene defines the hosting scene
  11464. * @param rootUrl defines the rootUrl for data loading
  11465. * @returns a new SubEmitter
  11466. */
  11467. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  11468. /** Release associated resources */
  11469. dispose(): void;
  11470. }
  11471. }
  11472. declare module BABYLON {
  11473. /** @hidden */
  11474. export var imageProcessingDeclaration: {
  11475. name: string;
  11476. shader: string;
  11477. };
  11478. }
  11479. declare module BABYLON {
  11480. /** @hidden */
  11481. export var imageProcessingFunctions: {
  11482. name: string;
  11483. shader: string;
  11484. };
  11485. }
  11486. declare module BABYLON {
  11487. /** @hidden */
  11488. export var particlesPixelShader: {
  11489. name: string;
  11490. shader: string;
  11491. };
  11492. }
  11493. declare module BABYLON {
  11494. /** @hidden */
  11495. export var particlesVertexShader: {
  11496. name: string;
  11497. shader: string;
  11498. };
  11499. }
  11500. declare module BABYLON {
  11501. /**
  11502. * This represents a particle system in Babylon.
  11503. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  11504. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  11505. * @example https://doc.babylonjs.com/babylon101/particles
  11506. */
  11507. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  11508. /**
  11509. * Billboard mode will only apply to Y axis
  11510. */
  11511. static readonly BILLBOARDMODE_Y: number;
  11512. /**
  11513. * Billboard mode will apply to all axes
  11514. */
  11515. static readonly BILLBOARDMODE_ALL: number;
  11516. /**
  11517. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  11518. */
  11519. static readonly BILLBOARDMODE_STRETCHED: number;
  11520. /**
  11521. * This function can be defined to provide custom update for active particles.
  11522. * This function will be called instead of regular update (age, position, color, etc.).
  11523. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  11524. */
  11525. updateFunction: (particles: Particle[]) => void;
  11526. private _emitterWorldMatrix;
  11527. /**
  11528. * This function can be defined to specify initial direction for every new particle.
  11529. * It by default use the emitterType defined function
  11530. */
  11531. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  11532. /**
  11533. * This function can be defined to specify initial position for every new particle.
  11534. * It by default use the emitterType defined function
  11535. */
  11536. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  11537. /**
  11538. * @hidden
  11539. */
  11540. _inheritedVelocityOffset: Vector3;
  11541. /**
  11542. * An event triggered when the system is disposed
  11543. */
  11544. onDisposeObservable: Observable<ParticleSystem>;
  11545. private _onDisposeObserver;
  11546. /**
  11547. * Sets a callback that will be triggered when the system is disposed
  11548. */
  11549. set onDispose(callback: () => void);
  11550. private _particles;
  11551. private _epsilon;
  11552. private _capacity;
  11553. private _stockParticles;
  11554. private _newPartsExcess;
  11555. private _vertexData;
  11556. private _vertexBuffer;
  11557. private _vertexBuffers;
  11558. private _spriteBuffer;
  11559. private _indexBuffer;
  11560. private _effect;
  11561. private _customEffect;
  11562. private _cachedDefines;
  11563. private _scaledColorStep;
  11564. private _colorDiff;
  11565. private _scaledDirection;
  11566. private _scaledGravity;
  11567. private _currentRenderId;
  11568. private _alive;
  11569. private _useInstancing;
  11570. private _started;
  11571. private _stopped;
  11572. private _actualFrame;
  11573. private _scaledUpdateSpeed;
  11574. private _vertexBufferSize;
  11575. /** @hidden */
  11576. _currentEmitRateGradient: Nullable<FactorGradient>;
  11577. /** @hidden */
  11578. _currentEmitRate1: number;
  11579. /** @hidden */
  11580. _currentEmitRate2: number;
  11581. /** @hidden */
  11582. _currentStartSizeGradient: Nullable<FactorGradient>;
  11583. /** @hidden */
  11584. _currentStartSize1: number;
  11585. /** @hidden */
  11586. _currentStartSize2: number;
  11587. private readonly _rawTextureWidth;
  11588. private _rampGradientsTexture;
  11589. private _useRampGradients;
  11590. /** Gets or sets a boolean indicating that ramp gradients must be used
  11591. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  11592. */
  11593. get useRampGradients(): boolean;
  11594. set useRampGradients(value: boolean);
  11595. /**
  11596. * The Sub-emitters templates that will be used to generate the sub particle system to be associated with the system, this property is used by the root particle system only.
  11597. * When a particle is spawned, an array will be chosen at random and all the emitters in that array will be attached to the particle. (Default: [])
  11598. */
  11599. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  11600. private _subEmitters;
  11601. /**
  11602. * @hidden
  11603. * If the particle systems emitter should be disposed when the particle system is disposed
  11604. */
  11605. _disposeEmitterOnDispose: boolean;
  11606. /**
  11607. * The current active Sub-systems, this property is used by the root particle system only.
  11608. */
  11609. activeSubSystems: Array<ParticleSystem>;
  11610. private _rootParticleSystem;
  11611. /**
  11612. * Gets the current list of active particles
  11613. */
  11614. get particles(): Particle[];
  11615. /**
  11616. * Returns the string "ParticleSystem"
  11617. * @returns a string containing the class name
  11618. */
  11619. getClassName(): string;
  11620. /**
  11621. * Instantiates a particle system.
  11622. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  11623. * @param name The name of the particle system
  11624. * @param capacity The max number of particles alive at the same time
  11625. * @param scene The scene the particle system belongs to
  11626. * @param customEffect a custom effect used to change the way particles are rendered by default
  11627. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  11628. * @param epsilon Offset used to render the particles
  11629. */
  11630. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  11631. private _addFactorGradient;
  11632. private _removeFactorGradient;
  11633. /**
  11634. * Adds a new life time gradient
  11635. * @param gradient defines the gradient to use (between 0 and 1)
  11636. * @param factor defines the life time factor to affect to the specified gradient
  11637. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11638. * @returns the current particle system
  11639. */
  11640. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11641. /**
  11642. * Remove a specific life time gradient
  11643. * @param gradient defines the gradient to remove
  11644. * @returns the current particle system
  11645. */
  11646. removeLifeTimeGradient(gradient: number): IParticleSystem;
  11647. /**
  11648. * Adds a new size gradient
  11649. * @param gradient defines the gradient to use (between 0 and 1)
  11650. * @param factor defines the size factor to affect to the specified gradient
  11651. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11652. * @returns the current particle system
  11653. */
  11654. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11655. /**
  11656. * Remove a specific size gradient
  11657. * @param gradient defines the gradient to remove
  11658. * @returns the current particle system
  11659. */
  11660. removeSizeGradient(gradient: number): IParticleSystem;
  11661. /**
  11662. * Adds a new color remap gradient
  11663. * @param gradient defines the gradient to use (between 0 and 1)
  11664. * @param min defines the color remap minimal range
  11665. * @param max defines the color remap maximal range
  11666. * @returns the current particle system
  11667. */
  11668. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  11669. /**
  11670. * Remove a specific color remap gradient
  11671. * @param gradient defines the gradient to remove
  11672. * @returns the current particle system
  11673. */
  11674. removeColorRemapGradient(gradient: number): IParticleSystem;
  11675. /**
  11676. * Adds a new alpha remap gradient
  11677. * @param gradient defines the gradient to use (between 0 and 1)
  11678. * @param min defines the alpha remap minimal range
  11679. * @param max defines the alpha remap maximal range
  11680. * @returns the current particle system
  11681. */
  11682. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  11683. /**
  11684. * Remove a specific alpha remap gradient
  11685. * @param gradient defines the gradient to remove
  11686. * @returns the current particle system
  11687. */
  11688. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  11689. /**
  11690. * Adds a new angular speed gradient
  11691. * @param gradient defines the gradient to use (between 0 and 1)
  11692. * @param factor defines the angular speed to affect to the specified gradient
  11693. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11694. * @returns the current particle system
  11695. */
  11696. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11697. /**
  11698. * Remove a specific angular speed gradient
  11699. * @param gradient defines the gradient to remove
  11700. * @returns the current particle system
  11701. */
  11702. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  11703. /**
  11704. * Adds a new velocity gradient
  11705. * @param gradient defines the gradient to use (between 0 and 1)
  11706. * @param factor defines the velocity to affect to the specified gradient
  11707. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11708. * @returns the current particle system
  11709. */
  11710. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11711. /**
  11712. * Remove a specific velocity gradient
  11713. * @param gradient defines the gradient to remove
  11714. * @returns the current particle system
  11715. */
  11716. removeVelocityGradient(gradient: number): IParticleSystem;
  11717. /**
  11718. * Adds a new limit velocity gradient
  11719. * @param gradient defines the gradient to use (between 0 and 1)
  11720. * @param factor defines the limit velocity value to affect to the specified gradient
  11721. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11722. * @returns the current particle system
  11723. */
  11724. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11725. /**
  11726. * Remove a specific limit velocity gradient
  11727. * @param gradient defines the gradient to remove
  11728. * @returns the current particle system
  11729. */
  11730. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  11731. /**
  11732. * Adds a new drag gradient
  11733. * @param gradient defines the gradient to use (between 0 and 1)
  11734. * @param factor defines the drag value to affect to the specified gradient
  11735. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11736. * @returns the current particle system
  11737. */
  11738. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11739. /**
  11740. * Remove a specific drag gradient
  11741. * @param gradient defines the gradient to remove
  11742. * @returns the current particle system
  11743. */
  11744. removeDragGradient(gradient: number): IParticleSystem;
  11745. /**
  11746. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  11747. * @param gradient defines the gradient to use (between 0 and 1)
  11748. * @param factor defines the emit rate value to affect to the specified gradient
  11749. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11750. * @returns the current particle system
  11751. */
  11752. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11753. /**
  11754. * Remove a specific emit rate gradient
  11755. * @param gradient defines the gradient to remove
  11756. * @returns the current particle system
  11757. */
  11758. removeEmitRateGradient(gradient: number): IParticleSystem;
  11759. /**
  11760. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  11761. * @param gradient defines the gradient to use (between 0 and 1)
  11762. * @param factor defines the start size value to affect to the specified gradient
  11763. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11764. * @returns the current particle system
  11765. */
  11766. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11767. /**
  11768. * Remove a specific start size gradient
  11769. * @param gradient defines the gradient to remove
  11770. * @returns the current particle system
  11771. */
  11772. removeStartSizeGradient(gradient: number): IParticleSystem;
  11773. private _createRampGradientTexture;
  11774. /**
  11775. * Gets the current list of ramp gradients.
  11776. * You must use addRampGradient and removeRampGradient to udpate this list
  11777. * @returns the list of ramp gradients
  11778. */
  11779. getRampGradients(): Nullable<Array<Color3Gradient>>;
  11780. /**
  11781. * Adds a new ramp gradient used to remap particle colors
  11782. * @param gradient defines the gradient to use (between 0 and 1)
  11783. * @param color defines the color to affect to the specified gradient
  11784. * @returns the current particle system
  11785. */
  11786. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  11787. /**
  11788. * Remove a specific ramp gradient
  11789. * @param gradient defines the gradient to remove
  11790. * @returns the current particle system
  11791. */
  11792. removeRampGradient(gradient: number): ParticleSystem;
  11793. /**
  11794. * Adds a new color gradient
  11795. * @param gradient defines the gradient to use (between 0 and 1)
  11796. * @param color1 defines the color to affect to the specified gradient
  11797. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  11798. * @returns this particle system
  11799. */
  11800. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  11801. /**
  11802. * Remove a specific color gradient
  11803. * @param gradient defines the gradient to remove
  11804. * @returns this particle system
  11805. */
  11806. removeColorGradient(gradient: number): IParticleSystem;
  11807. private _fetchR;
  11808. protected _reset(): void;
  11809. private _resetEffect;
  11810. private _createVertexBuffers;
  11811. private _createIndexBuffer;
  11812. /**
  11813. * Gets the maximum number of particles active at the same time.
  11814. * @returns The max number of active particles.
  11815. */
  11816. getCapacity(): number;
  11817. /**
  11818. * Gets whether there are still active particles in the system.
  11819. * @returns True if it is alive, otherwise false.
  11820. */
  11821. isAlive(): boolean;
  11822. /**
  11823. * Gets if the system has been started. (Note: this will still be true after stop is called)
  11824. * @returns True if it has been started, otherwise false.
  11825. */
  11826. isStarted(): boolean;
  11827. private _prepareSubEmitterInternalArray;
  11828. /**
  11829. * Starts the particle system and begins to emit
  11830. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  11831. */
  11832. start(delay?: number): void;
  11833. /**
  11834. * Stops the particle system.
  11835. * @param stopSubEmitters if true it will stop the current system and all created sub-Systems if false it will stop the current root system only, this param is used by the root particle system only. the default value is true.
  11836. */
  11837. stop(stopSubEmitters?: boolean): void;
  11838. /**
  11839. * Remove all active particles
  11840. */
  11841. reset(): void;
  11842. /**
  11843. * @hidden (for internal use only)
  11844. */
  11845. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  11846. /**
  11847. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  11848. * Its lifetime will start back at 0.
  11849. */
  11850. recycleParticle: (particle: Particle) => void;
  11851. private _stopSubEmitters;
  11852. private _createParticle;
  11853. private _removeFromRoot;
  11854. private _emitFromParticle;
  11855. private _update;
  11856. /** @hidden */
  11857. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  11858. /** @hidden */
  11859. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  11860. /** @hidden */
  11861. private _getEffect;
  11862. /**
  11863. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  11864. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  11865. */
  11866. animate(preWarmOnly?: boolean): void;
  11867. private _appendParticleVertices;
  11868. /**
  11869. * Rebuilds the particle system.
  11870. */
  11871. rebuild(): void;
  11872. /**
  11873. * Is this system ready to be used/rendered
  11874. * @return true if the system is ready
  11875. */
  11876. isReady(): boolean;
  11877. private _render;
  11878. /**
  11879. * Renders the particle system in its current state.
  11880. * @returns the current number of particles
  11881. */
  11882. render(): number;
  11883. /**
  11884. * Disposes the particle system and free the associated resources
  11885. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  11886. */
  11887. dispose(disposeTexture?: boolean): void;
  11888. /**
  11889. * Clones the particle system.
  11890. * @param name The name of the cloned object
  11891. * @param newEmitter The new emitter to use
  11892. * @returns the cloned particle system
  11893. */
  11894. clone(name: string, newEmitter: any): ParticleSystem;
  11895. /**
  11896. * Serializes the particle system to a JSON object.
  11897. * @returns the JSON object
  11898. */
  11899. serialize(): any;
  11900. /** @hidden */
  11901. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  11902. /** @hidden */
  11903. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  11904. /**
  11905. * Parses a JSON object to create a particle system.
  11906. * @param parsedParticleSystem The JSON object to parse
  11907. * @param scene The scene to create the particle system in
  11908. * @param rootUrl The root url to use to load external dependencies like texture
  11909. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  11910. * @returns the Parsed particle system
  11911. */
  11912. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  11913. }
  11914. }
  11915. declare module BABYLON {
  11916. /**
  11917. * A particle represents one of the element emitted by a particle system.
  11918. * This is mainly define by its coordinates, direction, velocity and age.
  11919. */
  11920. export class Particle {
  11921. /**
  11922. * The particle system the particle belongs to.
  11923. */
  11924. particleSystem: ParticleSystem;
  11925. private static _Count;
  11926. /**
  11927. * Unique ID of the particle
  11928. */
  11929. id: number;
  11930. /**
  11931. * The world position of the particle in the scene.
  11932. */
  11933. position: Vector3;
  11934. /**
  11935. * The world direction of the particle in the scene.
  11936. */
  11937. direction: Vector3;
  11938. /**
  11939. * The color of the particle.
  11940. */
  11941. color: Color4;
  11942. /**
  11943. * The color change of the particle per step.
  11944. */
  11945. colorStep: Color4;
  11946. /**
  11947. * Defines how long will the life of the particle be.
  11948. */
  11949. lifeTime: number;
  11950. /**
  11951. * The current age of the particle.
  11952. */
  11953. age: number;
  11954. /**
  11955. * The current size of the particle.
  11956. */
  11957. size: number;
  11958. /**
  11959. * The current scale of the particle.
  11960. */
  11961. scale: Vector2;
  11962. /**
  11963. * The current angle of the particle.
  11964. */
  11965. angle: number;
  11966. /**
  11967. * Defines how fast is the angle changing.
  11968. */
  11969. angularSpeed: number;
  11970. /**
  11971. * Defines the cell index used by the particle to be rendered from a sprite.
  11972. */
  11973. cellIndex: number;
  11974. /**
  11975. * The information required to support color remapping
  11976. */
  11977. remapData: Vector4;
  11978. /** @hidden */
  11979. _randomCellOffset?: number;
  11980. /** @hidden */
  11981. _initialDirection: Nullable<Vector3>;
  11982. /** @hidden */
  11983. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  11984. /** @hidden */
  11985. _initialStartSpriteCellID: number;
  11986. /** @hidden */
  11987. _initialEndSpriteCellID: number;
  11988. /** @hidden */
  11989. _currentColorGradient: Nullable<ColorGradient>;
  11990. /** @hidden */
  11991. _currentColor1: Color4;
  11992. /** @hidden */
  11993. _currentColor2: Color4;
  11994. /** @hidden */
  11995. _currentSizeGradient: Nullable<FactorGradient>;
  11996. /** @hidden */
  11997. _currentSize1: number;
  11998. /** @hidden */
  11999. _currentSize2: number;
  12000. /** @hidden */
  12001. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  12002. /** @hidden */
  12003. _currentAngularSpeed1: number;
  12004. /** @hidden */
  12005. _currentAngularSpeed2: number;
  12006. /** @hidden */
  12007. _currentVelocityGradient: Nullable<FactorGradient>;
  12008. /** @hidden */
  12009. _currentVelocity1: number;
  12010. /** @hidden */
  12011. _currentVelocity2: number;
  12012. /** @hidden */
  12013. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  12014. /** @hidden */
  12015. _currentLimitVelocity1: number;
  12016. /** @hidden */
  12017. _currentLimitVelocity2: number;
  12018. /** @hidden */
  12019. _currentDragGradient: Nullable<FactorGradient>;
  12020. /** @hidden */
  12021. _currentDrag1: number;
  12022. /** @hidden */
  12023. _currentDrag2: number;
  12024. /** @hidden */
  12025. _randomNoiseCoordinates1: Vector3;
  12026. /** @hidden */
  12027. _randomNoiseCoordinates2: Vector3;
  12028. /**
  12029. * Creates a new instance Particle
  12030. * @param particleSystem the particle system the particle belongs to
  12031. */
  12032. constructor(
  12033. /**
  12034. * The particle system the particle belongs to.
  12035. */
  12036. particleSystem: ParticleSystem);
  12037. private updateCellInfoFromSystem;
  12038. /**
  12039. * Defines how the sprite cell index is updated for the particle
  12040. */
  12041. updateCellIndex(): void;
  12042. /** @hidden */
  12043. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  12044. /** @hidden */
  12045. _inheritParticleInfoToSubEmitters(): void;
  12046. /** @hidden */
  12047. _reset(): void;
  12048. /**
  12049. * Copy the properties of particle to another one.
  12050. * @param other the particle to copy the information to.
  12051. */
  12052. copyTo(other: Particle): void;
  12053. }
  12054. }
  12055. declare module BABYLON {
  12056. /**
  12057. * Particle emitter represents a volume emitting particles.
  12058. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  12059. */
  12060. export interface IParticleEmitterType {
  12061. /**
  12062. * Called by the particle System when the direction is computed for the created particle.
  12063. * @param worldMatrix is the world matrix of the particle system
  12064. * @param directionToUpdate is the direction vector to update with the result
  12065. * @param particle is the particle we are computed the direction for
  12066. */
  12067. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  12068. /**
  12069. * Called by the particle System when the position is computed for the created particle.
  12070. * @param worldMatrix is the world matrix of the particle system
  12071. * @param positionToUpdate is the position vector to update with the result
  12072. * @param particle is the particle we are computed the position for
  12073. */
  12074. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  12075. /**
  12076. * Clones the current emitter and returns a copy of it
  12077. * @returns the new emitter
  12078. */
  12079. clone(): IParticleEmitterType;
  12080. /**
  12081. * Called by the GPUParticleSystem to setup the update shader
  12082. * @param effect defines the update shader
  12083. */
  12084. applyToShader(effect: Effect): void;
  12085. /**
  12086. * Returns a string to use to update the GPU particles update shader
  12087. * @returns the effect defines string
  12088. */
  12089. getEffectDefines(): string;
  12090. /**
  12091. * Returns a string representing the class name
  12092. * @returns a string containing the class name
  12093. */
  12094. getClassName(): string;
  12095. /**
  12096. * Serializes the particle system to a JSON object.
  12097. * @returns the JSON object
  12098. */
  12099. serialize(): any;
  12100. /**
  12101. * Parse properties from a JSON object
  12102. * @param serializationObject defines the JSON object
  12103. * @param scene defines the hosting scene
  12104. */
  12105. parse(serializationObject: any, scene: Scene): void;
  12106. }
  12107. }
  12108. declare module BABYLON {
  12109. /**
  12110. * Particle emitter emitting particles from the inside of a box.
  12111. * It emits the particles randomly between 2 given directions.
  12112. */
  12113. export class BoxParticleEmitter implements IParticleEmitterType {
  12114. /**
  12115. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12116. */
  12117. direction1: Vector3;
  12118. /**
  12119. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12120. */
  12121. direction2: Vector3;
  12122. /**
  12123. * Minimum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
  12124. */
  12125. minEmitBox: Vector3;
  12126. /**
  12127. * Maximum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
  12128. */
  12129. maxEmitBox: Vector3;
  12130. /**
  12131. * Creates a new instance BoxParticleEmitter
  12132. */
  12133. constructor();
  12134. /**
  12135. * Called by the particle System when the direction is computed for the created particle.
  12136. * @param worldMatrix is the world matrix of the particle system
  12137. * @param directionToUpdate is the direction vector to update with the result
  12138. * @param particle is the particle we are computed the direction for
  12139. */
  12140. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  12141. /**
  12142. * Called by the particle System when the position is computed for the created particle.
  12143. * @param worldMatrix is the world matrix of the particle system
  12144. * @param positionToUpdate is the position vector to update with the result
  12145. * @param particle is the particle we are computed the position for
  12146. */
  12147. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  12148. /**
  12149. * Clones the current emitter and returns a copy of it
  12150. * @returns the new emitter
  12151. */
  12152. clone(): BoxParticleEmitter;
  12153. /**
  12154. * Called by the GPUParticleSystem to setup the update shader
  12155. * @param effect defines the update shader
  12156. */
  12157. applyToShader(effect: Effect): void;
  12158. /**
  12159. * Returns a string to use to update the GPU particles update shader
  12160. * @returns a string containng the defines string
  12161. */
  12162. getEffectDefines(): string;
  12163. /**
  12164. * Returns the string "BoxParticleEmitter"
  12165. * @returns a string containing the class name
  12166. */
  12167. getClassName(): string;
  12168. /**
  12169. * Serializes the particle system to a JSON object.
  12170. * @returns the JSON object
  12171. */
  12172. serialize(): any;
  12173. /**
  12174. * Parse properties from a JSON object
  12175. * @param serializationObject defines the JSON object
  12176. */
  12177. parse(serializationObject: any): void;
  12178. }
  12179. }
  12180. declare module BABYLON {
  12181. /**
  12182. * Particle emitter emitting particles from the inside of a cone.
  12183. * It emits the particles alongside the cone volume from the base to the particle.
  12184. * The emission direction might be randomized.
  12185. */
  12186. export class ConeParticleEmitter implements IParticleEmitterType {
  12187. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  12188. directionRandomizer: number;
  12189. private _radius;
  12190. private _angle;
  12191. private _height;
  12192. /**
  12193. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  12194. */
  12195. radiusRange: number;
  12196. /**
  12197. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  12198. */
  12199. heightRange: number;
  12200. /**
  12201. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  12202. */
  12203. emitFromSpawnPointOnly: boolean;
  12204. /**
  12205. * Gets or sets the radius of the emission cone
  12206. */
  12207. get radius(): number;
  12208. set radius(value: number);
  12209. /**
  12210. * Gets or sets the angle of the emission cone
  12211. */
  12212. get angle(): number;
  12213. set angle(value: number);
  12214. private _buildHeight;
  12215. /**
  12216. * Creates a new instance ConeParticleEmitter
  12217. * @param radius the radius of the emission cone (1 by default)
  12218. * @param angle the cone base angle (PI by default)
  12219. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  12220. */
  12221. constructor(radius?: number, angle?: number,
  12222. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  12223. directionRandomizer?: number);
  12224. /**
  12225. * Called by the particle System when the direction is computed for the created particle.
  12226. * @param worldMatrix is the world matrix of the particle system
  12227. * @param directionToUpdate is the direction vector to update with the result
  12228. * @param particle is the particle we are computed the direction for
  12229. */
  12230. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  12231. /**
  12232. * Called by the particle System when the position is computed for the created particle.
  12233. * @param worldMatrix is the world matrix of the particle system
  12234. * @param positionToUpdate is the position vector to update with the result
  12235. * @param particle is the particle we are computed the position for
  12236. */
  12237. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  12238. /**
  12239. * Clones the current emitter and returns a copy of it
  12240. * @returns the new emitter
  12241. */
  12242. clone(): ConeParticleEmitter;
  12243. /**
  12244. * Called by the GPUParticleSystem to setup the update shader
  12245. * @param effect defines the update shader
  12246. */
  12247. applyToShader(effect: Effect): void;
  12248. /**
  12249. * Returns a string to use to update the GPU particles update shader
  12250. * @returns a string containng the defines string
  12251. */
  12252. getEffectDefines(): string;
  12253. /**
  12254. * Returns the string "ConeParticleEmitter"
  12255. * @returns a string containing the class name
  12256. */
  12257. getClassName(): string;
  12258. /**
  12259. * Serializes the particle system to a JSON object.
  12260. * @returns the JSON object
  12261. */
  12262. serialize(): any;
  12263. /**
  12264. * Parse properties from a JSON object
  12265. * @param serializationObject defines the JSON object
  12266. */
  12267. parse(serializationObject: any): void;
  12268. }
  12269. }
  12270. declare module BABYLON {
  12271. /**
  12272. * Particle emitter emitting particles from the inside of a cylinder.
  12273. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  12274. */
  12275. export class CylinderParticleEmitter implements IParticleEmitterType {
  12276. /**
  12277. * The radius of the emission cylinder.
  12278. */
  12279. radius: number;
  12280. /**
  12281. * The height of the emission cylinder.
  12282. */
  12283. height: number;
  12284. /**
  12285. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12286. */
  12287. radiusRange: number;
  12288. /**
  12289. * How much to randomize the particle direction [0-1].
  12290. */
  12291. directionRandomizer: number;
  12292. /**
  12293. * Creates a new instance CylinderParticleEmitter
  12294. * @param radius the radius of the emission cylinder (1 by default)
  12295. * @param height the height of the emission cylinder (1 by default)
  12296. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12297. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  12298. */
  12299. constructor(
  12300. /**
  12301. * The radius of the emission cylinder.
  12302. */
  12303. radius?: number,
  12304. /**
  12305. * The height of the emission cylinder.
  12306. */
  12307. height?: number,
  12308. /**
  12309. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12310. */
  12311. radiusRange?: number,
  12312. /**
  12313. * How much to randomize the particle direction [0-1].
  12314. */
  12315. directionRandomizer?: number);
  12316. /**
  12317. * Called by the particle System when the direction is computed for the created particle.
  12318. * @param worldMatrix is the world matrix of the particle system
  12319. * @param directionToUpdate is the direction vector to update with the result
  12320. * @param particle is the particle we are computed the direction for
  12321. */
  12322. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  12323. /**
  12324. * Called by the particle System when the position is computed for the created particle.
  12325. * @param worldMatrix is the world matrix of the particle system
  12326. * @param positionToUpdate is the position vector to update with the result
  12327. * @param particle is the particle we are computed the position for
  12328. */
  12329. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  12330. /**
  12331. * Clones the current emitter and returns a copy of it
  12332. * @returns the new emitter
  12333. */
  12334. clone(): CylinderParticleEmitter;
  12335. /**
  12336. * Called by the GPUParticleSystem to setup the update shader
  12337. * @param effect defines the update shader
  12338. */
  12339. applyToShader(effect: Effect): void;
  12340. /**
  12341. * Returns a string to use to update the GPU particles update shader
  12342. * @returns a string containng the defines string
  12343. */
  12344. getEffectDefines(): string;
  12345. /**
  12346. * Returns the string "CylinderParticleEmitter"
  12347. * @returns a string containing the class name
  12348. */
  12349. getClassName(): string;
  12350. /**
  12351. * Serializes the particle system to a JSON object.
  12352. * @returns the JSON object
  12353. */
  12354. serialize(): any;
  12355. /**
  12356. * Parse properties from a JSON object
  12357. * @param serializationObject defines the JSON object
  12358. */
  12359. parse(serializationObject: any): void;
  12360. }
  12361. /**
  12362. * Particle emitter emitting particles from the inside of a cylinder.
  12363. * It emits the particles randomly between two vectors.
  12364. */
  12365. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  12366. /**
  12367. * The min limit of the emission direction.
  12368. */
  12369. direction1: Vector3;
  12370. /**
  12371. * The max limit of the emission direction.
  12372. */
  12373. direction2: Vector3;
  12374. /**
  12375. * Creates a new instance CylinderDirectedParticleEmitter
  12376. * @param radius the radius of the emission cylinder (1 by default)
  12377. * @param height the height of the emission cylinder (1 by default)
  12378. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12379. * @param direction1 the min limit of the emission direction (up vector by default)
  12380. * @param direction2 the max limit of the emission direction (up vector by default)
  12381. */
  12382. constructor(radius?: number, height?: number, radiusRange?: number,
  12383. /**
  12384. * The min limit of the emission direction.
  12385. */
  12386. direction1?: Vector3,
  12387. /**
  12388. * The max limit of the emission direction.
  12389. */
  12390. direction2?: Vector3);
  12391. /**
  12392. * Called by the particle System when the direction is computed for the created particle.
  12393. * @param worldMatrix is the world matrix of the particle system
  12394. * @param directionToUpdate is the direction vector to update with the result
  12395. * @param particle is the particle we are computed the direction for
  12396. */
  12397. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  12398. /**
  12399. * Clones the current emitter and returns a copy of it
  12400. * @returns the new emitter
  12401. */
  12402. clone(): CylinderDirectedParticleEmitter;
  12403. /**
  12404. * Called by the GPUParticleSystem to setup the update shader
  12405. * @param effect defines the update shader
  12406. */
  12407. applyToShader(effect: Effect): void;
  12408. /**
  12409. * Returns a string to use to update the GPU particles update shader
  12410. * @returns a string containng the defines string
  12411. */
  12412. getEffectDefines(): string;
  12413. /**
  12414. * Returns the string "CylinderDirectedParticleEmitter"
  12415. * @returns a string containing the class name
  12416. */
  12417. getClassName(): string;
  12418. /**
  12419. * Serializes the particle system to a JSON object.
  12420. * @returns the JSON object
  12421. */
  12422. serialize(): any;
  12423. /**
  12424. * Parse properties from a JSON object
  12425. * @param serializationObject defines the JSON object
  12426. */
  12427. parse(serializationObject: any): void;
  12428. }
  12429. }
  12430. declare module BABYLON {
  12431. /**
  12432. * Particle emitter emitting particles from the inside of a hemisphere.
  12433. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  12434. */
  12435. export class HemisphericParticleEmitter implements IParticleEmitterType {
  12436. /**
  12437. * The radius of the emission hemisphere.
  12438. */
  12439. radius: number;
  12440. /**
  12441. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12442. */
  12443. radiusRange: number;
  12444. /**
  12445. * How much to randomize the particle direction [0-1].
  12446. */
  12447. directionRandomizer: number;
  12448. /**
  12449. * Creates a new instance HemisphericParticleEmitter
  12450. * @param radius the radius of the emission hemisphere (1 by default)
  12451. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12452. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  12453. */
  12454. constructor(
  12455. /**
  12456. * The radius of the emission hemisphere.
  12457. */
  12458. radius?: number,
  12459. /**
  12460. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12461. */
  12462. radiusRange?: number,
  12463. /**
  12464. * How much to randomize the particle direction [0-1].
  12465. */
  12466. directionRandomizer?: number);
  12467. /**
  12468. * Called by the particle System when the direction is computed for the created particle.
  12469. * @param worldMatrix is the world matrix of the particle system
  12470. * @param directionToUpdate is the direction vector to update with the result
  12471. * @param particle is the particle we are computed the direction for
  12472. */
  12473. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  12474. /**
  12475. * Called by the particle System when the position is computed for the created particle.
  12476. * @param worldMatrix is the world matrix of the particle system
  12477. * @param positionToUpdate is the position vector to update with the result
  12478. * @param particle is the particle we are computed the position for
  12479. */
  12480. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  12481. /**
  12482. * Clones the current emitter and returns a copy of it
  12483. * @returns the new emitter
  12484. */
  12485. clone(): HemisphericParticleEmitter;
  12486. /**
  12487. * Called by the GPUParticleSystem to setup the update shader
  12488. * @param effect defines the update shader
  12489. */
  12490. applyToShader(effect: Effect): void;
  12491. /**
  12492. * Returns a string to use to update the GPU particles update shader
  12493. * @returns a string containng the defines string
  12494. */
  12495. getEffectDefines(): string;
  12496. /**
  12497. * Returns the string "HemisphericParticleEmitter"
  12498. * @returns a string containing the class name
  12499. */
  12500. getClassName(): string;
  12501. /**
  12502. * Serializes the particle system to a JSON object.
  12503. * @returns the JSON object
  12504. */
  12505. serialize(): any;
  12506. /**
  12507. * Parse properties from a JSON object
  12508. * @param serializationObject defines the JSON object
  12509. */
  12510. parse(serializationObject: any): void;
  12511. }
  12512. }
  12513. declare module BABYLON {
  12514. /**
  12515. * Particle emitter emitting particles from a point.
  12516. * It emits the particles randomly between 2 given directions.
  12517. */
  12518. export class PointParticleEmitter implements IParticleEmitterType {
  12519. /**
  12520. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12521. */
  12522. direction1: Vector3;
  12523. /**
  12524. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12525. */
  12526. direction2: Vector3;
  12527. /**
  12528. * Creates a new instance PointParticleEmitter
  12529. */
  12530. constructor();
  12531. /**
  12532. * Called by the particle System when the direction is computed for the created particle.
  12533. * @param worldMatrix is the world matrix of the particle system
  12534. * @param directionToUpdate is the direction vector to update with the result
  12535. * @param particle is the particle we are computed the direction for
  12536. */
  12537. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  12538. /**
  12539. * Called by the particle System when the position is computed for the created particle.
  12540. * @param worldMatrix is the world matrix of the particle system
  12541. * @param positionToUpdate is the position vector to update with the result
  12542. * @param particle is the particle we are computed the position for
  12543. */
  12544. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  12545. /**
  12546. * Clones the current emitter and returns a copy of it
  12547. * @returns the new emitter
  12548. */
  12549. clone(): PointParticleEmitter;
  12550. /**
  12551. * Called by the GPUParticleSystem to setup the update shader
  12552. * @param effect defines the update shader
  12553. */
  12554. applyToShader(effect: Effect): void;
  12555. /**
  12556. * Returns a string to use to update the GPU particles update shader
  12557. * @returns a string containng the defines string
  12558. */
  12559. getEffectDefines(): string;
  12560. /**
  12561. * Returns the string "PointParticleEmitter"
  12562. * @returns a string containing the class name
  12563. */
  12564. getClassName(): string;
  12565. /**
  12566. * Serializes the particle system to a JSON object.
  12567. * @returns the JSON object
  12568. */
  12569. serialize(): any;
  12570. /**
  12571. * Parse properties from a JSON object
  12572. * @param serializationObject defines the JSON object
  12573. */
  12574. parse(serializationObject: any): void;
  12575. }
  12576. }
  12577. declare module BABYLON {
  12578. /**
  12579. * Particle emitter emitting particles from the inside of a sphere.
  12580. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  12581. */
  12582. export class SphereParticleEmitter implements IParticleEmitterType {
  12583. /**
  12584. * The radius of the emission sphere.
  12585. */
  12586. radius: number;
  12587. /**
  12588. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12589. */
  12590. radiusRange: number;
  12591. /**
  12592. * How much to randomize the particle direction [0-1].
  12593. */
  12594. directionRandomizer: number;
  12595. /**
  12596. * Creates a new instance SphereParticleEmitter
  12597. * @param radius the radius of the emission sphere (1 by default)
  12598. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12599. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  12600. */
  12601. constructor(
  12602. /**
  12603. * The radius of the emission sphere.
  12604. */
  12605. radius?: number,
  12606. /**
  12607. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12608. */
  12609. radiusRange?: number,
  12610. /**
  12611. * How much to randomize the particle direction [0-1].
  12612. */
  12613. directionRandomizer?: number);
  12614. /**
  12615. * Called by the particle System when the direction is computed for the created particle.
  12616. * @param worldMatrix is the world matrix of the particle system
  12617. * @param directionToUpdate is the direction vector to update with the result
  12618. * @param particle is the particle we are computed the direction for
  12619. */
  12620. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  12621. /**
  12622. * Called by the particle System when the position is computed for the created particle.
  12623. * @param worldMatrix is the world matrix of the particle system
  12624. * @param positionToUpdate is the position vector to update with the result
  12625. * @param particle is the particle we are computed the position for
  12626. */
  12627. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  12628. /**
  12629. * Clones the current emitter and returns a copy of it
  12630. * @returns the new emitter
  12631. */
  12632. clone(): SphereParticleEmitter;
  12633. /**
  12634. * Called by the GPUParticleSystem to setup the update shader
  12635. * @param effect defines the update shader
  12636. */
  12637. applyToShader(effect: Effect): void;
  12638. /**
  12639. * Returns a string to use to update the GPU particles update shader
  12640. * @returns a string containng the defines string
  12641. */
  12642. getEffectDefines(): string;
  12643. /**
  12644. * Returns the string "SphereParticleEmitter"
  12645. * @returns a string containing the class name
  12646. */
  12647. getClassName(): string;
  12648. /**
  12649. * Serializes the particle system to a JSON object.
  12650. * @returns the JSON object
  12651. */
  12652. serialize(): any;
  12653. /**
  12654. * Parse properties from a JSON object
  12655. * @param serializationObject defines the JSON object
  12656. */
  12657. parse(serializationObject: any): void;
  12658. }
  12659. /**
  12660. * Particle emitter emitting particles from the inside of a sphere.
  12661. * It emits the particles randomly between two vectors.
  12662. */
  12663. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  12664. /**
  12665. * The min limit of the emission direction.
  12666. */
  12667. direction1: Vector3;
  12668. /**
  12669. * The max limit of the emission direction.
  12670. */
  12671. direction2: Vector3;
  12672. /**
  12673. * Creates a new instance SphereDirectedParticleEmitter
  12674. * @param radius the radius of the emission sphere (1 by default)
  12675. * @param direction1 the min limit of the emission direction (up vector by default)
  12676. * @param direction2 the max limit of the emission direction (up vector by default)
  12677. */
  12678. constructor(radius?: number,
  12679. /**
  12680. * The min limit of the emission direction.
  12681. */
  12682. direction1?: Vector3,
  12683. /**
  12684. * The max limit of the emission direction.
  12685. */
  12686. direction2?: Vector3);
  12687. /**
  12688. * Called by the particle System when the direction is computed for the created particle.
  12689. * @param worldMatrix is the world matrix of the particle system
  12690. * @param directionToUpdate is the direction vector to update with the result
  12691. * @param particle is the particle we are computed the direction for
  12692. */
  12693. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  12694. /**
  12695. * Clones the current emitter and returns a copy of it
  12696. * @returns the new emitter
  12697. */
  12698. clone(): SphereDirectedParticleEmitter;
  12699. /**
  12700. * Called by the GPUParticleSystem to setup the update shader
  12701. * @param effect defines the update shader
  12702. */
  12703. applyToShader(effect: Effect): void;
  12704. /**
  12705. * Returns a string to use to update the GPU particles update shader
  12706. * @returns a string containng the defines string
  12707. */
  12708. getEffectDefines(): string;
  12709. /**
  12710. * Returns the string "SphereDirectedParticleEmitter"
  12711. * @returns a string containing the class name
  12712. */
  12713. getClassName(): string;
  12714. /**
  12715. * Serializes the particle system to a JSON object.
  12716. * @returns the JSON object
  12717. */
  12718. serialize(): any;
  12719. /**
  12720. * Parse properties from a JSON object
  12721. * @param serializationObject defines the JSON object
  12722. */
  12723. parse(serializationObject: any): void;
  12724. }
  12725. }
  12726. declare module BABYLON {
  12727. /**
  12728. * Particle emitter emitting particles from a custom list of positions.
  12729. */
  12730. export class CustomParticleEmitter implements IParticleEmitterType {
  12731. /**
  12732. * Gets or sets the position generator that will create the inital position of each particle.
  12733. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  12734. */
  12735. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  12736. /**
  12737. * Gets or sets the destination generator that will create the final destination of each particle.
  12738. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  12739. */
  12740. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  12741. /**
  12742. * Creates a new instance CustomParticleEmitter
  12743. */
  12744. constructor();
  12745. /**
  12746. * Called by the particle System when the direction is computed for the created particle.
  12747. * @param worldMatrix is the world matrix of the particle system
  12748. * @param directionToUpdate is the direction vector to update with the result
  12749. * @param particle is the particle we are computed the direction for
  12750. */
  12751. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  12752. /**
  12753. * Called by the particle System when the position is computed for the created particle.
  12754. * @param worldMatrix is the world matrix of the particle system
  12755. * @param positionToUpdate is the position vector to update with the result
  12756. * @param particle is the particle we are computed the position for
  12757. */
  12758. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  12759. /**
  12760. * Clones the current emitter and returns a copy of it
  12761. * @returns the new emitter
  12762. */
  12763. clone(): CustomParticleEmitter;
  12764. /**
  12765. * Called by the GPUParticleSystem to setup the update shader
  12766. * @param effect defines the update shader
  12767. */
  12768. applyToShader(effect: Effect): void;
  12769. /**
  12770. * Returns a string to use to update the GPU particles update shader
  12771. * @returns a string containng the defines string
  12772. */
  12773. getEffectDefines(): string;
  12774. /**
  12775. * Returns the string "PointParticleEmitter"
  12776. * @returns a string containing the class name
  12777. */
  12778. getClassName(): string;
  12779. /**
  12780. * Serializes the particle system to a JSON object.
  12781. * @returns the JSON object
  12782. */
  12783. serialize(): any;
  12784. /**
  12785. * Parse properties from a JSON object
  12786. * @param serializationObject defines the JSON object
  12787. */
  12788. parse(serializationObject: any): void;
  12789. }
  12790. }
  12791. declare module BABYLON {
  12792. /**
  12793. * Particle emitter emitting particles from the inside of a box.
  12794. * It emits the particles randomly between 2 given directions.
  12795. */
  12796. export class MeshParticleEmitter implements IParticleEmitterType {
  12797. /** Defines the mesh to use as source */
  12798. mesh?: AbstractMesh | undefined;
  12799. private _indices;
  12800. private _positions;
  12801. private _normals;
  12802. private _storedNormal;
  12803. /**
  12804. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12805. */
  12806. direction1: Vector3;
  12807. /**
  12808. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12809. */
  12810. direction2: Vector3;
  12811. /**
  12812. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  12813. */
  12814. useMeshNormalsForDirection: boolean;
  12815. /**
  12816. * Creates a new instance MeshParticleEmitter
  12817. * @param mesh defines the mesh to use as source
  12818. */
  12819. constructor(
  12820. /** Defines the mesh to use as source */
  12821. mesh?: AbstractMesh | undefined);
  12822. /**
  12823. * Called by the particle System when the direction is computed for the created particle.
  12824. * @param worldMatrix is the world matrix of the particle system
  12825. * @param directionToUpdate is the direction vector to update with the result
  12826. * @param particle is the particle we are computed the direction for
  12827. */
  12828. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  12829. /**
  12830. * Called by the particle System when the position is computed for the created particle.
  12831. * @param worldMatrix is the world matrix of the particle system
  12832. * @param positionToUpdate is the position vector to update with the result
  12833. * @param particle is the particle we are computed the position for
  12834. */
  12835. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  12836. /**
  12837. * Clones the current emitter and returns a copy of it
  12838. * @returns the new emitter
  12839. */
  12840. clone(): MeshParticleEmitter;
  12841. /**
  12842. * Called by the GPUParticleSystem to setup the update shader
  12843. * @param effect defines the update shader
  12844. */
  12845. applyToShader(effect: Effect): void;
  12846. /**
  12847. * Returns a string to use to update the GPU particles update shader
  12848. * @returns a string containng the defines string
  12849. */
  12850. getEffectDefines(): string;
  12851. /**
  12852. * Returns the string "BoxParticleEmitter"
  12853. * @returns a string containing the class name
  12854. */
  12855. getClassName(): string;
  12856. /**
  12857. * Serializes the particle system to a JSON object.
  12858. * @returns the JSON object
  12859. */
  12860. serialize(): any;
  12861. /**
  12862. * Parse properties from a JSON object
  12863. * @param serializationObject defines the JSON object
  12864. * @param scene defines the hosting scene
  12865. */
  12866. parse(serializationObject: any, scene: Scene): void;
  12867. }
  12868. }
  12869. declare module BABYLON {
  12870. /**
  12871. * Interface representing a particle system in Babylon.js.
  12872. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  12873. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  12874. */
  12875. export interface IParticleSystem {
  12876. /**
  12877. * List of animations used by the particle system.
  12878. */
  12879. animations: Animation[];
  12880. /**
  12881. * The id of the Particle system.
  12882. */
  12883. id: string;
  12884. /**
  12885. * The name of the Particle system.
  12886. */
  12887. name: string;
  12888. /**
  12889. * The emitter represents the Mesh or position we are attaching the particle system to.
  12890. */
  12891. emitter: Nullable<AbstractMesh | Vector3>;
  12892. /**
  12893. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  12894. */
  12895. isBillboardBased: boolean;
  12896. /**
  12897. * The rendering group used by the Particle system to chose when to render.
  12898. */
  12899. renderingGroupId: number;
  12900. /**
  12901. * The layer mask we are rendering the particles through.
  12902. */
  12903. layerMask: number;
  12904. /**
  12905. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  12906. */
  12907. updateSpeed: number;
  12908. /**
  12909. * The amount of time the particle system is running (depends of the overall update speed).
  12910. */
  12911. targetStopDuration: number;
  12912. /**
  12913. * The texture used to render each particle. (this can be a spritesheet)
  12914. */
  12915. particleTexture: Nullable<Texture>;
  12916. /**
  12917. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  12918. */
  12919. blendMode: number;
  12920. /**
  12921. * Minimum life time of emitting particles.
  12922. */
  12923. minLifeTime: number;
  12924. /**
  12925. * Maximum life time of emitting particles.
  12926. */
  12927. maxLifeTime: number;
  12928. /**
  12929. * Minimum Size of emitting particles.
  12930. */
  12931. minSize: number;
  12932. /**
  12933. * Maximum Size of emitting particles.
  12934. */
  12935. maxSize: number;
  12936. /**
  12937. * Minimum scale of emitting particles on X axis.
  12938. */
  12939. minScaleX: number;
  12940. /**
  12941. * Maximum scale of emitting particles on X axis.
  12942. */
  12943. maxScaleX: number;
  12944. /**
  12945. * Minimum scale of emitting particles on Y axis.
  12946. */
  12947. minScaleY: number;
  12948. /**
  12949. * Maximum scale of emitting particles on Y axis.
  12950. */
  12951. maxScaleY: number;
  12952. /**
  12953. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  12954. */
  12955. color1: Color4;
  12956. /**
  12957. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  12958. */
  12959. color2: Color4;
  12960. /**
  12961. * Color the particle will have at the end of its lifetime.
  12962. */
  12963. colorDead: Color4;
  12964. /**
  12965. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  12966. */
  12967. emitRate: number;
  12968. /**
  12969. * You can use gravity if you want to give an orientation to your particles.
  12970. */
  12971. gravity: Vector3;
  12972. /**
  12973. * Minimum power of emitting particles.
  12974. */
  12975. minEmitPower: number;
  12976. /**
  12977. * Maximum power of emitting particles.
  12978. */
  12979. maxEmitPower: number;
  12980. /**
  12981. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  12982. */
  12983. minAngularSpeed: number;
  12984. /**
  12985. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  12986. */
  12987. maxAngularSpeed: number;
  12988. /**
  12989. * Gets or sets the minimal initial rotation in radians.
  12990. */
  12991. minInitialRotation: number;
  12992. /**
  12993. * Gets or sets the maximal initial rotation in radians.
  12994. */
  12995. maxInitialRotation: number;
  12996. /**
  12997. * The particle emitter type defines the emitter used by the particle system.
  12998. * It can be for example box, sphere, or cone...
  12999. */
  13000. particleEmitterType: Nullable<IParticleEmitterType>;
  13001. /**
  13002. * Defines the delay in milliseconds before starting the system (0 by default)
  13003. */
  13004. startDelay: number;
  13005. /**
  13006. * Gets or sets a value indicating how many cycles (or frames) must be executed before first rendering (this value has to be set before starting the system). Default is 0
  13007. */
  13008. preWarmCycles: number;
  13009. /**
  13010. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  13011. */
  13012. preWarmStepOffset: number;
  13013. /**
  13014. * If using a spritesheet (isAnimationSheetEnabled) defines the speed of the sprite loop (default is 1 meaning the animation will play once during the entire particle lifetime)
  13015. */
  13016. spriteCellChangeSpeed: number;
  13017. /**
  13018. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  13019. */
  13020. startSpriteCellID: number;
  13021. /**
  13022. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  13023. */
  13024. endSpriteCellID: number;
  13025. /**
  13026. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  13027. */
  13028. spriteCellWidth: number;
  13029. /**
  13030. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  13031. */
  13032. spriteCellHeight: number;
  13033. /**
  13034. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  13035. */
  13036. spriteRandomStartCell: boolean;
  13037. /**
  13038. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  13039. */
  13040. isAnimationSheetEnabled: boolean;
  13041. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  13042. translationPivot: Vector2;
  13043. /**
  13044. * Gets or sets a texture used to add random noise to particle positions
  13045. */
  13046. noiseTexture: Nullable<BaseTexture>;
  13047. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  13048. noiseStrength: Vector3;
  13049. /**
  13050. * Gets or sets the billboard mode to use when isBillboardBased = true.
  13051. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  13052. */
  13053. billboardMode: number;
  13054. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  13055. limitVelocityDamping: number;
  13056. /**
  13057. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  13058. */
  13059. beginAnimationOnStart: boolean;
  13060. /**
  13061. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  13062. */
  13063. beginAnimationFrom: number;
  13064. /**
  13065. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  13066. */
  13067. beginAnimationTo: number;
  13068. /**
  13069. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  13070. */
  13071. beginAnimationLoop: boolean;
  13072. /**
  13073. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  13074. */
  13075. disposeOnStop: boolean;
  13076. /**
  13077. * Gets the maximum number of particles active at the same time.
  13078. * @returns The max number of active particles.
  13079. */
  13080. getCapacity(): number;
  13081. /**
  13082. * Gets if the system has been started. (Note: this will still be true after stop is called)
  13083. * @returns True if it has been started, otherwise false.
  13084. */
  13085. isStarted(): boolean;
  13086. /**
  13087. * Animates the particle system for this frame.
  13088. */
  13089. animate(): void;
  13090. /**
  13091. * Renders the particle system in its current state.
  13092. * @returns the current number of particles
  13093. */
  13094. render(): number;
  13095. /**
  13096. * Dispose the particle system and frees its associated resources.
  13097. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  13098. */
  13099. dispose(disposeTexture?: boolean): void;
  13100. /**
  13101. * Clones the particle system.
  13102. * @param name The name of the cloned object
  13103. * @param newEmitter The new emitter to use
  13104. * @returns the cloned particle system
  13105. */
  13106. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  13107. /**
  13108. * Serializes the particle system to a JSON object.
  13109. * @returns the JSON object
  13110. */
  13111. serialize(): any;
  13112. /**
  13113. * Rebuild the particle system
  13114. */
  13115. rebuild(): void;
  13116. /**
  13117. * Starts the particle system and begins to emit
  13118. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  13119. */
  13120. start(delay?: number): void;
  13121. /**
  13122. * Stops the particle system.
  13123. */
  13124. stop(): void;
  13125. /**
  13126. * Remove all active particles
  13127. */
  13128. reset(): void;
  13129. /**
  13130. * Is this system ready to be used/rendered
  13131. * @return true if the system is ready
  13132. */
  13133. isReady(): boolean;
  13134. /**
  13135. * Adds a new color gradient
  13136. * @param gradient defines the gradient to use (between 0 and 1)
  13137. * @param color1 defines the color to affect to the specified gradient
  13138. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  13139. * @returns the current particle system
  13140. */
  13141. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  13142. /**
  13143. * Remove a specific color gradient
  13144. * @param gradient defines the gradient to remove
  13145. * @returns the current particle system
  13146. */
  13147. removeColorGradient(gradient: number): IParticleSystem;
  13148. /**
  13149. * Adds a new size gradient
  13150. * @param gradient defines the gradient to use (between 0 and 1)
  13151. * @param factor defines the size factor to affect to the specified gradient
  13152. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13153. * @returns the current particle system
  13154. */
  13155. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13156. /**
  13157. * Remove a specific size gradient
  13158. * @param gradient defines the gradient to remove
  13159. * @returns the current particle system
  13160. */
  13161. removeSizeGradient(gradient: number): IParticleSystem;
  13162. /**
  13163. * Gets the current list of color gradients.
  13164. * You must use addColorGradient and removeColorGradient to udpate this list
  13165. * @returns the list of color gradients
  13166. */
  13167. getColorGradients(): Nullable<Array<ColorGradient>>;
  13168. /**
  13169. * Gets the current list of size gradients.
  13170. * You must use addSizeGradient and removeSizeGradient to udpate this list
  13171. * @returns the list of size gradients
  13172. */
  13173. getSizeGradients(): Nullable<Array<FactorGradient>>;
  13174. /**
  13175. * Gets the current list of angular speed gradients.
  13176. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  13177. * @returns the list of angular speed gradients
  13178. */
  13179. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  13180. /**
  13181. * Adds a new angular speed gradient
  13182. * @param gradient defines the gradient to use (between 0 and 1)
  13183. * @param factor defines the angular speed to affect to the specified gradient
  13184. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13185. * @returns the current particle system
  13186. */
  13187. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13188. /**
  13189. * Remove a specific angular speed gradient
  13190. * @param gradient defines the gradient to remove
  13191. * @returns the current particle system
  13192. */
  13193. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  13194. /**
  13195. * Gets the current list of velocity gradients.
  13196. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  13197. * @returns the list of velocity gradients
  13198. */
  13199. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  13200. /**
  13201. * Adds a new velocity gradient
  13202. * @param gradient defines the gradient to use (between 0 and 1)
  13203. * @param factor defines the velocity to affect to the specified gradient
  13204. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13205. * @returns the current particle system
  13206. */
  13207. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13208. /**
  13209. * Remove a specific velocity gradient
  13210. * @param gradient defines the gradient to remove
  13211. * @returns the current particle system
  13212. */
  13213. removeVelocityGradient(gradient: number): IParticleSystem;
  13214. /**
  13215. * Gets the current list of limit velocity gradients.
  13216. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  13217. * @returns the list of limit velocity gradients
  13218. */
  13219. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  13220. /**
  13221. * Adds a new limit velocity gradient
  13222. * @param gradient defines the gradient to use (between 0 and 1)
  13223. * @param factor defines the limit velocity to affect to the specified gradient
  13224. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13225. * @returns the current particle system
  13226. */
  13227. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13228. /**
  13229. * Remove a specific limit velocity gradient
  13230. * @param gradient defines the gradient to remove
  13231. * @returns the current particle system
  13232. */
  13233. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  13234. /**
  13235. * Adds a new drag gradient
  13236. * @param gradient defines the gradient to use (between 0 and 1)
  13237. * @param factor defines the drag to affect to the specified gradient
  13238. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13239. * @returns the current particle system
  13240. */
  13241. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13242. /**
  13243. * Remove a specific drag gradient
  13244. * @param gradient defines the gradient to remove
  13245. * @returns the current particle system
  13246. */
  13247. removeDragGradient(gradient: number): IParticleSystem;
  13248. /**
  13249. * Gets the current list of drag gradients.
  13250. * You must use addDragGradient and removeDragGradient to udpate this list
  13251. * @returns the list of drag gradients
  13252. */
  13253. getDragGradients(): Nullable<Array<FactorGradient>>;
  13254. /**
  13255. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  13256. * @param gradient defines the gradient to use (between 0 and 1)
  13257. * @param factor defines the emit rate to affect to the specified gradient
  13258. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13259. * @returns the current particle system
  13260. */
  13261. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13262. /**
  13263. * Remove a specific emit rate gradient
  13264. * @param gradient defines the gradient to remove
  13265. * @returns the current particle system
  13266. */
  13267. removeEmitRateGradient(gradient: number): IParticleSystem;
  13268. /**
  13269. * Gets the current list of emit rate gradients.
  13270. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  13271. * @returns the list of emit rate gradients
  13272. */
  13273. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  13274. /**
  13275. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  13276. * @param gradient defines the gradient to use (between 0 and 1)
  13277. * @param factor defines the start size to affect to the specified gradient
  13278. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13279. * @returns the current particle system
  13280. */
  13281. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13282. /**
  13283. * Remove a specific start size gradient
  13284. * @param gradient defines the gradient to remove
  13285. * @returns the current particle system
  13286. */
  13287. removeStartSizeGradient(gradient: number): IParticleSystem;
  13288. /**
  13289. * Gets the current list of start size gradients.
  13290. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  13291. * @returns the list of start size gradients
  13292. */
  13293. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  13294. /**
  13295. * Adds a new life time gradient
  13296. * @param gradient defines the gradient to use (between 0 and 1)
  13297. * @param factor defines the life time factor to affect to the specified gradient
  13298. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13299. * @returns the current particle system
  13300. */
  13301. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13302. /**
  13303. * Remove a specific life time gradient
  13304. * @param gradient defines the gradient to remove
  13305. * @returns the current particle system
  13306. */
  13307. removeLifeTimeGradient(gradient: number): IParticleSystem;
  13308. /**
  13309. * Gets the current list of life time gradients.
  13310. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  13311. * @returns the list of life time gradients
  13312. */
  13313. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  13314. /**
  13315. * Gets the current list of color gradients.
  13316. * You must use addColorGradient and removeColorGradient to udpate this list
  13317. * @returns the list of color gradients
  13318. */
  13319. getColorGradients(): Nullable<Array<ColorGradient>>;
  13320. /**
  13321. * Adds a new ramp gradient used to remap particle colors
  13322. * @param gradient defines the gradient to use (between 0 and 1)
  13323. * @param color defines the color to affect to the specified gradient
  13324. * @returns the current particle system
  13325. */
  13326. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  13327. /**
  13328. * Gets the current list of ramp gradients.
  13329. * You must use addRampGradient and removeRampGradient to udpate this list
  13330. * @returns the list of ramp gradients
  13331. */
  13332. getRampGradients(): Nullable<Array<Color3Gradient>>;
  13333. /** Gets or sets a boolean indicating that ramp gradients must be used
  13334. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  13335. */
  13336. useRampGradients: boolean;
  13337. /**
  13338. * Adds a new color remap gradient
  13339. * @param gradient defines the gradient to use (between 0 and 1)
  13340. * @param min defines the color remap minimal range
  13341. * @param max defines the color remap maximal range
  13342. * @returns the current particle system
  13343. */
  13344. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  13345. /**
  13346. * Gets the current list of color remap gradients.
  13347. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  13348. * @returns the list of color remap gradients
  13349. */
  13350. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  13351. /**
  13352. * Adds a new alpha remap gradient
  13353. * @param gradient defines the gradient to use (between 0 and 1)
  13354. * @param min defines the alpha remap minimal range
  13355. * @param max defines the alpha remap maximal range
  13356. * @returns the current particle system
  13357. */
  13358. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  13359. /**
  13360. * Gets the current list of alpha remap gradients.
  13361. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  13362. * @returns the list of alpha remap gradients
  13363. */
  13364. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  13365. /**
  13366. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  13367. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  13368. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  13369. * @returns the emitter
  13370. */
  13371. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  13372. /**
  13373. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  13374. * @param radius The radius of the hemisphere to emit from
  13375. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  13376. * @returns the emitter
  13377. */
  13378. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  13379. /**
  13380. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  13381. * @param radius The radius of the sphere to emit from
  13382. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  13383. * @returns the emitter
  13384. */
  13385. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  13386. /**
  13387. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  13388. * @param radius The radius of the sphere to emit from
  13389. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  13390. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  13391. * @returns the emitter
  13392. */
  13393. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  13394. /**
  13395. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  13396. * @param radius The radius of the emission cylinder
  13397. * @param height The height of the emission cylinder
  13398. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  13399. * @param directionRandomizer How much to randomize the particle direction [0-1]
  13400. * @returns the emitter
  13401. */
  13402. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  13403. /**
  13404. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  13405. * @param radius The radius of the cylinder to emit from
  13406. * @param height The height of the emission cylinder
  13407. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13408. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  13409. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  13410. * @returns the emitter
  13411. */
  13412. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  13413. /**
  13414. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  13415. * @param radius The radius of the cone to emit from
  13416. * @param angle The base angle of the cone
  13417. * @returns the emitter
  13418. */
  13419. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  13420. /**
  13421. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  13422. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  13423. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  13424. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  13425. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  13426. * @returns the emitter
  13427. */
  13428. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  13429. /**
  13430. * Get hosting scene
  13431. * @returns the scene
  13432. */
  13433. getScene(): Scene;
  13434. }
  13435. }
  13436. declare module BABYLON {
  13437. /**
  13438. * A TransformNode is an object that is not rendered but can be used as a center of transformation. This can decrease memory usage and increase rendering speed compared to using an empty mesh as a parent and is less complicated than using a pivot matrix.
  13439. * @see https://doc.babylonjs.com/how_to/transformnode
  13440. */
  13441. export class TransformNode extends Node {
  13442. /**
  13443. * Object will not rotate to face the camera
  13444. */
  13445. static BILLBOARDMODE_NONE: number;
  13446. /**
  13447. * Object will rotate to face the camera but only on the x axis
  13448. */
  13449. static BILLBOARDMODE_X: number;
  13450. /**
  13451. * Object will rotate to face the camera but only on the y axis
  13452. */
  13453. static BILLBOARDMODE_Y: number;
  13454. /**
  13455. * Object will rotate to face the camera but only on the z axis
  13456. */
  13457. static BILLBOARDMODE_Z: number;
  13458. /**
  13459. * Object will rotate to face the camera
  13460. */
  13461. static BILLBOARDMODE_ALL: number;
  13462. /**
  13463. * Object will rotate to face the camera's position instead of orientation
  13464. */
  13465. static BILLBOARDMODE_USE_POSITION: number;
  13466. private _forward;
  13467. private _forwardInverted;
  13468. private _up;
  13469. private _right;
  13470. private _rightInverted;
  13471. private _position;
  13472. private _rotation;
  13473. private _rotationQuaternion;
  13474. protected _scaling: Vector3;
  13475. protected _isDirty: boolean;
  13476. private _transformToBoneReferal;
  13477. private _isAbsoluteSynced;
  13478. private _billboardMode;
  13479. /**
  13480. * Gets or sets the billboard mode. Default is 0.
  13481. *
  13482. * | Value | Type | Description |
  13483. * | --- | --- | --- |
  13484. * | 0 | BILLBOARDMODE_NONE | |
  13485. * | 1 | BILLBOARDMODE_X | |
  13486. * | 2 | BILLBOARDMODE_Y | |
  13487. * | 4 | BILLBOARDMODE_Z | |
  13488. * | 7 | BILLBOARDMODE_ALL | |
  13489. *
  13490. */
  13491. get billboardMode(): number;
  13492. set billboardMode(value: number);
  13493. private _preserveParentRotationForBillboard;
  13494. /**
  13495. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  13496. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  13497. */
  13498. get preserveParentRotationForBillboard(): boolean;
  13499. set preserveParentRotationForBillboard(value: boolean);
  13500. /**
  13501. * Multiplication factor on scale x/y/z when computing the world matrix. Eg. for a 1x1x1 cube setting this to 2 will make it a 2x2x2 cube
  13502. */
  13503. scalingDeterminant: number;
  13504. private _infiniteDistance;
  13505. /**
  13506. * Gets or sets the distance of the object to max, often used by skybox
  13507. */
  13508. get infiniteDistance(): boolean;
  13509. set infiniteDistance(value: boolean);
  13510. /**
  13511. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  13512. * By default the system will update normals to compensate
  13513. */
  13514. ignoreNonUniformScaling: boolean;
  13515. /**
  13516. * Gets or sets a boolean indicating that even if rotationQuaternion is defined, you can keep updating rotation property and Babylon.js will just mix both
  13517. */
  13518. reIntegrateRotationIntoRotationQuaternion: boolean;
  13519. /** @hidden */
  13520. _poseMatrix: Nullable<Matrix>;
  13521. /** @hidden */
  13522. _localMatrix: Matrix;
  13523. private _usePivotMatrix;
  13524. private _absolutePosition;
  13525. private _absoluteScaling;
  13526. private _absoluteRotationQuaternion;
  13527. private _pivotMatrix;
  13528. private _pivotMatrixInverse;
  13529. protected _postMultiplyPivotMatrix: boolean;
  13530. protected _isWorldMatrixFrozen: boolean;
  13531. /** @hidden */
  13532. _indexInSceneTransformNodesArray: number;
  13533. /**
  13534. * An event triggered after the world matrix is updated
  13535. */
  13536. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  13537. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  13538. /**
  13539. * Gets a string identifying the name of the class
  13540. * @returns "TransformNode" string
  13541. */
  13542. getClassName(): string;
  13543. /**
  13544. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  13545. */
  13546. get position(): Vector3;
  13547. set position(newPosition: Vector3);
  13548. /**
  13549. * Gets or sets the rotation property : a Vector3 defining the rotation value in radians around each local axis X, Y, Z (default is (0.0, 0.0, 0.0)).
  13550. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  13551. */
  13552. get rotation(): Vector3;
  13553. set rotation(newRotation: Vector3);
  13554. /**
  13555. * Gets or sets the scaling property : a Vector3 defining the node scaling along each local axis X, Y, Z (default is (0.0, 0.0, 0.0)).
  13556. */
  13557. get scaling(): Vector3;
  13558. set scaling(newScaling: Vector3);
  13559. /**
  13560. * Gets or sets the rotation Quaternion property : this a Quaternion object defining the node rotation by using a unit quaternion (undefined by default, but can be null).
  13561. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  13562. */
  13563. get rotationQuaternion(): Nullable<Quaternion>;
  13564. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  13565. /**
  13566. * The forward direction of that transform in world space.
  13567. */
  13568. get forward(): Vector3;
  13569. /**
  13570. * The up direction of that transform in world space.
  13571. */
  13572. get up(): Vector3;
  13573. /**
  13574. * The right direction of that transform in world space.
  13575. */
  13576. get right(): Vector3;
  13577. /**
  13578. * Copies the parameter passed Matrix into the mesh Pose matrix.
  13579. * @param matrix the matrix to copy the pose from
  13580. * @returns this TransformNode.
  13581. */
  13582. updatePoseMatrix(matrix: Matrix): TransformNode;
  13583. /**
  13584. * Returns the mesh Pose matrix.
  13585. * @returns the pose matrix
  13586. */
  13587. getPoseMatrix(): Matrix;
  13588. /** @hidden */
  13589. _isSynchronized(): boolean;
  13590. /** @hidden */
  13591. _initCache(): void;
  13592. /**
  13593. * Flag the transform node as dirty (Forcing it to update everything)
  13594. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  13595. * @returns this transform node
  13596. */
  13597. markAsDirty(property: string): TransformNode;
  13598. /**
  13599. * Returns the current mesh absolute position.
  13600. * Returns a Vector3.
  13601. */
  13602. get absolutePosition(): Vector3;
  13603. /**
  13604. * Returns the current mesh absolute scaling.
  13605. * Returns a Vector3.
  13606. */
  13607. get absoluteScaling(): Vector3;
  13608. /**
  13609. * Returns the current mesh absolute rotation.
  13610. * Returns a Quaternion.
  13611. */
  13612. get absoluteRotationQuaternion(): Quaternion;
  13613. /**
  13614. * Sets a new matrix to apply before all other transformation
  13615. * @param matrix defines the transform matrix
  13616. * @returns the current TransformNode
  13617. */
  13618. setPreTransformMatrix(matrix: Matrix): TransformNode;
  13619. /**
  13620. * Sets a new pivot matrix to the current node
  13621. * @param matrix defines the new pivot matrix to use
  13622. * @param postMultiplyPivotMatrix defines if the pivot matrix must be cancelled in the world matrix. When this parameter is set to true (default), the inverse of the pivot matrix is also applied at the end to cancel the transformation effect
  13623. * @returns the current TransformNode
  13624. */
  13625. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  13626. /**
  13627. * Returns the mesh pivot matrix.
  13628. * Default : Identity.
  13629. * @returns the matrix
  13630. */
  13631. getPivotMatrix(): Matrix;
  13632. /**
  13633. * Instantiate (when possible) or clone that node with its hierarchy
  13634. * @param newParent defines the new parent to use for the instance (or clone)
  13635. * @param options defines options to configure how copy is done
  13636. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  13637. * @returns an instance (or a clone) of the current node with its hiearchy
  13638. */
  13639. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  13640. doNotInstantiate: boolean;
  13641. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  13642. /**
  13643. * Prevents the World matrix to be computed any longer
  13644. * @param newWorldMatrix defines an optional matrix to use as world matrix
  13645. * @returns the TransformNode.
  13646. */
  13647. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  13648. /**
  13649. * Allows back the World matrix computation.
  13650. * @returns the TransformNode.
  13651. */
  13652. unfreezeWorldMatrix(): this;
  13653. /**
  13654. * True if the World matrix has been frozen.
  13655. */
  13656. get isWorldMatrixFrozen(): boolean;
  13657. /**
  13658. * Retuns the mesh absolute position in the World.
  13659. * @returns a Vector3.
  13660. */
  13661. getAbsolutePosition(): Vector3;
  13662. /**
  13663. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  13664. * @param absolutePosition the absolute position to set
  13665. * @returns the TransformNode.
  13666. */
  13667. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  13668. /**
  13669. * Sets the mesh position in its local space.
  13670. * @param vector3 the position to set in localspace
  13671. * @returns the TransformNode.
  13672. */
  13673. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  13674. /**
  13675. * Returns the mesh position in the local space from the current World matrix values.
  13676. * @returns a new Vector3.
  13677. */
  13678. getPositionExpressedInLocalSpace(): Vector3;
  13679. /**
  13680. * Translates the mesh along the passed Vector3 in its local space.
  13681. * @param vector3 the distance to translate in localspace
  13682. * @returns the TransformNode.
  13683. */
  13684. locallyTranslate(vector3: Vector3): TransformNode;
  13685. private static _lookAtVectorCache;
  13686. /**
  13687. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  13688. * @param targetPoint the position (must be in same space as current mesh) to look at
  13689. * @param yawCor optional yaw (y-axis) correction in radians
  13690. * @param pitchCor optional pitch (x-axis) correction in radians
  13691. * @param rollCor optional roll (z-axis) correction in radians
  13692. * @param space the choosen space of the target
  13693. * @returns the TransformNode.
  13694. */
  13695. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  13696. /**
  13697. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  13698. * This Vector3 is expressed in the World space.
  13699. * @param localAxis axis to rotate
  13700. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  13701. */
  13702. getDirection(localAxis: Vector3): Vector3;
  13703. /**
  13704. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  13705. * localAxis is expressed in the mesh local space.
  13706. * result is computed in the Wordl space from the mesh World matrix.
  13707. * @param localAxis axis to rotate
  13708. * @param result the resulting transformnode
  13709. * @returns this TransformNode.
  13710. */
  13711. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  13712. /**
  13713. * Sets this transform node rotation to the given local axis.
  13714. * @param localAxis the axis in local space
  13715. * @param yawCor optional yaw (y-axis) correction in radians
  13716. * @param pitchCor optional pitch (x-axis) correction in radians
  13717. * @param rollCor optional roll (z-axis) correction in radians
  13718. * @returns this TransformNode
  13719. */
  13720. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  13721. /**
  13722. * Sets a new pivot point to the current node
  13723. * @param point defines the new pivot point to use
  13724. * @param space defines if the point is in world or local space (local by default)
  13725. * @returns the current TransformNode
  13726. */
  13727. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  13728. /**
  13729. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  13730. * @returns the pivot point
  13731. */
  13732. getPivotPoint(): Vector3;
  13733. /**
  13734. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  13735. * @param result the vector3 to store the result
  13736. * @returns this TransformNode.
  13737. */
  13738. getPivotPointToRef(result: Vector3): TransformNode;
  13739. /**
  13740. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  13741. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  13742. */
  13743. getAbsolutePivotPoint(): Vector3;
  13744. /**
  13745. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  13746. * @param result vector3 to store the result
  13747. * @returns this TransformNode.
  13748. */
  13749. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  13750. /**
  13751. * Defines the passed node as the parent of the current node.
  13752. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  13753. * @see https://doc.babylonjs.com/how_to/parenting
  13754. * @param node the node ot set as the parent
  13755. * @returns this TransformNode.
  13756. */
  13757. setParent(node: Nullable<Node>): TransformNode;
  13758. private _nonUniformScaling;
  13759. /**
  13760. * True if the scaling property of this object is non uniform eg. (1,2,1)
  13761. */
  13762. get nonUniformScaling(): boolean;
  13763. /** @hidden */
  13764. _updateNonUniformScalingState(value: boolean): boolean;
  13765. /**
  13766. * Attach the current TransformNode to another TransformNode associated with a bone
  13767. * @param bone Bone affecting the TransformNode
  13768. * @param affectedTransformNode TransformNode associated with the bone
  13769. * @returns this object
  13770. */
  13771. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  13772. /**
  13773. * Detach the transform node if its associated with a bone
  13774. * @returns this object
  13775. */
  13776. detachFromBone(): TransformNode;
  13777. private static _rotationAxisCache;
  13778. /**
  13779. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  13780. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  13781. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  13782. * The passed axis is also normalized.
  13783. * @param axis the axis to rotate around
  13784. * @param amount the amount to rotate in radians
  13785. * @param space Space to rotate in (Default: local)
  13786. * @returns the TransformNode.
  13787. */
  13788. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  13789. /**
  13790. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  13791. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  13792. * The passed axis is also normalized. .
  13793. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  13794. * @param point the point to rotate around
  13795. * @param axis the axis to rotate around
  13796. * @param amount the amount to rotate in radians
  13797. * @returns the TransformNode
  13798. */
  13799. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  13800. /**
  13801. * Translates the mesh along the axis vector for the passed distance in the given space.
  13802. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  13803. * @param axis the axis to translate in
  13804. * @param distance the distance to translate
  13805. * @param space Space to rotate in (Default: local)
  13806. * @returns the TransformNode.
  13807. */
  13808. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  13809. /**
  13810. * Adds a rotation step to the mesh current rotation.
  13811. * x, y, z are Euler angles expressed in radians.
  13812. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  13813. * This means this rotation is made in the mesh local space only.
  13814. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  13815. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  13816. * ```javascript
  13817. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  13818. * ```
  13819. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  13820. * Under the hood, only quaternions are used. So it's a little faster is you use .rotationQuaternion because it doesn't need to translate them back to Euler angles.
  13821. * @param x Rotation to add
  13822. * @param y Rotation to add
  13823. * @param z Rotation to add
  13824. * @returns the TransformNode.
  13825. */
  13826. addRotation(x: number, y: number, z: number): TransformNode;
  13827. /**
  13828. * @hidden
  13829. */
  13830. protected _getEffectiveParent(): Nullable<Node>;
  13831. /**
  13832. * Computes the world matrix of the node
  13833. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  13834. * @returns the world matrix
  13835. */
  13836. computeWorldMatrix(force?: boolean): Matrix;
  13837. /**
  13838. * Resets this nodeTransform's local matrix to Matrix.Identity().
  13839. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  13840. */
  13841. resetLocalMatrix(independentOfChildren?: boolean): void;
  13842. protected _afterComputeWorldMatrix(): void;
  13843. /**
  13844. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  13845. * @param func callback function to add
  13846. *
  13847. * @returns the TransformNode.
  13848. */
  13849. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  13850. /**
  13851. * Removes a registered callback function.
  13852. * @param func callback function to remove
  13853. * @returns the TransformNode.
  13854. */
  13855. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  13856. /**
  13857. * Gets the position of the current mesh in camera space
  13858. * @param camera defines the camera to use
  13859. * @returns a position
  13860. */
  13861. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  13862. /**
  13863. * Returns the distance from the mesh to the active camera
  13864. * @param camera defines the camera to use
  13865. * @returns the distance
  13866. */
  13867. getDistanceToCamera(camera?: Nullable<Camera>): number;
  13868. /**
  13869. * Clone the current transform node
  13870. * @param name Name of the new clone
  13871. * @param newParent New parent for the clone
  13872. * @param doNotCloneChildren Do not clone children hierarchy
  13873. * @returns the new transform node
  13874. */
  13875. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  13876. /**
  13877. * Serializes the objects information.
  13878. * @param currentSerializationObject defines the object to serialize in
  13879. * @returns the serialized object
  13880. */
  13881. serialize(currentSerializationObject?: any): any;
  13882. /**
  13883. * Returns a new TransformNode object parsed from the source provided.
  13884. * @param parsedTransformNode is the source.
  13885. * @param scene the scne the object belongs to
  13886. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  13887. * @returns a new TransformNode object parsed from the source provided.
  13888. */
  13889. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  13890. /**
  13891. * Get all child-transformNodes of this node
  13892. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered
  13893. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  13894. * @returns an array of TransformNode
  13895. */
  13896. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  13897. /**
  13898. * Releases resources associated with this transform node.
  13899. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  13900. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  13901. */
  13902. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  13903. /**
  13904. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  13905. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  13906. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  13907. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  13908. * @returns the current mesh
  13909. */
  13910. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  13911. private _syncAbsoluteScalingAndRotation;
  13912. }
  13913. }
  13914. declare module BABYLON {
  13915. /**
  13916. * Class used to override all child animations of a given target
  13917. */
  13918. export class AnimationPropertiesOverride {
  13919. /**
  13920. * Gets or sets a value indicating if animation blending must be used
  13921. */
  13922. enableBlending: boolean;
  13923. /**
  13924. * Gets or sets the blending speed to use when enableBlending is true
  13925. */
  13926. blendingSpeed: number;
  13927. /**
  13928. * Gets or sets the default loop mode to use
  13929. */
  13930. loopMode: number;
  13931. }
  13932. }
  13933. declare module BABYLON {
  13934. /**
  13935. * Class used to store bone information
  13936. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13937. */
  13938. export class Bone extends Node {
  13939. /**
  13940. * defines the bone name
  13941. */
  13942. name: string;
  13943. private static _tmpVecs;
  13944. private static _tmpQuat;
  13945. private static _tmpMats;
  13946. /**
  13947. * Gets the list of child bones
  13948. */
  13949. children: Bone[];
  13950. /** Gets the animations associated with this bone */
  13951. animations: Animation[];
  13952. /**
  13953. * Gets or sets bone length
  13954. */
  13955. length: number;
  13956. /**
  13957. * @hidden Internal only
  13958. * Set this value to map this bone to a different index in the transform matrices
  13959. * Set this value to -1 to exclude the bone from the transform matrices
  13960. */
  13961. _index: Nullable<number>;
  13962. private _skeleton;
  13963. private _localMatrix;
  13964. private _restPose;
  13965. private _baseMatrix;
  13966. private _absoluteTransform;
  13967. private _invertedAbsoluteTransform;
  13968. private _parent;
  13969. private _scalingDeterminant;
  13970. private _worldTransform;
  13971. private _localScaling;
  13972. private _localRotation;
  13973. private _localPosition;
  13974. private _needToDecompose;
  13975. private _needToCompose;
  13976. /** @hidden */
  13977. _linkedTransformNode: Nullable<TransformNode>;
  13978. /** @hidden */
  13979. _waitingTransformNodeId: Nullable<string>;
  13980. /** @hidden */
  13981. get _matrix(): Matrix;
  13982. /** @hidden */
  13983. set _matrix(value: Matrix);
  13984. /**
  13985. * Create a new bone
  13986. * @param name defines the bone name
  13987. * @param skeleton defines the parent skeleton
  13988. * @param parentBone defines the parent (can be null if the bone is the root)
  13989. * @param localMatrix defines the local matrix
  13990. * @param restPose defines the rest pose matrix
  13991. * @param baseMatrix defines the base matrix
  13992. * @param index defines index of the bone in the hiearchy
  13993. */
  13994. constructor(
  13995. /**
  13996. * defines the bone name
  13997. */
  13998. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  13999. /**
  14000. * Gets the current object class name.
  14001. * @return the class name
  14002. */
  14003. getClassName(): string;
  14004. /**
  14005. * Gets the parent skeleton
  14006. * @returns a skeleton
  14007. */
  14008. getSkeleton(): Skeleton;
  14009. /**
  14010. * Gets parent bone
  14011. * @returns a bone or null if the bone is the root of the bone hierarchy
  14012. */
  14013. getParent(): Nullable<Bone>;
  14014. /**
  14015. * Returns an array containing the root bones
  14016. * @returns an array containing the root bones
  14017. */
  14018. getChildren(): Array<Bone>;
  14019. /**
  14020. * Gets the node index in matrix array generated for rendering
  14021. * @returns the node index
  14022. */
  14023. getIndex(): number;
  14024. /**
  14025. * Sets the parent bone
  14026. * @param parent defines the parent (can be null if the bone is the root)
  14027. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  14028. */
  14029. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  14030. /**
  14031. * Gets the local matrix
  14032. * @returns a matrix
  14033. */
  14034. getLocalMatrix(): Matrix;
  14035. /**
  14036. * Gets the base matrix (initial matrix which remains unchanged)
  14037. * @returns a matrix
  14038. */
  14039. getBaseMatrix(): Matrix;
  14040. /**
  14041. * Gets the rest pose matrix
  14042. * @returns a matrix
  14043. */
  14044. getRestPose(): Matrix;
  14045. /**
  14046. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  14047. */
  14048. getWorldMatrix(): Matrix;
  14049. /**
  14050. * Sets the local matrix to rest pose matrix
  14051. */
  14052. returnToRest(): void;
  14053. /**
  14054. * Gets the inverse of the absolute transform matrix.
  14055. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  14056. * @returns a matrix
  14057. */
  14058. getInvertedAbsoluteTransform(): Matrix;
  14059. /**
  14060. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  14061. * @returns a matrix
  14062. */
  14063. getAbsoluteTransform(): Matrix;
  14064. /**
  14065. * Links with the given transform node.
  14066. * The local matrix of this bone is copied from the transform node every frame.
  14067. * @param transformNode defines the transform node to link to
  14068. */
  14069. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  14070. /**
  14071. * Gets the node used to drive the bone's transformation
  14072. * @returns a transform node or null
  14073. */
  14074. getTransformNode(): Nullable<TransformNode>;
  14075. /** Gets or sets current position (in local space) */
  14076. get position(): Vector3;
  14077. set position(newPosition: Vector3);
  14078. /** Gets or sets current rotation (in local space) */
  14079. get rotation(): Vector3;
  14080. set rotation(newRotation: Vector3);
  14081. /** Gets or sets current rotation quaternion (in local space) */
  14082. get rotationQuaternion(): Quaternion;
  14083. set rotationQuaternion(newRotation: Quaternion);
  14084. /** Gets or sets current scaling (in local space) */
  14085. get scaling(): Vector3;
  14086. set scaling(newScaling: Vector3);
  14087. /**
  14088. * Gets the animation properties override
  14089. */
  14090. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  14091. private _decompose;
  14092. private _compose;
  14093. /**
  14094. * Update the base and local matrices
  14095. * @param matrix defines the new base or local matrix
  14096. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  14097. * @param updateLocalMatrix defines if the local matrix should be updated
  14098. */
  14099. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  14100. /** @hidden */
  14101. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  14102. /**
  14103. * Flag the bone as dirty (Forcing it to update everything)
  14104. */
  14105. markAsDirty(): void;
  14106. /** @hidden */
  14107. _markAsDirtyAndCompose(): void;
  14108. private _markAsDirtyAndDecompose;
  14109. /**
  14110. * Translate the bone in local or world space
  14111. * @param vec The amount to translate the bone
  14112. * @param space The space that the translation is in
  14113. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14114. */
  14115. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14116. /**
  14117. * Set the postion of the bone in local or world space
  14118. * @param position The position to set the bone
  14119. * @param space The space that the position is in
  14120. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14121. */
  14122. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14123. /**
  14124. * Set the absolute position of the bone (world space)
  14125. * @param position The position to set the bone
  14126. * @param mesh The mesh that this bone is attached to
  14127. */
  14128. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  14129. /**
  14130. * Scale the bone on the x, y and z axes (in local space)
  14131. * @param x The amount to scale the bone on the x axis
  14132. * @param y The amount to scale the bone on the y axis
  14133. * @param z The amount to scale the bone on the z axis
  14134. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  14135. */
  14136. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  14137. /**
  14138. * Set the bone scaling in local space
  14139. * @param scale defines the scaling vector
  14140. */
  14141. setScale(scale: Vector3): void;
  14142. /**
  14143. * Gets the current scaling in local space
  14144. * @returns the current scaling vector
  14145. */
  14146. getScale(): Vector3;
  14147. /**
  14148. * Gets the current scaling in local space and stores it in a target vector
  14149. * @param result defines the target vector
  14150. */
  14151. getScaleToRef(result: Vector3): void;
  14152. /**
  14153. * Set the yaw, pitch, and roll of the bone in local or world space
  14154. * @param yaw The rotation of the bone on the y axis
  14155. * @param pitch The rotation of the bone on the x axis
  14156. * @param roll The rotation of the bone on the z axis
  14157. * @param space The space that the axes of rotation are in
  14158. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14159. */
  14160. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  14161. /**
  14162. * Add a rotation to the bone on an axis in local or world space
  14163. * @param axis The axis to rotate the bone on
  14164. * @param amount The amount to rotate the bone
  14165. * @param space The space that the axis is in
  14166. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14167. */
  14168. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  14169. /**
  14170. * Set the rotation of the bone to a particular axis angle in local or world space
  14171. * @param axis The axis to rotate the bone on
  14172. * @param angle The angle that the bone should be rotated to
  14173. * @param space The space that the axis is in
  14174. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14175. */
  14176. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  14177. /**
  14178. * Set the euler rotation of the bone in local of world space
  14179. * @param rotation The euler rotation that the bone should be set to
  14180. * @param space The space that the rotation is in
  14181. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14182. */
  14183. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14184. /**
  14185. * Set the quaternion rotation of the bone in local of world space
  14186. * @param quat The quaternion rotation that the bone should be set to
  14187. * @param space The space that the rotation is in
  14188. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14189. */
  14190. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  14191. /**
  14192. * Set the rotation matrix of the bone in local of world space
  14193. * @param rotMat The rotation matrix that the bone should be set to
  14194. * @param space The space that the rotation is in
  14195. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14196. */
  14197. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  14198. private _rotateWithMatrix;
  14199. private _getNegativeRotationToRef;
  14200. /**
  14201. * Get the position of the bone in local or world space
  14202. * @param space The space that the returned position is in
  14203. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14204. * @returns The position of the bone
  14205. */
  14206. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14207. /**
  14208. * Copy the position of the bone to a vector3 in local or world space
  14209. * @param space The space that the returned position is in
  14210. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14211. * @param result The vector3 to copy the position to
  14212. */
  14213. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  14214. /**
  14215. * Get the absolute position of the bone (world space)
  14216. * @param mesh The mesh that this bone is attached to
  14217. * @returns The absolute position of the bone
  14218. */
  14219. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  14220. /**
  14221. * Copy the absolute position of the bone (world space) to the result param
  14222. * @param mesh The mesh that this bone is attached to
  14223. * @param result The vector3 to copy the absolute position to
  14224. */
  14225. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  14226. /**
  14227. * Compute the absolute transforms of this bone and its children
  14228. */
  14229. computeAbsoluteTransforms(): void;
  14230. /**
  14231. * Get the world direction from an axis that is in the local space of the bone
  14232. * @param localAxis The local direction that is used to compute the world direction
  14233. * @param mesh The mesh that this bone is attached to
  14234. * @returns The world direction
  14235. */
  14236. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14237. /**
  14238. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  14239. * @param localAxis The local direction that is used to compute the world direction
  14240. * @param mesh The mesh that this bone is attached to
  14241. * @param result The vector3 that the world direction will be copied to
  14242. */
  14243. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14244. /**
  14245. * Get the euler rotation of the bone in local or world space
  14246. * @param space The space that the rotation should be in
  14247. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14248. * @returns The euler rotation
  14249. */
  14250. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14251. /**
  14252. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  14253. * @param space The space that the rotation should be in
  14254. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14255. * @param result The vector3 that the rotation should be copied to
  14256. */
  14257. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14258. /**
  14259. * Get the quaternion rotation of the bone in either local or world space
  14260. * @param space The space that the rotation should be in
  14261. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14262. * @returns The quaternion rotation
  14263. */
  14264. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  14265. /**
  14266. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  14267. * @param space The space that the rotation should be in
  14268. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14269. * @param result The quaternion that the rotation should be copied to
  14270. */
  14271. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  14272. /**
  14273. * Get the rotation matrix of the bone in local or world space
  14274. * @param space The space that the rotation should be in
  14275. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14276. * @returns The rotation matrix
  14277. */
  14278. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  14279. /**
  14280. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  14281. * @param space The space that the rotation should be in
  14282. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14283. * @param result The quaternion that the rotation should be copied to
  14284. */
  14285. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  14286. /**
  14287. * Get the world position of a point that is in the local space of the bone
  14288. * @param position The local position
  14289. * @param mesh The mesh that this bone is attached to
  14290. * @returns The world position
  14291. */
  14292. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14293. /**
  14294. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  14295. * @param position The local position
  14296. * @param mesh The mesh that this bone is attached to
  14297. * @param result The vector3 that the world position should be copied to
  14298. */
  14299. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14300. /**
  14301. * Get the local position of a point that is in world space
  14302. * @param position The world position
  14303. * @param mesh The mesh that this bone is attached to
  14304. * @returns The local position
  14305. */
  14306. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14307. /**
  14308. * Get the local position of a point that is in world space and copy it to the result param
  14309. * @param position The world position
  14310. * @param mesh The mesh that this bone is attached to
  14311. * @param result The vector3 that the local position should be copied to
  14312. */
  14313. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14314. }
  14315. }
  14316. declare module BABYLON {
  14317. /**
  14318. * Defines a runtime animation
  14319. */
  14320. export class RuntimeAnimation {
  14321. private _events;
  14322. /**
  14323. * The current frame of the runtime animation
  14324. */
  14325. private _currentFrame;
  14326. /**
  14327. * The animation used by the runtime animation
  14328. */
  14329. private _animation;
  14330. /**
  14331. * The target of the runtime animation
  14332. */
  14333. private _target;
  14334. /**
  14335. * The initiating animatable
  14336. */
  14337. private _host;
  14338. /**
  14339. * The original value of the runtime animation
  14340. */
  14341. private _originalValue;
  14342. /**
  14343. * The original blend value of the runtime animation
  14344. */
  14345. private _originalBlendValue;
  14346. /**
  14347. * The offsets cache of the runtime animation
  14348. */
  14349. private _offsetsCache;
  14350. /**
  14351. * The high limits cache of the runtime animation
  14352. */
  14353. private _highLimitsCache;
  14354. /**
  14355. * Specifies if the runtime animation has been stopped
  14356. */
  14357. private _stopped;
  14358. /**
  14359. * The blending factor of the runtime animation
  14360. */
  14361. private _blendingFactor;
  14362. /**
  14363. * The BabylonJS scene
  14364. */
  14365. private _scene;
  14366. /**
  14367. * The current value of the runtime animation
  14368. */
  14369. private _currentValue;
  14370. /** @hidden */
  14371. _animationState: _IAnimationState;
  14372. /**
  14373. * The active target of the runtime animation
  14374. */
  14375. private _activeTargets;
  14376. private _currentActiveTarget;
  14377. private _directTarget;
  14378. /**
  14379. * The target path of the runtime animation
  14380. */
  14381. private _targetPath;
  14382. /**
  14383. * The weight of the runtime animation
  14384. */
  14385. private _weight;
  14386. /**
  14387. * The ratio offset of the runtime animation
  14388. */
  14389. private _ratioOffset;
  14390. /**
  14391. * The previous delay of the runtime animation
  14392. */
  14393. private _previousDelay;
  14394. /**
  14395. * The previous ratio of the runtime animation
  14396. */
  14397. private _previousRatio;
  14398. private _enableBlending;
  14399. private _keys;
  14400. private _minFrame;
  14401. private _maxFrame;
  14402. private _minValue;
  14403. private _maxValue;
  14404. private _targetIsArray;
  14405. /**
  14406. * Gets the current frame of the runtime animation
  14407. */
  14408. get currentFrame(): number;
  14409. /**
  14410. * Gets the weight of the runtime animation
  14411. */
  14412. get weight(): number;
  14413. /**
  14414. * Gets the current value of the runtime animation
  14415. */
  14416. get currentValue(): any;
  14417. /**
  14418. * Gets the target path of the runtime animation
  14419. */
  14420. get targetPath(): string;
  14421. /**
  14422. * Gets the actual target of the runtime animation
  14423. */
  14424. get target(): any;
  14425. /** @hidden */
  14426. _onLoop: () => void;
  14427. /**
  14428. * Create a new RuntimeAnimation object
  14429. * @param target defines the target of the animation
  14430. * @param animation defines the source animation object
  14431. * @param scene defines the hosting scene
  14432. * @param host defines the initiating Animatable
  14433. */
  14434. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  14435. private _preparePath;
  14436. /**
  14437. * Gets the animation from the runtime animation
  14438. */
  14439. get animation(): Animation;
  14440. /**
  14441. * Resets the runtime animation to the beginning
  14442. * @param restoreOriginal defines whether to restore the target property to the original value
  14443. */
  14444. reset(restoreOriginal?: boolean): void;
  14445. /**
  14446. * Specifies if the runtime animation is stopped
  14447. * @returns Boolean specifying if the runtime animation is stopped
  14448. */
  14449. isStopped(): boolean;
  14450. /**
  14451. * Disposes of the runtime animation
  14452. */
  14453. dispose(): void;
  14454. /**
  14455. * Apply the interpolated value to the target
  14456. * @param currentValue defines the value computed by the animation
  14457. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  14458. */
  14459. setValue(currentValue: any, weight: number): void;
  14460. private _getOriginalValues;
  14461. private _setValue;
  14462. /**
  14463. * Gets the loop pmode of the runtime animation
  14464. * @returns Loop Mode
  14465. */
  14466. private _getCorrectLoopMode;
  14467. /**
  14468. * Move the current animation to a given frame
  14469. * @param frame defines the frame to move to
  14470. */
  14471. goToFrame(frame: number): void;
  14472. /**
  14473. * @hidden Internal use only
  14474. */
  14475. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  14476. /**
  14477. * Execute the current animation
  14478. * @param delay defines the delay to add to the current frame
  14479. * @param from defines the lower bound of the animation range
  14480. * @param to defines the upper bound of the animation range
  14481. * @param loop defines if the current animation must loop
  14482. * @param speedRatio defines the current speed ratio
  14483. * @param weight defines the weight of the animation (default is -1 so no weight)
  14484. * @param onLoop optional callback called when animation loops
  14485. * @returns a boolean indicating if the animation is running
  14486. */
  14487. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  14488. }
  14489. }
  14490. declare module BABYLON {
  14491. /**
  14492. * Class used to store an actual running animation
  14493. */
  14494. export class Animatable {
  14495. /** defines the target object */
  14496. target: any;
  14497. /** defines the starting frame number (default is 0) */
  14498. fromFrame: number;
  14499. /** defines the ending frame number (default is 100) */
  14500. toFrame: number;
  14501. /** defines if the animation must loop (default is false) */
  14502. loopAnimation: boolean;
  14503. /** defines a callback to call when animation ends if it is not looping */
  14504. onAnimationEnd?: (() => void) | null | undefined;
  14505. /** defines a callback to call when animation loops */
  14506. onAnimationLoop?: (() => void) | null | undefined;
  14507. private _localDelayOffset;
  14508. private _pausedDelay;
  14509. private _runtimeAnimations;
  14510. private _paused;
  14511. private _scene;
  14512. private _speedRatio;
  14513. private _weight;
  14514. private _syncRoot;
  14515. /**
  14516. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  14517. * This will only apply for non looping animation (default is true)
  14518. */
  14519. disposeOnEnd: boolean;
  14520. /**
  14521. * Gets a boolean indicating if the animation has started
  14522. */
  14523. animationStarted: boolean;
  14524. /**
  14525. * Observer raised when the animation ends
  14526. */
  14527. onAnimationEndObservable: Observable<Animatable>;
  14528. /**
  14529. * Observer raised when the animation loops
  14530. */
  14531. onAnimationLoopObservable: Observable<Animatable>;
  14532. /**
  14533. * Gets the root Animatable used to synchronize and normalize animations
  14534. */
  14535. get syncRoot(): Nullable<Animatable>;
  14536. /**
  14537. * Gets the current frame of the first RuntimeAnimation
  14538. * Used to synchronize Animatables
  14539. */
  14540. get masterFrame(): number;
  14541. /**
  14542. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  14543. */
  14544. get weight(): number;
  14545. set weight(value: number);
  14546. /**
  14547. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  14548. */
  14549. get speedRatio(): number;
  14550. set speedRatio(value: number);
  14551. /**
  14552. * Creates a new Animatable
  14553. * @param scene defines the hosting scene
  14554. * @param target defines the target object
  14555. * @param fromFrame defines the starting frame number (default is 0)
  14556. * @param toFrame defines the ending frame number (default is 100)
  14557. * @param loopAnimation defines if the animation must loop (default is false)
  14558. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  14559. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  14560. * @param animations defines a group of animation to add to the new Animatable
  14561. * @param onAnimationLoop defines a callback to call when animation loops
  14562. */
  14563. constructor(scene: Scene,
  14564. /** defines the target object */
  14565. target: any,
  14566. /** defines the starting frame number (default is 0) */
  14567. fromFrame?: number,
  14568. /** defines the ending frame number (default is 100) */
  14569. toFrame?: number,
  14570. /** defines if the animation must loop (default is false) */
  14571. loopAnimation?: boolean, speedRatio?: number,
  14572. /** defines a callback to call when animation ends if it is not looping */
  14573. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  14574. /** defines a callback to call when animation loops */
  14575. onAnimationLoop?: (() => void) | null | undefined);
  14576. /**
  14577. * Synchronize and normalize current Animatable with a source Animatable
  14578. * This is useful when using animation weights and when animations are not of the same length
  14579. * @param root defines the root Animatable to synchronize with
  14580. * @returns the current Animatable
  14581. */
  14582. syncWith(root: Animatable): Animatable;
  14583. /**
  14584. * Gets the list of runtime animations
  14585. * @returns an array of RuntimeAnimation
  14586. */
  14587. getAnimations(): RuntimeAnimation[];
  14588. /**
  14589. * Adds more animations to the current animatable
  14590. * @param target defines the target of the animations
  14591. * @param animations defines the new animations to add
  14592. */
  14593. appendAnimations(target: any, animations: Animation[]): void;
  14594. /**
  14595. * Gets the source animation for a specific property
  14596. * @param property defines the propertyu to look for
  14597. * @returns null or the source animation for the given property
  14598. */
  14599. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  14600. /**
  14601. * Gets the runtime animation for a specific property
  14602. * @param property defines the propertyu to look for
  14603. * @returns null or the runtime animation for the given property
  14604. */
  14605. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  14606. /**
  14607. * Resets the animatable to its original state
  14608. */
  14609. reset(): void;
  14610. /**
  14611. * Allows the animatable to blend with current running animations
  14612. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  14613. * @param blendingSpeed defines the blending speed to use
  14614. */
  14615. enableBlending(blendingSpeed: number): void;
  14616. /**
  14617. * Disable animation blending
  14618. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  14619. */
  14620. disableBlending(): void;
  14621. /**
  14622. * Jump directly to a given frame
  14623. * @param frame defines the frame to jump to
  14624. */
  14625. goToFrame(frame: number): void;
  14626. /**
  14627. * Pause the animation
  14628. */
  14629. pause(): void;
  14630. /**
  14631. * Restart the animation
  14632. */
  14633. restart(): void;
  14634. private _raiseOnAnimationEnd;
  14635. /**
  14636. * Stop and delete the current animation
  14637. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  14638. * @param targetMask - a function that determines if the animation should be stopped based on its target (all animations will be stopped if both this and animationName are empty)
  14639. */
  14640. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  14641. /**
  14642. * Wait asynchronously for the animation to end
  14643. * @returns a promise which will be fullfilled when the animation ends
  14644. */
  14645. waitAsync(): Promise<Animatable>;
  14646. /** @hidden */
  14647. _animate(delay: number): boolean;
  14648. }
  14649. interface Scene {
  14650. /** @hidden */
  14651. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  14652. /** @hidden */
  14653. _processLateAnimationBindingsForMatrices(holder: {
  14654. totalWeight: number;
  14655. animations: RuntimeAnimation[];
  14656. originalValue: Matrix;
  14657. }): any;
  14658. /** @hidden */
  14659. _processLateAnimationBindingsForQuaternions(holder: {
  14660. totalWeight: number;
  14661. animations: RuntimeAnimation[];
  14662. originalValue: Quaternion;
  14663. }, refQuaternion: Quaternion): Quaternion;
  14664. /** @hidden */
  14665. _processLateAnimationBindings(): void;
  14666. /**
  14667. * Will start the animation sequence of a given target
  14668. * @param target defines the target
  14669. * @param from defines from which frame should animation start
  14670. * @param to defines until which frame should animation run.
  14671. * @param weight defines the weight to apply to the animation (1.0 by default)
  14672. * @param loop defines if the animation loops
  14673. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  14674. * @param onAnimationEnd defines the function to be executed when the animation ends
  14675. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  14676. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  14677. * @param onAnimationLoop defines the callback to call when an animation loops
  14678. * @returns the animatable object created for this animation
  14679. */
  14680. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  14681. /**
  14682. * Will start the animation sequence of a given target
  14683. * @param target defines the target
  14684. * @param from defines from which frame should animation start
  14685. * @param to defines until which frame should animation run.
  14686. * @param loop defines if the animation loops
  14687. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  14688. * @param onAnimationEnd defines the function to be executed when the animation ends
  14689. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  14690. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  14691. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  14692. * @param onAnimationLoop defines the callback to call when an animation loops
  14693. * @returns the animatable object created for this animation
  14694. */
  14695. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  14696. /**
  14697. * Will start the animation sequence of a given target and its hierarchy
  14698. * @param target defines the target
  14699. * @param directDescendantsOnly if true only direct descendants will be used, if false direct and also indirect (children of children, an so on in a recursive manner) descendants will be used.
  14700. * @param from defines from which frame should animation start
  14701. * @param to defines until which frame should animation run.
  14702. * @param loop defines if the animation loops
  14703. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  14704. * @param onAnimationEnd defines the function to be executed when the animation ends
  14705. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  14706. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  14707. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  14708. * @param onAnimationLoop defines the callback to call when an animation loops
  14709. * @returns the list of created animatables
  14710. */
  14711. beginHierarchyAnimation(target: any, directDescendantsOnly: boolean, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable[];
  14712. /**
  14713. * Begin a new animation on a given node
  14714. * @param target defines the target where the animation will take place
  14715. * @param animations defines the list of animations to start
  14716. * @param from defines the initial value
  14717. * @param to defines the final value
  14718. * @param loop defines if you want animation to loop (off by default)
  14719. * @param speedRatio defines the speed ratio to apply to all animations
  14720. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  14721. * @param onAnimationLoop defines the callback to call when an animation loops
  14722. * @returns the list of created animatables
  14723. */
  14724. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  14725. /**
  14726. * Begin a new animation on a given node and its hierarchy
  14727. * @param target defines the root node where the animation will take place
  14728. * @param directDescendantsOnly if true only direct descendants will be used, if false direct and also indirect (children of children, an so on in a recursive manner) descendants will be used.
  14729. * @param animations defines the list of animations to start
  14730. * @param from defines the initial value
  14731. * @param to defines the final value
  14732. * @param loop defines if you want animation to loop (off by default)
  14733. * @param speedRatio defines the speed ratio to apply to all animations
  14734. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  14735. * @param onAnimationLoop defines the callback to call when an animation loops
  14736. * @returns the list of animatables created for all nodes
  14737. */
  14738. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  14739. /**
  14740. * Gets the animatable associated with a specific target
  14741. * @param target defines the target of the animatable
  14742. * @returns the required animatable if found
  14743. */
  14744. getAnimatableByTarget(target: any): Nullable<Animatable>;
  14745. /**
  14746. * Gets all animatables associated with a given target
  14747. * @param target defines the target to look animatables for
  14748. * @returns an array of Animatables
  14749. */
  14750. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  14751. /**
  14752. * Stops and removes all animations that have been applied to the scene
  14753. */
  14754. stopAllAnimations(): void;
  14755. /**
  14756. * Gets the current delta time used by animation engine
  14757. */
  14758. deltaTime: number;
  14759. }
  14760. interface Bone {
  14761. /**
  14762. * Copy an animation range from another bone
  14763. * @param source defines the source bone
  14764. * @param rangeName defines the range name to copy
  14765. * @param frameOffset defines the frame offset
  14766. * @param rescaleAsRequired defines if rescaling must be applied if required
  14767. * @param skelDimensionsRatio defines the scaling ratio
  14768. * @returns true if operation was successful
  14769. */
  14770. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  14771. }
  14772. }
  14773. declare module BABYLON {
  14774. /**
  14775. * Class used to handle skinning animations
  14776. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  14777. */
  14778. export class Skeleton implements IAnimatable {
  14779. /** defines the skeleton name */
  14780. name: string;
  14781. /** defines the skeleton Id */
  14782. id: string;
  14783. /**
  14784. * Defines the list of child bones
  14785. */
  14786. bones: Bone[];
  14787. /**
  14788. * Defines an estimate of the dimension of the skeleton at rest
  14789. */
  14790. dimensionsAtRest: Vector3;
  14791. /**
  14792. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  14793. */
  14794. needInitialSkinMatrix: boolean;
  14795. /**
  14796. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  14797. */
  14798. overrideMesh: Nullable<AbstractMesh>;
  14799. /**
  14800. * Gets the list of animations attached to this skeleton
  14801. */
  14802. animations: Array<Animation>;
  14803. private _scene;
  14804. private _isDirty;
  14805. private _transformMatrices;
  14806. private _transformMatrixTexture;
  14807. private _meshesWithPoseMatrix;
  14808. private _animatables;
  14809. private _identity;
  14810. private _synchronizedWithMesh;
  14811. private _ranges;
  14812. private _lastAbsoluteTransformsUpdateId;
  14813. private _canUseTextureForBones;
  14814. private _uniqueId;
  14815. /** @hidden */
  14816. _numBonesWithLinkedTransformNode: number;
  14817. /** @hidden */
  14818. _hasWaitingData: Nullable<boolean>;
  14819. /**
  14820. * Specifies if the skeleton should be serialized
  14821. */
  14822. doNotSerialize: boolean;
  14823. private _useTextureToStoreBoneMatrices;
  14824. /**
  14825. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  14826. * Please note that this option is not available if the hardware does not support it
  14827. */
  14828. get useTextureToStoreBoneMatrices(): boolean;
  14829. set useTextureToStoreBoneMatrices(value: boolean);
  14830. private _animationPropertiesOverride;
  14831. /**
  14832. * Gets or sets the animation properties override
  14833. */
  14834. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  14835. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  14836. /**
  14837. * List of inspectable custom properties (used by the Inspector)
  14838. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  14839. */
  14840. inspectableCustomProperties: IInspectable[];
  14841. /**
  14842. * An observable triggered before computing the skeleton's matrices
  14843. */
  14844. onBeforeComputeObservable: Observable<Skeleton>;
  14845. /**
  14846. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  14847. */
  14848. get isUsingTextureForMatrices(): boolean;
  14849. /**
  14850. * Gets the unique ID of this skeleton
  14851. */
  14852. get uniqueId(): number;
  14853. /**
  14854. * Creates a new skeleton
  14855. * @param name defines the skeleton name
  14856. * @param id defines the skeleton Id
  14857. * @param scene defines the hosting scene
  14858. */
  14859. constructor(
  14860. /** defines the skeleton name */
  14861. name: string,
  14862. /** defines the skeleton Id */
  14863. id: string, scene: Scene);
  14864. /**
  14865. * Gets the current object class name.
  14866. * @return the class name
  14867. */
  14868. getClassName(): string;
  14869. /**
  14870. * Returns an array containing the root bones
  14871. * @returns an array containing the root bones
  14872. */
  14873. getChildren(): Array<Bone>;
  14874. /**
  14875. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  14876. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  14877. * @returns a Float32Array containing matrices data
  14878. */
  14879. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  14880. /**
  14881. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  14882. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  14883. * @returns a raw texture containing the data
  14884. */
  14885. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  14886. /**
  14887. * Gets the current hosting scene
  14888. * @returns a scene object
  14889. */
  14890. getScene(): Scene;
  14891. /**
  14892. * Gets a string representing the current skeleton data
  14893. * @param fullDetails defines a boolean indicating if we want a verbose version
  14894. * @returns a string representing the current skeleton data
  14895. */
  14896. toString(fullDetails?: boolean): string;
  14897. /**
  14898. * Get bone's index searching by name
  14899. * @param name defines bone's name to search for
  14900. * @return the indice of the bone. Returns -1 if not found
  14901. */
  14902. getBoneIndexByName(name: string): number;
  14903. /**
  14904. * Creater a new animation range
  14905. * @param name defines the name of the range
  14906. * @param from defines the start key
  14907. * @param to defines the end key
  14908. */
  14909. createAnimationRange(name: string, from: number, to: number): void;
  14910. /**
  14911. * Delete a specific animation range
  14912. * @param name defines the name of the range
  14913. * @param deleteFrames defines if frames must be removed as well
  14914. */
  14915. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  14916. /**
  14917. * Gets a specific animation range
  14918. * @param name defines the name of the range to look for
  14919. * @returns the requested animation range or null if not found
  14920. */
  14921. getAnimationRange(name: string): Nullable<AnimationRange>;
  14922. /**
  14923. * Gets the list of all animation ranges defined on this skeleton
  14924. * @returns an array
  14925. */
  14926. getAnimationRanges(): Nullable<AnimationRange>[];
  14927. /**
  14928. * Copy animation range from a source skeleton.
  14929. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  14930. * @param source defines the source skeleton
  14931. * @param name defines the name of the range to copy
  14932. * @param rescaleAsRequired defines if rescaling must be applied if required
  14933. * @returns true if operation was successful
  14934. */
  14935. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  14936. /**
  14937. * Forces the skeleton to go to rest pose
  14938. */
  14939. returnToRest(): void;
  14940. private _getHighestAnimationFrame;
  14941. /**
  14942. * Begin a specific animation range
  14943. * @param name defines the name of the range to start
  14944. * @param loop defines if looping must be turned on (false by default)
  14945. * @param speedRatio defines the speed ratio to apply (1 by default)
  14946. * @param onAnimationEnd defines a callback which will be called when animation will end
  14947. * @returns a new animatable
  14948. */
  14949. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  14950. /** @hidden */
  14951. _markAsDirty(): void;
  14952. /** @hidden */
  14953. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  14954. /** @hidden */
  14955. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  14956. private _computeTransformMatrices;
  14957. /**
  14958. * Build all resources required to render a skeleton
  14959. */
  14960. prepare(): void;
  14961. /**
  14962. * Gets the list of animatables currently running for this skeleton
  14963. * @returns an array of animatables
  14964. */
  14965. getAnimatables(): IAnimatable[];
  14966. /**
  14967. * Clone the current skeleton
  14968. * @param name defines the name of the new skeleton
  14969. * @param id defines the id of the new skeleton
  14970. * @returns the new skeleton
  14971. */
  14972. clone(name: string, id?: string): Skeleton;
  14973. /**
  14974. * Enable animation blending for this skeleton
  14975. * @param blendingSpeed defines the blending speed to apply
  14976. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  14977. */
  14978. enableBlending(blendingSpeed?: number): void;
  14979. /**
  14980. * Releases all resources associated with the current skeleton
  14981. */
  14982. dispose(): void;
  14983. /**
  14984. * Serialize the skeleton in a JSON object
  14985. * @returns a JSON object
  14986. */
  14987. serialize(): any;
  14988. /**
  14989. * Creates a new skeleton from serialized data
  14990. * @param parsedSkeleton defines the serialized data
  14991. * @param scene defines the hosting scene
  14992. * @returns a new skeleton
  14993. */
  14994. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  14995. /**
  14996. * Compute all node absolute transforms
  14997. * @param forceUpdate defines if computation must be done even if cache is up to date
  14998. */
  14999. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  15000. /**
  15001. * Gets the root pose matrix
  15002. * @returns a matrix
  15003. */
  15004. getPoseMatrix(): Nullable<Matrix>;
  15005. /**
  15006. * Sorts bones per internal index
  15007. */
  15008. sortBones(): void;
  15009. private _sortBones;
  15010. }
  15011. }
  15012. declare module BABYLON {
  15013. /**
  15014. * Creates an instance based on a source mesh.
  15015. */
  15016. export class InstancedMesh extends AbstractMesh {
  15017. private _sourceMesh;
  15018. private _currentLOD;
  15019. /** @hidden */
  15020. _indexInSourceMeshInstanceArray: number;
  15021. constructor(name: string, source: Mesh);
  15022. /**
  15023. * Returns the string "InstancedMesh".
  15024. */
  15025. getClassName(): string;
  15026. /** Gets the list of lights affecting that mesh */
  15027. get lightSources(): Light[];
  15028. _resyncLightSources(): void;
  15029. _resyncLightSource(light: Light): void;
  15030. _removeLightSource(light: Light, dispose: boolean): void;
  15031. /**
  15032. * If the source mesh receives shadows
  15033. */
  15034. get receiveShadows(): boolean;
  15035. /**
  15036. * The material of the source mesh
  15037. */
  15038. get material(): Nullable<Material>;
  15039. /**
  15040. * Visibility of the source mesh
  15041. */
  15042. get visibility(): number;
  15043. /**
  15044. * Skeleton of the source mesh
  15045. */
  15046. get skeleton(): Nullable<Skeleton>;
  15047. /**
  15048. * Rendering ground id of the source mesh
  15049. */
  15050. get renderingGroupId(): number;
  15051. set renderingGroupId(value: number);
  15052. /**
  15053. * Returns the total number of vertices (integer).
  15054. */
  15055. getTotalVertices(): number;
  15056. /**
  15057. * Returns a positive integer : the total number of indices in this mesh geometry.
  15058. * @returns the numner of indices or zero if the mesh has no geometry.
  15059. */
  15060. getTotalIndices(): number;
  15061. /**
  15062. * The source mesh of the instance
  15063. */
  15064. get sourceMesh(): Mesh;
  15065. /**
  15066. * Is this node ready to be used/rendered
  15067. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  15068. * @return {boolean} is it ready
  15069. */
  15070. isReady(completeCheck?: boolean): boolean;
  15071. /**
  15072. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  15073. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  15074. * @param copyWhenShared If true (default false) and and if the mesh geometry is shared among some other meshes, the returned array is a copy of the internal one.
  15075. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  15076. */
  15077. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  15078. /**
  15079. * Sets the vertex data of the mesh geometry for the requested `kind`.
  15080. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  15081. * The `data` are either a numeric array either a Float32Array.
  15082. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  15083. * The parameter `stride` is an optional positive integer, it is usually automatically deducted from the `kind` (3 for positions or normals, 2 for UV, etc).
  15084. * Note that a new underlying VertexBuffer object is created each call.
  15085. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  15086. *
  15087. * Possible `kind` values :
  15088. * - VertexBuffer.PositionKind
  15089. * - VertexBuffer.UVKind
  15090. * - VertexBuffer.UV2Kind
  15091. * - VertexBuffer.UV3Kind
  15092. * - VertexBuffer.UV4Kind
  15093. * - VertexBuffer.UV5Kind
  15094. * - VertexBuffer.UV6Kind
  15095. * - VertexBuffer.ColorKind
  15096. * - VertexBuffer.MatricesIndicesKind
  15097. * - VertexBuffer.MatricesIndicesExtraKind
  15098. * - VertexBuffer.MatricesWeightsKind
  15099. * - VertexBuffer.MatricesWeightsExtraKind
  15100. *
  15101. * Returns the Mesh.
  15102. */
  15103. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  15104. /**
  15105. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  15106. * If the mesh has no geometry, it is simply returned as it is.
  15107. * The `data` are either a numeric array either a Float32Array.
  15108. * No new underlying VertexBuffer object is created.
  15109. * If the `kind` is the `PositionKind` and if `updateExtends` is true, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  15110. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  15111. *
  15112. * Possible `kind` values :
  15113. * - VertexBuffer.PositionKind
  15114. * - VertexBuffer.UVKind
  15115. * - VertexBuffer.UV2Kind
  15116. * - VertexBuffer.UV3Kind
  15117. * - VertexBuffer.UV4Kind
  15118. * - VertexBuffer.UV5Kind
  15119. * - VertexBuffer.UV6Kind
  15120. * - VertexBuffer.ColorKind
  15121. * - VertexBuffer.MatricesIndicesKind
  15122. * - VertexBuffer.MatricesIndicesExtraKind
  15123. * - VertexBuffer.MatricesWeightsKind
  15124. * - VertexBuffer.MatricesWeightsExtraKind
  15125. *
  15126. * Returns the Mesh.
  15127. */
  15128. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  15129. /**
  15130. * Sets the mesh indices.
  15131. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  15132. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  15133. * This method creates a new index buffer each call.
  15134. * Returns the Mesh.
  15135. */
  15136. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  15137. /**
  15138. * Boolean : True if the mesh owns the requested kind of data.
  15139. */
  15140. isVerticesDataPresent(kind: string): boolean;
  15141. /**
  15142. * Returns an array of indices (IndicesArray).
  15143. */
  15144. getIndices(): Nullable<IndicesArray>;
  15145. get _positions(): Nullable<Vector3[]>;
  15146. /**
  15147. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  15148. * This means the mesh underlying bounding box and sphere are recomputed.
  15149. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  15150. * @returns the current mesh
  15151. */
  15152. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  15153. /** @hidden */
  15154. _preActivate(): InstancedMesh;
  15155. /** @hidden */
  15156. _activate(renderId: number, intermediateRendering: boolean): boolean;
  15157. /** @hidden */
  15158. _postActivate(): void;
  15159. getWorldMatrix(): Matrix;
  15160. get isAnInstance(): boolean;
  15161. /**
  15162. * Returns the current associated LOD AbstractMesh.
  15163. */
  15164. getLOD(camera: Camera): AbstractMesh;
  15165. /** @hidden */
  15166. _syncSubMeshes(): InstancedMesh;
  15167. /** @hidden */
  15168. _generatePointsArray(): boolean;
  15169. /**
  15170. * Creates a new InstancedMesh from the current mesh.
  15171. * - name (string) : the cloned mesh name
  15172. * - newParent (optional Node) : the optional Node to parent the clone to.
  15173. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  15174. *
  15175. * Returns the clone.
  15176. */
  15177. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  15178. /**
  15179. * Disposes the InstancedMesh.
  15180. * Returns nothing.
  15181. */
  15182. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  15183. }
  15184. interface Mesh {
  15185. /**
  15186. * Register a custom buffer that will be instanced
  15187. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  15188. * @param kind defines the buffer kind
  15189. * @param stride defines the stride in floats
  15190. */
  15191. registerInstancedBuffer(kind: string, stride: number): void;
  15192. /** @hidden */
  15193. _userInstancedBuffersStorage: {
  15194. data: {
  15195. [key: string]: Float32Array;
  15196. };
  15197. sizes: {
  15198. [key: string]: number;
  15199. };
  15200. vertexBuffers: {
  15201. [key: string]: Nullable<VertexBuffer>;
  15202. };
  15203. strides: {
  15204. [key: string]: number;
  15205. };
  15206. };
  15207. }
  15208. interface AbstractMesh {
  15209. /**
  15210. * Object used to store instanced buffers defined by user
  15211. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  15212. */
  15213. instancedBuffers: {
  15214. [key: string]: any;
  15215. };
  15216. }
  15217. }
  15218. declare module BABYLON {
  15219. /**
  15220. * Defines the options associated with the creation of a shader material.
  15221. */
  15222. export interface IShaderMaterialOptions {
  15223. /**
  15224. * Does the material work in alpha blend mode
  15225. */
  15226. needAlphaBlending: boolean;
  15227. /**
  15228. * Does the material work in alpha test mode
  15229. */
  15230. needAlphaTesting: boolean;
  15231. /**
  15232. * The list of attribute names used in the shader
  15233. */
  15234. attributes: string[];
  15235. /**
  15236. * The list of unifrom names used in the shader
  15237. */
  15238. uniforms: string[];
  15239. /**
  15240. * The list of UBO names used in the shader
  15241. */
  15242. uniformBuffers: string[];
  15243. /**
  15244. * The list of sampler names used in the shader
  15245. */
  15246. samplers: string[];
  15247. /**
  15248. * The list of defines used in the shader
  15249. */
  15250. defines: string[];
  15251. }
  15252. /**
  15253. * The ShaderMaterial object has the necessary methods to pass data from your scene to the Vertex and Fragment Shaders and returns a material that can be applied to any mesh.
  15254. *
  15255. * This returned material effects how the mesh will look based on the code in the shaders.
  15256. *
  15257. * @see http://doc.babylonjs.com/how_to/shader_material
  15258. */
  15259. export class ShaderMaterial extends Material {
  15260. private _shaderPath;
  15261. private _options;
  15262. private _textures;
  15263. private _textureArrays;
  15264. private _floats;
  15265. private _ints;
  15266. private _floatsArrays;
  15267. private _colors3;
  15268. private _colors3Arrays;
  15269. private _colors4;
  15270. private _colors4Arrays;
  15271. private _vectors2;
  15272. private _vectors3;
  15273. private _vectors4;
  15274. private _matrices;
  15275. private _matrixArrays;
  15276. private _matrices3x3;
  15277. private _matrices2x2;
  15278. private _vectors2Arrays;
  15279. private _vectors3Arrays;
  15280. private _vectors4Arrays;
  15281. private _cachedWorldViewMatrix;
  15282. private _cachedWorldViewProjectionMatrix;
  15283. private _renderId;
  15284. private _multiview;
  15285. /**
  15286. * Instantiate a new shader material.
  15287. * The ShaderMaterial object has the necessary methods to pass data from your scene to the Vertex and Fragment Shaders and returns a material that can be applied to any mesh.
  15288. * This returned material effects how the mesh will look based on the code in the shaders.
  15289. * @see http://doc.babylonjs.com/how_to/shader_material
  15290. * @param name Define the name of the material in the scene
  15291. * @param scene Define the scene the material belongs to
  15292. * @param shaderPath Defines the route to the shader code in one of three ways:
  15293. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  15294. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  15295. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  15296. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  15297. * @param options Define the options used to create the shader
  15298. */
  15299. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  15300. /**
  15301. * Gets the shader path used to define the shader code
  15302. * It can be modified to trigger a new compilation
  15303. */
  15304. get shaderPath(): any;
  15305. /**
  15306. * Sets the shader path used to define the shader code
  15307. * It can be modified to trigger a new compilation
  15308. */
  15309. set shaderPath(shaderPath: any);
  15310. /**
  15311. * Gets the options used to compile the shader.
  15312. * They can be modified to trigger a new compilation
  15313. */
  15314. get options(): IShaderMaterialOptions;
  15315. /**
  15316. * Gets the current class name of the material e.g. "ShaderMaterial"
  15317. * Mainly use in serialization.
  15318. * @returns the class name
  15319. */
  15320. getClassName(): string;
  15321. /**
  15322. * Specifies if the material will require alpha blending
  15323. * @returns a boolean specifying if alpha blending is needed
  15324. */
  15325. needAlphaBlending(): boolean;
  15326. /**
  15327. * Specifies if this material should be rendered in alpha test mode
  15328. * @returns a boolean specifying if an alpha test is needed.
  15329. */
  15330. needAlphaTesting(): boolean;
  15331. private _checkUniform;
  15332. /**
  15333. * Set a texture in the shader.
  15334. * @param name Define the name of the uniform samplers as defined in the shader
  15335. * @param texture Define the texture to bind to this sampler
  15336. * @return the material itself allowing "fluent" like uniform updates
  15337. */
  15338. setTexture(name: string, texture: Texture): ShaderMaterial;
  15339. /**
  15340. * Set a texture array in the shader.
  15341. * @param name Define the name of the uniform sampler array as defined in the shader
  15342. * @param textures Define the list of textures to bind to this sampler
  15343. * @return the material itself allowing "fluent" like uniform updates
  15344. */
  15345. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  15346. /**
  15347. * Set a float in the shader.
  15348. * @param name Define the name of the uniform as defined in the shader
  15349. * @param value Define the value to give to the uniform
  15350. * @return the material itself allowing "fluent" like uniform updates
  15351. */
  15352. setFloat(name: string, value: number): ShaderMaterial;
  15353. /**
  15354. * Set a int in the shader.
  15355. * @param name Define the name of the uniform as defined in the shader
  15356. * @param value Define the value to give to the uniform
  15357. * @return the material itself allowing "fluent" like uniform updates
  15358. */
  15359. setInt(name: string, value: number): ShaderMaterial;
  15360. /**
  15361. * Set an array of floats in the shader.
  15362. * @param name Define the name of the uniform as defined in the shader
  15363. * @param value Define the value to give to the uniform
  15364. * @return the material itself allowing "fluent" like uniform updates
  15365. */
  15366. setFloats(name: string, value: number[]): ShaderMaterial;
  15367. /**
  15368. * Set a vec3 in the shader from a Color3.
  15369. * @param name Define the name of the uniform as defined in the shader
  15370. * @param value Define the value to give to the uniform
  15371. * @return the material itself allowing "fluent" like uniform updates
  15372. */
  15373. setColor3(name: string, value: Color3): ShaderMaterial;
  15374. /**
  15375. * Set a vec3 array in the shader from a Color3 array.
  15376. * @param name Define the name of the uniform as defined in the shader
  15377. * @param value Define the value to give to the uniform
  15378. * @return the material itself allowing "fluent" like uniform updates
  15379. */
  15380. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  15381. /**
  15382. * Set a vec4 in the shader from a Color4.
  15383. * @param name Define the name of the uniform as defined in the shader
  15384. * @param value Define the value to give to the uniform
  15385. * @return the material itself allowing "fluent" like uniform updates
  15386. */
  15387. setColor4(name: string, value: Color4): ShaderMaterial;
  15388. /**
  15389. * Set a vec4 array in the shader from a Color4 array.
  15390. * @param name Define the name of the uniform as defined in the shader
  15391. * @param value Define the value to give to the uniform
  15392. * @return the material itself allowing "fluent" like uniform updates
  15393. */
  15394. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  15395. /**
  15396. * Set a vec2 in the shader from a Vector2.
  15397. * @param name Define the name of the uniform as defined in the shader
  15398. * @param value Define the value to give to the uniform
  15399. * @return the material itself allowing "fluent" like uniform updates
  15400. */
  15401. setVector2(name: string, value: Vector2): ShaderMaterial;
  15402. /**
  15403. * Set a vec3 in the shader from a Vector3.
  15404. * @param name Define the name of the uniform as defined in the shader
  15405. * @param value Define the value to give to the uniform
  15406. * @return the material itself allowing "fluent" like uniform updates
  15407. */
  15408. setVector3(name: string, value: Vector3): ShaderMaterial;
  15409. /**
  15410. * Set a vec4 in the shader from a Vector4.
  15411. * @param name Define the name of the uniform as defined in the shader
  15412. * @param value Define the value to give to the uniform
  15413. * @return the material itself allowing "fluent" like uniform updates
  15414. */
  15415. setVector4(name: string, value: Vector4): ShaderMaterial;
  15416. /**
  15417. * Set a mat4 in the shader from a Matrix.
  15418. * @param name Define the name of the uniform as defined in the shader
  15419. * @param value Define the value to give to the uniform
  15420. * @return the material itself allowing "fluent" like uniform updates
  15421. */
  15422. setMatrix(name: string, value: Matrix): ShaderMaterial;
  15423. /**
  15424. * Set a float32Array in the shader from a matrix array.
  15425. * @param name Define the name of the uniform as defined in the shader
  15426. * @param value Define the value to give to the uniform
  15427. * @return the material itself allowing "fluent" like uniform updates
  15428. */
  15429. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  15430. /**
  15431. * Set a mat3 in the shader from a Float32Array.
  15432. * @param name Define the name of the uniform as defined in the shader
  15433. * @param value Define the value to give to the uniform
  15434. * @return the material itself allowing "fluent" like uniform updates
  15435. */
  15436. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  15437. /**
  15438. * Set a mat2 in the shader from a Float32Array.
  15439. * @param name Define the name of the uniform as defined in the shader
  15440. * @param value Define the value to give to the uniform
  15441. * @return the material itself allowing "fluent" like uniform updates
  15442. */
  15443. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  15444. /**
  15445. * Set a vec2 array in the shader from a number array.
  15446. * @param name Define the name of the uniform as defined in the shader
  15447. * @param value Define the value to give to the uniform
  15448. * @return the material itself allowing "fluent" like uniform updates
  15449. */
  15450. setArray2(name: string, value: number[]): ShaderMaterial;
  15451. /**
  15452. * Set a vec3 array in the shader from a number array.
  15453. * @param name Define the name of the uniform as defined in the shader
  15454. * @param value Define the value to give to the uniform
  15455. * @return the material itself allowing "fluent" like uniform updates
  15456. */
  15457. setArray3(name: string, value: number[]): ShaderMaterial;
  15458. /**
  15459. * Set a vec4 array in the shader from a number array.
  15460. * @param name Define the name of the uniform as defined in the shader
  15461. * @param value Define the value to give to the uniform
  15462. * @return the material itself allowing "fluent" like uniform updates
  15463. */
  15464. setArray4(name: string, value: number[]): ShaderMaterial;
  15465. private _checkCache;
  15466. /**
  15467. * Specifies that the submesh is ready to be used
  15468. * @param mesh defines the mesh to check
  15469. * @param subMesh defines which submesh to check
  15470. * @param useInstances specifies that instances should be used
  15471. * @returns a boolean indicating that the submesh is ready or not
  15472. */
  15473. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  15474. /**
  15475. * Checks if the material is ready to render the requested mesh
  15476. * @param mesh Define the mesh to render
  15477. * @param useInstances Define whether or not the material is used with instances
  15478. * @returns true if ready, otherwise false
  15479. */
  15480. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  15481. /**
  15482. * Binds the world matrix to the material
  15483. * @param world defines the world transformation matrix
  15484. */
  15485. bindOnlyWorldMatrix(world: Matrix): void;
  15486. /**
  15487. * Binds the material to the mesh
  15488. * @param world defines the world transformation matrix
  15489. * @param mesh defines the mesh to bind the material to
  15490. */
  15491. bind(world: Matrix, mesh?: Mesh): void;
  15492. /**
  15493. * Gets the active textures from the material
  15494. * @returns an array of textures
  15495. */
  15496. getActiveTextures(): BaseTexture[];
  15497. /**
  15498. * Specifies if the material uses a texture
  15499. * @param texture defines the texture to check against the material
  15500. * @returns a boolean specifying if the material uses the texture
  15501. */
  15502. hasTexture(texture: BaseTexture): boolean;
  15503. /**
  15504. * Makes a duplicate of the material, and gives it a new name
  15505. * @param name defines the new name for the duplicated material
  15506. * @returns the cloned material
  15507. */
  15508. clone(name: string): ShaderMaterial;
  15509. /**
  15510. * Disposes the material
  15511. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  15512. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  15513. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  15514. */
  15515. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  15516. /**
  15517. * Serializes this material in a JSON representation
  15518. * @returns the serialized material object
  15519. */
  15520. serialize(): any;
  15521. /**
  15522. * Creates a shader material from parsed shader material data
  15523. * @param source defines the JSON represnetation of the material
  15524. * @param scene defines the hosting scene
  15525. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  15526. * @returns a new material
  15527. */
  15528. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  15529. }
  15530. }
  15531. declare module BABYLON {
  15532. /** @hidden */
  15533. export var colorPixelShader: {
  15534. name: string;
  15535. shader: string;
  15536. };
  15537. }
  15538. declare module BABYLON {
  15539. /** @hidden */
  15540. export var colorVertexShader: {
  15541. name: string;
  15542. shader: string;
  15543. };
  15544. }
  15545. declare module BABYLON {
  15546. /**
  15547. * Line mesh
  15548. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  15549. */
  15550. export class LinesMesh extends Mesh {
  15551. /**
  15552. * If vertex color should be applied to the mesh
  15553. */
  15554. readonly useVertexColor?: boolean | undefined;
  15555. /**
  15556. * If vertex alpha should be applied to the mesh
  15557. */
  15558. readonly useVertexAlpha?: boolean | undefined;
  15559. /**
  15560. * Color of the line (Default: White)
  15561. */
  15562. color: Color3;
  15563. /**
  15564. * Alpha of the line (Default: 1)
  15565. */
  15566. alpha: number;
  15567. /**
  15568. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  15569. * This margin is expressed in world space coordinates, so its value may vary.
  15570. * Default value is 0.1
  15571. */
  15572. intersectionThreshold: number;
  15573. private _colorShader;
  15574. private color4;
  15575. /**
  15576. * Creates a new LinesMesh
  15577. * @param name defines the name
  15578. * @param scene defines the hosting scene
  15579. * @param parent defines the parent mesh if any
  15580. * @param source defines the optional source LinesMesh used to clone data from
  15581. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  15582. * When false, achieved by calling a clone(), also passing False.
  15583. * This will make creation of children, recursive.
  15584. * @param useVertexColor defines if this LinesMesh supports vertex color
  15585. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  15586. */
  15587. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  15588. /**
  15589. * If vertex color should be applied to the mesh
  15590. */
  15591. useVertexColor?: boolean | undefined,
  15592. /**
  15593. * If vertex alpha should be applied to the mesh
  15594. */
  15595. useVertexAlpha?: boolean | undefined);
  15596. private _addClipPlaneDefine;
  15597. private _removeClipPlaneDefine;
  15598. isReady(): boolean;
  15599. /**
  15600. * Returns the string "LineMesh"
  15601. */
  15602. getClassName(): string;
  15603. /**
  15604. * @hidden
  15605. */
  15606. get material(): Material;
  15607. /**
  15608. * @hidden
  15609. */
  15610. set material(value: Material);
  15611. /**
  15612. * @hidden
  15613. */
  15614. get checkCollisions(): boolean;
  15615. /** @hidden */
  15616. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  15617. /** @hidden */
  15618. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  15619. /**
  15620. * Disposes of the line mesh
  15621. * @param doNotRecurse If children should be disposed
  15622. */
  15623. dispose(doNotRecurse?: boolean): void;
  15624. /**
  15625. * Returns a new LineMesh object cloned from the current one.
  15626. */
  15627. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  15628. /**
  15629. * Creates a new InstancedLinesMesh object from the mesh model.
  15630. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  15631. * @param name defines the name of the new instance
  15632. * @returns a new InstancedLinesMesh
  15633. */
  15634. createInstance(name: string): InstancedLinesMesh;
  15635. }
  15636. /**
  15637. * Creates an instance based on a source LinesMesh
  15638. */
  15639. export class InstancedLinesMesh extends InstancedMesh {
  15640. /**
  15641. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  15642. * This margin is expressed in world space coordinates, so its value may vary.
  15643. * Initilized with the intersectionThreshold value of the source LinesMesh
  15644. */
  15645. intersectionThreshold: number;
  15646. constructor(name: string, source: LinesMesh);
  15647. /**
  15648. * Returns the string "InstancedLinesMesh".
  15649. */
  15650. getClassName(): string;
  15651. }
  15652. }
  15653. declare module BABYLON {
  15654. /** @hidden */
  15655. export var linePixelShader: {
  15656. name: string;
  15657. shader: string;
  15658. };
  15659. }
  15660. declare module BABYLON {
  15661. /** @hidden */
  15662. export var lineVertexShader: {
  15663. name: string;
  15664. shader: string;
  15665. };
  15666. }
  15667. declare module BABYLON {
  15668. interface AbstractMesh {
  15669. /**
  15670. * Gets the edgesRenderer associated with the mesh
  15671. */
  15672. edgesRenderer: Nullable<EdgesRenderer>;
  15673. }
  15674. interface LinesMesh {
  15675. /**
  15676. * Enables the edge rendering mode on the mesh.
  15677. * This mode makes the mesh edges visible
  15678. * @param epsilon defines the maximal distance between two angles to detect a face
  15679. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  15680. * @returns the currentAbstractMesh
  15681. * @see https://www.babylonjs-playground.com/#19O9TU#0
  15682. */
  15683. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  15684. }
  15685. interface InstancedLinesMesh {
  15686. /**
  15687. * Enables the edge rendering mode on the mesh.
  15688. * This mode makes the mesh edges visible
  15689. * @param epsilon defines the maximal distance between two angles to detect a face
  15690. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  15691. * @returns the current InstancedLinesMesh
  15692. * @see https://www.babylonjs-playground.com/#19O9TU#0
  15693. */
  15694. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  15695. }
  15696. /**
  15697. * Defines the minimum contract an Edges renderer should follow.
  15698. */
  15699. export interface IEdgesRenderer extends IDisposable {
  15700. /**
  15701. * Gets or sets a boolean indicating if the edgesRenderer is active
  15702. */
  15703. isEnabled: boolean;
  15704. /**
  15705. * Renders the edges of the attached mesh,
  15706. */
  15707. render(): void;
  15708. /**
  15709. * Checks wether or not the edges renderer is ready to render.
  15710. * @return true if ready, otherwise false.
  15711. */
  15712. isReady(): boolean;
  15713. }
  15714. /**
  15715. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  15716. */
  15717. export class EdgesRenderer implements IEdgesRenderer {
  15718. /**
  15719. * Define the size of the edges with an orthographic camera
  15720. */
  15721. edgesWidthScalerForOrthographic: number;
  15722. /**
  15723. * Define the size of the edges with a perspective camera
  15724. */
  15725. edgesWidthScalerForPerspective: number;
  15726. protected _source: AbstractMesh;
  15727. protected _linesPositions: number[];
  15728. protected _linesNormals: number[];
  15729. protected _linesIndices: number[];
  15730. protected _epsilon: number;
  15731. protected _indicesCount: number;
  15732. protected _lineShader: ShaderMaterial;
  15733. protected _ib: DataBuffer;
  15734. protected _buffers: {
  15735. [key: string]: Nullable<VertexBuffer>;
  15736. };
  15737. protected _checkVerticesInsteadOfIndices: boolean;
  15738. private _meshRebuildObserver;
  15739. private _meshDisposeObserver;
  15740. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  15741. isEnabled: boolean;
  15742. /**
  15743. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  15744. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  15745. * @param source Mesh used to create edges
  15746. * @param epsilon sum of angles in adjacency to check for edge
  15747. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  15748. * @param generateEdgesLines - should generate Lines or only prepare resources.
  15749. */
  15750. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  15751. protected _prepareRessources(): void;
  15752. /** @hidden */
  15753. _rebuild(): void;
  15754. /**
  15755. * Releases the required resources for the edges renderer
  15756. */
  15757. dispose(): void;
  15758. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  15759. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  15760. /**
  15761. * Checks if the pair of p0 and p1 is en edge
  15762. * @param faceIndex
  15763. * @param edge
  15764. * @param faceNormals
  15765. * @param p0
  15766. * @param p1
  15767. * @private
  15768. */
  15769. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  15770. /**
  15771. * push line into the position, normal and index buffer
  15772. * @protected
  15773. */
  15774. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  15775. /**
  15776. * Generates lines edges from adjacencjes
  15777. * @private
  15778. */
  15779. _generateEdgesLines(): void;
  15780. /**
  15781. * Checks wether or not the edges renderer is ready to render.
  15782. * @return true if ready, otherwise false.
  15783. */
  15784. isReady(): boolean;
  15785. /**
  15786. * Renders the edges of the attached mesh,
  15787. */
  15788. render(): void;
  15789. }
  15790. /**
  15791. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  15792. */
  15793. export class LineEdgesRenderer extends EdgesRenderer {
  15794. /**
  15795. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  15796. * @param source LineMesh used to generate edges
  15797. * @param epsilon not important (specified angle for edge detection)
  15798. * @param checkVerticesInsteadOfIndices not important for LineMesh
  15799. */
  15800. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  15801. /**
  15802. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  15803. */
  15804. _generateEdgesLines(): void;
  15805. }
  15806. }
  15807. declare module BABYLON {
  15808. /**
  15809. * This represents the object necessary to create a rendering group.
  15810. * This is exclusively used and created by the rendering manager.
  15811. * To modify the behavior, you use the available helpers in your scene or meshes.
  15812. * @hidden
  15813. */
  15814. export class RenderingGroup {
  15815. index: number;
  15816. private static _zeroVector;
  15817. private _scene;
  15818. private _opaqueSubMeshes;
  15819. private _transparentSubMeshes;
  15820. private _alphaTestSubMeshes;
  15821. private _depthOnlySubMeshes;
  15822. private _particleSystems;
  15823. private _spriteManagers;
  15824. private _opaqueSortCompareFn;
  15825. private _alphaTestSortCompareFn;
  15826. private _transparentSortCompareFn;
  15827. private _renderOpaque;
  15828. private _renderAlphaTest;
  15829. private _renderTransparent;
  15830. /** @hidden */
  15831. _edgesRenderers: SmartArray<IEdgesRenderer>;
  15832. onBeforeTransparentRendering: () => void;
  15833. /**
  15834. * Set the opaque sort comparison function.
  15835. * If null the sub meshes will be render in the order they were created
  15836. */
  15837. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  15838. /**
  15839. * Set the alpha test sort comparison function.
  15840. * If null the sub meshes will be render in the order they were created
  15841. */
  15842. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  15843. /**
  15844. * Set the transparent sort comparison function.
  15845. * If null the sub meshes will be render in the order they were created
  15846. */
  15847. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  15848. /**
  15849. * Creates a new rendering group.
  15850. * @param index The rendering group index
  15851. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  15852. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  15853. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  15854. */
  15855. constructor(index: number, scene: Scene, opaqueSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, alphaTestSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, transparentSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>);
  15856. /**
  15857. * Render all the sub meshes contained in the group.
  15858. * @param customRenderFunction Used to override the default render behaviour of the group.
  15859. * @returns true if rendered some submeshes.
  15860. */
  15861. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  15862. /**
  15863. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  15864. * @param subMeshes The submeshes to render
  15865. */
  15866. private renderOpaqueSorted;
  15867. /**
  15868. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  15869. * @param subMeshes The submeshes to render
  15870. */
  15871. private renderAlphaTestSorted;
  15872. /**
  15873. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  15874. * @param subMeshes The submeshes to render
  15875. */
  15876. private renderTransparentSorted;
  15877. /**
  15878. * Renders the submeshes in a specified order.
  15879. * @param subMeshes The submeshes to sort before render
  15880. * @param sortCompareFn The comparison function use to sort
  15881. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  15882. * @param transparent Specifies to activate blending if true
  15883. */
  15884. private static renderSorted;
  15885. /**
  15886. * Renders the submeshes in the order they were dispatched (no sort applied).
  15887. * @param subMeshes The submeshes to render
  15888. */
  15889. private static renderUnsorted;
  15890. /**
  15891. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  15892. * are rendered back to front if in the same alpha index.
  15893. *
  15894. * @param a The first submesh
  15895. * @param b The second submesh
  15896. * @returns The result of the comparison
  15897. */
  15898. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  15899. /**
  15900. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  15901. * are rendered back to front.
  15902. *
  15903. * @param a The first submesh
  15904. * @param b The second submesh
  15905. * @returns The result of the comparison
  15906. */
  15907. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  15908. /**
  15909. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  15910. * are rendered front to back (prevent overdraw).
  15911. *
  15912. * @param a The first submesh
  15913. * @param b The second submesh
  15914. * @returns The result of the comparison
  15915. */
  15916. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  15917. /**
  15918. * Resets the different lists of submeshes to prepare a new frame.
  15919. */
  15920. prepare(): void;
  15921. dispose(): void;
  15922. /**
  15923. * Inserts the submesh in its correct queue depending on its material.
  15924. * @param subMesh The submesh to dispatch
  15925. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  15926. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  15927. */
  15928. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  15929. dispatchSprites(spriteManager: ISpriteManager): void;
  15930. dispatchParticles(particleSystem: IParticleSystem): void;
  15931. private _renderParticles;
  15932. private _renderSprites;
  15933. }
  15934. }
  15935. declare module BABYLON {
  15936. /**
  15937. * Interface describing the different options available in the rendering manager
  15938. * regarding Auto Clear between groups.
  15939. */
  15940. export interface IRenderingManagerAutoClearSetup {
  15941. /**
  15942. * Defines whether or not autoclear is enable.
  15943. */
  15944. autoClear: boolean;
  15945. /**
  15946. * Defines whether or not to autoclear the depth buffer.
  15947. */
  15948. depth: boolean;
  15949. /**
  15950. * Defines whether or not to autoclear the stencil buffer.
  15951. */
  15952. stencil: boolean;
  15953. }
  15954. /**
  15955. * This class is used by the onRenderingGroupObservable
  15956. */
  15957. export class RenderingGroupInfo {
  15958. /**
  15959. * The Scene that being rendered
  15960. */
  15961. scene: Scene;
  15962. /**
  15963. * The camera currently used for the rendering pass
  15964. */
  15965. camera: Nullable<Camera>;
  15966. /**
  15967. * The ID of the renderingGroup being processed
  15968. */
  15969. renderingGroupId: number;
  15970. }
  15971. /**
  15972. * This is the manager responsible of all the rendering for meshes sprites and particles.
  15973. * It is enable to manage the different groups as well as the different necessary sort functions.
  15974. * This should not be used directly aside of the few static configurations
  15975. */
  15976. export class RenderingManager {
  15977. /**
  15978. * The max id used for rendering groups (not included)
  15979. */
  15980. static MAX_RENDERINGGROUPS: number;
  15981. /**
  15982. * The min id used for rendering groups (included)
  15983. */
  15984. static MIN_RENDERINGGROUPS: number;
  15985. /**
  15986. * Used to globally prevent autoclearing scenes.
  15987. */
  15988. static AUTOCLEAR: boolean;
  15989. /**
  15990. * @hidden
  15991. */
  15992. _useSceneAutoClearSetup: boolean;
  15993. private _scene;
  15994. private _renderingGroups;
  15995. private _depthStencilBufferAlreadyCleaned;
  15996. private _autoClearDepthStencil;
  15997. private _customOpaqueSortCompareFn;
  15998. private _customAlphaTestSortCompareFn;
  15999. private _customTransparentSortCompareFn;
  16000. private _renderingGroupInfo;
  16001. /**
  16002. * Instantiates a new rendering group for a particular scene
  16003. * @param scene Defines the scene the groups belongs to
  16004. */
  16005. constructor(scene: Scene);
  16006. private _clearDepthStencilBuffer;
  16007. /**
  16008. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  16009. * @hidden
  16010. */
  16011. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  16012. /**
  16013. * Resets the different information of the group to prepare a new frame
  16014. * @hidden
  16015. */
  16016. reset(): void;
  16017. /**
  16018. * Dispose and release the group and its associated resources.
  16019. * @hidden
  16020. */
  16021. dispose(): void;
  16022. /**
  16023. * Clear the info related to rendering groups preventing retention points during dispose.
  16024. */
  16025. freeRenderingGroups(): void;
  16026. private _prepareRenderingGroup;
  16027. /**
  16028. * Add a sprite manager to the rendering manager in order to render it this frame.
  16029. * @param spriteManager Define the sprite manager to render
  16030. */
  16031. dispatchSprites(spriteManager: ISpriteManager): void;
  16032. /**
  16033. * Add a particle system to the rendering manager in order to render it this frame.
  16034. * @param particleSystem Define the particle system to render
  16035. */
  16036. dispatchParticles(particleSystem: IParticleSystem): void;
  16037. /**
  16038. * Add a submesh to the manager in order to render it this frame
  16039. * @param subMesh The submesh to dispatch
  16040. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  16041. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  16042. */
  16043. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  16044. /**
  16045. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  16046. * This allowed control for front to back rendering or reversly depending of the special needs.
  16047. *
  16048. * @param renderingGroupId The rendering group id corresponding to its index
  16049. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  16050. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  16051. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  16052. */
  16053. setRenderingOrder(renderingGroupId: number, opaqueSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, alphaTestSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, transparentSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>): void;
  16054. /**
  16055. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  16056. *
  16057. * @param renderingGroupId The rendering group id corresponding to its index
  16058. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  16059. * @param depth Automatically clears depth between groups if true and autoClear is true.
  16060. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  16061. */
  16062. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  16063. /**
  16064. * Gets the current auto clear configuration for one rendering group of the rendering
  16065. * manager.
  16066. * @param index the rendering group index to get the information for
  16067. * @returns The auto clear setup for the requested rendering group
  16068. */
  16069. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  16070. }
  16071. }
  16072. declare module BABYLON {
  16073. /**
  16074. * Defines the options associated with the creation of a custom shader for a shadow generator.
  16075. */
  16076. export interface ICustomShaderOptions {
  16077. /**
  16078. * Gets or sets the custom shader name to use
  16079. */
  16080. shaderName: string;
  16081. /**
  16082. * The list of attribute names used in the shader
  16083. */
  16084. attributes?: string[];
  16085. /**
  16086. * The list of unifrom names used in the shader
  16087. */
  16088. uniforms?: string[];
  16089. /**
  16090. * The list of sampler names used in the shader
  16091. */
  16092. samplers?: string[];
  16093. /**
  16094. * The list of defines used in the shader
  16095. */
  16096. defines?: string[];
  16097. }
  16098. /**
  16099. * Interface to implement to create a shadow generator compatible with BJS.
  16100. */
  16101. export interface IShadowGenerator {
  16102. /**
  16103. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  16104. * @returns The render target texture if present otherwise, null
  16105. */
  16106. getShadowMap(): Nullable<RenderTargetTexture>;
  16107. /**
  16108. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  16109. * @param subMesh The submesh we want to render in the shadow map
  16110. * @param useInstances Defines wether will draw in the map using instances
  16111. * @returns true if ready otherwise, false
  16112. */
  16113. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  16114. /**
  16115. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  16116. * @param defines Defines of the material we want to update
  16117. * @param lightIndex Index of the light in the enabled light list of the material
  16118. */
  16119. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  16120. /**
  16121. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  16122. * defined in the generator but impacting the effect).
  16123. * It implies the unifroms available on the materials are the standard BJS ones.
  16124. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  16125. * @param effect The effect we are binfing the information for
  16126. */
  16127. bindShadowLight(lightIndex: string, effect: Effect): void;
  16128. /**
  16129. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  16130. * (eq to shadow prjection matrix * light transform matrix)
  16131. * @returns The transform matrix used to create the shadow map
  16132. */
  16133. getTransformMatrix(): Matrix;
  16134. /**
  16135. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  16136. * Cube and 2D textures for instance.
  16137. */
  16138. recreateShadowMap(): void;
  16139. /**
  16140. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  16141. * @param onCompiled Callback triggered at the and of the effects compilation
  16142. * @param options Sets of optional options forcing the compilation with different modes
  16143. */
  16144. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  16145. useInstances: boolean;
  16146. }>): void;
  16147. /**
  16148. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  16149. * @param options Sets of optional options forcing the compilation with different modes
  16150. * @returns A promise that resolves when the compilation completes
  16151. */
  16152. forceCompilationAsync(options?: Partial<{
  16153. useInstances: boolean;
  16154. }>): Promise<void>;
  16155. /**
  16156. * Serializes the shadow generator setup to a json object.
  16157. * @returns The serialized JSON object
  16158. */
  16159. serialize(): any;
  16160. /**
  16161. * Disposes the Shadow map and related Textures and effects.
  16162. */
  16163. dispose(): void;
  16164. }
  16165. /**
  16166. * Default implementation IShadowGenerator.
  16167. * This is the main object responsible of generating shadows in the framework.
  16168. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  16169. */
  16170. export class ShadowGenerator implements IShadowGenerator {
  16171. /**
  16172. * Name of the shadow generator class
  16173. */
  16174. static CLASSNAME: string;
  16175. /**
  16176. * Shadow generator mode None: no filtering applied.
  16177. */
  16178. static readonly FILTER_NONE: number;
  16179. /**
  16180. * Shadow generator mode ESM: Exponential Shadow Mapping.
  16181. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16182. */
  16183. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  16184. /**
  16185. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  16186. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  16187. */
  16188. static readonly FILTER_POISSONSAMPLING: number;
  16189. /**
  16190. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  16191. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16192. */
  16193. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  16194. /**
  16195. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  16196. * edge artifacts on steep falloff.
  16197. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16198. */
  16199. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  16200. /**
  16201. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  16202. * edge artifacts on steep falloff.
  16203. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16204. */
  16205. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  16206. /**
  16207. * Shadow generator mode PCF: Percentage Closer Filtering
  16208. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  16209. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  16210. */
  16211. static readonly FILTER_PCF: number;
  16212. /**
  16213. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  16214. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  16215. * Contact Hardening
  16216. */
  16217. static readonly FILTER_PCSS: number;
  16218. /**
  16219. * Reserved for PCF and PCSS
  16220. * Highest Quality.
  16221. *
  16222. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  16223. *
  16224. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  16225. */
  16226. static readonly QUALITY_HIGH: number;
  16227. /**
  16228. * Reserved for PCF and PCSS
  16229. * Good tradeoff for quality/perf cross devices
  16230. *
  16231. * Execute PCF on a 3*3 kernel.
  16232. *
  16233. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  16234. */
  16235. static readonly QUALITY_MEDIUM: number;
  16236. /**
  16237. * Reserved for PCF and PCSS
  16238. * The lowest quality but the fastest.
  16239. *
  16240. * Execute PCF on a 1*1 kernel.
  16241. *
  16242. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  16243. */
  16244. static readonly QUALITY_LOW: number;
  16245. /** Gets or sets the custom shader name to use */
  16246. customShaderOptions: ICustomShaderOptions;
  16247. /**
  16248. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  16249. */
  16250. onBeforeShadowMapRenderObservable: Observable<Effect>;
  16251. /**
  16252. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  16253. */
  16254. onAfterShadowMapRenderObservable: Observable<Effect>;
  16255. /**
  16256. * Observable triggered before a mesh is rendered in the shadow map.
  16257. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  16258. */
  16259. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  16260. /**
  16261. * Observable triggered after a mesh is rendered in the shadow map.
  16262. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  16263. */
  16264. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  16265. protected _bias: number;
  16266. /**
  16267. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  16268. */
  16269. get bias(): number;
  16270. /**
  16271. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  16272. */
  16273. set bias(bias: number);
  16274. protected _normalBias: number;
  16275. /**
  16276. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  16277. */
  16278. get normalBias(): number;
  16279. /**
  16280. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  16281. */
  16282. set normalBias(normalBias: number);
  16283. protected _blurBoxOffset: number;
  16284. /**
  16285. * Gets the blur box offset: offset applied during the blur pass.
  16286. * Only useful if useKernelBlur = false
  16287. */
  16288. get blurBoxOffset(): number;
  16289. /**
  16290. * Sets the blur box offset: offset applied during the blur pass.
  16291. * Only useful if useKernelBlur = false
  16292. */
  16293. set blurBoxOffset(value: number);
  16294. protected _blurScale: number;
  16295. /**
  16296. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  16297. * 2 means half of the size.
  16298. */
  16299. get blurScale(): number;
  16300. /**
  16301. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  16302. * 2 means half of the size.
  16303. */
  16304. set blurScale(value: number);
  16305. protected _blurKernel: number;
  16306. /**
  16307. * Gets the blur kernel: kernel size of the blur pass.
  16308. * Only useful if useKernelBlur = true
  16309. */
  16310. get blurKernel(): number;
  16311. /**
  16312. * Sets the blur kernel: kernel size of the blur pass.
  16313. * Only useful if useKernelBlur = true
  16314. */
  16315. set blurKernel(value: number);
  16316. protected _useKernelBlur: boolean;
  16317. /**
  16318. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  16319. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  16320. */
  16321. get useKernelBlur(): boolean;
  16322. /**
  16323. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  16324. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  16325. */
  16326. set useKernelBlur(value: boolean);
  16327. protected _depthScale: number;
  16328. /**
  16329. * Gets the depth scale used in ESM mode.
  16330. */
  16331. get depthScale(): number;
  16332. /**
  16333. * Sets the depth scale used in ESM mode.
  16334. * This can override the scale stored on the light.
  16335. */
  16336. set depthScale(value: number);
  16337. protected _validateFilter(filter: number): number;
  16338. protected _filter: number;
  16339. /**
  16340. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  16341. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  16342. */
  16343. get filter(): number;
  16344. /**
  16345. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  16346. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  16347. */
  16348. set filter(value: number);
  16349. /**
  16350. * Gets if the current filter is set to Poisson Sampling.
  16351. */
  16352. get usePoissonSampling(): boolean;
  16353. /**
  16354. * Sets the current filter to Poisson Sampling.
  16355. */
  16356. set usePoissonSampling(value: boolean);
  16357. /**
  16358. * Gets if the current filter is set to ESM.
  16359. */
  16360. get useExponentialShadowMap(): boolean;
  16361. /**
  16362. * Sets the current filter is to ESM.
  16363. */
  16364. set useExponentialShadowMap(value: boolean);
  16365. /**
  16366. * Gets if the current filter is set to filtered ESM.
  16367. */
  16368. get useBlurExponentialShadowMap(): boolean;
  16369. /**
  16370. * Gets if the current filter is set to filtered ESM.
  16371. */
  16372. set useBlurExponentialShadowMap(value: boolean);
  16373. /**
  16374. * Gets if the current filter is set to "close ESM" (using the inverse of the
  16375. * exponential to prevent steep falloff artifacts).
  16376. */
  16377. get useCloseExponentialShadowMap(): boolean;
  16378. /**
  16379. * Sets the current filter to "close ESM" (using the inverse of the
  16380. * exponential to prevent steep falloff artifacts).
  16381. */
  16382. set useCloseExponentialShadowMap(value: boolean);
  16383. /**
  16384. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  16385. * exponential to prevent steep falloff artifacts).
  16386. */
  16387. get useBlurCloseExponentialShadowMap(): boolean;
  16388. /**
  16389. * Sets the current filter to filtered "close ESM" (using the inverse of the
  16390. * exponential to prevent steep falloff artifacts).
  16391. */
  16392. set useBlurCloseExponentialShadowMap(value: boolean);
  16393. /**
  16394. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  16395. */
  16396. get usePercentageCloserFiltering(): boolean;
  16397. /**
  16398. * Sets the current filter to "PCF" (percentage closer filtering).
  16399. */
  16400. set usePercentageCloserFiltering(value: boolean);
  16401. protected _filteringQuality: number;
  16402. /**
  16403. * Gets the PCF or PCSS Quality.
  16404. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  16405. */
  16406. get filteringQuality(): number;
  16407. /**
  16408. * Sets the PCF or PCSS Quality.
  16409. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  16410. */
  16411. set filteringQuality(filteringQuality: number);
  16412. /**
  16413. * Gets if the current filter is set to "PCSS" (contact hardening).
  16414. */
  16415. get useContactHardeningShadow(): boolean;
  16416. /**
  16417. * Sets the current filter to "PCSS" (contact hardening).
  16418. */
  16419. set useContactHardeningShadow(value: boolean);
  16420. protected _contactHardeningLightSizeUVRatio: number;
  16421. /**
  16422. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  16423. * Using a ratio helps keeping shape stability independently of the map size.
  16424. *
  16425. * It does not account for the light projection as it was having too much
  16426. * instability during the light setup or during light position changes.
  16427. *
  16428. * Only valid if useContactHardeningShadow is true.
  16429. */
  16430. get contactHardeningLightSizeUVRatio(): number;
  16431. /**
  16432. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  16433. * Using a ratio helps keeping shape stability independently of the map size.
  16434. *
  16435. * It does not account for the light projection as it was having too much
  16436. * instability during the light setup or during light position changes.
  16437. *
  16438. * Only valid if useContactHardeningShadow is true.
  16439. */
  16440. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  16441. protected _darkness: number;
  16442. /** Gets or sets the actual darkness of a shadow */
  16443. get darkness(): number;
  16444. set darkness(value: number);
  16445. /**
  16446. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  16447. * 0 means strongest and 1 would means no shadow.
  16448. * @returns the darkness.
  16449. */
  16450. getDarkness(): number;
  16451. /**
  16452. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  16453. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  16454. * @returns the shadow generator allowing fluent coding.
  16455. */
  16456. setDarkness(darkness: number): ShadowGenerator;
  16457. protected _transparencyShadow: boolean;
  16458. /** Gets or sets the ability to have transparent shadow */
  16459. get transparencyShadow(): boolean;
  16460. set transparencyShadow(value: boolean);
  16461. /**
  16462. * Sets the ability to have transparent shadow (boolean).
  16463. * @param transparent True if transparent else False
  16464. * @returns the shadow generator allowing fluent coding
  16465. */
  16466. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  16467. protected _shadowMap: Nullable<RenderTargetTexture>;
  16468. protected _shadowMap2: Nullable<RenderTargetTexture>;
  16469. /**
  16470. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  16471. * @returns The render target texture if present otherwise, null
  16472. */
  16473. getShadowMap(): Nullable<RenderTargetTexture>;
  16474. /**
  16475. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  16476. * @returns The render target texture if the shadow map is present otherwise, null
  16477. */
  16478. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  16479. /**
  16480. * Gets the class name of that object
  16481. * @returns "ShadowGenerator"
  16482. */
  16483. getClassName(): string;
  16484. /**
  16485. * Helper function to add a mesh and its descendants to the list of shadow casters.
  16486. * @param mesh Mesh to add
  16487. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  16488. * @returns the Shadow Generator itself
  16489. */
  16490. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  16491. /**
  16492. * Helper function to remove a mesh and its descendants from the list of shadow casters
  16493. * @param mesh Mesh to remove
  16494. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  16495. * @returns the Shadow Generator itself
  16496. */
  16497. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  16498. /**
  16499. * Controls the extent to which the shadows fade out at the edge of the frustum
  16500. */
  16501. frustumEdgeFalloff: number;
  16502. protected _light: IShadowLight;
  16503. /**
  16504. * Returns the associated light object.
  16505. * @returns the light generating the shadow
  16506. */
  16507. getLight(): IShadowLight;
  16508. /**
  16509. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  16510. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  16511. * It might on the other hand introduce peter panning.
  16512. */
  16513. forceBackFacesOnly: boolean;
  16514. protected _scene: Scene;
  16515. protected _lightDirection: Vector3;
  16516. protected _effect: Effect;
  16517. protected _viewMatrix: Matrix;
  16518. protected _projectionMatrix: Matrix;
  16519. protected _transformMatrix: Matrix;
  16520. protected _cachedPosition: Vector3;
  16521. protected _cachedDirection: Vector3;
  16522. protected _cachedDefines: string;
  16523. protected _currentRenderID: number;
  16524. protected _boxBlurPostprocess: Nullable<PostProcess>;
  16525. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  16526. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  16527. protected _blurPostProcesses: PostProcess[];
  16528. protected _mapSize: number;
  16529. protected _currentFaceIndex: number;
  16530. protected _currentFaceIndexCache: number;
  16531. protected _textureType: number;
  16532. protected _defaultTextureMatrix: Matrix;
  16533. protected _storedUniqueId: Nullable<number>;
  16534. /** @hidden */
  16535. static _SceneComponentInitialization: (scene: Scene) => void;
  16536. /**
  16537. * Creates a ShadowGenerator object.
  16538. * A ShadowGenerator is the required tool to use the shadows.
  16539. * Each light casting shadows needs to use its own ShadowGenerator.
  16540. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  16541. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  16542. * @param light The light object generating the shadows.
  16543. * @param usefulFloatFirst By default the generator will try to use half float textures but if you need precision (for self shadowing for instance), you can use this option to enforce full float texture.
  16544. */
  16545. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  16546. protected _initializeGenerator(): void;
  16547. protected _createTargetRenderTexture(): void;
  16548. protected _initializeShadowMap(): void;
  16549. protected _initializeBlurRTTAndPostProcesses(): void;
  16550. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  16551. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect): void;
  16552. protected _renderSubMeshForShadowMap(subMesh: SubMesh): void;
  16553. protected _applyFilterValues(): void;
  16554. /**
  16555. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  16556. * @param onCompiled Callback triggered at the and of the effects compilation
  16557. * @param options Sets of optional options forcing the compilation with different modes
  16558. */
  16559. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  16560. useInstances: boolean;
  16561. }>): void;
  16562. /**
  16563. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  16564. * @param options Sets of optional options forcing the compilation with different modes
  16565. * @returns A promise that resolves when the compilation completes
  16566. */
  16567. forceCompilationAsync(options?: Partial<{
  16568. useInstances: boolean;
  16569. }>): Promise<void>;
  16570. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  16571. /**
  16572. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  16573. * @param subMesh The submesh we want to render in the shadow map
  16574. * @param useInstances Defines wether will draw in the map using instances
  16575. * @returns true if ready otherwise, false
  16576. */
  16577. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  16578. /**
  16579. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  16580. * @param defines Defines of the material we want to update
  16581. * @param lightIndex Index of the light in the enabled light list of the material
  16582. */
  16583. prepareDefines(defines: any, lightIndex: number): void;
  16584. /**
  16585. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  16586. * defined in the generator but impacting the effect).
  16587. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  16588. * @param effect The effect we are binfing the information for
  16589. */
  16590. bindShadowLight(lightIndex: string, effect: Effect): void;
  16591. /**
  16592. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  16593. * (eq to shadow prjection matrix * light transform matrix)
  16594. * @returns The transform matrix used to create the shadow map
  16595. */
  16596. getTransformMatrix(): Matrix;
  16597. /**
  16598. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  16599. * Cube and 2D textures for instance.
  16600. */
  16601. recreateShadowMap(): void;
  16602. protected _disposeBlurPostProcesses(): void;
  16603. protected _disposeRTTandPostProcesses(): void;
  16604. /**
  16605. * Disposes the ShadowGenerator.
  16606. * Returns nothing.
  16607. */
  16608. dispose(): void;
  16609. /**
  16610. * Serializes the shadow generator setup to a json object.
  16611. * @returns The serialized JSON object
  16612. */
  16613. serialize(): any;
  16614. /**
  16615. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  16616. * @param parsedShadowGenerator The JSON object to parse
  16617. * @param scene The scene to create the shadow map for
  16618. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  16619. * @returns The parsed shadow generator
  16620. */
  16621. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  16622. }
  16623. }
  16624. declare module BABYLON {
  16625. /**
  16626. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  16627. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  16628. * All meshes allow light to pass through them unless shadow generation is activated. The default number of lights allowed is four but this can be increased.
  16629. */
  16630. export abstract class Light extends Node {
  16631. /**
  16632. * Falloff Default: light is falling off following the material specification:
  16633. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  16634. */
  16635. static readonly FALLOFF_DEFAULT: number;
  16636. /**
  16637. * Falloff Physical: light is falling off following the inverse squared distance law.
  16638. */
  16639. static readonly FALLOFF_PHYSICAL: number;
  16640. /**
  16641. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  16642. * to enhance interoperability with other engines.
  16643. */
  16644. static readonly FALLOFF_GLTF: number;
  16645. /**
  16646. * Falloff Standard: light is falling off like in the standard material
  16647. * to enhance interoperability with other materials.
  16648. */
  16649. static readonly FALLOFF_STANDARD: number;
  16650. /**
  16651. * If every light affecting the material is in this lightmapMode,
  16652. * material.lightmapTexture adds or multiplies
  16653. * (depends on material.useLightmapAsShadowmap)
  16654. * after every other light calculations.
  16655. */
  16656. static readonly LIGHTMAP_DEFAULT: number;
  16657. /**
  16658. * material.lightmapTexture as only diffuse lighting from this light
  16659. * adds only specular lighting from this light
  16660. * adds dynamic shadows
  16661. */
  16662. static readonly LIGHTMAP_SPECULAR: number;
  16663. /**
  16664. * material.lightmapTexture as only lighting
  16665. * no light calculation from this light
  16666. * only adds dynamic shadows from this light
  16667. */
  16668. static readonly LIGHTMAP_SHADOWSONLY: number;
  16669. /**
  16670. * Each light type uses the default quantity according to its type:
  16671. * point/spot lights use luminous intensity
  16672. * directional lights use illuminance
  16673. */
  16674. static readonly INTENSITYMODE_AUTOMATIC: number;
  16675. /**
  16676. * lumen (lm)
  16677. */
  16678. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  16679. /**
  16680. * candela (lm/sr)
  16681. */
  16682. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  16683. /**
  16684. * lux (lm/m^2)
  16685. */
  16686. static readonly INTENSITYMODE_ILLUMINANCE: number;
  16687. /**
  16688. * nit (cd/m^2)
  16689. */
  16690. static readonly INTENSITYMODE_LUMINANCE: number;
  16691. /**
  16692. * Light type const id of the point light.
  16693. */
  16694. static readonly LIGHTTYPEID_POINTLIGHT: number;
  16695. /**
  16696. * Light type const id of the directional light.
  16697. */
  16698. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  16699. /**
  16700. * Light type const id of the spot light.
  16701. */
  16702. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  16703. /**
  16704. * Light type const id of the hemispheric light.
  16705. */
  16706. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  16707. /**
  16708. * Diffuse gives the basic color to an object.
  16709. */
  16710. diffuse: Color3;
  16711. /**
  16712. * Specular produces a highlight color on an object.
  16713. * Note: This is note affecting PBR materials.
  16714. */
  16715. specular: Color3;
  16716. /**
  16717. * Defines the falloff type for this light. This lets overrriding how punctual light are
  16718. * falling off base on range or angle.
  16719. * This can be set to any values in Light.FALLOFF_x.
  16720. *
  16721. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  16722. * other types of materials.
  16723. */
  16724. falloffType: number;
  16725. /**
  16726. * Strength of the light.
  16727. * Note: By default it is define in the framework own unit.
  16728. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  16729. */
  16730. intensity: number;
  16731. private _range;
  16732. protected _inverseSquaredRange: number;
  16733. /**
  16734. * Defines how far from the source the light is impacting in scene units.
  16735. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  16736. */
  16737. get range(): number;
  16738. /**
  16739. * Defines how far from the source the light is impacting in scene units.
  16740. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  16741. */
  16742. set range(value: number);
  16743. /**
  16744. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  16745. * of light.
  16746. */
  16747. private _photometricScale;
  16748. private _intensityMode;
  16749. /**
  16750. * Gets the photometric scale used to interpret the intensity.
  16751. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  16752. */
  16753. get intensityMode(): number;
  16754. /**
  16755. * Sets the photometric scale used to interpret the intensity.
  16756. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  16757. */
  16758. set intensityMode(value: number);
  16759. private _radius;
  16760. /**
  16761. * Gets the light radius used by PBR Materials to simulate soft area lights.
  16762. */
  16763. get radius(): number;
  16764. /**
  16765. * sets the light radius used by PBR Materials to simulate soft area lights.
  16766. */
  16767. set radius(value: number);
  16768. private _renderPriority;
  16769. /**
  16770. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  16771. * exceeding the number allowed of the materials.
  16772. */
  16773. renderPriority: number;
  16774. private _shadowEnabled;
  16775. /**
  16776. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  16777. * the current shadow generator.
  16778. */
  16779. get shadowEnabled(): boolean;
  16780. /**
  16781. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  16782. * the current shadow generator.
  16783. */
  16784. set shadowEnabled(value: boolean);
  16785. private _includedOnlyMeshes;
  16786. /**
  16787. * Gets the only meshes impacted by this light.
  16788. */
  16789. get includedOnlyMeshes(): AbstractMesh[];
  16790. /**
  16791. * Sets the only meshes impacted by this light.
  16792. */
  16793. set includedOnlyMeshes(value: AbstractMesh[]);
  16794. private _excludedMeshes;
  16795. /**
  16796. * Gets the meshes not impacted by this light.
  16797. */
  16798. get excludedMeshes(): AbstractMesh[];
  16799. /**
  16800. * Sets the meshes not impacted by this light.
  16801. */
  16802. set excludedMeshes(value: AbstractMesh[]);
  16803. private _excludeWithLayerMask;
  16804. /**
  16805. * Gets the layer id use to find what meshes are not impacted by the light.
  16806. * Inactive if 0
  16807. */
  16808. get excludeWithLayerMask(): number;
  16809. /**
  16810. * Sets the layer id use to find what meshes are not impacted by the light.
  16811. * Inactive if 0
  16812. */
  16813. set excludeWithLayerMask(value: number);
  16814. private _includeOnlyWithLayerMask;
  16815. /**
  16816. * Gets the layer id use to find what meshes are impacted by the light.
  16817. * Inactive if 0
  16818. */
  16819. get includeOnlyWithLayerMask(): number;
  16820. /**
  16821. * Sets the layer id use to find what meshes are impacted by the light.
  16822. * Inactive if 0
  16823. */
  16824. set includeOnlyWithLayerMask(value: number);
  16825. private _lightmapMode;
  16826. /**
  16827. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  16828. */
  16829. get lightmapMode(): number;
  16830. /**
  16831. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  16832. */
  16833. set lightmapMode(value: number);
  16834. /**
  16835. * Shadow generator associted to the light.
  16836. * @hidden Internal use only.
  16837. */
  16838. _shadowGenerator: Nullable<IShadowGenerator>;
  16839. /**
  16840. * @hidden Internal use only.
  16841. */
  16842. _excludedMeshesIds: string[];
  16843. /**
  16844. * @hidden Internal use only.
  16845. */
  16846. _includedOnlyMeshesIds: string[];
  16847. /**
  16848. * The current light unifom buffer.
  16849. * @hidden Internal use only.
  16850. */
  16851. _uniformBuffer: UniformBuffer;
  16852. /** @hidden */
  16853. _renderId: number;
  16854. /**
  16855. * Creates a Light object in the scene.
  16856. * Documentation : https://doc.babylonjs.com/babylon101/lights
  16857. * @param name The firendly name of the light
  16858. * @param scene The scene the light belongs too
  16859. */
  16860. constructor(name: string, scene: Scene);
  16861. protected abstract _buildUniformLayout(): void;
  16862. /**
  16863. * Sets the passed Effect "effect" with the Light information.
  16864. * @param effect The effect to update
  16865. * @param lightIndex The index of the light in the effect to update
  16866. * @returns The light
  16867. */
  16868. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  16869. /**
  16870. * Sets the passed Effect "effect" with the Light textures.
  16871. * @param effect The effect to update
  16872. * @param lightIndex The index of the light in the effect to update
  16873. * @returns The light
  16874. */
  16875. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  16876. /**
  16877. * Binds the lights information from the scene to the effect for the given mesh.
  16878. * @param lightIndex Light index
  16879. * @param scene The scene where the light belongs to
  16880. * @param effect The effect we are binding the data to
  16881. * @param useSpecular Defines if specular is supported
  16882. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  16883. */
  16884. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  16885. /**
  16886. * Sets the passed Effect "effect" with the Light information.
  16887. * @param effect The effect to update
  16888. * @param lightDataUniformName The uniform used to store light data (position or direction)
  16889. * @returns The light
  16890. */
  16891. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  16892. /**
  16893. * Returns the string "Light".
  16894. * @returns the class name
  16895. */
  16896. getClassName(): string;
  16897. /** @hidden */
  16898. readonly _isLight: boolean;
  16899. /**
  16900. * Converts the light information to a readable string for debug purpose.
  16901. * @param fullDetails Supports for multiple levels of logging within scene loading
  16902. * @returns the human readable light info
  16903. */
  16904. toString(fullDetails?: boolean): string;
  16905. /** @hidden */
  16906. protected _syncParentEnabledState(): void;
  16907. /**
  16908. * Set the enabled state of this node.
  16909. * @param value - the new enabled state
  16910. */
  16911. setEnabled(value: boolean): void;
  16912. /**
  16913. * Returns the Light associated shadow generator if any.
  16914. * @return the associated shadow generator.
  16915. */
  16916. getShadowGenerator(): Nullable<IShadowGenerator>;
  16917. /**
  16918. * Returns a Vector3, the absolute light position in the World.
  16919. * @returns the world space position of the light
  16920. */
  16921. getAbsolutePosition(): Vector3;
  16922. /**
  16923. * Specifies if the light will affect the passed mesh.
  16924. * @param mesh The mesh to test against the light
  16925. * @return true the mesh is affected otherwise, false.
  16926. */
  16927. canAffectMesh(mesh: AbstractMesh): boolean;
  16928. /**
  16929. * Sort function to order lights for rendering.
  16930. * @param a First Light object to compare to second.
  16931. * @param b Second Light object to compare first.
  16932. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  16933. */
  16934. static CompareLightsPriority(a: Light, b: Light): number;
  16935. /**
  16936. * Releases resources associated with this node.
  16937. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  16938. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  16939. */
  16940. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  16941. /**
  16942. * Returns the light type ID (integer).
  16943. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  16944. */
  16945. getTypeID(): number;
  16946. /**
  16947. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  16948. * @returns the scaled intensity in intensity mode unit
  16949. */
  16950. getScaledIntensity(): number;
  16951. /**
  16952. * Returns a new Light object, named "name", from the current one.
  16953. * @param name The name of the cloned light
  16954. * @returns the new created light
  16955. */
  16956. clone(name: string): Nullable<Light>;
  16957. /**
  16958. * Serializes the current light into a Serialization object.
  16959. * @returns the serialized object.
  16960. */
  16961. serialize(): any;
  16962. /**
  16963. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  16964. * This new light is named "name" and added to the passed scene.
  16965. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  16966. * @param name The friendly name of the light
  16967. * @param scene The scene the new light will belong to
  16968. * @returns the constructor function
  16969. */
  16970. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  16971. /**
  16972. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  16973. * @param parsedLight The JSON representation of the light
  16974. * @param scene The scene to create the parsed light in
  16975. * @returns the created light after parsing
  16976. */
  16977. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  16978. private _hookArrayForExcluded;
  16979. private _hookArrayForIncludedOnly;
  16980. private _resyncMeshes;
  16981. /**
  16982. * Forces the meshes to update their light related information in their rendering used effects
  16983. * @hidden Internal Use Only
  16984. */
  16985. _markMeshesAsLightDirty(): void;
  16986. /**
  16987. * Recomputes the cached photometric scale if needed.
  16988. */
  16989. private _computePhotometricScale;
  16990. /**
  16991. * Returns the Photometric Scale according to the light type and intensity mode.
  16992. */
  16993. private _getPhotometricScale;
  16994. /**
  16995. * Reorder the light in the scene according to their defined priority.
  16996. * @hidden Internal Use Only
  16997. */
  16998. _reorderLightsInScene(): void;
  16999. /**
  17000. * Prepares the list of defines specific to the light type.
  17001. * @param defines the list of defines
  17002. * @param lightIndex defines the index of the light for the effect
  17003. */
  17004. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  17005. }
  17006. }
  17007. declare module BABYLON {
  17008. /**
  17009. * Interface used to define Action
  17010. */
  17011. export interface IAction {
  17012. /**
  17013. * Trigger for the action
  17014. */
  17015. trigger: number;
  17016. /** Options of the trigger */
  17017. triggerOptions: any;
  17018. /**
  17019. * Gets the trigger parameters
  17020. * @returns the trigger parameters
  17021. */
  17022. getTriggerParameter(): any;
  17023. /**
  17024. * Internal only - executes current action event
  17025. * @hidden
  17026. */
  17027. _executeCurrent(evt?: ActionEvent): void;
  17028. /**
  17029. * Serialize placeholder for child classes
  17030. * @param parent of child
  17031. * @returns the serialized object
  17032. */
  17033. serialize(parent: any): any;
  17034. /**
  17035. * Internal only
  17036. * @hidden
  17037. */
  17038. _prepare(): void;
  17039. /**
  17040. * Internal only - manager for action
  17041. * @hidden
  17042. */
  17043. _actionManager: AbstractActionManager;
  17044. /**
  17045. * Adds action to chain of actions, may be a DoNothingAction
  17046. * @param action defines the next action to execute
  17047. * @returns The action passed in
  17048. * @see https://www.babylonjs-playground.com/#1T30HR#0
  17049. */
  17050. then(action: IAction): IAction;
  17051. }
  17052. /**
  17053. * The action to be carried out following a trigger
  17054. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  17055. */
  17056. export class Action implements IAction {
  17057. /** the trigger, with or without parameters, for the action */
  17058. triggerOptions: any;
  17059. /**
  17060. * Trigger for the action
  17061. */
  17062. trigger: number;
  17063. /**
  17064. * Internal only - manager for action
  17065. * @hidden
  17066. */
  17067. _actionManager: ActionManager;
  17068. private _nextActiveAction;
  17069. private _child;
  17070. private _condition?;
  17071. private _triggerParameter;
  17072. /**
  17073. * An event triggered prior to action being executed.
  17074. */
  17075. onBeforeExecuteObservable: Observable<Action>;
  17076. /**
  17077. * Creates a new Action
  17078. * @param triggerOptions the trigger, with or without parameters, for the action
  17079. * @param condition an optional determinant of action
  17080. */
  17081. constructor(
  17082. /** the trigger, with or without parameters, for the action */
  17083. triggerOptions: any, condition?: Condition);
  17084. /**
  17085. * Internal only
  17086. * @hidden
  17087. */
  17088. _prepare(): void;
  17089. /**
  17090. * Gets the trigger parameters
  17091. * @returns the trigger parameters
  17092. */
  17093. getTriggerParameter(): any;
  17094. /**
  17095. * Internal only - executes current action event
  17096. * @hidden
  17097. */
  17098. _executeCurrent(evt?: ActionEvent): void;
  17099. /**
  17100. * Execute placeholder for child classes
  17101. * @param evt optional action event
  17102. */
  17103. execute(evt?: ActionEvent): void;
  17104. /**
  17105. * Skips to next active action
  17106. */
  17107. skipToNextActiveAction(): void;
  17108. /**
  17109. * Adds action to chain of actions, may be a DoNothingAction
  17110. * @param action defines the next action to execute
  17111. * @returns The action passed in
  17112. * @see https://www.babylonjs-playground.com/#1T30HR#0
  17113. */
  17114. then(action: Action): Action;
  17115. /**
  17116. * Internal only
  17117. * @hidden
  17118. */
  17119. _getProperty(propertyPath: string): string;
  17120. /**
  17121. * Internal only
  17122. * @hidden
  17123. */
  17124. _getEffectiveTarget(target: any, propertyPath: string): any;
  17125. /**
  17126. * Serialize placeholder for child classes
  17127. * @param parent of child
  17128. * @returns the serialized object
  17129. */
  17130. serialize(parent: any): any;
  17131. /**
  17132. * Internal only called by serialize
  17133. * @hidden
  17134. */
  17135. protected _serialize(serializedAction: any, parent?: any): any;
  17136. /**
  17137. * Internal only
  17138. * @hidden
  17139. */
  17140. static _SerializeValueAsString: (value: any) => string;
  17141. /**
  17142. * Internal only
  17143. * @hidden
  17144. */
  17145. static _GetTargetProperty: (target: Node | Scene) => {
  17146. name: string;
  17147. targetType: string;
  17148. value: string;
  17149. };
  17150. }
  17151. }
  17152. declare module BABYLON {
  17153. /**
  17154. * A Condition applied to an Action
  17155. */
  17156. export class Condition {
  17157. /**
  17158. * Internal only - manager for action
  17159. * @hidden
  17160. */
  17161. _actionManager: ActionManager;
  17162. /**
  17163. * Internal only
  17164. * @hidden
  17165. */
  17166. _evaluationId: number;
  17167. /**
  17168. * Internal only
  17169. * @hidden
  17170. */
  17171. _currentResult: boolean;
  17172. /**
  17173. * Creates a new Condition
  17174. * @param actionManager the manager of the action the condition is applied to
  17175. */
  17176. constructor(actionManager: ActionManager);
  17177. /**
  17178. * Check if the current condition is valid
  17179. * @returns a boolean
  17180. */
  17181. isValid(): boolean;
  17182. /**
  17183. * Internal only
  17184. * @hidden
  17185. */
  17186. _getProperty(propertyPath: string): string;
  17187. /**
  17188. * Internal only
  17189. * @hidden
  17190. */
  17191. _getEffectiveTarget(target: any, propertyPath: string): any;
  17192. /**
  17193. * Serialize placeholder for child classes
  17194. * @returns the serialized object
  17195. */
  17196. serialize(): any;
  17197. /**
  17198. * Internal only
  17199. * @hidden
  17200. */
  17201. protected _serialize(serializedCondition: any): any;
  17202. }
  17203. /**
  17204. * Defines specific conditional operators as extensions of Condition
  17205. */
  17206. export class ValueCondition extends Condition {
  17207. /** path to specify the property of the target the conditional operator uses */
  17208. propertyPath: string;
  17209. /** the value compared by the conditional operator against the current value of the property */
  17210. value: any;
  17211. /** the conditional operator, default ValueCondition.IsEqual */
  17212. operator: number;
  17213. /**
  17214. * Internal only
  17215. * @hidden
  17216. */
  17217. private static _IsEqual;
  17218. /**
  17219. * Internal only
  17220. * @hidden
  17221. */
  17222. private static _IsDifferent;
  17223. /**
  17224. * Internal only
  17225. * @hidden
  17226. */
  17227. private static _IsGreater;
  17228. /**
  17229. * Internal only
  17230. * @hidden
  17231. */
  17232. private static _IsLesser;
  17233. /**
  17234. * returns the number for IsEqual
  17235. */
  17236. static get IsEqual(): number;
  17237. /**
  17238. * Returns the number for IsDifferent
  17239. */
  17240. static get IsDifferent(): number;
  17241. /**
  17242. * Returns the number for IsGreater
  17243. */
  17244. static get IsGreater(): number;
  17245. /**
  17246. * Returns the number for IsLesser
  17247. */
  17248. static get IsLesser(): number;
  17249. /**
  17250. * Internal only The action manager for the condition
  17251. * @hidden
  17252. */
  17253. _actionManager: ActionManager;
  17254. /**
  17255. * Internal only
  17256. * @hidden
  17257. */
  17258. private _target;
  17259. /**
  17260. * Internal only
  17261. * @hidden
  17262. */
  17263. private _effectiveTarget;
  17264. /**
  17265. * Internal only
  17266. * @hidden
  17267. */
  17268. private _property;
  17269. /**
  17270. * Creates a new ValueCondition
  17271. * @param actionManager manager for the action the condition applies to
  17272. * @param target for the action
  17273. * @param propertyPath path to specify the property of the target the conditional operator uses
  17274. * @param value the value compared by the conditional operator against the current value of the property
  17275. * @param operator the conditional operator, default ValueCondition.IsEqual
  17276. */
  17277. constructor(actionManager: ActionManager, target: any,
  17278. /** path to specify the property of the target the conditional operator uses */
  17279. propertyPath: string,
  17280. /** the value compared by the conditional operator against the current value of the property */
  17281. value: any,
  17282. /** the conditional operator, default ValueCondition.IsEqual */
  17283. operator?: number);
  17284. /**
  17285. * Compares the given value with the property value for the specified conditional operator
  17286. * @returns the result of the comparison
  17287. */
  17288. isValid(): boolean;
  17289. /**
  17290. * Serialize the ValueCondition into a JSON compatible object
  17291. * @returns serialization object
  17292. */
  17293. serialize(): any;
  17294. /**
  17295. * Gets the name of the conditional operator for the ValueCondition
  17296. * @param operator the conditional operator
  17297. * @returns the name
  17298. */
  17299. static GetOperatorName(operator: number): string;
  17300. }
  17301. /**
  17302. * Defines a predicate condition as an extension of Condition
  17303. */
  17304. export class PredicateCondition extends Condition {
  17305. /** defines the predicate function used to validate the condition */
  17306. predicate: () => boolean;
  17307. /**
  17308. * Internal only - manager for action
  17309. * @hidden
  17310. */
  17311. _actionManager: ActionManager;
  17312. /**
  17313. * Creates a new PredicateCondition
  17314. * @param actionManager manager for the action the condition applies to
  17315. * @param predicate defines the predicate function used to validate the condition
  17316. */
  17317. constructor(actionManager: ActionManager,
  17318. /** defines the predicate function used to validate the condition */
  17319. predicate: () => boolean);
  17320. /**
  17321. * @returns the validity of the predicate condition
  17322. */
  17323. isValid(): boolean;
  17324. }
  17325. /**
  17326. * Defines a state condition as an extension of Condition
  17327. */
  17328. export class StateCondition extends Condition {
  17329. /** Value to compare with target state */
  17330. value: string;
  17331. /**
  17332. * Internal only - manager for action
  17333. * @hidden
  17334. */
  17335. _actionManager: ActionManager;
  17336. /**
  17337. * Internal only
  17338. * @hidden
  17339. */
  17340. private _target;
  17341. /**
  17342. * Creates a new StateCondition
  17343. * @param actionManager manager for the action the condition applies to
  17344. * @param target of the condition
  17345. * @param value to compare with target state
  17346. */
  17347. constructor(actionManager: ActionManager, target: any,
  17348. /** Value to compare with target state */
  17349. value: string);
  17350. /**
  17351. * Gets a boolean indicating if the current condition is met
  17352. * @returns the validity of the state
  17353. */
  17354. isValid(): boolean;
  17355. /**
  17356. * Serialize the StateCondition into a JSON compatible object
  17357. * @returns serialization object
  17358. */
  17359. serialize(): any;
  17360. }
  17361. }
  17362. declare module BABYLON {
  17363. /**
  17364. * This defines an action responsible to toggle a boolean once triggered.
  17365. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17366. */
  17367. export class SwitchBooleanAction extends Action {
  17368. /**
  17369. * The path to the boolean property in the target object
  17370. */
  17371. propertyPath: string;
  17372. private _target;
  17373. private _effectiveTarget;
  17374. private _property;
  17375. /**
  17376. * Instantiate the action
  17377. * @param triggerOptions defines the trigger options
  17378. * @param target defines the object containing the boolean
  17379. * @param propertyPath defines the path to the boolean property in the target object
  17380. * @param condition defines the trigger related conditions
  17381. */
  17382. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  17383. /** @hidden */
  17384. _prepare(): void;
  17385. /**
  17386. * Execute the action toggle the boolean value.
  17387. */
  17388. execute(): void;
  17389. /**
  17390. * Serializes the actions and its related information.
  17391. * @param parent defines the object to serialize in
  17392. * @returns the serialized object
  17393. */
  17394. serialize(parent: any): any;
  17395. }
  17396. /**
  17397. * This defines an action responsible to set a the state field of the target
  17398. * to a desired value once triggered.
  17399. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17400. */
  17401. export class SetStateAction extends Action {
  17402. /**
  17403. * The value to store in the state field.
  17404. */
  17405. value: string;
  17406. private _target;
  17407. /**
  17408. * Instantiate the action
  17409. * @param triggerOptions defines the trigger options
  17410. * @param target defines the object containing the state property
  17411. * @param value defines the value to store in the state field
  17412. * @param condition defines the trigger related conditions
  17413. */
  17414. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  17415. /**
  17416. * Execute the action and store the value on the target state property.
  17417. */
  17418. execute(): void;
  17419. /**
  17420. * Serializes the actions and its related information.
  17421. * @param parent defines the object to serialize in
  17422. * @returns the serialized object
  17423. */
  17424. serialize(parent: any): any;
  17425. }
  17426. /**
  17427. * This defines an action responsible to set a property of the target
  17428. * to a desired value once triggered.
  17429. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17430. */
  17431. export class SetValueAction extends Action {
  17432. /**
  17433. * The path of the property to set in the target.
  17434. */
  17435. propertyPath: string;
  17436. /**
  17437. * The value to set in the property
  17438. */
  17439. value: any;
  17440. private _target;
  17441. private _effectiveTarget;
  17442. private _property;
  17443. /**
  17444. * Instantiate the action
  17445. * @param triggerOptions defines the trigger options
  17446. * @param target defines the object containing the property
  17447. * @param propertyPath defines the path of the property to set in the target
  17448. * @param value defines the value to set in the property
  17449. * @param condition defines the trigger related conditions
  17450. */
  17451. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  17452. /** @hidden */
  17453. _prepare(): void;
  17454. /**
  17455. * Execute the action and set the targetted property to the desired value.
  17456. */
  17457. execute(): void;
  17458. /**
  17459. * Serializes the actions and its related information.
  17460. * @param parent defines the object to serialize in
  17461. * @returns the serialized object
  17462. */
  17463. serialize(parent: any): any;
  17464. }
  17465. /**
  17466. * This defines an action responsible to increment the target value
  17467. * to a desired value once triggered.
  17468. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17469. */
  17470. export class IncrementValueAction extends Action {
  17471. /**
  17472. * The path of the property to increment in the target.
  17473. */
  17474. propertyPath: string;
  17475. /**
  17476. * The value we should increment the property by.
  17477. */
  17478. value: any;
  17479. private _target;
  17480. private _effectiveTarget;
  17481. private _property;
  17482. /**
  17483. * Instantiate the action
  17484. * @param triggerOptions defines the trigger options
  17485. * @param target defines the object containing the property
  17486. * @param propertyPath defines the path of the property to increment in the target
  17487. * @param value defines the value value we should increment the property by
  17488. * @param condition defines the trigger related conditions
  17489. */
  17490. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  17491. /** @hidden */
  17492. _prepare(): void;
  17493. /**
  17494. * Execute the action and increment the target of the value amount.
  17495. */
  17496. execute(): void;
  17497. /**
  17498. * Serializes the actions and its related information.
  17499. * @param parent defines the object to serialize in
  17500. * @returns the serialized object
  17501. */
  17502. serialize(parent: any): any;
  17503. }
  17504. /**
  17505. * This defines an action responsible to start an animation once triggered.
  17506. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17507. */
  17508. export class PlayAnimationAction extends Action {
  17509. /**
  17510. * Where the animation should start (animation frame)
  17511. */
  17512. from: number;
  17513. /**
  17514. * Where the animation should stop (animation frame)
  17515. */
  17516. to: number;
  17517. /**
  17518. * Define if the animation should loop or stop after the first play.
  17519. */
  17520. loop?: boolean;
  17521. private _target;
  17522. /**
  17523. * Instantiate the action
  17524. * @param triggerOptions defines the trigger options
  17525. * @param target defines the target animation or animation name
  17526. * @param from defines from where the animation should start (animation frame)
  17527. * @param end defines where the animation should stop (animation frame)
  17528. * @param loop defines if the animation should loop or stop after the first play
  17529. * @param condition defines the trigger related conditions
  17530. */
  17531. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  17532. /** @hidden */
  17533. _prepare(): void;
  17534. /**
  17535. * Execute the action and play the animation.
  17536. */
  17537. execute(): void;
  17538. /**
  17539. * Serializes the actions and its related information.
  17540. * @param parent defines the object to serialize in
  17541. * @returns the serialized object
  17542. */
  17543. serialize(parent: any): any;
  17544. }
  17545. /**
  17546. * This defines an action responsible to stop an animation once triggered.
  17547. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17548. */
  17549. export class StopAnimationAction extends Action {
  17550. private _target;
  17551. /**
  17552. * Instantiate the action
  17553. * @param triggerOptions defines the trigger options
  17554. * @param target defines the target animation or animation name
  17555. * @param condition defines the trigger related conditions
  17556. */
  17557. constructor(triggerOptions: any, target: any, condition?: Condition);
  17558. /** @hidden */
  17559. _prepare(): void;
  17560. /**
  17561. * Execute the action and stop the animation.
  17562. */
  17563. execute(): void;
  17564. /**
  17565. * Serializes the actions and its related information.
  17566. * @param parent defines the object to serialize in
  17567. * @returns the serialized object
  17568. */
  17569. serialize(parent: any): any;
  17570. }
  17571. /**
  17572. * This defines an action responsible that does nothing once triggered.
  17573. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17574. */
  17575. export class DoNothingAction extends Action {
  17576. /**
  17577. * Instantiate the action
  17578. * @param triggerOptions defines the trigger options
  17579. * @param condition defines the trigger related conditions
  17580. */
  17581. constructor(triggerOptions?: any, condition?: Condition);
  17582. /**
  17583. * Execute the action and do nothing.
  17584. */
  17585. execute(): void;
  17586. /**
  17587. * Serializes the actions and its related information.
  17588. * @param parent defines the object to serialize in
  17589. * @returns the serialized object
  17590. */
  17591. serialize(parent: any): any;
  17592. }
  17593. /**
  17594. * This defines an action responsible to trigger several actions once triggered.
  17595. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17596. */
  17597. export class CombineAction extends Action {
  17598. /**
  17599. * The list of aggregated animations to run.
  17600. */
  17601. children: Action[];
  17602. /**
  17603. * Instantiate the action
  17604. * @param triggerOptions defines the trigger options
  17605. * @param children defines the list of aggregated animations to run
  17606. * @param condition defines the trigger related conditions
  17607. */
  17608. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  17609. /** @hidden */
  17610. _prepare(): void;
  17611. /**
  17612. * Execute the action and executes all the aggregated actions.
  17613. */
  17614. execute(evt: ActionEvent): void;
  17615. /**
  17616. * Serializes the actions and its related information.
  17617. * @param parent defines the object to serialize in
  17618. * @returns the serialized object
  17619. */
  17620. serialize(parent: any): any;
  17621. }
  17622. /**
  17623. * This defines an action responsible to run code (external event) once triggered.
  17624. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17625. */
  17626. export class ExecuteCodeAction extends Action {
  17627. /**
  17628. * The callback function to run.
  17629. */
  17630. func: (evt: ActionEvent) => void;
  17631. /**
  17632. * Instantiate the action
  17633. * @param triggerOptions defines the trigger options
  17634. * @param func defines the callback function to run
  17635. * @param condition defines the trigger related conditions
  17636. */
  17637. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  17638. /**
  17639. * Execute the action and run the attached code.
  17640. */
  17641. execute(evt: ActionEvent): void;
  17642. }
  17643. /**
  17644. * This defines an action responsible to set the parent property of the target once triggered.
  17645. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17646. */
  17647. export class SetParentAction extends Action {
  17648. private _parent;
  17649. private _target;
  17650. /**
  17651. * Instantiate the action
  17652. * @param triggerOptions defines the trigger options
  17653. * @param target defines the target containing the parent property
  17654. * @param parent defines from where the animation should start (animation frame)
  17655. * @param condition defines the trigger related conditions
  17656. */
  17657. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  17658. /** @hidden */
  17659. _prepare(): void;
  17660. /**
  17661. * Execute the action and set the parent property.
  17662. */
  17663. execute(): void;
  17664. /**
  17665. * Serializes the actions and its related information.
  17666. * @param parent defines the object to serialize in
  17667. * @returns the serialized object
  17668. */
  17669. serialize(parent: any): any;
  17670. }
  17671. }
  17672. declare module BABYLON {
  17673. /**
  17674. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  17675. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  17676. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17677. */
  17678. export class ActionManager extends AbstractActionManager {
  17679. /**
  17680. * Nothing
  17681. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17682. */
  17683. static readonly NothingTrigger: number;
  17684. /**
  17685. * On pick
  17686. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17687. */
  17688. static readonly OnPickTrigger: number;
  17689. /**
  17690. * On left pick
  17691. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17692. */
  17693. static readonly OnLeftPickTrigger: number;
  17694. /**
  17695. * On right pick
  17696. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17697. */
  17698. static readonly OnRightPickTrigger: number;
  17699. /**
  17700. * On center pick
  17701. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17702. */
  17703. static readonly OnCenterPickTrigger: number;
  17704. /**
  17705. * On pick down
  17706. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17707. */
  17708. static readonly OnPickDownTrigger: number;
  17709. /**
  17710. * On double pick
  17711. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17712. */
  17713. static readonly OnDoublePickTrigger: number;
  17714. /**
  17715. * On pick up
  17716. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17717. */
  17718. static readonly OnPickUpTrigger: number;
  17719. /**
  17720. * On pick out.
  17721. * This trigger will only be raised if you also declared a OnPickDown
  17722. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17723. */
  17724. static readonly OnPickOutTrigger: number;
  17725. /**
  17726. * On long press
  17727. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17728. */
  17729. static readonly OnLongPressTrigger: number;
  17730. /**
  17731. * On pointer over
  17732. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17733. */
  17734. static readonly OnPointerOverTrigger: number;
  17735. /**
  17736. * On pointer out
  17737. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17738. */
  17739. static readonly OnPointerOutTrigger: number;
  17740. /**
  17741. * On every frame
  17742. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17743. */
  17744. static readonly OnEveryFrameTrigger: number;
  17745. /**
  17746. * On intersection enter
  17747. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17748. */
  17749. static readonly OnIntersectionEnterTrigger: number;
  17750. /**
  17751. * On intersection exit
  17752. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17753. */
  17754. static readonly OnIntersectionExitTrigger: number;
  17755. /**
  17756. * On key down
  17757. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17758. */
  17759. static readonly OnKeyDownTrigger: number;
  17760. /**
  17761. * On key up
  17762. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17763. */
  17764. static readonly OnKeyUpTrigger: number;
  17765. private _scene;
  17766. /**
  17767. * Creates a new action manager
  17768. * @param scene defines the hosting scene
  17769. */
  17770. constructor(scene: Scene);
  17771. /**
  17772. * Releases all associated resources
  17773. */
  17774. dispose(): void;
  17775. /**
  17776. * Gets hosting scene
  17777. * @returns the hosting scene
  17778. */
  17779. getScene(): Scene;
  17780. /**
  17781. * Does this action manager handles actions of any of the given triggers
  17782. * @param triggers defines the triggers to be tested
  17783. * @return a boolean indicating whether one (or more) of the triggers is handled
  17784. */
  17785. hasSpecificTriggers(triggers: number[]): boolean;
  17786. /**
  17787. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  17788. * speed.
  17789. * @param triggerA defines the trigger to be tested
  17790. * @param triggerB defines the trigger to be tested
  17791. * @return a boolean indicating whether one (or more) of the triggers is handled
  17792. */
  17793. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  17794. /**
  17795. * Does this action manager handles actions of a given trigger
  17796. * @param trigger defines the trigger to be tested
  17797. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  17798. * @return whether the trigger is handled
  17799. */
  17800. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  17801. /**
  17802. * Does this action manager has pointer triggers
  17803. */
  17804. get hasPointerTriggers(): boolean;
  17805. /**
  17806. * Does this action manager has pick triggers
  17807. */
  17808. get hasPickTriggers(): boolean;
  17809. /**
  17810. * Registers an action to this action manager
  17811. * @param action defines the action to be registered
  17812. * @return the action amended (prepared) after registration
  17813. */
  17814. registerAction(action: IAction): Nullable<IAction>;
  17815. /**
  17816. * Unregisters an action to this action manager
  17817. * @param action defines the action to be unregistered
  17818. * @return a boolean indicating whether the action has been unregistered
  17819. */
  17820. unregisterAction(action: IAction): Boolean;
  17821. /**
  17822. * Process a specific trigger
  17823. * @param trigger defines the trigger to process
  17824. * @param evt defines the event details to be processed
  17825. */
  17826. processTrigger(trigger: number, evt?: IActionEvent): void;
  17827. /** @hidden */
  17828. _getEffectiveTarget(target: any, propertyPath: string): any;
  17829. /** @hidden */
  17830. _getProperty(propertyPath: string): string;
  17831. /**
  17832. * Serialize this manager to a JSON object
  17833. * @param name defines the property name to store this manager
  17834. * @returns a JSON representation of this manager
  17835. */
  17836. serialize(name: string): any;
  17837. /**
  17838. * Creates a new ActionManager from a JSON data
  17839. * @param parsedActions defines the JSON data to read from
  17840. * @param object defines the hosting mesh
  17841. * @param scene defines the hosting scene
  17842. */
  17843. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  17844. /**
  17845. * Get a trigger name by index
  17846. * @param trigger defines the trigger index
  17847. * @returns a trigger name
  17848. */
  17849. static GetTriggerName(trigger: number): string;
  17850. }
  17851. }
  17852. declare module BABYLON {
  17853. /**
  17854. * Class used to represent a sprite
  17855. * @see http://doc.babylonjs.com/babylon101/sprites
  17856. */
  17857. export class Sprite {
  17858. /** defines the name */
  17859. name: string;
  17860. /** Gets or sets the current world position */
  17861. position: Vector3;
  17862. /** Gets or sets the main color */
  17863. color: Color4;
  17864. /** Gets or sets the width */
  17865. width: number;
  17866. /** Gets or sets the height */
  17867. height: number;
  17868. /** Gets or sets rotation angle */
  17869. angle: number;
  17870. /** Gets or sets the cell index in the sprite sheet */
  17871. cellIndex: number;
  17872. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  17873. cellRef: string;
  17874. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  17875. invertU: number;
  17876. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  17877. invertV: number;
  17878. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  17879. disposeWhenFinishedAnimating: boolean;
  17880. /** Gets the list of attached animations */
  17881. animations: Animation[];
  17882. /** Gets or sets a boolean indicating if the sprite can be picked */
  17883. isPickable: boolean;
  17884. /**
  17885. * Gets or sets the associated action manager
  17886. */
  17887. actionManager: Nullable<ActionManager>;
  17888. private _animationStarted;
  17889. private _loopAnimation;
  17890. private _fromIndex;
  17891. private _toIndex;
  17892. private _delay;
  17893. private _direction;
  17894. private _manager;
  17895. private _time;
  17896. private _onAnimationEnd;
  17897. /**
  17898. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  17899. */
  17900. isVisible: boolean;
  17901. /**
  17902. * Gets or sets the sprite size
  17903. */
  17904. get size(): number;
  17905. set size(value: number);
  17906. /**
  17907. * Creates a new Sprite
  17908. * @param name defines the name
  17909. * @param manager defines the manager
  17910. */
  17911. constructor(
  17912. /** defines the name */
  17913. name: string, manager: ISpriteManager);
  17914. /**
  17915. * Starts an animation
  17916. * @param from defines the initial key
  17917. * @param to defines the end key
  17918. * @param loop defines if the animation must loop
  17919. * @param delay defines the start delay (in ms)
  17920. * @param onAnimationEnd defines a callback to call when animation ends
  17921. */
  17922. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  17923. /** Stops current animation (if any) */
  17924. stopAnimation(): void;
  17925. /** @hidden */
  17926. _animate(deltaTime: number): void;
  17927. /** Release associated resources */
  17928. dispose(): void;
  17929. }
  17930. }
  17931. declare module BABYLON {
  17932. /**
  17933. * Information about the result of picking within a scene
  17934. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  17935. */
  17936. export class PickingInfo {
  17937. /** @hidden */
  17938. _pickingUnavailable: boolean;
  17939. /**
  17940. * If the pick collided with an object
  17941. */
  17942. hit: boolean;
  17943. /**
  17944. * Distance away where the pick collided
  17945. */
  17946. distance: number;
  17947. /**
  17948. * The location of pick collision
  17949. */
  17950. pickedPoint: Nullable<Vector3>;
  17951. /**
  17952. * The mesh corresponding the the pick collision
  17953. */
  17954. pickedMesh: Nullable<AbstractMesh>;
  17955. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  17956. bu: number;
  17957. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  17958. bv: number;
  17959. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  17960. faceId: number;
  17961. /** Id of the the submesh that was picked */
  17962. subMeshId: number;
  17963. /** If a sprite was picked, this will be the sprite the pick collided with */
  17964. pickedSprite: Nullable<Sprite>;
  17965. /**
  17966. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  17967. */
  17968. originMesh: Nullable<AbstractMesh>;
  17969. /**
  17970. * The ray that was used to perform the picking.
  17971. */
  17972. ray: Nullable<Ray>;
  17973. /**
  17974. * Gets the normal correspodning to the face the pick collided with
  17975. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  17976. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  17977. * @returns The normal correspodning to the face the pick collided with
  17978. */
  17979. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  17980. /**
  17981. * Gets the texture coordinates of where the pick occured
  17982. * @returns the vector containing the coordnates of the texture
  17983. */
  17984. getTextureCoordinates(): Nullable<Vector2>;
  17985. }
  17986. }
  17987. declare module BABYLON {
  17988. /**
  17989. * Gather the list of pointer event types as constants.
  17990. */
  17991. export class PointerEventTypes {
  17992. /**
  17993. * The pointerdown event is fired when a pointer becomes active. For mouse, it is fired when the device transitions from no buttons depressed to at least one button depressed. For touch, it is fired when physical contact is made with the digitizer. For pen, it is fired when the stylus makes physical contact with the digitizer.
  17994. */
  17995. static readonly POINTERDOWN: number;
  17996. /**
  17997. * The pointerup event is fired when a pointer is no longer active.
  17998. */
  17999. static readonly POINTERUP: number;
  18000. /**
  18001. * The pointermove event is fired when a pointer changes coordinates.
  18002. */
  18003. static readonly POINTERMOVE: number;
  18004. /**
  18005. * The pointerwheel event is fired when a mouse wheel has been rotated.
  18006. */
  18007. static readonly POINTERWHEEL: number;
  18008. /**
  18009. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  18010. */
  18011. static readonly POINTERPICK: number;
  18012. /**
  18013. * The pointertap event is fired when a the object has been touched and released without drag.
  18014. */
  18015. static readonly POINTERTAP: number;
  18016. /**
  18017. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  18018. */
  18019. static readonly POINTERDOUBLETAP: number;
  18020. }
  18021. /**
  18022. * Base class of pointer info types.
  18023. */
  18024. export class PointerInfoBase {
  18025. /**
  18026. * Defines the type of event (PointerEventTypes)
  18027. */
  18028. type: number;
  18029. /**
  18030. * Defines the related dom event
  18031. */
  18032. event: PointerEvent | MouseWheelEvent;
  18033. /**
  18034. * Instantiates the base class of pointers info.
  18035. * @param type Defines the type of event (PointerEventTypes)
  18036. * @param event Defines the related dom event
  18037. */
  18038. constructor(
  18039. /**
  18040. * Defines the type of event (PointerEventTypes)
  18041. */
  18042. type: number,
  18043. /**
  18044. * Defines the related dom event
  18045. */
  18046. event: PointerEvent | MouseWheelEvent);
  18047. }
  18048. /**
  18049. * This class is used to store pointer related info for the onPrePointerObservable event.
  18050. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  18051. */
  18052. export class PointerInfoPre extends PointerInfoBase {
  18053. /**
  18054. * Ray from a pointer if availible (eg. 6dof controller)
  18055. */
  18056. ray: Nullable<Ray>;
  18057. /**
  18058. * Defines the local position of the pointer on the canvas.
  18059. */
  18060. localPosition: Vector2;
  18061. /**
  18062. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  18063. */
  18064. skipOnPointerObservable: boolean;
  18065. /**
  18066. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  18067. * @param type Defines the type of event (PointerEventTypes)
  18068. * @param event Defines the related dom event
  18069. * @param localX Defines the local x coordinates of the pointer when the event occured
  18070. * @param localY Defines the local y coordinates of the pointer when the event occured
  18071. */
  18072. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  18073. }
  18074. /**
  18075. * This type contains all the data related to a pointer event in Babylon.js.
  18076. * The event member is an instance of PointerEvent for all types except PointerWheel and is of type MouseWheelEvent when type equals PointerWheel. The different event types can be found in the PointerEventTypes class.
  18077. */
  18078. export class PointerInfo extends PointerInfoBase {
  18079. /**
  18080. * Defines the picking info associated to the info (if any)\
  18081. */
  18082. pickInfo: Nullable<PickingInfo>;
  18083. /**
  18084. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  18085. * @param type Defines the type of event (PointerEventTypes)
  18086. * @param event Defines the related dom event
  18087. * @param pickInfo Defines the picking info associated to the info (if any)\
  18088. */
  18089. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  18090. /**
  18091. * Defines the picking info associated to the info (if any)\
  18092. */
  18093. pickInfo: Nullable<PickingInfo>);
  18094. }
  18095. /**
  18096. * Data relating to a touch event on the screen.
  18097. */
  18098. export interface PointerTouch {
  18099. /**
  18100. * X coordinate of touch.
  18101. */
  18102. x: number;
  18103. /**
  18104. * Y coordinate of touch.
  18105. */
  18106. y: number;
  18107. /**
  18108. * Id of touch. Unique for each finger.
  18109. */
  18110. pointerId: number;
  18111. /**
  18112. * Event type passed from DOM.
  18113. */
  18114. type: any;
  18115. }
  18116. }
  18117. declare module BABYLON {
  18118. /**
  18119. * Manage the mouse inputs to control the movement of a free camera.
  18120. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18121. */
  18122. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  18123. /**
  18124. * Define if touch is enabled in the mouse input
  18125. */
  18126. touchEnabled: boolean;
  18127. /**
  18128. * Defines the camera the input is attached to.
  18129. */
  18130. camera: FreeCamera;
  18131. /**
  18132. * Defines the buttons associated with the input to handle camera move.
  18133. */
  18134. buttons: number[];
  18135. /**
  18136. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  18137. */
  18138. angularSensibility: number;
  18139. private _pointerInput;
  18140. private _onMouseMove;
  18141. private _observer;
  18142. private previousPosition;
  18143. /**
  18144. * Observable for when a pointer move event occurs containing the move offset
  18145. */
  18146. onPointerMovedObservable: Observable<{
  18147. offsetX: number;
  18148. offsetY: number;
  18149. }>;
  18150. /**
  18151. * @hidden
  18152. * If the camera should be rotated automatically based on pointer movement
  18153. */
  18154. _allowCameraRotation: boolean;
  18155. /**
  18156. * Manage the mouse inputs to control the movement of a free camera.
  18157. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18158. * @param touchEnabled Defines if touch is enabled or not
  18159. */
  18160. constructor(
  18161. /**
  18162. * Define if touch is enabled in the mouse input
  18163. */
  18164. touchEnabled?: boolean);
  18165. /**
  18166. * Attach the input controls to a specific dom element to get the input from.
  18167. * @param element Defines the element the controls should be listened from
  18168. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18169. */
  18170. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18171. /**
  18172. * Called on JS contextmenu event.
  18173. * Override this method to provide functionality.
  18174. */
  18175. protected onContextMenu(evt: PointerEvent): void;
  18176. /**
  18177. * Detach the current controls from the specified dom element.
  18178. * @param element Defines the element to stop listening the inputs from
  18179. */
  18180. detachControl(element: Nullable<HTMLElement>): void;
  18181. /**
  18182. * Gets the class name of the current intput.
  18183. * @returns the class name
  18184. */
  18185. getClassName(): string;
  18186. /**
  18187. * Get the friendly name associated with the input class.
  18188. * @returns the input friendly name
  18189. */
  18190. getSimpleName(): string;
  18191. }
  18192. }
  18193. declare module BABYLON {
  18194. /**
  18195. * Manage the touch inputs to control the movement of a free camera.
  18196. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18197. */
  18198. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  18199. /**
  18200. * Defines the camera the input is attached to.
  18201. */
  18202. camera: FreeCamera;
  18203. /**
  18204. * Defines the touch sensibility for rotation.
  18205. * The higher the faster.
  18206. */
  18207. touchAngularSensibility: number;
  18208. /**
  18209. * Defines the touch sensibility for move.
  18210. * The higher the faster.
  18211. */
  18212. touchMoveSensibility: number;
  18213. private _offsetX;
  18214. private _offsetY;
  18215. private _pointerPressed;
  18216. private _pointerInput;
  18217. private _observer;
  18218. private _onLostFocus;
  18219. /**
  18220. * Attach the input controls to a specific dom element to get the input from.
  18221. * @param element Defines the element the controls should be listened from
  18222. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18223. */
  18224. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18225. /**
  18226. * Detach the current controls from the specified dom element.
  18227. * @param element Defines the element to stop listening the inputs from
  18228. */
  18229. detachControl(element: Nullable<HTMLElement>): void;
  18230. /**
  18231. * Update the current camera state depending on the inputs that have been used this frame.
  18232. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  18233. */
  18234. checkInputs(): void;
  18235. /**
  18236. * Gets the class name of the current intput.
  18237. * @returns the class name
  18238. */
  18239. getClassName(): string;
  18240. /**
  18241. * Get the friendly name associated with the input class.
  18242. * @returns the input friendly name
  18243. */
  18244. getSimpleName(): string;
  18245. }
  18246. }
  18247. declare module BABYLON {
  18248. /**
  18249. * Default Inputs manager for the FreeCamera.
  18250. * It groups all the default supported inputs for ease of use.
  18251. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18252. */
  18253. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  18254. /**
  18255. * @hidden
  18256. */
  18257. _mouseInput: Nullable<FreeCameraMouseInput>;
  18258. /**
  18259. * Instantiates a new FreeCameraInputsManager.
  18260. * @param camera Defines the camera the inputs belong to
  18261. */
  18262. constructor(camera: FreeCamera);
  18263. /**
  18264. * Add keyboard input support to the input manager.
  18265. * @returns the current input manager
  18266. */
  18267. addKeyboard(): FreeCameraInputsManager;
  18268. /**
  18269. * Add mouse input support to the input manager.
  18270. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  18271. * @returns the current input manager
  18272. */
  18273. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  18274. /**
  18275. * Removes the mouse input support from the manager
  18276. * @returns the current input manager
  18277. */
  18278. removeMouse(): FreeCameraInputsManager;
  18279. /**
  18280. * Add touch input support to the input manager.
  18281. * @returns the current input manager
  18282. */
  18283. addTouch(): FreeCameraInputsManager;
  18284. /**
  18285. * Remove all attached input methods from a camera
  18286. */
  18287. clear(): void;
  18288. }
  18289. }
  18290. declare module BABYLON {
  18291. /**
  18292. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  18293. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  18294. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  18295. */
  18296. export class FreeCamera extends TargetCamera {
  18297. /**
  18298. * Define the collision ellipsoid of the camera.
  18299. * This is helpful to simulate a camera body like the player body around the camera
  18300. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  18301. */
  18302. ellipsoid: Vector3;
  18303. /**
  18304. * Define an offset for the position of the ellipsoid around the camera.
  18305. * This can be helpful to determine the center of the body near the gravity center of the body
  18306. * instead of its head.
  18307. */
  18308. ellipsoidOffset: Vector3;
  18309. /**
  18310. * Enable or disable collisions of the camera with the rest of the scene objects.
  18311. */
  18312. checkCollisions: boolean;
  18313. /**
  18314. * Enable or disable gravity on the camera.
  18315. */
  18316. applyGravity: boolean;
  18317. /**
  18318. * Define the input manager associated to the camera.
  18319. */
  18320. inputs: FreeCameraInputsManager;
  18321. /**
  18322. * Gets the input sensibility for a mouse input. (default is 2000.0)
  18323. * Higher values reduce sensitivity.
  18324. */
  18325. get angularSensibility(): number;
  18326. /**
  18327. * Sets the input sensibility for a mouse input. (default is 2000.0)
  18328. * Higher values reduce sensitivity.
  18329. */
  18330. set angularSensibility(value: number);
  18331. /**
  18332. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  18333. */
  18334. get keysUp(): number[];
  18335. set keysUp(value: number[]);
  18336. /**
  18337. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  18338. */
  18339. get keysDown(): number[];
  18340. set keysDown(value: number[]);
  18341. /**
  18342. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  18343. */
  18344. get keysLeft(): number[];
  18345. set keysLeft(value: number[]);
  18346. /**
  18347. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  18348. */
  18349. get keysRight(): number[];
  18350. set keysRight(value: number[]);
  18351. /**
  18352. * Event raised when the camera collide with a mesh in the scene.
  18353. */
  18354. onCollide: (collidedMesh: AbstractMesh) => void;
  18355. private _collider;
  18356. private _needMoveForGravity;
  18357. private _oldPosition;
  18358. private _diffPosition;
  18359. private _newPosition;
  18360. /** @hidden */
  18361. _localDirection: Vector3;
  18362. /** @hidden */
  18363. _transformedDirection: Vector3;
  18364. /**
  18365. * Instantiates a Free Camera.
  18366. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  18367. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  18368. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  18369. * @param name Define the name of the camera in the scene
  18370. * @param position Define the start position of the camera in the scene
  18371. * @param scene Define the scene the camera belongs to
  18372. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  18373. */
  18374. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  18375. /**
  18376. * Attached controls to the current camera.
  18377. * @param element Defines the element the controls should be listened from
  18378. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18379. */
  18380. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18381. /**
  18382. * Detach the current controls from the camera.
  18383. * The camera will stop reacting to inputs.
  18384. * @param element Defines the element to stop listening the inputs from
  18385. */
  18386. detachControl(element: HTMLElement): void;
  18387. private _collisionMask;
  18388. /**
  18389. * Define a collision mask to limit the list of object the camera can collide with
  18390. */
  18391. get collisionMask(): number;
  18392. set collisionMask(mask: number);
  18393. /** @hidden */
  18394. _collideWithWorld(displacement: Vector3): void;
  18395. private _onCollisionPositionChange;
  18396. /** @hidden */
  18397. _checkInputs(): void;
  18398. /** @hidden */
  18399. _decideIfNeedsToMove(): boolean;
  18400. /** @hidden */
  18401. _updatePosition(): void;
  18402. /**
  18403. * Destroy the camera and release the current resources hold by it.
  18404. */
  18405. dispose(): void;
  18406. /**
  18407. * Gets the current object class name.
  18408. * @return the class name
  18409. */
  18410. getClassName(): string;
  18411. }
  18412. }
  18413. declare module BABYLON {
  18414. /**
  18415. * Represents a gamepad control stick position
  18416. */
  18417. export class StickValues {
  18418. /**
  18419. * The x component of the control stick
  18420. */
  18421. x: number;
  18422. /**
  18423. * The y component of the control stick
  18424. */
  18425. y: number;
  18426. /**
  18427. * Initializes the gamepad x and y control stick values
  18428. * @param x The x component of the gamepad control stick value
  18429. * @param y The y component of the gamepad control stick value
  18430. */
  18431. constructor(
  18432. /**
  18433. * The x component of the control stick
  18434. */
  18435. x: number,
  18436. /**
  18437. * The y component of the control stick
  18438. */
  18439. y: number);
  18440. }
  18441. /**
  18442. * An interface which manages callbacks for gamepad button changes
  18443. */
  18444. export interface GamepadButtonChanges {
  18445. /**
  18446. * Called when a gamepad has been changed
  18447. */
  18448. changed: boolean;
  18449. /**
  18450. * Called when a gamepad press event has been triggered
  18451. */
  18452. pressChanged: boolean;
  18453. /**
  18454. * Called when a touch event has been triggered
  18455. */
  18456. touchChanged: boolean;
  18457. /**
  18458. * Called when a value has changed
  18459. */
  18460. valueChanged: boolean;
  18461. }
  18462. /**
  18463. * Represents a gamepad
  18464. */
  18465. export class Gamepad {
  18466. /**
  18467. * The id of the gamepad
  18468. */
  18469. id: string;
  18470. /**
  18471. * The index of the gamepad
  18472. */
  18473. index: number;
  18474. /**
  18475. * The browser gamepad
  18476. */
  18477. browserGamepad: any;
  18478. /**
  18479. * Specifies what type of gamepad this represents
  18480. */
  18481. type: number;
  18482. private _leftStick;
  18483. private _rightStick;
  18484. /** @hidden */
  18485. _isConnected: boolean;
  18486. private _leftStickAxisX;
  18487. private _leftStickAxisY;
  18488. private _rightStickAxisX;
  18489. private _rightStickAxisY;
  18490. /**
  18491. * Triggered when the left control stick has been changed
  18492. */
  18493. private _onleftstickchanged;
  18494. /**
  18495. * Triggered when the right control stick has been changed
  18496. */
  18497. private _onrightstickchanged;
  18498. /**
  18499. * Represents a gamepad controller
  18500. */
  18501. static GAMEPAD: number;
  18502. /**
  18503. * Represents a generic controller
  18504. */
  18505. static GENERIC: number;
  18506. /**
  18507. * Represents an XBox controller
  18508. */
  18509. static XBOX: number;
  18510. /**
  18511. * Represents a pose-enabled controller
  18512. */
  18513. static POSE_ENABLED: number;
  18514. /**
  18515. * Represents an Dual Shock controller
  18516. */
  18517. static DUALSHOCK: number;
  18518. /**
  18519. * Specifies whether the left control stick should be Y-inverted
  18520. */
  18521. protected _invertLeftStickY: boolean;
  18522. /**
  18523. * Specifies if the gamepad has been connected
  18524. */
  18525. get isConnected(): boolean;
  18526. /**
  18527. * Initializes the gamepad
  18528. * @param id The id of the gamepad
  18529. * @param index The index of the gamepad
  18530. * @param browserGamepad The browser gamepad
  18531. * @param leftStickX The x component of the left joystick
  18532. * @param leftStickY The y component of the left joystick
  18533. * @param rightStickX The x component of the right joystick
  18534. * @param rightStickY The y component of the right joystick
  18535. */
  18536. constructor(
  18537. /**
  18538. * The id of the gamepad
  18539. */
  18540. id: string,
  18541. /**
  18542. * The index of the gamepad
  18543. */
  18544. index: number,
  18545. /**
  18546. * The browser gamepad
  18547. */
  18548. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  18549. /**
  18550. * Callback triggered when the left joystick has changed
  18551. * @param callback
  18552. */
  18553. onleftstickchanged(callback: (values: StickValues) => void): void;
  18554. /**
  18555. * Callback triggered when the right joystick has changed
  18556. * @param callback
  18557. */
  18558. onrightstickchanged(callback: (values: StickValues) => void): void;
  18559. /**
  18560. * Gets the left joystick
  18561. */
  18562. get leftStick(): StickValues;
  18563. /**
  18564. * Sets the left joystick values
  18565. */
  18566. set leftStick(newValues: StickValues);
  18567. /**
  18568. * Gets the right joystick
  18569. */
  18570. get rightStick(): StickValues;
  18571. /**
  18572. * Sets the right joystick value
  18573. */
  18574. set rightStick(newValues: StickValues);
  18575. /**
  18576. * Updates the gamepad joystick positions
  18577. */
  18578. update(): void;
  18579. /**
  18580. * Disposes the gamepad
  18581. */
  18582. dispose(): void;
  18583. }
  18584. /**
  18585. * Represents a generic gamepad
  18586. */
  18587. export class GenericPad extends Gamepad {
  18588. private _buttons;
  18589. private _onbuttondown;
  18590. private _onbuttonup;
  18591. /**
  18592. * Observable triggered when a button has been pressed
  18593. */
  18594. onButtonDownObservable: Observable<number>;
  18595. /**
  18596. * Observable triggered when a button has been released
  18597. */
  18598. onButtonUpObservable: Observable<number>;
  18599. /**
  18600. * Callback triggered when a button has been pressed
  18601. * @param callback Called when a button has been pressed
  18602. */
  18603. onbuttondown(callback: (buttonPressed: number) => void): void;
  18604. /**
  18605. * Callback triggered when a button has been released
  18606. * @param callback Called when a button has been released
  18607. */
  18608. onbuttonup(callback: (buttonReleased: number) => void): void;
  18609. /**
  18610. * Initializes the generic gamepad
  18611. * @param id The id of the generic gamepad
  18612. * @param index The index of the generic gamepad
  18613. * @param browserGamepad The browser gamepad
  18614. */
  18615. constructor(id: string, index: number, browserGamepad: any);
  18616. private _setButtonValue;
  18617. /**
  18618. * Updates the generic gamepad
  18619. */
  18620. update(): void;
  18621. /**
  18622. * Disposes the generic gamepad
  18623. */
  18624. dispose(): void;
  18625. }
  18626. }
  18627. declare module BABYLON {
  18628. /**
  18629. * Defines the types of pose enabled controllers that are supported
  18630. */
  18631. export enum PoseEnabledControllerType {
  18632. /**
  18633. * HTC Vive
  18634. */
  18635. VIVE = 0,
  18636. /**
  18637. * Oculus Rift
  18638. */
  18639. OCULUS = 1,
  18640. /**
  18641. * Windows mixed reality
  18642. */
  18643. WINDOWS = 2,
  18644. /**
  18645. * Samsung gear VR
  18646. */
  18647. GEAR_VR = 3,
  18648. /**
  18649. * Google Daydream
  18650. */
  18651. DAYDREAM = 4,
  18652. /**
  18653. * Generic
  18654. */
  18655. GENERIC = 5
  18656. }
  18657. /**
  18658. * Defines the MutableGamepadButton interface for the state of a gamepad button
  18659. */
  18660. export interface MutableGamepadButton {
  18661. /**
  18662. * Value of the button/trigger
  18663. */
  18664. value: number;
  18665. /**
  18666. * If the button/trigger is currently touched
  18667. */
  18668. touched: boolean;
  18669. /**
  18670. * If the button/trigger is currently pressed
  18671. */
  18672. pressed: boolean;
  18673. }
  18674. /**
  18675. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  18676. * @hidden
  18677. */
  18678. export interface ExtendedGamepadButton extends GamepadButton {
  18679. /**
  18680. * If the button/trigger is currently pressed
  18681. */
  18682. readonly pressed: boolean;
  18683. /**
  18684. * If the button/trigger is currently touched
  18685. */
  18686. readonly touched: boolean;
  18687. /**
  18688. * Value of the button/trigger
  18689. */
  18690. readonly value: number;
  18691. }
  18692. /** @hidden */
  18693. export interface _GamePadFactory {
  18694. /**
  18695. * Returns whether or not the current gamepad can be created for this type of controller.
  18696. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  18697. * @returns true if it can be created, otherwise false
  18698. */
  18699. canCreate(gamepadInfo: any): boolean;
  18700. /**
  18701. * Creates a new instance of the Gamepad.
  18702. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  18703. * @returns the new gamepad instance
  18704. */
  18705. create(gamepadInfo: any): Gamepad;
  18706. }
  18707. /**
  18708. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  18709. */
  18710. export class PoseEnabledControllerHelper {
  18711. /** @hidden */
  18712. static _ControllerFactories: _GamePadFactory[];
  18713. /** @hidden */
  18714. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  18715. /**
  18716. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  18717. * @param vrGamepad the gamepad to initialized
  18718. * @returns a vr controller of the type the gamepad identified as
  18719. */
  18720. static InitiateController(vrGamepad: any): Gamepad;
  18721. }
  18722. /**
  18723. * Defines the PoseEnabledController object that contains state of a vr capable controller
  18724. */
  18725. export class PoseEnabledController extends Gamepad implements PoseControlled {
  18726. /**
  18727. * If the controller is used in a webXR session
  18728. */
  18729. isXR: boolean;
  18730. private _deviceRoomPosition;
  18731. private _deviceRoomRotationQuaternion;
  18732. /**
  18733. * The device position in babylon space
  18734. */
  18735. devicePosition: Vector3;
  18736. /**
  18737. * The device rotation in babylon space
  18738. */
  18739. deviceRotationQuaternion: Quaternion;
  18740. /**
  18741. * The scale factor of the device in babylon space
  18742. */
  18743. deviceScaleFactor: number;
  18744. /**
  18745. * (Likely devicePosition should be used instead) The device position in its room space
  18746. */
  18747. position: Vector3;
  18748. /**
  18749. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  18750. */
  18751. rotationQuaternion: Quaternion;
  18752. /**
  18753. * The type of controller (Eg. Windows mixed reality)
  18754. */
  18755. controllerType: PoseEnabledControllerType;
  18756. protected _calculatedPosition: Vector3;
  18757. private _calculatedRotation;
  18758. /**
  18759. * The raw pose from the device
  18760. */
  18761. rawPose: DevicePose;
  18762. private _trackPosition;
  18763. private _maxRotationDistFromHeadset;
  18764. private _draggedRoomRotation;
  18765. /**
  18766. * @hidden
  18767. */
  18768. _disableTrackPosition(fixedPosition: Vector3): void;
  18769. /**
  18770. * Internal, the mesh attached to the controller
  18771. * @hidden
  18772. */
  18773. _mesh: Nullable<AbstractMesh>;
  18774. private _poseControlledCamera;
  18775. private _leftHandSystemQuaternion;
  18776. /**
  18777. * Internal, matrix used to convert room space to babylon space
  18778. * @hidden
  18779. */
  18780. _deviceToWorld: Matrix;
  18781. /**
  18782. * Node to be used when casting a ray from the controller
  18783. * @hidden
  18784. */
  18785. _pointingPoseNode: Nullable<TransformNode>;
  18786. /**
  18787. * Name of the child mesh that can be used to cast a ray from the controller
  18788. */
  18789. static readonly POINTING_POSE: string;
  18790. /**
  18791. * Creates a new PoseEnabledController from a gamepad
  18792. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  18793. */
  18794. constructor(browserGamepad: any);
  18795. private _workingMatrix;
  18796. /**
  18797. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  18798. */
  18799. update(): void;
  18800. /**
  18801. * Updates only the pose device and mesh without doing any button event checking
  18802. */
  18803. protected _updatePoseAndMesh(): void;
  18804. /**
  18805. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  18806. * @param poseData raw pose fromthe device
  18807. */
  18808. updateFromDevice(poseData: DevicePose): void;
  18809. /**
  18810. * @hidden
  18811. */
  18812. _meshAttachedObservable: Observable<AbstractMesh>;
  18813. /**
  18814. * Attaches a mesh to the controller
  18815. * @param mesh the mesh to be attached
  18816. */
  18817. attachToMesh(mesh: AbstractMesh): void;
  18818. /**
  18819. * Attaches the controllers mesh to a camera
  18820. * @param camera the camera the mesh should be attached to
  18821. */
  18822. attachToPoseControlledCamera(camera: TargetCamera): void;
  18823. /**
  18824. * Disposes of the controller
  18825. */
  18826. dispose(): void;
  18827. /**
  18828. * The mesh that is attached to the controller
  18829. */
  18830. get mesh(): Nullable<AbstractMesh>;
  18831. /**
  18832. * Gets the ray of the controller in the direction the controller is pointing
  18833. * @param length the length the resulting ray should be
  18834. * @returns a ray in the direction the controller is pointing
  18835. */
  18836. getForwardRay(length?: number): Ray;
  18837. }
  18838. }
  18839. declare module BABYLON {
  18840. /**
  18841. * Defines the WebVRController object that represents controllers tracked in 3D space
  18842. */
  18843. export abstract class WebVRController extends PoseEnabledController {
  18844. /**
  18845. * Internal, the default controller model for the controller
  18846. */
  18847. protected _defaultModel: Nullable<AbstractMesh>;
  18848. /**
  18849. * Fired when the trigger state has changed
  18850. */
  18851. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  18852. /**
  18853. * Fired when the main button state has changed
  18854. */
  18855. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  18856. /**
  18857. * Fired when the secondary button state has changed
  18858. */
  18859. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  18860. /**
  18861. * Fired when the pad state has changed
  18862. */
  18863. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  18864. /**
  18865. * Fired when controllers stick values have changed
  18866. */
  18867. onPadValuesChangedObservable: Observable<StickValues>;
  18868. /**
  18869. * Array of button availible on the controller
  18870. */
  18871. protected _buttons: Array<MutableGamepadButton>;
  18872. private _onButtonStateChange;
  18873. /**
  18874. * Fired when a controller button's state has changed
  18875. * @param callback the callback containing the button that was modified
  18876. */
  18877. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  18878. /**
  18879. * X and Y axis corresponding to the controllers joystick
  18880. */
  18881. pad: StickValues;
  18882. /**
  18883. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  18884. */
  18885. hand: string;
  18886. /**
  18887. * The default controller model for the controller
  18888. */
  18889. get defaultModel(): Nullable<AbstractMesh>;
  18890. /**
  18891. * Creates a new WebVRController from a gamepad
  18892. * @param vrGamepad the gamepad that the WebVRController should be created from
  18893. */
  18894. constructor(vrGamepad: any);
  18895. /**
  18896. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  18897. */
  18898. update(): void;
  18899. /**
  18900. * Function to be called when a button is modified
  18901. */
  18902. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  18903. /**
  18904. * Loads a mesh and attaches it to the controller
  18905. * @param scene the scene the mesh should be added to
  18906. * @param meshLoaded callback for when the mesh has been loaded
  18907. */
  18908. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  18909. private _setButtonValue;
  18910. private _changes;
  18911. private _checkChanges;
  18912. /**
  18913. * Disposes of th webVRCOntroller
  18914. */
  18915. dispose(): void;
  18916. }
  18917. }
  18918. declare module BABYLON {
  18919. /**
  18920. * The HemisphericLight simulates the ambient environment light,
  18921. * so the passed direction is the light reflection direction, not the incoming direction.
  18922. */
  18923. export class HemisphericLight extends Light {
  18924. /**
  18925. * The groundColor is the light in the opposite direction to the one specified during creation.
  18926. * You can think of the diffuse and specular light as coming from the centre of the object in the given direction and the groundColor light in the opposite direction.
  18927. */
  18928. groundColor: Color3;
  18929. /**
  18930. * The light reflection direction, not the incoming direction.
  18931. */
  18932. direction: Vector3;
  18933. /**
  18934. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  18935. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  18936. * The HemisphericLight can't cast shadows.
  18937. * Documentation : https://doc.babylonjs.com/babylon101/lights
  18938. * @param name The friendly name of the light
  18939. * @param direction The direction of the light reflection
  18940. * @param scene The scene the light belongs to
  18941. */
  18942. constructor(name: string, direction: Vector3, scene: Scene);
  18943. protected _buildUniformLayout(): void;
  18944. /**
  18945. * Returns the string "HemisphericLight".
  18946. * @return The class name
  18947. */
  18948. getClassName(): string;
  18949. /**
  18950. * Sets the HemisphericLight direction towards the passed target (Vector3).
  18951. * Returns the updated direction.
  18952. * @param target The target the direction should point to
  18953. * @return The computed direction
  18954. */
  18955. setDirectionToTarget(target: Vector3): Vector3;
  18956. /**
  18957. * Returns the shadow generator associated to the light.
  18958. * @returns Always null for hemispheric lights because it does not support shadows.
  18959. */
  18960. getShadowGenerator(): Nullable<IShadowGenerator>;
  18961. /**
  18962. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  18963. * @param effect The effect to update
  18964. * @param lightIndex The index of the light in the effect to update
  18965. * @returns The hemispheric light
  18966. */
  18967. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  18968. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  18969. /**
  18970. * Computes the world matrix of the node
  18971. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  18972. * @param useWasUpdatedFlag defines a reserved property
  18973. * @returns the world matrix
  18974. */
  18975. computeWorldMatrix(): Matrix;
  18976. /**
  18977. * Returns the integer 3.
  18978. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  18979. */
  18980. getTypeID(): number;
  18981. /**
  18982. * Prepares the list of defines specific to the light type.
  18983. * @param defines the list of defines
  18984. * @param lightIndex defines the index of the light for the effect
  18985. */
  18986. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  18987. }
  18988. }
  18989. declare module BABYLON {
  18990. /** @hidden */
  18991. export var vrMultiviewToSingleviewPixelShader: {
  18992. name: string;
  18993. shader: string;
  18994. };
  18995. }
  18996. declare module BABYLON {
  18997. /**
  18998. * Renders to multiple views with a single draw call
  18999. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  19000. */
  19001. export class MultiviewRenderTarget extends RenderTargetTexture {
  19002. /**
  19003. * Creates a multiview render target
  19004. * @param scene scene used with the render target
  19005. * @param size the size of the render target (used for each view)
  19006. */
  19007. constructor(scene: Scene, size?: number | {
  19008. width: number;
  19009. height: number;
  19010. } | {
  19011. ratio: number;
  19012. });
  19013. /**
  19014. * @hidden
  19015. * @param faceIndex the face index, if its a cube texture
  19016. */
  19017. _bindFrameBuffer(faceIndex?: number): void;
  19018. /**
  19019. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  19020. * @returns the view count
  19021. */
  19022. getViewCount(): number;
  19023. }
  19024. }
  19025. declare module BABYLON {
  19026. /**
  19027. * Represents a camera frustum
  19028. */
  19029. export class Frustum {
  19030. /**
  19031. * Gets the planes representing the frustum
  19032. * @param transform matrix to be applied to the returned planes
  19033. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  19034. */
  19035. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  19036. /**
  19037. * Gets the near frustum plane transformed by the transform matrix
  19038. * @param transform transformation matrix to be applied to the resulting frustum plane
  19039. * @param frustumPlane the resuling frustum plane
  19040. */
  19041. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19042. /**
  19043. * Gets the far frustum plane transformed by the transform matrix
  19044. * @param transform transformation matrix to be applied to the resulting frustum plane
  19045. * @param frustumPlane the resuling frustum plane
  19046. */
  19047. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19048. /**
  19049. * Gets the left frustum plane transformed by the transform matrix
  19050. * @param transform transformation matrix to be applied to the resulting frustum plane
  19051. * @param frustumPlane the resuling frustum plane
  19052. */
  19053. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19054. /**
  19055. * Gets the right frustum plane transformed by the transform matrix
  19056. * @param transform transformation matrix to be applied to the resulting frustum plane
  19057. * @param frustumPlane the resuling frustum plane
  19058. */
  19059. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19060. /**
  19061. * Gets the top frustum plane transformed by the transform matrix
  19062. * @param transform transformation matrix to be applied to the resulting frustum plane
  19063. * @param frustumPlane the resuling frustum plane
  19064. */
  19065. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19066. /**
  19067. * Gets the bottom frustum plane transformed by the transform matrix
  19068. * @param transform transformation matrix to be applied to the resulting frustum plane
  19069. * @param frustumPlane the resuling frustum plane
  19070. */
  19071. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19072. /**
  19073. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  19074. * @param transform transformation matrix to be applied to the resulting frustum planes
  19075. * @param frustumPlanes the resuling frustum planes
  19076. */
  19077. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  19078. }
  19079. }
  19080. declare module BABYLON {
  19081. interface Engine {
  19082. /**
  19083. * Creates a new multiview render target
  19084. * @param width defines the width of the texture
  19085. * @param height defines the height of the texture
  19086. * @returns the created multiview texture
  19087. */
  19088. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  19089. /**
  19090. * Binds a multiview framebuffer to be drawn to
  19091. * @param multiviewTexture texture to bind
  19092. */
  19093. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  19094. }
  19095. interface Camera {
  19096. /**
  19097. * @hidden
  19098. * For cameras that cannot use multiview images to display directly. (e.g. webVR camera will render to multiview texture, then copy to each eye texture and go from there)
  19099. */
  19100. _useMultiviewToSingleView: boolean;
  19101. /**
  19102. * @hidden
  19103. * For cameras that cannot use multiview images to display directly. (e.g. webVR camera will render to multiview texture, then copy to each eye texture and go from there)
  19104. */
  19105. _multiviewTexture: Nullable<RenderTargetTexture>;
  19106. /**
  19107. * @hidden
  19108. * ensures the multiview texture of the camera exists and has the specified width/height
  19109. * @param width height to set on the multiview texture
  19110. * @param height width to set on the multiview texture
  19111. */
  19112. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  19113. }
  19114. interface Scene {
  19115. /** @hidden */
  19116. _transformMatrixR: Matrix;
  19117. /** @hidden */
  19118. _multiviewSceneUbo: Nullable<UniformBuffer>;
  19119. /** @hidden */
  19120. _createMultiviewUbo(): void;
  19121. /** @hidden */
  19122. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  19123. /** @hidden */
  19124. _renderMultiviewToSingleView(camera: Camera): void;
  19125. }
  19126. }
  19127. declare module BABYLON {
  19128. /**
  19129. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  19130. * This will not be used for webXR as it supports displaying texture arrays directly
  19131. */
  19132. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  19133. /**
  19134. * Initializes a VRMultiviewToSingleview
  19135. * @param name name of the post process
  19136. * @param camera camera to be applied to
  19137. * @param scaleFactor scaling factor to the size of the output texture
  19138. */
  19139. constructor(name: string, camera: Camera, scaleFactor: number);
  19140. }
  19141. }
  19142. declare module BABYLON {
  19143. /**
  19144. * Interface used to define additional presentation attributes
  19145. */
  19146. export interface IVRPresentationAttributes {
  19147. /**
  19148. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  19149. */
  19150. highRefreshRate: boolean;
  19151. /**
  19152. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  19153. */
  19154. foveationLevel: number;
  19155. }
  19156. interface Engine {
  19157. /** @hidden */
  19158. _vrDisplay: any;
  19159. /** @hidden */
  19160. _vrSupported: boolean;
  19161. /** @hidden */
  19162. _oldSize: Size;
  19163. /** @hidden */
  19164. _oldHardwareScaleFactor: number;
  19165. /** @hidden */
  19166. _vrExclusivePointerMode: boolean;
  19167. /** @hidden */
  19168. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  19169. /** @hidden */
  19170. _onVRDisplayPointerRestricted: () => void;
  19171. /** @hidden */
  19172. _onVRDisplayPointerUnrestricted: () => void;
  19173. /** @hidden */
  19174. _onVrDisplayConnect: Nullable<(display: any) => void>;
  19175. /** @hidden */
  19176. _onVrDisplayDisconnect: Nullable<() => void>;
  19177. /** @hidden */
  19178. _onVrDisplayPresentChange: Nullable<() => void>;
  19179. /**
  19180. * Observable signaled when VR display mode changes
  19181. */
  19182. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  19183. /**
  19184. * Observable signaled when VR request present is complete
  19185. */
  19186. onVRRequestPresentComplete: Observable<boolean>;
  19187. /**
  19188. * Observable signaled when VR request present starts
  19189. */
  19190. onVRRequestPresentStart: Observable<Engine>;
  19191. /**
  19192. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  19193. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  19194. */
  19195. isInVRExclusivePointerMode: boolean;
  19196. /**
  19197. * Gets a boolean indicating if a webVR device was detected
  19198. * @returns true if a webVR device was detected
  19199. */
  19200. isVRDevicePresent(): boolean;
  19201. /**
  19202. * Gets the current webVR device
  19203. * @returns the current webVR device (or null)
  19204. */
  19205. getVRDevice(): any;
  19206. /**
  19207. * Initializes a webVR display and starts listening to display change events
  19208. * The onVRDisplayChangedObservable will be notified upon these changes
  19209. * @returns A promise containing a VRDisplay and if vr is supported
  19210. */
  19211. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  19212. /** @hidden */
  19213. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  19214. /**
  19215. * Gets or sets the presentation attributes used to configure VR rendering
  19216. */
  19217. vrPresentationAttributes?: IVRPresentationAttributes;
  19218. /**
  19219. * Call this function to switch to webVR mode
  19220. * Will do nothing if webVR is not supported or if there is no webVR device
  19221. * @param options the webvr options provided to the camera. mainly used for multiview
  19222. * @see http://doc.babylonjs.com/how_to/webvr_camera
  19223. */
  19224. enableVR(options: WebVROptions): void;
  19225. /** @hidden */
  19226. _onVRFullScreenTriggered(): void;
  19227. }
  19228. }
  19229. declare module BABYLON {
  19230. /**
  19231. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  19232. * IMPORTANT!! The data is right-hand data.
  19233. * @export
  19234. * @interface DevicePose
  19235. */
  19236. export interface DevicePose {
  19237. /**
  19238. * The position of the device, values in array are [x,y,z].
  19239. */
  19240. readonly position: Nullable<Float32Array>;
  19241. /**
  19242. * The linearVelocity of the device, values in array are [x,y,z].
  19243. */
  19244. readonly linearVelocity: Nullable<Float32Array>;
  19245. /**
  19246. * The linearAcceleration of the device, values in array are [x,y,z].
  19247. */
  19248. readonly linearAcceleration: Nullable<Float32Array>;
  19249. /**
  19250. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  19251. */
  19252. readonly orientation: Nullable<Float32Array>;
  19253. /**
  19254. * The angularVelocity of the device, values in array are [x,y,z].
  19255. */
  19256. readonly angularVelocity: Nullable<Float32Array>;
  19257. /**
  19258. * The angularAcceleration of the device, values in array are [x,y,z].
  19259. */
  19260. readonly angularAcceleration: Nullable<Float32Array>;
  19261. }
  19262. /**
  19263. * Interface representing a pose controlled object in Babylon.
  19264. * A pose controlled object has both regular pose values as well as pose values
  19265. * from an external device such as a VR head mounted display
  19266. */
  19267. export interface PoseControlled {
  19268. /**
  19269. * The position of the object in babylon space.
  19270. */
  19271. position: Vector3;
  19272. /**
  19273. * The rotation quaternion of the object in babylon space.
  19274. */
  19275. rotationQuaternion: Quaternion;
  19276. /**
  19277. * The position of the device in babylon space.
  19278. */
  19279. devicePosition?: Vector3;
  19280. /**
  19281. * The rotation quaternion of the device in babylon space.
  19282. */
  19283. deviceRotationQuaternion: Quaternion;
  19284. /**
  19285. * The raw pose coming from the device.
  19286. */
  19287. rawPose: Nullable<DevicePose>;
  19288. /**
  19289. * The scale of the device to be used when translating from device space to babylon space.
  19290. */
  19291. deviceScaleFactor: number;
  19292. /**
  19293. * Updates the poseControlled values based on the input device pose.
  19294. * @param poseData the pose data to update the object with
  19295. */
  19296. updateFromDevice(poseData: DevicePose): void;
  19297. }
  19298. /**
  19299. * Set of options to customize the webVRCamera
  19300. */
  19301. export interface WebVROptions {
  19302. /**
  19303. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  19304. */
  19305. trackPosition?: boolean;
  19306. /**
  19307. * Sets the scale of the vrDevice in babylon space. (default: 1)
  19308. */
  19309. positionScale?: number;
  19310. /**
  19311. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  19312. */
  19313. displayName?: string;
  19314. /**
  19315. * Should the native controller meshes be initialized. (default: true)
  19316. */
  19317. controllerMeshes?: boolean;
  19318. /**
  19319. * Creating a default HemiLight only on controllers. (default: true)
  19320. */
  19321. defaultLightingOnControllers?: boolean;
  19322. /**
  19323. * If you don't want to use the default VR button of the helper. (default: false)
  19324. */
  19325. useCustomVRButton?: boolean;
  19326. /**
  19327. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  19328. */
  19329. customVRButton?: HTMLButtonElement;
  19330. /**
  19331. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  19332. */
  19333. rayLength?: number;
  19334. /**
  19335. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  19336. */
  19337. defaultHeight?: number;
  19338. /**
  19339. * If multiview should be used if availible (default: false)
  19340. */
  19341. useMultiview?: boolean;
  19342. }
  19343. /**
  19344. * This represents a WebVR camera.
  19345. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  19346. * @example http://doc.babylonjs.com/how_to/webvr_camera
  19347. */
  19348. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  19349. private webVROptions;
  19350. /**
  19351. * @hidden
  19352. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  19353. */
  19354. _vrDevice: any;
  19355. /**
  19356. * The rawPose of the vrDevice.
  19357. */
  19358. rawPose: Nullable<DevicePose>;
  19359. private _onVREnabled;
  19360. private _specsVersion;
  19361. private _attached;
  19362. private _frameData;
  19363. protected _descendants: Array<Node>;
  19364. private _deviceRoomPosition;
  19365. /** @hidden */
  19366. _deviceRoomRotationQuaternion: Quaternion;
  19367. private _standingMatrix;
  19368. /**
  19369. * Represents device position in babylon space.
  19370. */
  19371. devicePosition: Vector3;
  19372. /**
  19373. * Represents device rotation in babylon space.
  19374. */
  19375. deviceRotationQuaternion: Quaternion;
  19376. /**
  19377. * The scale of the device to be used when translating from device space to babylon space.
  19378. */
  19379. deviceScaleFactor: number;
  19380. private _deviceToWorld;
  19381. private _worldToDevice;
  19382. /**
  19383. * References to the webVR controllers for the vrDevice.
  19384. */
  19385. controllers: Array<WebVRController>;
  19386. /**
  19387. * Emits an event when a controller is attached.
  19388. */
  19389. onControllersAttachedObservable: Observable<WebVRController[]>;
  19390. /**
  19391. * Emits an event when a controller's mesh has been loaded;
  19392. */
  19393. onControllerMeshLoadedObservable: Observable<WebVRController>;
  19394. /**
  19395. * Emits an event when the HMD's pose has been updated.
  19396. */
  19397. onPoseUpdatedFromDeviceObservable: Observable<any>;
  19398. private _poseSet;
  19399. /**
  19400. * If the rig cameras be used as parent instead of this camera.
  19401. */
  19402. rigParenting: boolean;
  19403. private _lightOnControllers;
  19404. private _defaultHeight?;
  19405. /**
  19406. * Instantiates a WebVRFreeCamera.
  19407. * @param name The name of the WebVRFreeCamera
  19408. * @param position The starting anchor position for the camera
  19409. * @param scene The scene the camera belongs to
  19410. * @param webVROptions a set of customizable options for the webVRCamera
  19411. */
  19412. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  19413. /**
  19414. * Gets the device distance from the ground in meters.
  19415. * @returns the distance in meters from the vrDevice to ground in device space. If standing matrix is not supported for the vrDevice 0 is returned.
  19416. */
  19417. deviceDistanceToRoomGround(): number;
  19418. /**
  19419. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  19420. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  19421. */
  19422. useStandingMatrix(callback?: (bool: boolean) => void): void;
  19423. /**
  19424. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  19425. * @returns A promise with a boolean set to if the standing matrix is supported.
  19426. */
  19427. useStandingMatrixAsync(): Promise<boolean>;
  19428. /**
  19429. * Disposes the camera
  19430. */
  19431. dispose(): void;
  19432. /**
  19433. * Gets a vrController by name.
  19434. * @param name The name of the controller to retreive
  19435. * @returns the controller matching the name specified or null if not found
  19436. */
  19437. getControllerByName(name: string): Nullable<WebVRController>;
  19438. private _leftController;
  19439. /**
  19440. * The controller corresponding to the users left hand.
  19441. */
  19442. get leftController(): Nullable<WebVRController>;
  19443. private _rightController;
  19444. /**
  19445. * The controller corresponding to the users right hand.
  19446. */
  19447. get rightController(): Nullable<WebVRController>;
  19448. /**
  19449. * Casts a ray forward from the vrCamera's gaze.
  19450. * @param length Length of the ray (default: 100)
  19451. * @returns the ray corresponding to the gaze
  19452. */
  19453. getForwardRay(length?: number): Ray;
  19454. /**
  19455. * @hidden
  19456. * Updates the camera based on device's frame data
  19457. */
  19458. _checkInputs(): void;
  19459. /**
  19460. * Updates the poseControlled values based on the input device pose.
  19461. * @param poseData Pose coming from the device
  19462. */
  19463. updateFromDevice(poseData: DevicePose): void;
  19464. private _htmlElementAttached;
  19465. private _detachIfAttached;
  19466. /**
  19467. * WebVR's attach control will start broadcasting frames to the device.
  19468. * Note that in certain browsers (chrome for example) this function must be called
  19469. * within a user-interaction callback. Example:
  19470. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  19471. *
  19472. * @param element html element to attach the vrDevice to
  19473. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  19474. */
  19475. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19476. /**
  19477. * Detaches the camera from the html element and disables VR
  19478. *
  19479. * @param element html element to detach from
  19480. */
  19481. detachControl(element: HTMLElement): void;
  19482. /**
  19483. * @returns the name of this class
  19484. */
  19485. getClassName(): string;
  19486. /**
  19487. * Calls resetPose on the vrDisplay
  19488. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  19489. */
  19490. resetToCurrentRotation(): void;
  19491. /**
  19492. * @hidden
  19493. * Updates the rig cameras (left and right eye)
  19494. */
  19495. _updateRigCameras(): void;
  19496. private _workingVector;
  19497. private _oneVector;
  19498. private _workingMatrix;
  19499. private updateCacheCalled;
  19500. private _correctPositionIfNotTrackPosition;
  19501. /**
  19502. * @hidden
  19503. * Updates the cached values of the camera
  19504. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  19505. */
  19506. _updateCache(ignoreParentClass?: boolean): void;
  19507. /**
  19508. * @hidden
  19509. * Get current device position in babylon world
  19510. */
  19511. _computeDevicePosition(): void;
  19512. /**
  19513. * Updates the current device position and rotation in the babylon world
  19514. */
  19515. update(): void;
  19516. /**
  19517. * @hidden
  19518. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  19519. * @returns an identity matrix
  19520. */
  19521. _getViewMatrix(): Matrix;
  19522. private _tmpMatrix;
  19523. /**
  19524. * This function is called by the two RIG cameras.
  19525. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  19526. * @hidden
  19527. */
  19528. _getWebVRViewMatrix(): Matrix;
  19529. /** @hidden */
  19530. _getWebVRProjectionMatrix(): Matrix;
  19531. private _onGamepadConnectedObserver;
  19532. private _onGamepadDisconnectedObserver;
  19533. private _updateCacheWhenTrackingDisabledObserver;
  19534. /**
  19535. * Initializes the controllers and their meshes
  19536. */
  19537. initControllers(): void;
  19538. }
  19539. }
  19540. declare module BABYLON {
  19541. /**
  19542. * Size options for a post process
  19543. */
  19544. export type PostProcessOptions = {
  19545. width: number;
  19546. height: number;
  19547. };
  19548. /**
  19549. * PostProcess can be used to apply a shader to a texture after it has been rendered
  19550. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  19551. */
  19552. export class PostProcess {
  19553. /** Name of the PostProcess. */
  19554. name: string;
  19555. /**
  19556. * Gets or sets the unique id of the post process
  19557. */
  19558. uniqueId: number;
  19559. /**
  19560. * Width of the texture to apply the post process on
  19561. */
  19562. width: number;
  19563. /**
  19564. * Height of the texture to apply the post process on
  19565. */
  19566. height: number;
  19567. /**
  19568. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  19569. * @hidden
  19570. */
  19571. _outputTexture: Nullable<InternalTexture>;
  19572. /**
  19573. * Sampling mode used by the shader
  19574. * See https://doc.babylonjs.com/classes/3.1/texture
  19575. */
  19576. renderTargetSamplingMode: number;
  19577. /**
  19578. * Clear color to use when screen clearing
  19579. */
  19580. clearColor: Color4;
  19581. /**
  19582. * If the buffer needs to be cleared before applying the post process. (default: true)
  19583. * Should be set to false if shader will overwrite all previous pixels.
  19584. */
  19585. autoClear: boolean;
  19586. /**
  19587. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  19588. */
  19589. alphaMode: number;
  19590. /**
  19591. * Sets the setAlphaBlendConstants of the babylon engine
  19592. */
  19593. alphaConstants: Color4;
  19594. /**
  19595. * Animations to be used for the post processing
  19596. */
  19597. animations: Animation[];
  19598. /**
  19599. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  19600. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  19601. */
  19602. enablePixelPerfectMode: boolean;
  19603. /**
  19604. * Force the postprocess to be applied without taking in account viewport
  19605. */
  19606. forceFullscreenViewport: boolean;
  19607. /**
  19608. * List of inspectable custom properties (used by the Inspector)
  19609. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  19610. */
  19611. inspectableCustomProperties: IInspectable[];
  19612. /**
  19613. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  19614. *
  19615. * | Value | Type | Description |
  19616. * | ----- | ----------------------------------- | ----------- |
  19617. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  19618. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  19619. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  19620. *
  19621. */
  19622. scaleMode: number;
  19623. /**
  19624. * Force textures to be a power of two (default: false)
  19625. */
  19626. alwaysForcePOT: boolean;
  19627. private _samples;
  19628. /**
  19629. * Number of sample textures (default: 1)
  19630. */
  19631. get samples(): number;
  19632. set samples(n: number);
  19633. /**
  19634. * Modify the scale of the post process to be the same as the viewport (default: false)
  19635. */
  19636. adaptScaleToCurrentViewport: boolean;
  19637. private _camera;
  19638. private _scene;
  19639. private _engine;
  19640. private _options;
  19641. private _reusable;
  19642. private _textureType;
  19643. private _textureFormat;
  19644. /**
  19645. * Smart array of input and output textures for the post process.
  19646. * @hidden
  19647. */
  19648. _textures: SmartArray<InternalTexture>;
  19649. /**
  19650. * The index in _textures that corresponds to the output texture.
  19651. * @hidden
  19652. */
  19653. _currentRenderTextureInd: number;
  19654. private _effect;
  19655. private _samplers;
  19656. private _fragmentUrl;
  19657. private _vertexUrl;
  19658. private _parameters;
  19659. private _scaleRatio;
  19660. protected _indexParameters: any;
  19661. private _shareOutputWithPostProcess;
  19662. private _texelSize;
  19663. private _forcedOutputTexture;
  19664. /**
  19665. * Returns the fragment url or shader name used in the post process.
  19666. * @returns the fragment url or name in the shader store.
  19667. */
  19668. getEffectName(): string;
  19669. /**
  19670. * An event triggered when the postprocess is activated.
  19671. */
  19672. onActivateObservable: Observable<Camera>;
  19673. private _onActivateObserver;
  19674. /**
  19675. * A function that is added to the onActivateObservable
  19676. */
  19677. set onActivate(callback: Nullable<(camera: Camera) => void>);
  19678. /**
  19679. * An event triggered when the postprocess changes its size.
  19680. */
  19681. onSizeChangedObservable: Observable<PostProcess>;
  19682. private _onSizeChangedObserver;
  19683. /**
  19684. * A function that is added to the onSizeChangedObservable
  19685. */
  19686. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  19687. /**
  19688. * An event triggered when the postprocess applies its effect.
  19689. */
  19690. onApplyObservable: Observable<Effect>;
  19691. private _onApplyObserver;
  19692. /**
  19693. * A function that is added to the onApplyObservable
  19694. */
  19695. set onApply(callback: (effect: Effect) => void);
  19696. /**
  19697. * An event triggered before rendering the postprocess
  19698. */
  19699. onBeforeRenderObservable: Observable<Effect>;
  19700. private _onBeforeRenderObserver;
  19701. /**
  19702. * A function that is added to the onBeforeRenderObservable
  19703. */
  19704. set onBeforeRender(callback: (effect: Effect) => void);
  19705. /**
  19706. * An event triggered after rendering the postprocess
  19707. */
  19708. onAfterRenderObservable: Observable<Effect>;
  19709. private _onAfterRenderObserver;
  19710. /**
  19711. * A function that is added to the onAfterRenderObservable
  19712. */
  19713. set onAfterRender(callback: (efect: Effect) => void);
  19714. /**
  19715. * The input texture for this post process and the output texture of the previous post process. When added to a pipeline the previous post process will
  19716. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  19717. */
  19718. get inputTexture(): InternalTexture;
  19719. set inputTexture(value: InternalTexture);
  19720. /**
  19721. * Gets the camera which post process is applied to.
  19722. * @returns The camera the post process is applied to.
  19723. */
  19724. getCamera(): Camera;
  19725. /**
  19726. * Gets the texel size of the postprocess.
  19727. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  19728. */
  19729. get texelSize(): Vector2;
  19730. /**
  19731. * Creates a new instance PostProcess
  19732. * @param name The name of the PostProcess.
  19733. * @param fragmentUrl The url of the fragment shader to be used.
  19734. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  19735. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  19736. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  19737. * @param camera The camera to apply the render pass to.
  19738. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  19739. * @param engine The engine which the post process will be applied. (default: current engine)
  19740. * @param reusable If the post process can be reused on the same frame. (default: false)
  19741. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  19742. * @param textureType Type of textures used when performing the post process. (default: 0)
  19743. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  19744. * @param indexParameters The index parameters to be used for babylons include syntax "#include<kernelBlurVaryingDeclaration>[0..varyingCount]". (default: undefined) See usage in babylon.blurPostProcess.ts and kernelBlur.vertex.fx
  19745. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  19746. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  19747. */
  19748. constructor(
  19749. /** Name of the PostProcess. */
  19750. name: string, fragmentUrl: string, parameters: Nullable<string[]>, samplers: Nullable<string[]>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, defines?: Nullable<string>, textureType?: number, vertexUrl?: string, indexParameters?: any, blockCompilation?: boolean, textureFormat?: number);
  19751. /**
  19752. * Gets a string idenfifying the name of the class
  19753. * @returns "PostProcess" string
  19754. */
  19755. getClassName(): string;
  19756. /**
  19757. * Gets the engine which this post process belongs to.
  19758. * @returns The engine the post process was enabled with.
  19759. */
  19760. getEngine(): Engine;
  19761. /**
  19762. * The effect that is created when initializing the post process.
  19763. * @returns The created effect corresponding the the postprocess.
  19764. */
  19765. getEffect(): Effect;
  19766. /**
  19767. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  19768. * @param postProcess The post process to share the output with.
  19769. * @returns This post process.
  19770. */
  19771. shareOutputWith(postProcess: PostProcess): PostProcess;
  19772. /**
  19773. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  19774. * This should be called if the post process that shares output with this post process is disabled/disposed.
  19775. */
  19776. useOwnOutput(): void;
  19777. /**
  19778. * Updates the effect with the current post process compile time values and recompiles the shader.
  19779. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  19780. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  19781. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  19782. * @param indexParameters The index parameters to be used for babylons include syntax "#include<kernelBlurVaryingDeclaration>[0..varyingCount]". (default: undefined) See usage in babylon.blurPostProcess.ts and kernelBlur.vertex.fx
  19783. * @param onCompiled Called when the shader has been compiled.
  19784. * @param onError Called if there is an error when compiling a shader.
  19785. */
  19786. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  19787. /**
  19788. * The post process is reusable if it can be used multiple times within one frame.
  19789. * @returns If the post process is reusable
  19790. */
  19791. isReusable(): boolean;
  19792. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  19793. markTextureDirty(): void;
  19794. /**
  19795. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  19796. * When this post process is used in a pipeline, this is call will bind the input texture of this post process to the output of the previous.
  19797. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  19798. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  19799. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  19800. * @returns The target texture that was bound to be written to.
  19801. */
  19802. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  19803. /**
  19804. * If the post process is supported.
  19805. */
  19806. get isSupported(): boolean;
  19807. /**
  19808. * The aspect ratio of the output texture.
  19809. */
  19810. get aspectRatio(): number;
  19811. /**
  19812. * Get a value indicating if the post-process is ready to be used
  19813. * @returns true if the post-process is ready (shader is compiled)
  19814. */
  19815. isReady(): boolean;
  19816. /**
  19817. * Binds all textures and uniforms to the shader, this will be run on every pass.
  19818. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  19819. */
  19820. apply(): Nullable<Effect>;
  19821. private _disposeTextures;
  19822. /**
  19823. * Disposes the post process.
  19824. * @param camera The camera to dispose the post process on.
  19825. */
  19826. dispose(camera?: Camera): void;
  19827. }
  19828. }
  19829. declare module BABYLON {
  19830. /** @hidden */
  19831. export var kernelBlurVaryingDeclaration: {
  19832. name: string;
  19833. shader: string;
  19834. };
  19835. }
  19836. declare module BABYLON {
  19837. /** @hidden */
  19838. export var kernelBlurFragment: {
  19839. name: string;
  19840. shader: string;
  19841. };
  19842. }
  19843. declare module BABYLON {
  19844. /** @hidden */
  19845. export var kernelBlurFragment2: {
  19846. name: string;
  19847. shader: string;
  19848. };
  19849. }
  19850. declare module BABYLON {
  19851. /** @hidden */
  19852. export var kernelBlurPixelShader: {
  19853. name: string;
  19854. shader: string;
  19855. };
  19856. }
  19857. declare module BABYLON {
  19858. /** @hidden */
  19859. export var kernelBlurVertex: {
  19860. name: string;
  19861. shader: string;
  19862. };
  19863. }
  19864. declare module BABYLON {
  19865. /** @hidden */
  19866. export var kernelBlurVertexShader: {
  19867. name: string;
  19868. shader: string;
  19869. };
  19870. }
  19871. declare module BABYLON {
  19872. /**
  19873. * The Blur Post Process which blurs an image based on a kernel and direction.
  19874. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  19875. */
  19876. export class BlurPostProcess extends PostProcess {
  19877. /** The direction in which to blur the image. */
  19878. direction: Vector2;
  19879. private blockCompilation;
  19880. protected _kernel: number;
  19881. protected _idealKernel: number;
  19882. protected _packedFloat: boolean;
  19883. private _staticDefines;
  19884. /**
  19885. * Sets the length in pixels of the blur sample region
  19886. */
  19887. set kernel(v: number);
  19888. /**
  19889. * Gets the length in pixels of the blur sample region
  19890. */
  19891. get kernel(): number;
  19892. /**
  19893. * Sets wether or not the blur needs to unpack/repack floats
  19894. */
  19895. set packedFloat(v: boolean);
  19896. /**
  19897. * Gets wether or not the blur is unpacking/repacking floats
  19898. */
  19899. get packedFloat(): boolean;
  19900. /**
  19901. * Creates a new instance BlurPostProcess
  19902. * @param name The name of the effect.
  19903. * @param direction The direction in which to blur the image.
  19904. * @param kernel The size of the kernel to be used when computing the blur. eg. Size of 3 will blur the center pixel by 2 pixels surrounding it.
  19905. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  19906. * @param camera The camera to apply the render pass to.
  19907. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  19908. * @param engine The engine which the post process will be applied. (default: current engine)
  19909. * @param reusable If the post process can be reused on the same frame. (default: false)
  19910. * @param textureType Type of textures used when performing the post process. (default: 0)
  19911. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
  19912. */
  19913. constructor(name: string,
  19914. /** The direction in which to blur the image. */
  19915. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  19916. /**
  19917. * Updates the effect with the current post process compile time values and recompiles the shader.
  19918. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  19919. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  19920. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  19921. * @param indexParameters The index parameters to be used for babylons include syntax "#include<kernelBlurVaryingDeclaration>[0..varyingCount]". (default: undefined) See usage in babylon.blurPostProcess.ts and kernelBlur.vertex.fx
  19922. * @param onCompiled Called when the shader has been compiled.
  19923. * @param onError Called if there is an error when compiling a shader.
  19924. */
  19925. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  19926. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  19927. /**
  19928. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  19929. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  19930. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  19931. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  19932. * The gaps between physical kernels are compensated for in the weighting of the samples
  19933. * @param idealKernel Ideal blur kernel.
  19934. * @return Nearest best kernel.
  19935. */
  19936. protected _nearestBestKernel(idealKernel: number): number;
  19937. /**
  19938. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  19939. * @param x The point on the Gaussian distribution to sample.
  19940. * @return the value of the Gaussian function at x.
  19941. */
  19942. protected _gaussianWeight(x: number): number;
  19943. /**
  19944. * Generates a string that can be used as a floating point number in GLSL.
  19945. * @param x Value to print.
  19946. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  19947. * @return GLSL float string.
  19948. */
  19949. protected _glslFloat(x: number, decimalFigures?: number): string;
  19950. }
  19951. }
  19952. declare module BABYLON {
  19953. /**
  19954. * Mirror texture can be used to simulate the view from a mirror in a scene.
  19955. * It will dynamically be rendered every frame to adapt to the camera point of view.
  19956. * You can then easily use it as a reflectionTexture on a flat surface.
  19957. * In case the surface is not a plane, please consider relying on reflection probes.
  19958. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  19959. */
  19960. export class MirrorTexture extends RenderTargetTexture {
  19961. private scene;
  19962. /**
  19963. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  19964. * It is possible to directly set the mirrorPlane by directly using a Plane(a, b, c, d) where a, b and c give the plane normal vector (a, b, c) and d is a scalar displacement from the mirrorPlane to the origin. However in all but the very simplest of situations it is more straight forward to set it to the reflector as stated in the doc.
  19965. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  19966. */
  19967. mirrorPlane: Plane;
  19968. /**
  19969. * Define the blur ratio used to blur the reflection if needed.
  19970. */
  19971. set blurRatio(value: number);
  19972. get blurRatio(): number;
  19973. /**
  19974. * Define the adaptive blur kernel used to blur the reflection if needed.
  19975. * This will autocompute the closest best match for the `blurKernel`
  19976. */
  19977. set adaptiveBlurKernel(value: number);
  19978. /**
  19979. * Define the blur kernel used to blur the reflection if needed.
  19980. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  19981. */
  19982. set blurKernel(value: number);
  19983. /**
  19984. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  19985. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  19986. */
  19987. set blurKernelX(value: number);
  19988. get blurKernelX(): number;
  19989. /**
  19990. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  19991. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  19992. */
  19993. set blurKernelY(value: number);
  19994. get blurKernelY(): number;
  19995. private _autoComputeBlurKernel;
  19996. protected _onRatioRescale(): void;
  19997. private _updateGammaSpace;
  19998. private _imageProcessingConfigChangeObserver;
  19999. private _transformMatrix;
  20000. private _mirrorMatrix;
  20001. private _savedViewMatrix;
  20002. private _blurX;
  20003. private _blurY;
  20004. private _adaptiveBlurKernel;
  20005. private _blurKernelX;
  20006. private _blurKernelY;
  20007. private _blurRatio;
  20008. /**
  20009. * Instantiates a Mirror Texture.
  20010. * Mirror texture can be used to simulate the view from a mirror in a scene.
  20011. * It will dynamically be rendered every frame to adapt to the camera point of view.
  20012. * You can then easily use it as a reflectionTexture on a flat surface.
  20013. * In case the surface is not a plane, please consider relying on reflection probes.
  20014. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  20015. * @param name
  20016. * @param size
  20017. * @param scene
  20018. * @param generateMipMaps
  20019. * @param type
  20020. * @param samplingMode
  20021. * @param generateDepthBuffer
  20022. */
  20023. constructor(name: string, size: number | {
  20024. width: number;
  20025. height: number;
  20026. } | {
  20027. ratio: number;
  20028. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  20029. private _preparePostProcesses;
  20030. /**
  20031. * Clone the mirror texture.
  20032. * @returns the cloned texture
  20033. */
  20034. clone(): MirrorTexture;
  20035. /**
  20036. * Serialize the texture to a JSON representation you could use in Parse later on
  20037. * @returns the serialized JSON representation
  20038. */
  20039. serialize(): any;
  20040. /**
  20041. * Dispose the texture and release its associated resources.
  20042. */
  20043. dispose(): void;
  20044. }
  20045. }
  20046. declare module BABYLON {
  20047. /**
  20048. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  20049. * @see http://doc.babylonjs.com/babylon101/materials#texture
  20050. */
  20051. export class Texture extends BaseTexture {
  20052. /**
  20053. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  20054. */
  20055. static SerializeBuffers: boolean;
  20056. /** @hidden */
  20057. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  20058. /** @hidden */
  20059. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  20060. /** @hidden */
  20061. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  20062. /** nearest is mag = nearest and min = nearest and mip = linear */
  20063. static readonly NEAREST_SAMPLINGMODE: number;
  20064. /** nearest is mag = nearest and min = nearest and mip = linear */
  20065. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  20066. /** Bilinear is mag = linear and min = linear and mip = nearest */
  20067. static readonly BILINEAR_SAMPLINGMODE: number;
  20068. /** Bilinear is mag = linear and min = linear and mip = nearest */
  20069. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  20070. /** Trilinear is mag = linear and min = linear and mip = linear */
  20071. static readonly TRILINEAR_SAMPLINGMODE: number;
  20072. /** Trilinear is mag = linear and min = linear and mip = linear */
  20073. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  20074. /** mag = nearest and min = nearest and mip = nearest */
  20075. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  20076. /** mag = nearest and min = linear and mip = nearest */
  20077. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  20078. /** mag = nearest and min = linear and mip = linear */
  20079. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  20080. /** mag = nearest and min = linear and mip = none */
  20081. static readonly NEAREST_LINEAR: number;
  20082. /** mag = nearest and min = nearest and mip = none */
  20083. static readonly NEAREST_NEAREST: number;
  20084. /** mag = linear and min = nearest and mip = nearest */
  20085. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  20086. /** mag = linear and min = nearest and mip = linear */
  20087. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  20088. /** mag = linear and min = linear and mip = none */
  20089. static readonly LINEAR_LINEAR: number;
  20090. /** mag = linear and min = nearest and mip = none */
  20091. static readonly LINEAR_NEAREST: number;
  20092. /** Explicit coordinates mode */
  20093. static readonly EXPLICIT_MODE: number;
  20094. /** Spherical coordinates mode */
  20095. static readonly SPHERICAL_MODE: number;
  20096. /** Planar coordinates mode */
  20097. static readonly PLANAR_MODE: number;
  20098. /** Cubic coordinates mode */
  20099. static readonly CUBIC_MODE: number;
  20100. /** Projection coordinates mode */
  20101. static readonly PROJECTION_MODE: number;
  20102. /** Inverse Cubic coordinates mode */
  20103. static readonly SKYBOX_MODE: number;
  20104. /** Inverse Cubic coordinates mode */
  20105. static readonly INVCUBIC_MODE: number;
  20106. /** Equirectangular coordinates mode */
  20107. static readonly EQUIRECTANGULAR_MODE: number;
  20108. /** Equirectangular Fixed coordinates mode */
  20109. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  20110. /** Equirectangular Fixed Mirrored coordinates mode */
  20111. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  20112. /** Texture is not repeating outside of 0..1 UVs */
  20113. static readonly CLAMP_ADDRESSMODE: number;
  20114. /** Texture is repeating outside of 0..1 UVs */
  20115. static readonly WRAP_ADDRESSMODE: number;
  20116. /** Texture is repeating and mirrored */
  20117. static readonly MIRROR_ADDRESSMODE: number;
  20118. /**
  20119. * Gets or sets a boolean which defines if the texture url must be build from the serialized URL instead of just using the name and loading them side by side with the scene file
  20120. */
  20121. static UseSerializedUrlIfAny: boolean;
  20122. /**
  20123. * Define the url of the texture.
  20124. */
  20125. url: Nullable<string>;
  20126. /**
  20127. * Define an offset on the texture to offset the u coordinates of the UVs
  20128. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  20129. */
  20130. uOffset: number;
  20131. /**
  20132. * Define an offset on the texture to offset the v coordinates of the UVs
  20133. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  20134. */
  20135. vOffset: number;
  20136. /**
  20137. * Define an offset on the texture to scale the u coordinates of the UVs
  20138. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  20139. */
  20140. uScale: number;
  20141. /**
  20142. * Define an offset on the texture to scale the v coordinates of the UVs
  20143. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  20144. */
  20145. vScale: number;
  20146. /**
  20147. * Define an offset on the texture to rotate around the u coordinates of the UVs
  20148. * @see http://doc.babylonjs.com/how_to/more_materials
  20149. */
  20150. uAng: number;
  20151. /**
  20152. * Define an offset on the texture to rotate around the v coordinates of the UVs
  20153. * @see http://doc.babylonjs.com/how_to/more_materials
  20154. */
  20155. vAng: number;
  20156. /**
  20157. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  20158. * @see http://doc.babylonjs.com/how_to/more_materials
  20159. */
  20160. wAng: number;
  20161. /**
  20162. * Defines the center of rotation (U)
  20163. */
  20164. uRotationCenter: number;
  20165. /**
  20166. * Defines the center of rotation (V)
  20167. */
  20168. vRotationCenter: number;
  20169. /**
  20170. * Defines the center of rotation (W)
  20171. */
  20172. wRotationCenter: number;
  20173. /**
  20174. * Are mip maps generated for this texture or not.
  20175. */
  20176. get noMipmap(): boolean;
  20177. /**
  20178. * List of inspectable custom properties (used by the Inspector)
  20179. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  20180. */
  20181. inspectableCustomProperties: Nullable<IInspectable[]>;
  20182. private _noMipmap;
  20183. /** @hidden */
  20184. _invertY: boolean;
  20185. private _rowGenerationMatrix;
  20186. private _cachedTextureMatrix;
  20187. private _projectionModeMatrix;
  20188. private _t0;
  20189. private _t1;
  20190. private _t2;
  20191. private _cachedUOffset;
  20192. private _cachedVOffset;
  20193. private _cachedUScale;
  20194. private _cachedVScale;
  20195. private _cachedUAng;
  20196. private _cachedVAng;
  20197. private _cachedWAng;
  20198. private _cachedProjectionMatrixId;
  20199. private _cachedCoordinatesMode;
  20200. /** @hidden */
  20201. protected _initialSamplingMode: number;
  20202. /** @hidden */
  20203. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  20204. private _deleteBuffer;
  20205. protected _format: Nullable<number>;
  20206. private _delayedOnLoad;
  20207. private _delayedOnError;
  20208. private _mimeType?;
  20209. /**
  20210. * Observable triggered once the texture has been loaded.
  20211. */
  20212. onLoadObservable: Observable<Texture>;
  20213. protected _isBlocking: boolean;
  20214. /**
  20215. * Is the texture preventing material to render while loading.
  20216. * If false, a default texture will be used instead of the loading one during the preparation step.
  20217. */
  20218. set isBlocking(value: boolean);
  20219. get isBlocking(): boolean;
  20220. /**
  20221. * Get the current sampling mode associated with the texture.
  20222. */
  20223. get samplingMode(): number;
  20224. /**
  20225. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  20226. */
  20227. get invertY(): boolean;
  20228. /**
  20229. * Instantiates a new texture.
  20230. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  20231. * @see http://doc.babylonjs.com/babylon101/materials#texture
  20232. * @param url defines the url of the picture to load as a texture
  20233. * @param scene defines the scene or engine the texture will belong to
  20234. * @param noMipmap defines if the texture will require mip maps or not
  20235. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  20236. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  20237. * @param onLoad defines a callback triggered when the texture has been loaded
  20238. * @param onError defines a callback triggered when an error occurred during the loading session
  20239. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  20240. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  20241. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  20242. * @param mimeType defines an optional mime type information
  20243. */
  20244. constructor(url: Nullable<string>, sceneOrEngine: Nullable<Scene | ThinEngine>, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, deleteBuffer?: boolean, format?: number, mimeType?: string);
  20245. /**
  20246. * Update the url (and optional buffer) of this texture if url was null during construction.
  20247. * @param url the url of the texture
  20248. * @param buffer the buffer of the texture (defaults to null)
  20249. * @param onLoad callback called when the texture is loaded (defaults to null)
  20250. */
  20251. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  20252. /**
  20253. * Finish the loading sequence of a texture flagged as delayed load.
  20254. * @hidden
  20255. */
  20256. delayLoad(): void;
  20257. private _prepareRowForTextureGeneration;
  20258. /**
  20259. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  20260. * @returns the transform matrix of the texture.
  20261. */
  20262. getTextureMatrix(uBase?: number): Matrix;
  20263. /**
  20264. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  20265. * @returns The reflection texture transform
  20266. */
  20267. getReflectionTextureMatrix(): Matrix;
  20268. /**
  20269. * Clones the texture.
  20270. * @returns the cloned texture
  20271. */
  20272. clone(): Texture;
  20273. /**
  20274. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  20275. * @returns The JSON representation of the texture
  20276. */
  20277. serialize(): any;
  20278. /**
  20279. * Get the current class name of the texture useful for serialization or dynamic coding.
  20280. * @returns "Texture"
  20281. */
  20282. getClassName(): string;
  20283. /**
  20284. * Dispose the texture and release its associated resources.
  20285. */
  20286. dispose(): void;
  20287. /**
  20288. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  20289. * @param parsedTexture Define the JSON representation of the texture
  20290. * @param scene Define the scene the parsed texture should be instantiated in
  20291. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  20292. * @returns The parsed texture if successful
  20293. */
  20294. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  20295. /**
  20296. * Creates a texture from its base 64 representation.
  20297. * @param data Define the base64 payload without the data: prefix
  20298. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  20299. * @param scene Define the scene the texture should belong to
  20300. * @param noMipmap Forces the texture to not create mip map information if true
  20301. * @param invertY define if the texture needs to be inverted on the y axis during loading
  20302. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  20303. * @param onLoad define a callback triggered when the texture has been loaded
  20304. * @param onError define a callback triggered when an error occurred during the loading session
  20305. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  20306. * @returns the created texture
  20307. */
  20308. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  20309. /**
  20310. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  20311. * @param data Define the base64 payload without the data: prefix
  20312. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  20313. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  20314. * @param scene Define the scene the texture should belong to
  20315. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  20316. * @param noMipmap Forces the texture to not create mip map information if true
  20317. * @param invertY define if the texture needs to be inverted on the y axis during loading
  20318. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  20319. * @param onLoad define a callback triggered when the texture has been loaded
  20320. * @param onError define a callback triggered when an error occurred during the loading session
  20321. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  20322. * @returns the created texture
  20323. */
  20324. static LoadFromDataString(name: string, buffer: any, scene: Scene, deleteBuffer?: boolean, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number): Texture;
  20325. }
  20326. }
  20327. declare module BABYLON {
  20328. /**
  20329. * PostProcessManager is used to manage one or more post processes or post process pipelines
  20330. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  20331. */
  20332. export class PostProcessManager {
  20333. private _scene;
  20334. private _indexBuffer;
  20335. private _vertexBuffers;
  20336. /**
  20337. * Creates a new instance PostProcess
  20338. * @param scene The scene that the post process is associated with.
  20339. */
  20340. constructor(scene: Scene);
  20341. private _prepareBuffers;
  20342. private _buildIndexBuffer;
  20343. /**
  20344. * Rebuilds the vertex buffers of the manager.
  20345. * @hidden
  20346. */
  20347. _rebuild(): void;
  20348. /**
  20349. * Prepares a frame to be run through a post process.
  20350. * @param sourceTexture The input texture to the post procesess. (default: null)
  20351. * @param postProcesses An array of post processes to be run. (default: null)
  20352. * @returns True if the post processes were able to be run.
  20353. * @hidden
  20354. */
  20355. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  20356. /**
  20357. * Manually render a set of post processes to a texture.
  20358. * @param postProcesses An array of post processes to be run.
  20359. * @param targetTexture The target texture to render to.
  20360. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  20361. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  20362. * @param lodLevel defines which lod of the texture to render to
  20363. */
  20364. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  20365. /**
  20366. * Finalize the result of the output of the postprocesses.
  20367. * @param doNotPresent If true the result will not be displayed to the screen.
  20368. * @param targetTexture The target texture to render to.
  20369. * @param faceIndex The index of the face to bind the target texture to.
  20370. * @param postProcesses The array of post processes to render.
  20371. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  20372. * @hidden
  20373. */
  20374. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  20375. /**
  20376. * Disposes of the post process manager.
  20377. */
  20378. dispose(): void;
  20379. }
  20380. }
  20381. declare module BABYLON {
  20382. /**
  20383. * This Helps creating a texture that will be created from a camera in your scene.
  20384. * It is basically a dynamic texture that could be used to create special effects for instance.
  20385. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  20386. */
  20387. export class RenderTargetTexture extends Texture {
  20388. isCube: boolean;
  20389. /**
  20390. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  20391. */
  20392. static readonly REFRESHRATE_RENDER_ONCE: number;
  20393. /**
  20394. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  20395. */
  20396. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  20397. /**
  20398. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  20399. * the central point of your effect and can save a lot of performances.
  20400. */
  20401. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  20402. /**
  20403. * Use this predicate to dynamically define the list of mesh you want to render.
  20404. * If set, the renderList property will be overwritten.
  20405. */
  20406. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  20407. private _renderList;
  20408. /**
  20409. * Use this list to define the list of mesh you want to render.
  20410. */
  20411. get renderList(): Nullable<Array<AbstractMesh>>;
  20412. set renderList(value: Nullable<Array<AbstractMesh>>);
  20413. /**
  20414. * Use this function to overload the renderList array at rendering time.
  20415. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  20416. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  20417. * the cube (if the RTT is a cube, else layerOrFace=0).
  20418. * The renderList passed to the function is the current render list (the one that will be used if the function returns null)
  20419. */
  20420. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>) => Nullable<Array<AbstractMesh>>;
  20421. private _hookArray;
  20422. /**
  20423. * Define if particles should be rendered in your texture.
  20424. */
  20425. renderParticles: boolean;
  20426. /**
  20427. * Define if sprites should be rendered in your texture.
  20428. */
  20429. renderSprites: boolean;
  20430. /**
  20431. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  20432. */
  20433. coordinatesMode: number;
  20434. /**
  20435. * Define the camera used to render the texture.
  20436. */
  20437. activeCamera: Nullable<Camera>;
  20438. /**
  20439. * Override the render function of the texture with your own one.
  20440. */
  20441. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  20442. /**
  20443. * Define if camera post processes should be use while rendering the texture.
  20444. */
  20445. useCameraPostProcesses: boolean;
  20446. /**
  20447. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  20448. */
  20449. ignoreCameraViewport: boolean;
  20450. private _postProcessManager;
  20451. private _postProcesses;
  20452. private _resizeObserver;
  20453. /**
  20454. * An event triggered when the texture is unbind.
  20455. */
  20456. onBeforeBindObservable: Observable<RenderTargetTexture>;
  20457. /**
  20458. * An event triggered when the texture is unbind.
  20459. */
  20460. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  20461. private _onAfterUnbindObserver;
  20462. /**
  20463. * Set a after unbind callback in the texture.
  20464. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  20465. */
  20466. set onAfterUnbind(callback: () => void);
  20467. /**
  20468. * An event triggered before rendering the texture
  20469. */
  20470. onBeforeRenderObservable: Observable<number>;
  20471. private _onBeforeRenderObserver;
  20472. /**
  20473. * Set a before render callback in the texture.
  20474. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  20475. */
  20476. set onBeforeRender(callback: (faceIndex: number) => void);
  20477. /**
  20478. * An event triggered after rendering the texture
  20479. */
  20480. onAfterRenderObservable: Observable<number>;
  20481. private _onAfterRenderObserver;
  20482. /**
  20483. * Set a after render callback in the texture.
  20484. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  20485. */
  20486. set onAfterRender(callback: (faceIndex: number) => void);
  20487. /**
  20488. * An event triggered after the texture clear
  20489. */
  20490. onClearObservable: Observable<Engine>;
  20491. private _onClearObserver;
  20492. /**
  20493. * Set a clear callback in the texture.
  20494. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  20495. */
  20496. set onClear(callback: (Engine: Engine) => void);
  20497. /**
  20498. * An event triggered when the texture is resized.
  20499. */
  20500. onResizeObservable: Observable<RenderTargetTexture>;
  20501. /**
  20502. * Define the clear color of the Render Target if it should be different from the scene.
  20503. */
  20504. clearColor: Color4;
  20505. protected _size: number | {
  20506. width: number;
  20507. height: number;
  20508. layers?: number;
  20509. };
  20510. protected _initialSizeParameter: number | {
  20511. width: number;
  20512. height: number;
  20513. } | {
  20514. ratio: number;
  20515. };
  20516. protected _sizeRatio: Nullable<number>;
  20517. /** @hidden */
  20518. _generateMipMaps: boolean;
  20519. protected _renderingManager: RenderingManager;
  20520. /** @hidden */
  20521. _waitingRenderList: string[];
  20522. protected _doNotChangeAspectRatio: boolean;
  20523. protected _currentRefreshId: number;
  20524. protected _refreshRate: number;
  20525. protected _textureMatrix: Matrix;
  20526. protected _samples: number;
  20527. protected _renderTargetOptions: RenderTargetCreationOptions;
  20528. /**
  20529. * Gets render target creation options that were used.
  20530. */
  20531. get renderTargetOptions(): RenderTargetCreationOptions;
  20532. protected _engine: Engine;
  20533. protected _onRatioRescale(): void;
  20534. /**
  20535. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  20536. * It must define where the camera used to render the texture is set
  20537. */
  20538. boundingBoxPosition: Vector3;
  20539. private _boundingBoxSize;
  20540. /**
  20541. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  20542. * When defined, the cubemap will switch to local mode
  20543. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  20544. * @example https://www.babylonjs-playground.com/#RNASML
  20545. */
  20546. set boundingBoxSize(value: Vector3);
  20547. get boundingBoxSize(): Vector3;
  20548. /**
  20549. * In case the RTT has been created with a depth texture, get the associated
  20550. * depth texture.
  20551. * Otherwise, return null.
  20552. */
  20553. get depthStencilTexture(): Nullable<InternalTexture>;
  20554. /**
  20555. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  20556. * or used a shadow, depth texture...
  20557. * @param name The friendly name of the texture
  20558. * @param size The size of the RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  20559. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  20560. * @param generateMipMaps True if mip maps need to be generated after render.
  20561. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  20562. * @param type The type of the buffer in the RTT (int, half float, float...)
  20563. * @param isCube True if a cube texture needs to be created
  20564. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  20565. * @param generateDepthBuffer True to generate a depth buffer
  20566. * @param generateStencilBuffer True to generate a stencil buffer
  20567. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  20568. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  20569. * @param delayAllocation if the texture allocation should be delayed (default: false)
  20570. */
  20571. constructor(name: string, size: number | {
  20572. width: number;
  20573. height: number;
  20574. layers?: number;
  20575. } | {
  20576. ratio: number;
  20577. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  20578. /**
  20579. * Creates a depth stencil texture.
  20580. * This is only available in WebGL 2 or with the depth texture extension available.
  20581. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  20582. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  20583. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  20584. */
  20585. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  20586. private _processSizeParameter;
  20587. /**
  20588. * Define the number of samples to use in case of MSAA.
  20589. * It defaults to one meaning no MSAA has been enabled.
  20590. */
  20591. get samples(): number;
  20592. set samples(value: number);
  20593. /**
  20594. * Resets the refresh counter of the texture and start bak from scratch.
  20595. * Could be useful to regenerate the texture if it is setup to render only once.
  20596. */
  20597. resetRefreshCounter(): void;
  20598. /**
  20599. * Define the refresh rate of the texture or the rendering frequency.
  20600. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  20601. */
  20602. get refreshRate(): number;
  20603. set refreshRate(value: number);
  20604. /**
  20605. * Adds a post process to the render target rendering passes.
  20606. * @param postProcess define the post process to add
  20607. */
  20608. addPostProcess(postProcess: PostProcess): void;
  20609. /**
  20610. * Clear all the post processes attached to the render target
  20611. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  20612. */
  20613. clearPostProcesses(dispose?: boolean): void;
  20614. /**
  20615. * Remove one of the post process from the list of attached post processes to the texture
  20616. * @param postProcess define the post process to remove from the list
  20617. */
  20618. removePostProcess(postProcess: PostProcess): void;
  20619. /** @hidden */
  20620. _shouldRender(): boolean;
  20621. /**
  20622. * Gets the actual render size of the texture.
  20623. * @returns the width of the render size
  20624. */
  20625. getRenderSize(): number;
  20626. /**
  20627. * Gets the actual render width of the texture.
  20628. * @returns the width of the render size
  20629. */
  20630. getRenderWidth(): number;
  20631. /**
  20632. * Gets the actual render height of the texture.
  20633. * @returns the height of the render size
  20634. */
  20635. getRenderHeight(): number;
  20636. /**
  20637. * Gets the actual number of layers of the texture.
  20638. * @returns the number of layers
  20639. */
  20640. getRenderLayers(): number;
  20641. /**
  20642. * Get if the texture can be rescaled or not.
  20643. */
  20644. get canRescale(): boolean;
  20645. /**
  20646. * Resize the texture using a ratio.
  20647. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  20648. */
  20649. scale(ratio: number): void;
  20650. /**
  20651. * Get the texture reflection matrix used to rotate/transform the reflection.
  20652. * @returns the reflection matrix
  20653. */
  20654. getReflectionTextureMatrix(): Matrix;
  20655. /**
  20656. * Resize the texture to a new desired size.
  20657. * Be carrefull as it will recreate all the data in the new texture.
  20658. * @param size Define the new size. It can be:
  20659. * - a number for squared texture,
  20660. * - an object containing { width: number, height: number }
  20661. * - or an object containing a ratio { ratio: number }
  20662. */
  20663. resize(size: number | {
  20664. width: number;
  20665. height: number;
  20666. } | {
  20667. ratio: number;
  20668. }): void;
  20669. private _defaultRenderListPrepared;
  20670. /**
  20671. * Renders all the objects from the render list into the texture.
  20672. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  20673. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  20674. */
  20675. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  20676. private _bestReflectionRenderTargetDimension;
  20677. private _prepareRenderingManager;
  20678. /**
  20679. * @hidden
  20680. * @param faceIndex face index to bind to if this is a cubetexture
  20681. * @param layer defines the index of the texture to bind in the array
  20682. */
  20683. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  20684. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  20685. private renderToTarget;
  20686. /**
  20687. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20688. * This allowed control for front to back rendering or reversly depending of the special needs.
  20689. *
  20690. * @param renderingGroupId The rendering group id corresponding to its index
  20691. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20692. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20693. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20694. */
  20695. setRenderingOrder(renderingGroupId: number, opaqueSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, alphaTestSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, transparentSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>): void;
  20696. /**
  20697. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20698. *
  20699. * @param renderingGroupId The rendering group id corresponding to its index
  20700. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20701. */
  20702. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  20703. /**
  20704. * Clones the texture.
  20705. * @returns the cloned texture
  20706. */
  20707. clone(): RenderTargetTexture;
  20708. /**
  20709. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  20710. * @returns The JSON representation of the texture
  20711. */
  20712. serialize(): any;
  20713. /**
  20714. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  20715. */
  20716. disposeFramebufferObjects(): void;
  20717. /**
  20718. * Dispose the texture and release its associated resources.
  20719. */
  20720. dispose(): void;
  20721. /** @hidden */
  20722. _rebuild(): void;
  20723. /**
  20724. * Clear the info related to rendering groups preventing retention point in material dispose.
  20725. */
  20726. freeRenderingGroups(): void;
  20727. /**
  20728. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  20729. * @returns the view count
  20730. */
  20731. getViewCount(): number;
  20732. }
  20733. }
  20734. declare module BABYLON {
  20735. /**
  20736. * Options for compiling materials.
  20737. */
  20738. export interface IMaterialCompilationOptions {
  20739. /**
  20740. * Defines whether clip planes are enabled.
  20741. */
  20742. clipPlane: boolean;
  20743. /**
  20744. * Defines whether instances are enabled.
  20745. */
  20746. useInstances: boolean;
  20747. }
  20748. /**
  20749. * Base class for the main features of a material in Babylon.js
  20750. */
  20751. export class Material implements IAnimatable {
  20752. /**
  20753. * Returns the triangle fill mode
  20754. */
  20755. static readonly TriangleFillMode: number;
  20756. /**
  20757. * Returns the wireframe mode
  20758. */
  20759. static readonly WireFrameFillMode: number;
  20760. /**
  20761. * Returns the point fill mode
  20762. */
  20763. static readonly PointFillMode: number;
  20764. /**
  20765. * Returns the point list draw mode
  20766. */
  20767. static readonly PointListDrawMode: number;
  20768. /**
  20769. * Returns the line list draw mode
  20770. */
  20771. static readonly LineListDrawMode: number;
  20772. /**
  20773. * Returns the line loop draw mode
  20774. */
  20775. static readonly LineLoopDrawMode: number;
  20776. /**
  20777. * Returns the line strip draw mode
  20778. */
  20779. static readonly LineStripDrawMode: number;
  20780. /**
  20781. * Returns the triangle strip draw mode
  20782. */
  20783. static readonly TriangleStripDrawMode: number;
  20784. /**
  20785. * Returns the triangle fan draw mode
  20786. */
  20787. static readonly TriangleFanDrawMode: number;
  20788. /**
  20789. * Stores the clock-wise side orientation
  20790. */
  20791. static readonly ClockWiseSideOrientation: number;
  20792. /**
  20793. * Stores the counter clock-wise side orientation
  20794. */
  20795. static readonly CounterClockWiseSideOrientation: number;
  20796. /**
  20797. * The dirty texture flag value
  20798. */
  20799. static readonly TextureDirtyFlag: number;
  20800. /**
  20801. * The dirty light flag value
  20802. */
  20803. static readonly LightDirtyFlag: number;
  20804. /**
  20805. * The dirty fresnel flag value
  20806. */
  20807. static readonly FresnelDirtyFlag: number;
  20808. /**
  20809. * The dirty attribute flag value
  20810. */
  20811. static readonly AttributesDirtyFlag: number;
  20812. /**
  20813. * The dirty misc flag value
  20814. */
  20815. static readonly MiscDirtyFlag: number;
  20816. /**
  20817. * The all dirty flag value
  20818. */
  20819. static readonly AllDirtyFlag: number;
  20820. /**
  20821. * The ID of the material
  20822. */
  20823. id: string;
  20824. /**
  20825. * Gets or sets the unique id of the material
  20826. */
  20827. uniqueId: number;
  20828. /**
  20829. * The name of the material
  20830. */
  20831. name: string;
  20832. /**
  20833. * Gets or sets user defined metadata
  20834. */
  20835. metadata: any;
  20836. /**
  20837. * For internal use only. Please do not use.
  20838. */
  20839. reservedDataStore: any;
  20840. /**
  20841. * Specifies if the ready state should be checked on each call
  20842. */
  20843. checkReadyOnEveryCall: boolean;
  20844. /**
  20845. * Specifies if the ready state should be checked once
  20846. */
  20847. checkReadyOnlyOnce: boolean;
  20848. /**
  20849. * The state of the material
  20850. */
  20851. state: string;
  20852. /**
  20853. * The alpha value of the material
  20854. */
  20855. protected _alpha: number;
  20856. /**
  20857. * List of inspectable custom properties (used by the Inspector)
  20858. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  20859. */
  20860. inspectableCustomProperties: IInspectable[];
  20861. /**
  20862. * Sets the alpha value of the material
  20863. */
  20864. set alpha(value: number);
  20865. /**
  20866. * Gets the alpha value of the material
  20867. */
  20868. get alpha(): number;
  20869. /**
  20870. * Specifies if back face culling is enabled
  20871. */
  20872. protected _backFaceCulling: boolean;
  20873. /**
  20874. * Sets the back-face culling state
  20875. */
  20876. set backFaceCulling(value: boolean);
  20877. /**
  20878. * Gets the back-face culling state
  20879. */
  20880. get backFaceCulling(): boolean;
  20881. /**
  20882. * Stores the value for side orientation
  20883. */
  20884. sideOrientation: number;
  20885. /**
  20886. * Callback triggered when the material is compiled
  20887. */
  20888. onCompiled: Nullable<(effect: Effect) => void>;
  20889. /**
  20890. * Callback triggered when an error occurs
  20891. */
  20892. onError: Nullable<(effect: Effect, errors: string) => void>;
  20893. /**
  20894. * Callback triggered to get the render target textures
  20895. */
  20896. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  20897. /**
  20898. * Gets a boolean indicating that current material needs to register RTT
  20899. */
  20900. get hasRenderTargetTextures(): boolean;
  20901. /**
  20902. * Specifies if the material should be serialized
  20903. */
  20904. doNotSerialize: boolean;
  20905. /**
  20906. * @hidden
  20907. */
  20908. _storeEffectOnSubMeshes: boolean;
  20909. /**
  20910. * Stores the animations for the material
  20911. */
  20912. animations: Nullable<Array<Animation>>;
  20913. /**
  20914. * An event triggered when the material is disposed
  20915. */
  20916. onDisposeObservable: Observable<Material>;
  20917. /**
  20918. * An observer which watches for dispose events
  20919. */
  20920. private _onDisposeObserver;
  20921. private _onUnBindObservable;
  20922. /**
  20923. * Called during a dispose event
  20924. */
  20925. set onDispose(callback: () => void);
  20926. private _onBindObservable;
  20927. /**
  20928. * An event triggered when the material is bound
  20929. */
  20930. get onBindObservable(): Observable<AbstractMesh>;
  20931. /**
  20932. * An observer which watches for bind events
  20933. */
  20934. private _onBindObserver;
  20935. /**
  20936. * Called during a bind event
  20937. */
  20938. set onBind(callback: (Mesh: AbstractMesh) => void);
  20939. /**
  20940. * An event triggered when the material is unbound
  20941. */
  20942. get onUnBindObservable(): Observable<Material>;
  20943. /**
  20944. * Stores the value of the alpha mode
  20945. */
  20946. private _alphaMode;
  20947. /**
  20948. * Sets the value of the alpha mode.
  20949. *
  20950. * | Value | Type | Description |
  20951. * | --- | --- | --- |
  20952. * | 0 | ALPHA_DISABLE | |
  20953. * | 1 | ALPHA_ADD | |
  20954. * | 2 | ALPHA_COMBINE | |
  20955. * | 3 | ALPHA_SUBTRACT | |
  20956. * | 4 | ALPHA_MULTIPLY | |
  20957. * | 5 | ALPHA_MAXIMIZED | |
  20958. * | 6 | ALPHA_ONEONE | |
  20959. * | 7 | ALPHA_PREMULTIPLIED | |
  20960. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  20961. * | 9 | ALPHA_INTERPOLATE | |
  20962. * | 10 | ALPHA_SCREENMODE | |
  20963. *
  20964. */
  20965. set alphaMode(value: number);
  20966. /**
  20967. * Gets the value of the alpha mode
  20968. */
  20969. get alphaMode(): number;
  20970. /**
  20971. * Stores the state of the need depth pre-pass value
  20972. */
  20973. private _needDepthPrePass;
  20974. /**
  20975. * Sets the need depth pre-pass value
  20976. */
  20977. set needDepthPrePass(value: boolean);
  20978. /**
  20979. * Gets the depth pre-pass value
  20980. */
  20981. get needDepthPrePass(): boolean;
  20982. /**
  20983. * Specifies if depth writing should be disabled
  20984. */
  20985. disableDepthWrite: boolean;
  20986. /**
  20987. * Specifies if depth writing should be forced
  20988. */
  20989. forceDepthWrite: boolean;
  20990. /**
  20991. * Specifies the depth function that should be used. 0 means the default engine function
  20992. */
  20993. depthFunction: number;
  20994. /**
  20995. * Specifies if there should be a separate pass for culling
  20996. */
  20997. separateCullingPass: boolean;
  20998. /**
  20999. * Stores the state specifing if fog should be enabled
  21000. */
  21001. private _fogEnabled;
  21002. /**
  21003. * Sets the state for enabling fog
  21004. */
  21005. set fogEnabled(value: boolean);
  21006. /**
  21007. * Gets the value of the fog enabled state
  21008. */
  21009. get fogEnabled(): boolean;
  21010. /**
  21011. * Stores the size of points
  21012. */
  21013. pointSize: number;
  21014. /**
  21015. * Stores the z offset value
  21016. */
  21017. zOffset: number;
  21018. /**
  21019. * Gets a value specifying if wireframe mode is enabled
  21020. */
  21021. get wireframe(): boolean;
  21022. /**
  21023. * Sets the state of wireframe mode
  21024. */
  21025. set wireframe(value: boolean);
  21026. /**
  21027. * Gets the value specifying if point clouds are enabled
  21028. */
  21029. get pointsCloud(): boolean;
  21030. /**
  21031. * Sets the state of point cloud mode
  21032. */
  21033. set pointsCloud(value: boolean);
  21034. /**
  21035. * Gets the material fill mode
  21036. */
  21037. get fillMode(): number;
  21038. /**
  21039. * Sets the material fill mode
  21040. */
  21041. set fillMode(value: number);
  21042. /**
  21043. * @hidden
  21044. * Stores the effects for the material
  21045. */
  21046. _effect: Nullable<Effect>;
  21047. /**
  21048. * Specifies if uniform buffers should be used
  21049. */
  21050. private _useUBO;
  21051. /**
  21052. * Stores a reference to the scene
  21053. */
  21054. private _scene;
  21055. /**
  21056. * Stores the fill mode state
  21057. */
  21058. private _fillMode;
  21059. /**
  21060. * Specifies if the depth write state should be cached
  21061. */
  21062. private _cachedDepthWriteState;
  21063. /**
  21064. * Specifies if the depth function state should be cached
  21065. */
  21066. private _cachedDepthFunctionState;
  21067. /**
  21068. * Stores the uniform buffer
  21069. */
  21070. protected _uniformBuffer: UniformBuffer;
  21071. /** @hidden */
  21072. _indexInSceneMaterialArray: number;
  21073. /** @hidden */
  21074. meshMap: Nullable<{
  21075. [id: string]: AbstractMesh | undefined;
  21076. }>;
  21077. /**
  21078. * Creates a material instance
  21079. * @param name defines the name of the material
  21080. * @param scene defines the scene to reference
  21081. * @param doNotAdd specifies if the material should be added to the scene
  21082. */
  21083. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  21084. /**
  21085. * Returns a string representation of the current material
  21086. * @param fullDetails defines a boolean indicating which levels of logging is desired
  21087. * @returns a string with material information
  21088. */
  21089. toString(fullDetails?: boolean): string;
  21090. /**
  21091. * Gets the class name of the material
  21092. * @returns a string with the class name of the material
  21093. */
  21094. getClassName(): string;
  21095. /**
  21096. * Specifies if updates for the material been locked
  21097. */
  21098. get isFrozen(): boolean;
  21099. /**
  21100. * Locks updates for the material
  21101. */
  21102. freeze(): void;
  21103. /**
  21104. * Unlocks updates for the material
  21105. */
  21106. unfreeze(): void;
  21107. /**
  21108. * Specifies if the material is ready to be used
  21109. * @param mesh defines the mesh to check
  21110. * @param useInstances specifies if instances should be used
  21111. * @returns a boolean indicating if the material is ready to be used
  21112. */
  21113. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21114. /**
  21115. * Specifies that the submesh is ready to be used
  21116. * @param mesh defines the mesh to check
  21117. * @param subMesh defines which submesh to check
  21118. * @param useInstances specifies that instances should be used
  21119. * @returns a boolean indicating that the submesh is ready or not
  21120. */
  21121. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21122. /**
  21123. * Returns the material effect
  21124. * @returns the effect associated with the material
  21125. */
  21126. getEffect(): Nullable<Effect>;
  21127. /**
  21128. * Returns the current scene
  21129. * @returns a Scene
  21130. */
  21131. getScene(): Scene;
  21132. /**
  21133. * Specifies if the material will require alpha blending
  21134. * @returns a boolean specifying if alpha blending is needed
  21135. */
  21136. needAlphaBlending(): boolean;
  21137. /**
  21138. * Specifies if the mesh will require alpha blending
  21139. * @param mesh defines the mesh to check
  21140. * @returns a boolean specifying if alpha blending is needed for the mesh
  21141. */
  21142. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  21143. /**
  21144. * Specifies if this material should be rendered in alpha test mode
  21145. * @returns a boolean specifying if an alpha test is needed.
  21146. */
  21147. needAlphaTesting(): boolean;
  21148. /**
  21149. * Gets the texture used for the alpha test
  21150. * @returns the texture to use for alpha testing
  21151. */
  21152. getAlphaTestTexture(): Nullable<BaseTexture>;
  21153. /**
  21154. * Marks the material to indicate that it needs to be re-calculated
  21155. */
  21156. markDirty(): void;
  21157. /** @hidden */
  21158. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  21159. /**
  21160. * Binds the material to the mesh
  21161. * @param world defines the world transformation matrix
  21162. * @param mesh defines the mesh to bind the material to
  21163. */
  21164. bind(world: Matrix, mesh?: Mesh): void;
  21165. /**
  21166. * Binds the submesh to the material
  21167. * @param world defines the world transformation matrix
  21168. * @param mesh defines the mesh containing the submesh
  21169. * @param subMesh defines the submesh to bind the material to
  21170. */
  21171. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  21172. /**
  21173. * Binds the world matrix to the material
  21174. * @param world defines the world transformation matrix
  21175. */
  21176. bindOnlyWorldMatrix(world: Matrix): void;
  21177. /**
  21178. * Binds the scene's uniform buffer to the effect.
  21179. * @param effect defines the effect to bind to the scene uniform buffer
  21180. * @param sceneUbo defines the uniform buffer storing scene data
  21181. */
  21182. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  21183. /**
  21184. * Binds the view matrix to the effect
  21185. * @param effect defines the effect to bind the view matrix to
  21186. */
  21187. bindView(effect: Effect): void;
  21188. /**
  21189. * Binds the view projection matrix to the effect
  21190. * @param effect defines the effect to bind the view projection matrix to
  21191. */
  21192. bindViewProjection(effect: Effect): void;
  21193. /**
  21194. * Specifies if material alpha testing should be turned on for the mesh
  21195. * @param mesh defines the mesh to check
  21196. */
  21197. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  21198. /**
  21199. * Processes to execute after binding the material to a mesh
  21200. * @param mesh defines the rendered mesh
  21201. */
  21202. protected _afterBind(mesh?: Mesh): void;
  21203. /**
  21204. * Unbinds the material from the mesh
  21205. */
  21206. unbind(): void;
  21207. /**
  21208. * Gets the active textures from the material
  21209. * @returns an array of textures
  21210. */
  21211. getActiveTextures(): BaseTexture[];
  21212. /**
  21213. * Specifies if the material uses a texture
  21214. * @param texture defines the texture to check against the material
  21215. * @returns a boolean specifying if the material uses the texture
  21216. */
  21217. hasTexture(texture: BaseTexture): boolean;
  21218. /**
  21219. * Makes a duplicate of the material, and gives it a new name
  21220. * @param name defines the new name for the duplicated material
  21221. * @returns the cloned material
  21222. */
  21223. clone(name: string): Nullable<Material>;
  21224. /**
  21225. * Gets the meshes bound to the material
  21226. * @returns an array of meshes bound to the material
  21227. */
  21228. getBindedMeshes(): AbstractMesh[];
  21229. /**
  21230. * Force shader compilation
  21231. * @param mesh defines the mesh associated with this material
  21232. * @param onCompiled defines a function to execute once the material is compiled
  21233. * @param options defines the options to configure the compilation
  21234. * @param onError defines a function to execute if the material fails compiling
  21235. */
  21236. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  21237. /**
  21238. * Force shader compilation
  21239. * @param mesh defines the mesh that will use this material
  21240. * @param options defines additional options for compiling the shaders
  21241. * @returns a promise that resolves when the compilation completes
  21242. */
  21243. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  21244. private static readonly _AllDirtyCallBack;
  21245. private static readonly _ImageProcessingDirtyCallBack;
  21246. private static readonly _TextureDirtyCallBack;
  21247. private static readonly _FresnelDirtyCallBack;
  21248. private static readonly _MiscDirtyCallBack;
  21249. private static readonly _LightsDirtyCallBack;
  21250. private static readonly _AttributeDirtyCallBack;
  21251. private static _FresnelAndMiscDirtyCallBack;
  21252. private static _TextureAndMiscDirtyCallBack;
  21253. private static readonly _DirtyCallbackArray;
  21254. private static readonly _RunDirtyCallBacks;
  21255. /**
  21256. * Marks a define in the material to indicate that it needs to be re-computed
  21257. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  21258. */
  21259. markAsDirty(flag: number): void;
  21260. /**
  21261. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  21262. * @param func defines a function which checks material defines against the submeshes
  21263. */
  21264. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  21265. /**
  21266. * Indicates that we need to re-calculated for all submeshes
  21267. */
  21268. protected _markAllSubMeshesAsAllDirty(): void;
  21269. /**
  21270. * Indicates that image processing needs to be re-calculated for all submeshes
  21271. */
  21272. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  21273. /**
  21274. * Indicates that textures need to be re-calculated for all submeshes
  21275. */
  21276. protected _markAllSubMeshesAsTexturesDirty(): void;
  21277. /**
  21278. * Indicates that fresnel needs to be re-calculated for all submeshes
  21279. */
  21280. protected _markAllSubMeshesAsFresnelDirty(): void;
  21281. /**
  21282. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  21283. */
  21284. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  21285. /**
  21286. * Indicates that lights need to be re-calculated for all submeshes
  21287. */
  21288. protected _markAllSubMeshesAsLightsDirty(): void;
  21289. /**
  21290. * Indicates that attributes need to be re-calculated for all submeshes
  21291. */
  21292. protected _markAllSubMeshesAsAttributesDirty(): void;
  21293. /**
  21294. * Indicates that misc needs to be re-calculated for all submeshes
  21295. */
  21296. protected _markAllSubMeshesAsMiscDirty(): void;
  21297. /**
  21298. * Indicates that textures and misc need to be re-calculated for all submeshes
  21299. */
  21300. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  21301. /**
  21302. * Disposes the material
  21303. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  21304. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  21305. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  21306. */
  21307. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  21308. /** @hidden */
  21309. private releaseVertexArrayObject;
  21310. /**
  21311. * Serializes this material
  21312. * @returns the serialized material object
  21313. */
  21314. serialize(): any;
  21315. /**
  21316. * Creates a material from parsed material data
  21317. * @param parsedMaterial defines parsed material data
  21318. * @param scene defines the hosting scene
  21319. * @param rootUrl defines the root URL to use to load textures
  21320. * @returns a new material
  21321. */
  21322. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  21323. }
  21324. }
  21325. declare module BABYLON {
  21326. /**
  21327. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21328. * separate meshes. This can be use to improve performances.
  21329. * @see http://doc.babylonjs.com/how_to/multi_materials
  21330. */
  21331. export class MultiMaterial extends Material {
  21332. private _subMaterials;
  21333. /**
  21334. * Gets or Sets the list of Materials used within the multi material.
  21335. * They need to be ordered according to the submeshes order in the associated mesh
  21336. */
  21337. get subMaterials(): Nullable<Material>[];
  21338. set subMaterials(value: Nullable<Material>[]);
  21339. /**
  21340. * Function used to align with Node.getChildren()
  21341. * @returns the list of Materials used within the multi material
  21342. */
  21343. getChildren(): Nullable<Material>[];
  21344. /**
  21345. * Instantiates a new Multi Material
  21346. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21347. * separate meshes. This can be use to improve performances.
  21348. * @see http://doc.babylonjs.com/how_to/multi_materials
  21349. * @param name Define the name in the scene
  21350. * @param scene Define the scene the material belongs to
  21351. */
  21352. constructor(name: string, scene: Scene);
  21353. private _hookArray;
  21354. /**
  21355. * Get one of the submaterial by its index in the submaterials array
  21356. * @param index The index to look the sub material at
  21357. * @returns The Material if the index has been defined
  21358. */
  21359. getSubMaterial(index: number): Nullable<Material>;
  21360. /**
  21361. * Get the list of active textures for the whole sub materials list.
  21362. * @returns All the textures that will be used during the rendering
  21363. */
  21364. getActiveTextures(): BaseTexture[];
  21365. /**
  21366. * Gets the current class name of the material e.g. "MultiMaterial"
  21367. * Mainly use in serialization.
  21368. * @returns the class name
  21369. */
  21370. getClassName(): string;
  21371. /**
  21372. * Checks if the material is ready to render the requested sub mesh
  21373. * @param mesh Define the mesh the submesh belongs to
  21374. * @param subMesh Define the sub mesh to look readyness for
  21375. * @param useInstances Define whether or not the material is used with instances
  21376. * @returns true if ready, otherwise false
  21377. */
  21378. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21379. /**
  21380. * Clones the current material and its related sub materials
  21381. * @param name Define the name of the newly cloned material
  21382. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  21383. * @returns the cloned material
  21384. */
  21385. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  21386. /**
  21387. * Serializes the materials into a JSON representation.
  21388. * @returns the JSON representation
  21389. */
  21390. serialize(): any;
  21391. /**
  21392. * Dispose the material and release its associated resources
  21393. * @param forceDisposeEffect Define if we want to force disposing the associated effect (if false the shader is not released and could be reuse later on)
  21394. * @param forceDisposeTextures Define if we want to force disposing the associated textures (if false, they will not be disposed and can still be use elsewhere in the app)
  21395. * @param forceDisposeChildren Define if we want to force disposing the associated submaterials (if false, they will not be disposed and can still be use elsewhere in the app)
  21396. */
  21397. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  21398. /**
  21399. * Creates a MultiMaterial from parsed MultiMaterial data.
  21400. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  21401. * @param scene defines the hosting scene
  21402. * @returns a new MultiMaterial
  21403. */
  21404. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  21405. }
  21406. }
  21407. declare module BABYLON {
  21408. /**
  21409. * Base class for submeshes
  21410. */
  21411. export class BaseSubMesh {
  21412. /** @hidden */
  21413. _materialDefines: Nullable<MaterialDefines>;
  21414. /** @hidden */
  21415. _materialEffect: Nullable<Effect>;
  21416. /**
  21417. * Gets material defines used by the effect associated to the sub mesh
  21418. */
  21419. get materialDefines(): Nullable<MaterialDefines>;
  21420. /**
  21421. * Sets material defines used by the effect associated to the sub mesh
  21422. */
  21423. set materialDefines(defines: Nullable<MaterialDefines>);
  21424. /**
  21425. * Gets associated effect
  21426. */
  21427. get effect(): Nullable<Effect>;
  21428. /**
  21429. * Sets associated effect (effect used to render this submesh)
  21430. * @param effect defines the effect to associate with
  21431. * @param defines defines the set of defines used to compile this effect
  21432. */
  21433. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  21434. }
  21435. /**
  21436. * Defines a subdivision inside a mesh
  21437. */
  21438. export class SubMesh extends BaseSubMesh implements ICullable {
  21439. /** the material index to use */
  21440. materialIndex: number;
  21441. /** vertex index start */
  21442. verticesStart: number;
  21443. /** vertices count */
  21444. verticesCount: number;
  21445. /** index start */
  21446. indexStart: number;
  21447. /** indices count */
  21448. indexCount: number;
  21449. /** @hidden */
  21450. _linesIndexCount: number;
  21451. private _mesh;
  21452. private _renderingMesh;
  21453. private _boundingInfo;
  21454. private _linesIndexBuffer;
  21455. /** @hidden */
  21456. _lastColliderWorldVertices: Nullable<Vector3[]>;
  21457. /** @hidden */
  21458. _trianglePlanes: Plane[];
  21459. /** @hidden */
  21460. _lastColliderTransformMatrix: Nullable<Matrix>;
  21461. /** @hidden */
  21462. _renderId: number;
  21463. /** @hidden */
  21464. _alphaIndex: number;
  21465. /** @hidden */
  21466. _distanceToCamera: number;
  21467. /** @hidden */
  21468. _id: number;
  21469. private _currentMaterial;
  21470. /**
  21471. * Add a new submesh to a mesh
  21472. * @param materialIndex defines the material index to use
  21473. * @param verticesStart defines vertex index start
  21474. * @param verticesCount defines vertices count
  21475. * @param indexStart defines index start
  21476. * @param indexCount defines indices count
  21477. * @param mesh defines the parent mesh
  21478. * @param renderingMesh defines an optional rendering mesh
  21479. * @param createBoundingBox defines if bounding box should be created for this submesh
  21480. * @returns the new submesh
  21481. */
  21482. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  21483. /**
  21484. * Creates a new submesh
  21485. * @param materialIndex defines the material index to use
  21486. * @param verticesStart defines vertex index start
  21487. * @param verticesCount defines vertices count
  21488. * @param indexStart defines index start
  21489. * @param indexCount defines indices count
  21490. * @param mesh defines the parent mesh
  21491. * @param renderingMesh defines an optional rendering mesh
  21492. * @param createBoundingBox defines if bounding box should be created for this submesh
  21493. */
  21494. constructor(
  21495. /** the material index to use */
  21496. materialIndex: number,
  21497. /** vertex index start */
  21498. verticesStart: number,
  21499. /** vertices count */
  21500. verticesCount: number,
  21501. /** index start */
  21502. indexStart: number,
  21503. /** indices count */
  21504. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  21505. /**
  21506. * Returns true if this submesh covers the entire parent mesh
  21507. * @ignorenaming
  21508. */
  21509. get IsGlobal(): boolean;
  21510. /**
  21511. * Returns the submesh BoudingInfo object
  21512. * @returns current bounding info (or mesh's one if the submesh is global)
  21513. */
  21514. getBoundingInfo(): BoundingInfo;
  21515. /**
  21516. * Sets the submesh BoundingInfo
  21517. * @param boundingInfo defines the new bounding info to use
  21518. * @returns the SubMesh
  21519. */
  21520. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  21521. /**
  21522. * Returns the mesh of the current submesh
  21523. * @return the parent mesh
  21524. */
  21525. getMesh(): AbstractMesh;
  21526. /**
  21527. * Returns the rendering mesh of the submesh
  21528. * @returns the rendering mesh (could be different from parent mesh)
  21529. */
  21530. getRenderingMesh(): Mesh;
  21531. /**
  21532. * Returns the submesh material
  21533. * @returns null or the current material
  21534. */
  21535. getMaterial(): Nullable<Material>;
  21536. /**
  21537. * Sets a new updated BoundingInfo object to the submesh
  21538. * @param data defines an optional position array to use to determine the bounding info
  21539. * @returns the SubMesh
  21540. */
  21541. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  21542. /** @hidden */
  21543. _checkCollision(collider: Collider): boolean;
  21544. /**
  21545. * Updates the submesh BoundingInfo
  21546. * @param world defines the world matrix to use to update the bounding info
  21547. * @returns the submesh
  21548. */
  21549. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  21550. /**
  21551. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  21552. * @param frustumPlanes defines the frustum planes
  21553. * @returns true if the submesh is intersecting with the frustum
  21554. */
  21555. isInFrustum(frustumPlanes: Plane[]): boolean;
  21556. /**
  21557. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  21558. * @param frustumPlanes defines the frustum planes
  21559. * @returns true if the submesh is inside the frustum
  21560. */
  21561. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  21562. /**
  21563. * Renders the submesh
  21564. * @param enableAlphaMode defines if alpha needs to be used
  21565. * @returns the submesh
  21566. */
  21567. render(enableAlphaMode: boolean): SubMesh;
  21568. /**
  21569. * @hidden
  21570. */
  21571. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  21572. /**
  21573. * Checks if the submesh intersects with a ray
  21574. * @param ray defines the ray to test
  21575. * @returns true is the passed ray intersects the submesh bounding box
  21576. */
  21577. canIntersects(ray: Ray): boolean;
  21578. /**
  21579. * Intersects current submesh with a ray
  21580. * @param ray defines the ray to test
  21581. * @param positions defines mesh's positions array
  21582. * @param indices defines mesh's indices array
  21583. * @param fastCheck defines if only bounding info should be used
  21584. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  21585. * @returns intersection info or null if no intersection
  21586. */
  21587. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  21588. /** @hidden */
  21589. private _intersectLines;
  21590. /** @hidden */
  21591. private _intersectUnIndexedLines;
  21592. /** @hidden */
  21593. private _intersectTriangles;
  21594. /** @hidden */
  21595. private _intersectUnIndexedTriangles;
  21596. /** @hidden */
  21597. _rebuild(): void;
  21598. /**
  21599. * Creates a new submesh from the passed mesh
  21600. * @param newMesh defines the new hosting mesh
  21601. * @param newRenderingMesh defines an optional rendering mesh
  21602. * @returns the new submesh
  21603. */
  21604. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  21605. /**
  21606. * Release associated resources
  21607. */
  21608. dispose(): void;
  21609. /**
  21610. * Gets the class name
  21611. * @returns the string "SubMesh".
  21612. */
  21613. getClassName(): string;
  21614. /**
  21615. * Creates a new submesh from indices data
  21616. * @param materialIndex the index of the main mesh material
  21617. * @param startIndex the index where to start the copy in the mesh indices array
  21618. * @param indexCount the number of indices to copy then from the startIndex
  21619. * @param mesh the main mesh to create the submesh from
  21620. * @param renderingMesh the optional rendering mesh
  21621. * @returns a new submesh
  21622. */
  21623. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  21624. }
  21625. }
  21626. declare module BABYLON {
  21627. /**
  21628. * Class used to represent data loading progression
  21629. */
  21630. export class SceneLoaderFlags {
  21631. private static _ForceFullSceneLoadingForIncremental;
  21632. private static _ShowLoadingScreen;
  21633. private static _CleanBoneMatrixWeights;
  21634. private static _loggingLevel;
  21635. /**
  21636. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  21637. */
  21638. static get ForceFullSceneLoadingForIncremental(): boolean;
  21639. static set ForceFullSceneLoadingForIncremental(value: boolean);
  21640. /**
  21641. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  21642. */
  21643. static get ShowLoadingScreen(): boolean;
  21644. static set ShowLoadingScreen(value: boolean);
  21645. /**
  21646. * Defines the current logging level (while loading the scene)
  21647. * @ignorenaming
  21648. */
  21649. static get loggingLevel(): number;
  21650. static set loggingLevel(value: number);
  21651. /**
  21652. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  21653. */
  21654. static get CleanBoneMatrixWeights(): boolean;
  21655. static set CleanBoneMatrixWeights(value: boolean);
  21656. }
  21657. }
  21658. declare module BABYLON {
  21659. /**
  21660. * Class used to store geometry data (vertex buffers + index buffer)
  21661. */
  21662. export class Geometry implements IGetSetVerticesData {
  21663. /**
  21664. * Gets or sets the ID of the geometry
  21665. */
  21666. id: string;
  21667. /**
  21668. * Gets or sets the unique ID of the geometry
  21669. */
  21670. uniqueId: number;
  21671. /**
  21672. * Gets the delay loading state of the geometry (none by default which means not delayed)
  21673. */
  21674. delayLoadState: number;
  21675. /**
  21676. * Gets the file containing the data to load when running in delay load state
  21677. */
  21678. delayLoadingFile: Nullable<string>;
  21679. /**
  21680. * Callback called when the geometry is updated
  21681. */
  21682. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  21683. private _scene;
  21684. private _engine;
  21685. private _meshes;
  21686. private _totalVertices;
  21687. /** @hidden */
  21688. _indices: IndicesArray;
  21689. /** @hidden */
  21690. _vertexBuffers: {
  21691. [key: string]: VertexBuffer;
  21692. };
  21693. private _isDisposed;
  21694. private _extend;
  21695. private _boundingBias;
  21696. /** @hidden */
  21697. _delayInfo: Array<string>;
  21698. private _indexBuffer;
  21699. private _indexBufferIsUpdatable;
  21700. /** @hidden */
  21701. _boundingInfo: Nullable<BoundingInfo>;
  21702. /** @hidden */
  21703. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  21704. /** @hidden */
  21705. _softwareSkinningFrameId: number;
  21706. private _vertexArrayObjects;
  21707. private _updatable;
  21708. /** @hidden */
  21709. _positions: Nullable<Vector3[]>;
  21710. /**
  21711. * Gets or sets the Bias Vector to apply on the bounding elements (box/sphere), the max extend is computed as v += v * bias.x + bias.y, the min is computed as v -= v * bias.x + bias.y
  21712. */
  21713. get boundingBias(): Vector2;
  21714. /**
  21715. * Gets or sets the Bias Vector to apply on the bounding elements (box/sphere), the max extend is computed as v += v * bias.x + bias.y, the min is computed as v -= v * bias.x + bias.y
  21716. */
  21717. set boundingBias(value: Vector2);
  21718. /**
  21719. * Static function used to attach a new empty geometry to a mesh
  21720. * @param mesh defines the mesh to attach the geometry to
  21721. * @returns the new Geometry
  21722. */
  21723. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  21724. /**
  21725. * Creates a new geometry
  21726. * @param id defines the unique ID
  21727. * @param scene defines the hosting scene
  21728. * @param vertexData defines the VertexData used to get geometry data
  21729. * @param updatable defines if geometry must be updatable (false by default)
  21730. * @param mesh defines the mesh that will be associated with the geometry
  21731. */
  21732. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  21733. /**
  21734. * Gets the current extend of the geometry
  21735. */
  21736. get extend(): {
  21737. minimum: Vector3;
  21738. maximum: Vector3;
  21739. };
  21740. /**
  21741. * Gets the hosting scene
  21742. * @returns the hosting Scene
  21743. */
  21744. getScene(): Scene;
  21745. /**
  21746. * Gets the hosting engine
  21747. * @returns the hosting Engine
  21748. */
  21749. getEngine(): Engine;
  21750. /**
  21751. * Defines if the geometry is ready to use
  21752. * @returns true if the geometry is ready to be used
  21753. */
  21754. isReady(): boolean;
  21755. /**
  21756. * Gets a value indicating that the geometry should not be serialized
  21757. */
  21758. get doNotSerialize(): boolean;
  21759. /** @hidden */
  21760. _rebuild(): void;
  21761. /**
  21762. * Affects all geometry data in one call
  21763. * @param vertexData defines the geometry data
  21764. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  21765. */
  21766. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  21767. /**
  21768. * Set specific vertex data
  21769. * @param kind defines the data kind (Position, normal, etc...)
  21770. * @param data defines the vertex data to use
  21771. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21772. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21773. */
  21774. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  21775. /**
  21776. * Removes a specific vertex data
  21777. * @param kind defines the data kind (Position, normal, etc...)
  21778. */
  21779. removeVerticesData(kind: string): void;
  21780. /**
  21781. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  21782. * @param buffer defines the vertex buffer to use
  21783. * @param totalVertices defines the total number of vertices for position kind (could be null)
  21784. */
  21785. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  21786. /**
  21787. * Update a specific vertex buffer
  21788. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  21789. * It will do nothing if the buffer is not updatable
  21790. * @param kind defines the data kind (Position, normal, etc...)
  21791. * @param data defines the data to use
  21792. * @param offset defines the offset in the target buffer where to store the data
  21793. * @param useBytes set to true if the offset is in bytes
  21794. */
  21795. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  21796. /**
  21797. * Update a specific vertex buffer
  21798. * This function will create a new buffer if the current one is not updatable
  21799. * @param kind defines the data kind (Position, normal, etc...)
  21800. * @param data defines the data to use
  21801. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  21802. */
  21803. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  21804. private _updateBoundingInfo;
  21805. /** @hidden */
  21806. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  21807. /**
  21808. * Gets total number of vertices
  21809. * @returns the total number of vertices
  21810. */
  21811. getTotalVertices(): number;
  21812. /**
  21813. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21814. * @param kind defines the data kind (Position, normal, etc...)
  21815. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21816. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21817. * @returns a float array containing vertex data
  21818. */
  21819. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21820. /**
  21821. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  21822. * @param kind defines the data kind (Position, normal, etc...)
  21823. * @returns true if the vertex buffer with the specified kind is updatable
  21824. */
  21825. isVertexBufferUpdatable(kind: string): boolean;
  21826. /**
  21827. * Gets a specific vertex buffer
  21828. * @param kind defines the data kind (Position, normal, etc...)
  21829. * @returns a VertexBuffer
  21830. */
  21831. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  21832. /**
  21833. * Returns all vertex buffers
  21834. * @return an object holding all vertex buffers indexed by kind
  21835. */
  21836. getVertexBuffers(): Nullable<{
  21837. [key: string]: VertexBuffer;
  21838. }>;
  21839. /**
  21840. * Gets a boolean indicating if specific vertex buffer is present
  21841. * @param kind defines the data kind (Position, normal, etc...)
  21842. * @returns true if data is present
  21843. */
  21844. isVerticesDataPresent(kind: string): boolean;
  21845. /**
  21846. * Gets a list of all attached data kinds (Position, normal, etc...)
  21847. * @returns a list of string containing all kinds
  21848. */
  21849. getVerticesDataKinds(): string[];
  21850. /**
  21851. * Update index buffer
  21852. * @param indices defines the indices to store in the index buffer
  21853. * @param offset defines the offset in the target buffer where to store the data
  21854. * @param gpuMemoryOnly defines a boolean indicating that only the GPU memory must be updated leaving the CPU version of the indices unchanged (false by default)
  21855. */
  21856. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  21857. /**
  21858. * Creates a new index buffer
  21859. * @param indices defines the indices to store in the index buffer
  21860. * @param totalVertices defines the total number of vertices (could be null)
  21861. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21862. */
  21863. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  21864. /**
  21865. * Return the total number of indices
  21866. * @returns the total number of indices
  21867. */
  21868. getTotalIndices(): number;
  21869. /**
  21870. * Gets the index buffer array
  21871. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21872. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21873. * @returns the index buffer array
  21874. */
  21875. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21876. /**
  21877. * Gets the index buffer
  21878. * @return the index buffer
  21879. */
  21880. getIndexBuffer(): Nullable<DataBuffer>;
  21881. /** @hidden */
  21882. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  21883. /**
  21884. * Release the associated resources for a specific mesh
  21885. * @param mesh defines the source mesh
  21886. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  21887. */
  21888. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  21889. /**
  21890. * Apply current geometry to a given mesh
  21891. * @param mesh defines the mesh to apply geometry to
  21892. */
  21893. applyToMesh(mesh: Mesh): void;
  21894. private _updateExtend;
  21895. private _applyToMesh;
  21896. private notifyUpdate;
  21897. /**
  21898. * Load the geometry if it was flagged as delay loaded
  21899. * @param scene defines the hosting scene
  21900. * @param onLoaded defines a callback called when the geometry is loaded
  21901. */
  21902. load(scene: Scene, onLoaded?: () => void): void;
  21903. private _queueLoad;
  21904. /**
  21905. * Invert the geometry to move from a right handed system to a left handed one.
  21906. */
  21907. toLeftHanded(): void;
  21908. /** @hidden */
  21909. _resetPointsArrayCache(): void;
  21910. /** @hidden */
  21911. _generatePointsArray(): boolean;
  21912. /**
  21913. * Gets a value indicating if the geometry is disposed
  21914. * @returns true if the geometry was disposed
  21915. */
  21916. isDisposed(): boolean;
  21917. private _disposeVertexArrayObjects;
  21918. /**
  21919. * Free all associated resources
  21920. */
  21921. dispose(): void;
  21922. /**
  21923. * Clone the current geometry into a new geometry
  21924. * @param id defines the unique ID of the new geometry
  21925. * @returns a new geometry object
  21926. */
  21927. copy(id: string): Geometry;
  21928. /**
  21929. * Serialize the current geometry info (and not the vertices data) into a JSON object
  21930. * @return a JSON representation of the current geometry data (without the vertices data)
  21931. */
  21932. serialize(): any;
  21933. private toNumberArray;
  21934. /**
  21935. * Serialize all vertices data into a JSON oject
  21936. * @returns a JSON representation of the current geometry data
  21937. */
  21938. serializeVerticeData(): any;
  21939. /**
  21940. * Extracts a clone of a mesh geometry
  21941. * @param mesh defines the source mesh
  21942. * @param id defines the unique ID of the new geometry object
  21943. * @returns the new geometry object
  21944. */
  21945. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  21946. /**
  21947. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  21948. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  21949. * Be aware Math.random() could cause collisions, but:
  21950. * "All but 6 of the 128 bits of the ID are randomly generated, which means that for any two ids, there's a 1 in 2^^122 (or 5.3x10^^36) chance they'll collide"
  21951. * @returns a string containing a new GUID
  21952. */
  21953. static RandomId(): string;
  21954. /** @hidden */
  21955. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  21956. private static _CleanMatricesWeights;
  21957. /**
  21958. * Create a new geometry from persisted data (Using .babylon file format)
  21959. * @param parsedVertexData defines the persisted data
  21960. * @param scene defines the hosting scene
  21961. * @param rootUrl defines the root url to use to load assets (like delayed data)
  21962. * @returns the new geometry object
  21963. */
  21964. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  21965. }
  21966. }
  21967. declare module BABYLON {
  21968. /**
  21969. * Define an interface for all classes that will get and set the data on vertices
  21970. */
  21971. export interface IGetSetVerticesData {
  21972. /**
  21973. * Gets a boolean indicating if specific vertex data is present
  21974. * @param kind defines the vertex data kind to use
  21975. * @returns true is data kind is present
  21976. */
  21977. isVerticesDataPresent(kind: string): boolean;
  21978. /**
  21979. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21980. * @param kind defines the data kind (Position, normal, etc...)
  21981. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21982. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21983. * @returns a float array containing vertex data
  21984. */
  21985. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21986. /**
  21987. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  21988. * @param copyWhenShared If true (default false) and and if the mesh geometry is shared among some other meshes, the returned array is a copy of the internal one.
  21989. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21990. * @returns the indices array or an empty array if the mesh has no geometry
  21991. */
  21992. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21993. /**
  21994. * Set specific vertex data
  21995. * @param kind defines the data kind (Position, normal, etc...)
  21996. * @param data defines the vertex data to use
  21997. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21998. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21999. */
  22000. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  22001. /**
  22002. * Update a specific associated vertex buffer
  22003. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  22004. * - VertexBuffer.PositionKind
  22005. * - VertexBuffer.UVKind
  22006. * - VertexBuffer.UV2Kind
  22007. * - VertexBuffer.UV3Kind
  22008. * - VertexBuffer.UV4Kind
  22009. * - VertexBuffer.UV5Kind
  22010. * - VertexBuffer.UV6Kind
  22011. * - VertexBuffer.ColorKind
  22012. * - VertexBuffer.MatricesIndicesKind
  22013. * - VertexBuffer.MatricesIndicesExtraKind
  22014. * - VertexBuffer.MatricesWeightsKind
  22015. * - VertexBuffer.MatricesWeightsExtraKind
  22016. * @param data defines the data source
  22017. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  22018. * @param makeItUnique defines if the geometry associated with the mesh must be cloned to make the change only for this mesh (and not all meshes associated with the same geometry)
  22019. */
  22020. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  22021. /**
  22022. * Creates a new index buffer
  22023. * @param indices defines the indices to store in the index buffer
  22024. * @param totalVertices defines the total number of vertices (could be null)
  22025. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22026. */
  22027. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  22028. }
  22029. /**
  22030. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  22031. */
  22032. export class VertexData {
  22033. /**
  22034. * Mesh side orientation : usually the external or front surface
  22035. */
  22036. static readonly FRONTSIDE: number;
  22037. /**
  22038. * Mesh side orientation : usually the internal or back surface
  22039. */
  22040. static readonly BACKSIDE: number;
  22041. /**
  22042. * Mesh side orientation : both internal and external or front and back surfaces
  22043. */
  22044. static readonly DOUBLESIDE: number;
  22045. /**
  22046. * Mesh side orientation : by default, `FRONTSIDE`
  22047. */
  22048. static readonly DEFAULTSIDE: number;
  22049. /**
  22050. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  22051. */
  22052. positions: Nullable<FloatArray>;
  22053. /**
  22054. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  22055. */
  22056. normals: Nullable<FloatArray>;
  22057. /**
  22058. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  22059. */
  22060. tangents: Nullable<FloatArray>;
  22061. /**
  22062. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22063. */
  22064. uvs: Nullable<FloatArray>;
  22065. /**
  22066. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22067. */
  22068. uvs2: Nullable<FloatArray>;
  22069. /**
  22070. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22071. */
  22072. uvs3: Nullable<FloatArray>;
  22073. /**
  22074. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22075. */
  22076. uvs4: Nullable<FloatArray>;
  22077. /**
  22078. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22079. */
  22080. uvs5: Nullable<FloatArray>;
  22081. /**
  22082. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22083. */
  22084. uvs6: Nullable<FloatArray>;
  22085. /**
  22086. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  22087. */
  22088. colors: Nullable<FloatArray>;
  22089. /**
  22090. * An array containing the list of indices to the array of matrices produced by bones, each vertex have up to 4 indices (8 if the matricesIndicesExtra is set).
  22091. */
  22092. matricesIndices: Nullable<FloatArray>;
  22093. /**
  22094. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  22095. */
  22096. matricesWeights: Nullable<FloatArray>;
  22097. /**
  22098. * An array extending the number of possible indices
  22099. */
  22100. matricesIndicesExtra: Nullable<FloatArray>;
  22101. /**
  22102. * An array extending the number of possible weights when the number of indices is extended
  22103. */
  22104. matricesWeightsExtra: Nullable<FloatArray>;
  22105. /**
  22106. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  22107. */
  22108. indices: Nullable<IndicesArray>;
  22109. /**
  22110. * Uses the passed data array to set the set the values for the specified kind of data
  22111. * @param data a linear array of floating numbers
  22112. * @param kind the type of data that is being set, eg positions, colors etc
  22113. */
  22114. set(data: FloatArray, kind: string): void;
  22115. /**
  22116. * Associates the vertexData to the passed Mesh.
  22117. * Sets it as updatable or not (default `false`)
  22118. * @param mesh the mesh the vertexData is applied to
  22119. * @param updatable when used and having the value true allows new data to update the vertexData
  22120. * @returns the VertexData
  22121. */
  22122. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  22123. /**
  22124. * Associates the vertexData to the passed Geometry.
  22125. * Sets it as updatable or not (default `false`)
  22126. * @param geometry the geometry the vertexData is applied to
  22127. * @param updatable when used and having the value true allows new data to update the vertexData
  22128. * @returns VertexData
  22129. */
  22130. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  22131. /**
  22132. * Updates the associated mesh
  22133. * @param mesh the mesh to be updated
  22134. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22135. * @param makeItUnique when true, and when and if position kind is updated, a new global geometry will be created from these positions and set to the mesh, optional with default false
  22136. * @returns VertexData
  22137. */
  22138. updateMesh(mesh: Mesh): VertexData;
  22139. /**
  22140. * Updates the associated geometry
  22141. * @param geometry the geometry to be updated
  22142. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22143. * @param makeItUnique when true, and when and if position kind is updated, a new global geometry will be created from these positions and set to the mesh, optional with default false
  22144. * @returns VertexData.
  22145. */
  22146. updateGeometry(geometry: Geometry): VertexData;
  22147. private _applyTo;
  22148. private _update;
  22149. /**
  22150. * Transforms each position and each normal of the vertexData according to the passed Matrix
  22151. * @param matrix the transforming matrix
  22152. * @returns the VertexData
  22153. */
  22154. transform(matrix: Matrix): VertexData;
  22155. /**
  22156. * Merges the passed VertexData into the current one
  22157. * @param other the VertexData to be merged into the current one
  22158. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  22159. * @returns the modified VertexData
  22160. */
  22161. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  22162. private _mergeElement;
  22163. private _validate;
  22164. /**
  22165. * Serializes the VertexData
  22166. * @returns a serialized object
  22167. */
  22168. serialize(): any;
  22169. /**
  22170. * Extracts the vertexData from a mesh
  22171. * @param mesh the mesh from which to extract the VertexData
  22172. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  22173. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22174. * @returns the object VertexData associated to the passed mesh
  22175. */
  22176. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22177. /**
  22178. * Extracts the vertexData from the geometry
  22179. * @param geometry the geometry from which to extract the VertexData
  22180. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  22181. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22182. * @returns the object VertexData associated to the passed mesh
  22183. */
  22184. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22185. private static _ExtractFrom;
  22186. /**
  22187. * Creates the VertexData for a Ribbon
  22188. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  22189. * * pathArray array of paths, each of which an array of successive Vector3
  22190. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  22191. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  22192. * * offset a positive integer, only used when pathArray contains a single path (offset = 10 means the point 1 is joined to the point 11), default rounded half size of the pathArray length
  22193. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22194. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  22195. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  22196. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  22197. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  22198. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  22199. * @returns the VertexData of the ribbon
  22200. */
  22201. static CreateRibbon(options: {
  22202. pathArray: Vector3[][];
  22203. closeArray?: boolean;
  22204. closePath?: boolean;
  22205. offset?: number;
  22206. sideOrientation?: number;
  22207. frontUVs?: Vector4;
  22208. backUVs?: Vector4;
  22209. invertUV?: boolean;
  22210. uvs?: Vector2[];
  22211. colors?: Color4[];
  22212. }): VertexData;
  22213. /**
  22214. * Creates the VertexData for a box
  22215. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22216. * * size sets the width, height and depth of the box to the value of size, optional default 1
  22217. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  22218. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  22219. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  22220. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22221. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22222. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22223. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  22224. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  22225. * @returns the VertexData of the box
  22226. */
  22227. static CreateBox(options: {
  22228. size?: number;
  22229. width?: number;
  22230. height?: number;
  22231. depth?: number;
  22232. faceUV?: Vector4[];
  22233. faceColors?: Color4[];
  22234. sideOrientation?: number;
  22235. frontUVs?: Vector4;
  22236. backUVs?: Vector4;
  22237. }): VertexData;
  22238. /**
  22239. * Creates the VertexData for a tiled box
  22240. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22241. * * faceTiles sets the pattern, tile size and number of tiles for a face
  22242. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22243. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22244. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22245. * @returns the VertexData of the box
  22246. */
  22247. static CreateTiledBox(options: {
  22248. pattern?: number;
  22249. width?: number;
  22250. height?: number;
  22251. depth?: number;
  22252. tileSize?: number;
  22253. tileWidth?: number;
  22254. tileHeight?: number;
  22255. alignHorizontal?: number;
  22256. alignVertical?: number;
  22257. faceUV?: Vector4[];
  22258. faceColors?: Color4[];
  22259. sideOrientation?: number;
  22260. }): VertexData;
  22261. /**
  22262. * Creates the VertexData for a tiled plane
  22263. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22264. * * pattern a limited pattern arrangement depending on the number
  22265. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  22266. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  22267. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  22268. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22269. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  22270. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  22271. * @returns the VertexData of the tiled plane
  22272. */
  22273. static CreateTiledPlane(options: {
  22274. pattern?: number;
  22275. tileSize?: number;
  22276. tileWidth?: number;
  22277. tileHeight?: number;
  22278. size?: number;
  22279. width?: number;
  22280. height?: number;
  22281. alignHorizontal?: number;
  22282. alignVertical?: number;
  22283. sideOrientation?: number;
  22284. frontUVs?: Vector4;
  22285. backUVs?: Vector4;
  22286. }): VertexData;
  22287. /**
  22288. * Creates the VertexData for an ellipsoid, defaults to a sphere
  22289. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22290. * * segments sets the number of horizontal strips optional, default 32
  22291. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  22292. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  22293. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  22294. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  22295. * * arc a number from 0 to 1, to create an unclosed ellipsoid based on the fraction of the circumference (latitude) given by the arc value, optional, default 1
  22296. * * slice a number from 0 to 1, to create an unclosed ellipsoid based on the fraction of the height (latitude) given by the arc value, optional, default 1
  22297. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22298. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  22299. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  22300. * @returns the VertexData of the ellipsoid
  22301. */
  22302. static CreateSphere(options: {
  22303. segments?: number;
  22304. diameter?: number;
  22305. diameterX?: number;
  22306. diameterY?: number;
  22307. diameterZ?: number;
  22308. arc?: number;
  22309. slice?: number;
  22310. sideOrientation?: number;
  22311. frontUVs?: Vector4;
  22312. backUVs?: Vector4;
  22313. }): VertexData;
  22314. /**
  22315. * Creates the VertexData for a cylinder, cone or prism
  22316. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22317. * * height sets the height (y direction) of the cylinder, optional, default 2
  22318. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  22319. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  22320. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  22321. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22322. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  22323. * * arc a number from 0 to 1, to create an unclosed cylinder based on the fraction of the circumference given by the arc value, optional, default 1
  22324. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22325. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22326. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  22327. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  22328. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22329. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  22330. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  22331. * @returns the VertexData of the cylinder, cone or prism
  22332. */
  22333. static CreateCylinder(options: {
  22334. height?: number;
  22335. diameterTop?: number;
  22336. diameterBottom?: number;
  22337. diameter?: number;
  22338. tessellation?: number;
  22339. subdivisions?: number;
  22340. arc?: number;
  22341. faceColors?: Color4[];
  22342. faceUV?: Vector4[];
  22343. hasRings?: boolean;
  22344. enclose?: boolean;
  22345. sideOrientation?: number;
  22346. frontUVs?: Vector4;
  22347. backUVs?: Vector4;
  22348. }): VertexData;
  22349. /**
  22350. * Creates the VertexData for a torus
  22351. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22352. * * diameter the diameter of the torus, optional default 1
  22353. * * thickness the diameter of the tube forming the torus, optional default 0.5
  22354. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22355. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22356. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  22357. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  22358. * @returns the VertexData of the torus
  22359. */
  22360. static CreateTorus(options: {
  22361. diameter?: number;
  22362. thickness?: number;
  22363. tessellation?: number;
  22364. sideOrientation?: number;
  22365. frontUVs?: Vector4;
  22366. backUVs?: Vector4;
  22367. }): VertexData;
  22368. /**
  22369. * Creates the VertexData of the LineSystem
  22370. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  22371. * - lines an array of lines, each line being an array of successive Vector3
  22372. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  22373. * @returns the VertexData of the LineSystem
  22374. */
  22375. static CreateLineSystem(options: {
  22376. lines: Vector3[][];
  22377. colors?: Nullable<Color4[][]>;
  22378. }): VertexData;
  22379. /**
  22380. * Create the VertexData for a DashedLines
  22381. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  22382. * - points an array successive Vector3
  22383. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  22384. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  22385. * - dashNb the intended total number of dashes, optional, default 200
  22386. * @returns the VertexData for the DashedLines
  22387. */
  22388. static CreateDashedLines(options: {
  22389. points: Vector3[];
  22390. dashSize?: number;
  22391. gapSize?: number;
  22392. dashNb?: number;
  22393. }): VertexData;
  22394. /**
  22395. * Creates the VertexData for a Ground
  22396. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22397. * - width the width (x direction) of the ground, optional, default 1
  22398. * - height the height (z direction) of the ground, optional, default 1
  22399. * - subdivisions the number of subdivisions per side, optional, default 1
  22400. * @returns the VertexData of the Ground
  22401. */
  22402. static CreateGround(options: {
  22403. width?: number;
  22404. height?: number;
  22405. subdivisions?: number;
  22406. subdivisionsX?: number;
  22407. subdivisionsY?: number;
  22408. }): VertexData;
  22409. /**
  22410. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  22411. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22412. * * xmin the ground minimum X coordinate, optional, default -1
  22413. * * zmin the ground minimum Z coordinate, optional, default -1
  22414. * * xmax the ground maximum X coordinate, optional, default 1
  22415. * * zmax the ground maximum Z coordinate, optional, default 1
  22416. * * subdivisions a javascript object {w: positive integer, h: positive integer}, `w` and `h` are the numbers of subdivisions on the ground width and height creating 'tiles', default {w: 6, h: 6}
  22417. * * precision a javascript object {w: positive integer, h: positive integer}, `w` and `h` are the numbers of subdivisions on the tile width and height, default {w: 2, h: 2}
  22418. * @returns the VertexData of the TiledGround
  22419. */
  22420. static CreateTiledGround(options: {
  22421. xmin: number;
  22422. zmin: number;
  22423. xmax: number;
  22424. zmax: number;
  22425. subdivisions?: {
  22426. w: number;
  22427. h: number;
  22428. };
  22429. precision?: {
  22430. w: number;
  22431. h: number;
  22432. };
  22433. }): VertexData;
  22434. /**
  22435. * Creates the VertexData of the Ground designed from a heightmap
  22436. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  22437. * * width the width (x direction) of the ground
  22438. * * height the height (z direction) of the ground
  22439. * * subdivisions the number of subdivisions per side
  22440. * * minHeight the minimum altitude on the ground, optional, default 0
  22441. * * maxHeight the maximum altitude on the ground, optional default 1
  22442. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  22443. * * buffer the array holding the image color data
  22444. * * bufferWidth the width of image
  22445. * * bufferHeight the height of image
  22446. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  22447. * @returns the VertexData of the Ground designed from a heightmap
  22448. */
  22449. static CreateGroundFromHeightMap(options: {
  22450. width: number;
  22451. height: number;
  22452. subdivisions: number;
  22453. minHeight: number;
  22454. maxHeight: number;
  22455. colorFilter: Color3;
  22456. buffer: Uint8Array;
  22457. bufferWidth: number;
  22458. bufferHeight: number;
  22459. alphaFilter: number;
  22460. }): VertexData;
  22461. /**
  22462. * Creates the VertexData for a Plane
  22463. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  22464. * * size sets the width and height of the plane to the value of size, optional default 1
  22465. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  22466. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  22467. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22468. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  22469. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  22470. * @returns the VertexData of the box
  22471. */
  22472. static CreatePlane(options: {
  22473. size?: number;
  22474. width?: number;
  22475. height?: number;
  22476. sideOrientation?: number;
  22477. frontUVs?: Vector4;
  22478. backUVs?: Vector4;
  22479. }): VertexData;
  22480. /**
  22481. * Creates the VertexData of the Disc or regular Polygon
  22482. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  22483. * * radius the radius of the disc, optional default 0.5
  22484. * * tessellation the number of polygon sides, optional, default 64
  22485. * * arc a number from 0 to 1, to create an unclosed polygon based on the fraction of the circumference given by the arc value, optional, default 1
  22486. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22487. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  22488. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  22489. * @returns the VertexData of the box
  22490. */
  22491. static CreateDisc(options: {
  22492. radius?: number;
  22493. tessellation?: number;
  22494. arc?: number;
  22495. sideOrientation?: number;
  22496. frontUVs?: Vector4;
  22497. backUVs?: Vector4;
  22498. }): VertexData;
  22499. /**
  22500. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  22501. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  22502. * @param polygon a mesh built from polygonTriangulation.build()
  22503. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22504. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22505. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22506. * @param frontUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  22507. * @param backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  22508. * @returns the VertexData of the Polygon
  22509. */
  22510. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  22511. /**
  22512. * Creates the VertexData of the IcoSphere
  22513. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  22514. * * radius the radius of the IcoSphere, optional default 1
  22515. * * radiusX allows stretching in the x direction, optional, default radius
  22516. * * radiusY allows stretching in the y direction, optional, default radius
  22517. * * radiusZ allows stretching in the z direction, optional, default radius
  22518. * * flat when true creates a flat shaded mesh, optional, default true
  22519. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22520. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22521. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  22522. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  22523. * @returns the VertexData of the IcoSphere
  22524. */
  22525. static CreateIcoSphere(options: {
  22526. radius?: number;
  22527. radiusX?: number;
  22528. radiusY?: number;
  22529. radiusZ?: number;
  22530. flat?: boolean;
  22531. subdivisions?: number;
  22532. sideOrientation?: number;
  22533. frontUVs?: Vector4;
  22534. backUVs?: Vector4;
  22535. }): VertexData;
  22536. /**
  22537. * Creates the VertexData for a Polyhedron
  22538. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  22539. * * type provided types are:
  22540. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  22541. * * 9 : Pentagonal Pyramid (J2), 10 : Triangular Dipyramid (J12), 11 : Pentagonal Dipyramid (J13), 12 : Elongated Square Dipyramid (J15), 13 : Elongated Pentagonal Dipyramid (J16), 14 : Elongated Pentagonal Cupola (J20)
  22542. * * size the size of the IcoSphere, optional default 1
  22543. * * sizeX allows stretching in the x direction, optional, default size
  22544. * * sizeY allows stretching in the y direction, optional, default size
  22545. * * sizeZ allows stretching in the z direction, optional, default size
  22546. * * custom a number that overwrites the type to create from an extended set of polyhedron from https://www.babylonjs-playground.com/#21QRSK#15 with minimised editor
  22547. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22548. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22549. * * flat when true creates a flat shaded mesh, optional, default true
  22550. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22551. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22552. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  22553. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  22554. * @returns the VertexData of the Polyhedron
  22555. */
  22556. static CreatePolyhedron(options: {
  22557. type?: number;
  22558. size?: number;
  22559. sizeX?: number;
  22560. sizeY?: number;
  22561. sizeZ?: number;
  22562. custom?: any;
  22563. faceUV?: Vector4[];
  22564. faceColors?: Color4[];
  22565. flat?: boolean;
  22566. sideOrientation?: number;
  22567. frontUVs?: Vector4;
  22568. backUVs?: Vector4;
  22569. }): VertexData;
  22570. /**
  22571. * Creates the VertexData for a TorusKnot
  22572. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  22573. * * radius the radius of the torus knot, optional, default 2
  22574. * * tube the thickness of the tube, optional, default 0.5
  22575. * * radialSegments the number of sides on each tube segments, optional, default 32
  22576. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  22577. * * p the number of windings around the z axis, optional, default 2
  22578. * * q the number of windings around the x axis, optional, default 3
  22579. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22580. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  22581. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  22582. * @returns the VertexData of the Torus Knot
  22583. */
  22584. static CreateTorusKnot(options: {
  22585. radius?: number;
  22586. tube?: number;
  22587. radialSegments?: number;
  22588. tubularSegments?: number;
  22589. p?: number;
  22590. q?: number;
  22591. sideOrientation?: number;
  22592. frontUVs?: Vector4;
  22593. backUVs?: Vector4;
  22594. }): VertexData;
  22595. /**
  22596. * Compute normals for given positions and indices
  22597. * @param positions an array of vertex positions, [...., x, y, z, ......]
  22598. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  22599. * @param normals an array of vertex normals, [...., x, y, z, ......]
  22600. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  22601. * * facetNormals : optional array of facet normals (vector3)
  22602. * * facetPositions : optional array of facet positions (vector3)
  22603. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  22604. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  22605. * * bInfo : optional bounding info, required for facetPartitioning computation
  22606. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  22607. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  22608. * * useRightHandedSystem: optional boolean to for right handed system computation
  22609. * * depthSort : optional boolean to enable the facet depth sort computation
  22610. * * distanceTo : optional Vector3 to compute the facet depth from this location
  22611. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  22612. */
  22613. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  22614. facetNormals?: any;
  22615. facetPositions?: any;
  22616. facetPartitioning?: any;
  22617. ratio?: number;
  22618. bInfo?: any;
  22619. bbSize?: Vector3;
  22620. subDiv?: any;
  22621. useRightHandedSystem?: boolean;
  22622. depthSort?: boolean;
  22623. distanceTo?: Vector3;
  22624. depthSortedFacets?: any;
  22625. }): void;
  22626. /** @hidden */
  22627. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  22628. /**
  22629. * Applies VertexData created from the imported parameters to the geometry
  22630. * @param parsedVertexData the parsed data from an imported file
  22631. * @param geometry the geometry to apply the VertexData to
  22632. */
  22633. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  22634. }
  22635. }
  22636. declare module BABYLON {
  22637. /**
  22638. * Defines a target to use with MorphTargetManager
  22639. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22640. */
  22641. export class MorphTarget implements IAnimatable {
  22642. /** defines the name of the target */
  22643. name: string;
  22644. /**
  22645. * Gets or sets the list of animations
  22646. */
  22647. animations: Animation[];
  22648. private _scene;
  22649. private _positions;
  22650. private _normals;
  22651. private _tangents;
  22652. private _uvs;
  22653. private _influence;
  22654. private _uniqueId;
  22655. /**
  22656. * Observable raised when the influence changes
  22657. */
  22658. onInfluenceChanged: Observable<boolean>;
  22659. /** @hidden */
  22660. _onDataLayoutChanged: Observable<void>;
  22661. /**
  22662. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  22663. */
  22664. get influence(): number;
  22665. set influence(influence: number);
  22666. /**
  22667. * Gets or sets the id of the morph Target
  22668. */
  22669. id: string;
  22670. private _animationPropertiesOverride;
  22671. /**
  22672. * Gets or sets the animation properties override
  22673. */
  22674. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  22675. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  22676. /**
  22677. * Creates a new MorphTarget
  22678. * @param name defines the name of the target
  22679. * @param influence defines the influence to use
  22680. * @param scene defines the scene the morphtarget belongs to
  22681. */
  22682. constructor(
  22683. /** defines the name of the target */
  22684. name: string, influence?: number, scene?: Nullable<Scene>);
  22685. /**
  22686. * Gets the unique ID of this manager
  22687. */
  22688. get uniqueId(): number;
  22689. /**
  22690. * Gets a boolean defining if the target contains position data
  22691. */
  22692. get hasPositions(): boolean;
  22693. /**
  22694. * Gets a boolean defining if the target contains normal data
  22695. */
  22696. get hasNormals(): boolean;
  22697. /**
  22698. * Gets a boolean defining if the target contains tangent data
  22699. */
  22700. get hasTangents(): boolean;
  22701. /**
  22702. * Gets a boolean defining if the target contains texture coordinates data
  22703. */
  22704. get hasUVs(): boolean;
  22705. /**
  22706. * Affects position data to this target
  22707. * @param data defines the position data to use
  22708. */
  22709. setPositions(data: Nullable<FloatArray>): void;
  22710. /**
  22711. * Gets the position data stored in this target
  22712. * @returns a FloatArray containing the position data (or null if not present)
  22713. */
  22714. getPositions(): Nullable<FloatArray>;
  22715. /**
  22716. * Affects normal data to this target
  22717. * @param data defines the normal data to use
  22718. */
  22719. setNormals(data: Nullable<FloatArray>): void;
  22720. /**
  22721. * Gets the normal data stored in this target
  22722. * @returns a FloatArray containing the normal data (or null if not present)
  22723. */
  22724. getNormals(): Nullable<FloatArray>;
  22725. /**
  22726. * Affects tangent data to this target
  22727. * @param data defines the tangent data to use
  22728. */
  22729. setTangents(data: Nullable<FloatArray>): void;
  22730. /**
  22731. * Gets the tangent data stored in this target
  22732. * @returns a FloatArray containing the tangent data (or null if not present)
  22733. */
  22734. getTangents(): Nullable<FloatArray>;
  22735. /**
  22736. * Affects texture coordinates data to this target
  22737. * @param data defines the texture coordinates data to use
  22738. */
  22739. setUVs(data: Nullable<FloatArray>): void;
  22740. /**
  22741. * Gets the texture coordinates data stored in this target
  22742. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  22743. */
  22744. getUVs(): Nullable<FloatArray>;
  22745. /**
  22746. * Clone the current target
  22747. * @returns a new MorphTarget
  22748. */
  22749. clone(): MorphTarget;
  22750. /**
  22751. * Serializes the current target into a Serialization object
  22752. * @returns the serialized object
  22753. */
  22754. serialize(): any;
  22755. /**
  22756. * Returns the string "MorphTarget"
  22757. * @returns "MorphTarget"
  22758. */
  22759. getClassName(): string;
  22760. /**
  22761. * Creates a new target from serialized data
  22762. * @param serializationObject defines the serialized data to use
  22763. * @returns a new MorphTarget
  22764. */
  22765. static Parse(serializationObject: any): MorphTarget;
  22766. /**
  22767. * Creates a MorphTarget from mesh data
  22768. * @param mesh defines the source mesh
  22769. * @param name defines the name to use for the new target
  22770. * @param influence defines the influence to attach to the target
  22771. * @returns a new MorphTarget
  22772. */
  22773. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  22774. }
  22775. }
  22776. declare module BABYLON {
  22777. /**
  22778. * This class is used to deform meshes using morphing between different targets
  22779. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22780. */
  22781. export class MorphTargetManager {
  22782. private _targets;
  22783. private _targetInfluenceChangedObservers;
  22784. private _targetDataLayoutChangedObservers;
  22785. private _activeTargets;
  22786. private _scene;
  22787. private _influences;
  22788. private _supportsNormals;
  22789. private _supportsTangents;
  22790. private _supportsUVs;
  22791. private _vertexCount;
  22792. private _uniqueId;
  22793. private _tempInfluences;
  22794. /**
  22795. * Gets or sets a boolean indicating if normals must be morphed
  22796. */
  22797. enableNormalMorphing: boolean;
  22798. /**
  22799. * Gets or sets a boolean indicating if tangents must be morphed
  22800. */
  22801. enableTangentMorphing: boolean;
  22802. /**
  22803. * Gets or sets a boolean indicating if UV must be morphed
  22804. */
  22805. enableUVMorphing: boolean;
  22806. /**
  22807. * Creates a new MorphTargetManager
  22808. * @param scene defines the current scene
  22809. */
  22810. constructor(scene?: Nullable<Scene>);
  22811. /**
  22812. * Gets the unique ID of this manager
  22813. */
  22814. get uniqueId(): number;
  22815. /**
  22816. * Gets the number of vertices handled by this manager
  22817. */
  22818. get vertexCount(): number;
  22819. /**
  22820. * Gets a boolean indicating if this manager supports morphing of normals
  22821. */
  22822. get supportsNormals(): boolean;
  22823. /**
  22824. * Gets a boolean indicating if this manager supports morphing of tangents
  22825. */
  22826. get supportsTangents(): boolean;
  22827. /**
  22828. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  22829. */
  22830. get supportsUVs(): boolean;
  22831. /**
  22832. * Gets the number of targets stored in this manager
  22833. */
  22834. get numTargets(): number;
  22835. /**
  22836. * Gets the number of influencers (ie. the number of targets with influences > 0)
  22837. */
  22838. get numInfluencers(): number;
  22839. /**
  22840. * Gets the list of influences (one per target)
  22841. */
  22842. get influences(): Float32Array;
  22843. /**
  22844. * Gets the active target at specified index. An active target is a target with an influence > 0
  22845. * @param index defines the index to check
  22846. * @returns the requested target
  22847. */
  22848. getActiveTarget(index: number): MorphTarget;
  22849. /**
  22850. * Gets the target at specified index
  22851. * @param index defines the index to check
  22852. * @returns the requested target
  22853. */
  22854. getTarget(index: number): MorphTarget;
  22855. /**
  22856. * Add a new target to this manager
  22857. * @param target defines the target to add
  22858. */
  22859. addTarget(target: MorphTarget): void;
  22860. /**
  22861. * Removes a target from the manager
  22862. * @param target defines the target to remove
  22863. */
  22864. removeTarget(target: MorphTarget): void;
  22865. /**
  22866. * Clone the current manager
  22867. * @returns a new MorphTargetManager
  22868. */
  22869. clone(): MorphTargetManager;
  22870. /**
  22871. * Serializes the current manager into a Serialization object
  22872. * @returns the serialized object
  22873. */
  22874. serialize(): any;
  22875. private _syncActiveTargets;
  22876. /**
  22877. * Syncrhonize the targets with all the meshes using this morph target manager
  22878. */
  22879. synchronize(): void;
  22880. /**
  22881. * Creates a new MorphTargetManager from serialized data
  22882. * @param serializationObject defines the serialized data
  22883. * @param scene defines the hosting scene
  22884. * @returns the new MorphTargetManager
  22885. */
  22886. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  22887. }
  22888. }
  22889. declare module BABYLON {
  22890. /**
  22891. * Class used to represent a specific level of detail of a mesh
  22892. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  22893. */
  22894. export class MeshLODLevel {
  22895. /** Defines the distance where this level should start being displayed */
  22896. distance: number;
  22897. /** Defines the mesh to use to render this level */
  22898. mesh: Nullable<Mesh>;
  22899. /**
  22900. * Creates a new LOD level
  22901. * @param distance defines the distance where this level should star being displayed
  22902. * @param mesh defines the mesh to use to render this level
  22903. */
  22904. constructor(
  22905. /** Defines the distance where this level should start being displayed */
  22906. distance: number,
  22907. /** Defines the mesh to use to render this level */
  22908. mesh: Nullable<Mesh>);
  22909. }
  22910. }
  22911. declare module BABYLON {
  22912. /**
  22913. * Mesh representing the gorund
  22914. */
  22915. export class GroundMesh extends Mesh {
  22916. /** If octree should be generated */
  22917. generateOctree: boolean;
  22918. private _heightQuads;
  22919. /** @hidden */
  22920. _subdivisionsX: number;
  22921. /** @hidden */
  22922. _subdivisionsY: number;
  22923. /** @hidden */
  22924. _width: number;
  22925. /** @hidden */
  22926. _height: number;
  22927. /** @hidden */
  22928. _minX: number;
  22929. /** @hidden */
  22930. _maxX: number;
  22931. /** @hidden */
  22932. _minZ: number;
  22933. /** @hidden */
  22934. _maxZ: number;
  22935. constructor(name: string, scene: Scene);
  22936. /**
  22937. * "GroundMesh"
  22938. * @returns "GroundMesh"
  22939. */
  22940. getClassName(): string;
  22941. /**
  22942. * The minimum of x and y subdivisions
  22943. */
  22944. get subdivisions(): number;
  22945. /**
  22946. * X subdivisions
  22947. */
  22948. get subdivisionsX(): number;
  22949. /**
  22950. * Y subdivisions
  22951. */
  22952. get subdivisionsY(): number;
  22953. /**
  22954. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  22955. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  22956. * @param chunksCount the number of subdivisions for x and y
  22957. * @param octreeBlocksSize (Default: 32)
  22958. */
  22959. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  22960. /**
  22961. * Returns a height (y) value in the Worl system :
  22962. * the ground altitude at the coordinates (x, z) expressed in the World system.
  22963. * @param x x coordinate
  22964. * @param z z coordinate
  22965. * @returns the ground y position if (x, z) are outside the ground surface.
  22966. */
  22967. getHeightAtCoordinates(x: number, z: number): number;
  22968. /**
  22969. * Returns a normalized vector (Vector3) orthogonal to the ground
  22970. * at the ground coordinates (x, z) expressed in the World system.
  22971. * @param x x coordinate
  22972. * @param z z coordinate
  22973. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  22974. */
  22975. getNormalAtCoordinates(x: number, z: number): Vector3;
  22976. /**
  22977. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  22978. * at the ground coordinates (x, z) expressed in the World system.
  22979. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  22980. * @param x x coordinate
  22981. * @param z z coordinate
  22982. * @param ref vector to store the result
  22983. * @returns the GroundMesh.
  22984. */
  22985. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  22986. /**
  22987. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  22988. * if the ground has been updated.
  22989. * This can be used in the render loop.
  22990. * @returns the GroundMesh.
  22991. */
  22992. updateCoordinateHeights(): GroundMesh;
  22993. private _getFacetAt;
  22994. private _initHeightQuads;
  22995. private _computeHeightQuads;
  22996. /**
  22997. * Serializes this ground mesh
  22998. * @param serializationObject object to write serialization to
  22999. */
  23000. serialize(serializationObject: any): void;
  23001. /**
  23002. * Parses a serialized ground mesh
  23003. * @param parsedMesh the serialized mesh
  23004. * @param scene the scene to create the ground mesh in
  23005. * @returns the created ground mesh
  23006. */
  23007. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  23008. }
  23009. }
  23010. declare module BABYLON {
  23011. /**
  23012. * Interface for Physics-Joint data
  23013. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23014. */
  23015. export interface PhysicsJointData {
  23016. /**
  23017. * The main pivot of the joint
  23018. */
  23019. mainPivot?: Vector3;
  23020. /**
  23021. * The connected pivot of the joint
  23022. */
  23023. connectedPivot?: Vector3;
  23024. /**
  23025. * The main axis of the joint
  23026. */
  23027. mainAxis?: Vector3;
  23028. /**
  23029. * The connected axis of the joint
  23030. */
  23031. connectedAxis?: Vector3;
  23032. /**
  23033. * The collision of the joint
  23034. */
  23035. collision?: boolean;
  23036. /**
  23037. * Native Oimo/Cannon/Energy data
  23038. */
  23039. nativeParams?: any;
  23040. }
  23041. /**
  23042. * This is a holder class for the physics joint created by the physics plugin
  23043. * It holds a set of functions to control the underlying joint
  23044. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23045. */
  23046. export class PhysicsJoint {
  23047. /**
  23048. * The type of the physics joint
  23049. */
  23050. type: number;
  23051. /**
  23052. * The data for the physics joint
  23053. */
  23054. jointData: PhysicsJointData;
  23055. private _physicsJoint;
  23056. protected _physicsPlugin: IPhysicsEnginePlugin;
  23057. /**
  23058. * Initializes the physics joint
  23059. * @param type The type of the physics joint
  23060. * @param jointData The data for the physics joint
  23061. */
  23062. constructor(
  23063. /**
  23064. * The type of the physics joint
  23065. */
  23066. type: number,
  23067. /**
  23068. * The data for the physics joint
  23069. */
  23070. jointData: PhysicsJointData);
  23071. /**
  23072. * Gets the physics joint
  23073. */
  23074. get physicsJoint(): any;
  23075. /**
  23076. * Sets the physics joint
  23077. */
  23078. set physicsJoint(newJoint: any);
  23079. /**
  23080. * Sets the physics plugin
  23081. */
  23082. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  23083. /**
  23084. * Execute a function that is physics-plugin specific.
  23085. * @param {Function} func the function that will be executed.
  23086. * It accepts two parameters: the physics world and the physics joint
  23087. */
  23088. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  23089. /**
  23090. * Distance-Joint type
  23091. */
  23092. static DistanceJoint: number;
  23093. /**
  23094. * Hinge-Joint type
  23095. */
  23096. static HingeJoint: number;
  23097. /**
  23098. * Ball-and-Socket joint type
  23099. */
  23100. static BallAndSocketJoint: number;
  23101. /**
  23102. * Wheel-Joint type
  23103. */
  23104. static WheelJoint: number;
  23105. /**
  23106. * Slider-Joint type
  23107. */
  23108. static SliderJoint: number;
  23109. /**
  23110. * Prismatic-Joint type
  23111. */
  23112. static PrismaticJoint: number;
  23113. /**
  23114. * Universal-Joint type
  23115. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  23116. */
  23117. static UniversalJoint: number;
  23118. /**
  23119. * Hinge-Joint 2 type
  23120. */
  23121. static Hinge2Joint: number;
  23122. /**
  23123. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  23124. */
  23125. static PointToPointJoint: number;
  23126. /**
  23127. * Spring-Joint type
  23128. */
  23129. static SpringJoint: number;
  23130. /**
  23131. * Lock-Joint type
  23132. */
  23133. static LockJoint: number;
  23134. }
  23135. /**
  23136. * A class representing a physics distance joint
  23137. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23138. */
  23139. export class DistanceJoint extends PhysicsJoint {
  23140. /**
  23141. *
  23142. * @param jointData The data for the Distance-Joint
  23143. */
  23144. constructor(jointData: DistanceJointData);
  23145. /**
  23146. * Update the predefined distance.
  23147. * @param maxDistance The maximum preferred distance
  23148. * @param minDistance The minimum preferred distance
  23149. */
  23150. updateDistance(maxDistance: number, minDistance?: number): void;
  23151. }
  23152. /**
  23153. * Represents a Motor-Enabled Joint
  23154. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23155. */
  23156. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  23157. /**
  23158. * Initializes the Motor-Enabled Joint
  23159. * @param type The type of the joint
  23160. * @param jointData The physica joint data for the joint
  23161. */
  23162. constructor(type: number, jointData: PhysicsJointData);
  23163. /**
  23164. * Set the motor values.
  23165. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23166. * @param force the force to apply
  23167. * @param maxForce max force for this motor.
  23168. */
  23169. setMotor(force?: number, maxForce?: number): void;
  23170. /**
  23171. * Set the motor's limits.
  23172. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23173. * @param upperLimit The upper limit of the motor
  23174. * @param lowerLimit The lower limit of the motor
  23175. */
  23176. setLimit(upperLimit: number, lowerLimit?: number): void;
  23177. }
  23178. /**
  23179. * This class represents a single physics Hinge-Joint
  23180. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23181. */
  23182. export class HingeJoint extends MotorEnabledJoint {
  23183. /**
  23184. * Initializes the Hinge-Joint
  23185. * @param jointData The joint data for the Hinge-Joint
  23186. */
  23187. constructor(jointData: PhysicsJointData);
  23188. /**
  23189. * Set the motor values.
  23190. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23191. * @param {number} force the force to apply
  23192. * @param {number} maxForce max force for this motor.
  23193. */
  23194. setMotor(force?: number, maxForce?: number): void;
  23195. /**
  23196. * Set the motor's limits.
  23197. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23198. * @param upperLimit The upper limit of the motor
  23199. * @param lowerLimit The lower limit of the motor
  23200. */
  23201. setLimit(upperLimit: number, lowerLimit?: number): void;
  23202. }
  23203. /**
  23204. * This class represents a dual hinge physics joint (same as wheel joint)
  23205. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23206. */
  23207. export class Hinge2Joint extends MotorEnabledJoint {
  23208. /**
  23209. * Initializes the Hinge2-Joint
  23210. * @param jointData The joint data for the Hinge2-Joint
  23211. */
  23212. constructor(jointData: PhysicsJointData);
  23213. /**
  23214. * Set the motor values.
  23215. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23216. * @param {number} targetSpeed the speed the motor is to reach
  23217. * @param {number} maxForce max force for this motor.
  23218. * @param {motorIndex} the motor's index, 0 or 1.
  23219. */
  23220. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  23221. /**
  23222. * Set the motor limits.
  23223. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23224. * @param {number} upperLimit the upper limit
  23225. * @param {number} lowerLimit lower limit
  23226. * @param {motorIndex} the motor's index, 0 or 1.
  23227. */
  23228. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23229. }
  23230. /**
  23231. * Interface for a motor enabled joint
  23232. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23233. */
  23234. export interface IMotorEnabledJoint {
  23235. /**
  23236. * Physics joint
  23237. */
  23238. physicsJoint: any;
  23239. /**
  23240. * Sets the motor of the motor-enabled joint
  23241. * @param force The force of the motor
  23242. * @param maxForce The maximum force of the motor
  23243. * @param motorIndex The index of the motor
  23244. */
  23245. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  23246. /**
  23247. * Sets the limit of the motor
  23248. * @param upperLimit The upper limit of the motor
  23249. * @param lowerLimit The lower limit of the motor
  23250. * @param motorIndex The index of the motor
  23251. */
  23252. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23253. }
  23254. /**
  23255. * Joint data for a Distance-Joint
  23256. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23257. */
  23258. export interface DistanceJointData extends PhysicsJointData {
  23259. /**
  23260. * Max distance the 2 joint objects can be apart
  23261. */
  23262. maxDistance: number;
  23263. }
  23264. /**
  23265. * Joint data from a spring joint
  23266. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23267. */
  23268. export interface SpringJointData extends PhysicsJointData {
  23269. /**
  23270. * Length of the spring
  23271. */
  23272. length: number;
  23273. /**
  23274. * Stiffness of the spring
  23275. */
  23276. stiffness: number;
  23277. /**
  23278. * Damping of the spring
  23279. */
  23280. damping: number;
  23281. /** this callback will be called when applying the force to the impostors. */
  23282. forceApplicationCallback: () => void;
  23283. }
  23284. }
  23285. declare module BABYLON {
  23286. /**
  23287. * Holds the data for the raycast result
  23288. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23289. */
  23290. export class PhysicsRaycastResult {
  23291. private _hasHit;
  23292. private _hitDistance;
  23293. private _hitNormalWorld;
  23294. private _hitPointWorld;
  23295. private _rayFromWorld;
  23296. private _rayToWorld;
  23297. /**
  23298. * Gets if there was a hit
  23299. */
  23300. get hasHit(): boolean;
  23301. /**
  23302. * Gets the distance from the hit
  23303. */
  23304. get hitDistance(): number;
  23305. /**
  23306. * Gets the hit normal/direction in the world
  23307. */
  23308. get hitNormalWorld(): Vector3;
  23309. /**
  23310. * Gets the hit point in the world
  23311. */
  23312. get hitPointWorld(): Vector3;
  23313. /**
  23314. * Gets the ray "start point" of the ray in the world
  23315. */
  23316. get rayFromWorld(): Vector3;
  23317. /**
  23318. * Gets the ray "end point" of the ray in the world
  23319. */
  23320. get rayToWorld(): Vector3;
  23321. /**
  23322. * Sets the hit data (normal & point in world space)
  23323. * @param hitNormalWorld defines the normal in world space
  23324. * @param hitPointWorld defines the point in world space
  23325. */
  23326. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  23327. /**
  23328. * Sets the distance from the start point to the hit point
  23329. * @param distance
  23330. */
  23331. setHitDistance(distance: number): void;
  23332. /**
  23333. * Calculates the distance manually
  23334. */
  23335. calculateHitDistance(): void;
  23336. /**
  23337. * Resets all the values to default
  23338. * @param from The from point on world space
  23339. * @param to The to point on world space
  23340. */
  23341. reset(from?: Vector3, to?: Vector3): void;
  23342. }
  23343. /**
  23344. * Interface for the size containing width and height
  23345. */
  23346. interface IXYZ {
  23347. /**
  23348. * X
  23349. */
  23350. x: number;
  23351. /**
  23352. * Y
  23353. */
  23354. y: number;
  23355. /**
  23356. * Z
  23357. */
  23358. z: number;
  23359. }
  23360. }
  23361. declare module BABYLON {
  23362. /**
  23363. * Interface used to describe a physics joint
  23364. */
  23365. export interface PhysicsImpostorJoint {
  23366. /** Defines the main impostor to which the joint is linked */
  23367. mainImpostor: PhysicsImpostor;
  23368. /** Defines the impostor that is connected to the main impostor using this joint */
  23369. connectedImpostor: PhysicsImpostor;
  23370. /** Defines the joint itself */
  23371. joint: PhysicsJoint;
  23372. }
  23373. /** @hidden */
  23374. export interface IPhysicsEnginePlugin {
  23375. world: any;
  23376. name: string;
  23377. setGravity(gravity: Vector3): void;
  23378. setTimeStep(timeStep: number): void;
  23379. getTimeStep(): number;
  23380. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  23381. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23382. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23383. generatePhysicsBody(impostor: PhysicsImpostor): void;
  23384. removePhysicsBody(impostor: PhysicsImpostor): void;
  23385. generateJoint(joint: PhysicsImpostorJoint): void;
  23386. removeJoint(joint: PhysicsImpostorJoint): void;
  23387. isSupported(): boolean;
  23388. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  23389. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  23390. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23391. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23392. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23393. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23394. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  23395. getBodyMass(impostor: PhysicsImpostor): number;
  23396. getBodyFriction(impostor: PhysicsImpostor): number;
  23397. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  23398. getBodyRestitution(impostor: PhysicsImpostor): number;
  23399. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  23400. getBodyPressure?(impostor: PhysicsImpostor): number;
  23401. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  23402. getBodyStiffness?(impostor: PhysicsImpostor): number;
  23403. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  23404. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  23405. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  23406. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  23407. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  23408. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23409. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23410. sleepBody(impostor: PhysicsImpostor): void;
  23411. wakeUpBody(impostor: PhysicsImpostor): void;
  23412. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23413. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  23414. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  23415. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23416. getRadius(impostor: PhysicsImpostor): number;
  23417. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  23418. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  23419. dispose(): void;
  23420. }
  23421. /**
  23422. * Interface used to define a physics engine
  23423. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  23424. */
  23425. export interface IPhysicsEngine {
  23426. /**
  23427. * Gets the gravity vector used by the simulation
  23428. */
  23429. gravity: Vector3;
  23430. /**
  23431. * Sets the gravity vector used by the simulation
  23432. * @param gravity defines the gravity vector to use
  23433. */
  23434. setGravity(gravity: Vector3): void;
  23435. /**
  23436. * Set the time step of the physics engine.
  23437. * Default is 1/60.
  23438. * To slow it down, enter 1/600 for example.
  23439. * To speed it up, 1/30
  23440. * @param newTimeStep the new timestep to apply to this world.
  23441. */
  23442. setTimeStep(newTimeStep: number): void;
  23443. /**
  23444. * Get the time step of the physics engine.
  23445. * @returns the current time step
  23446. */
  23447. getTimeStep(): number;
  23448. /**
  23449. * Set the sub time step of the physics engine.
  23450. * Default is 0 meaning there is no sub steps
  23451. * To increase physics resolution precision, set a small value (like 1 ms)
  23452. * @param subTimeStep defines the new sub timestep used for physics resolution.
  23453. */
  23454. setSubTimeStep(subTimeStep: number): void;
  23455. /**
  23456. * Get the sub time step of the physics engine.
  23457. * @returns the current sub time step
  23458. */
  23459. getSubTimeStep(): number;
  23460. /**
  23461. * Release all resources
  23462. */
  23463. dispose(): void;
  23464. /**
  23465. * Gets the name of the current physics plugin
  23466. * @returns the name of the plugin
  23467. */
  23468. getPhysicsPluginName(): string;
  23469. /**
  23470. * Adding a new impostor for the impostor tracking.
  23471. * This will be done by the impostor itself.
  23472. * @param impostor the impostor to add
  23473. */
  23474. addImpostor(impostor: PhysicsImpostor): void;
  23475. /**
  23476. * Remove an impostor from the engine.
  23477. * This impostor and its mesh will not longer be updated by the physics engine.
  23478. * @param impostor the impostor to remove
  23479. */
  23480. removeImpostor(impostor: PhysicsImpostor): void;
  23481. /**
  23482. * Add a joint to the physics engine
  23483. * @param mainImpostor defines the main impostor to which the joint is added.
  23484. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  23485. * @param joint defines the joint that will connect both impostors.
  23486. */
  23487. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23488. /**
  23489. * Removes a joint from the simulation
  23490. * @param mainImpostor defines the impostor used with the joint
  23491. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  23492. * @param joint defines the joint to remove
  23493. */
  23494. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23495. /**
  23496. * Gets the current plugin used to run the simulation
  23497. * @returns current plugin
  23498. */
  23499. getPhysicsPlugin(): IPhysicsEnginePlugin;
  23500. /**
  23501. * Gets the list of physic impostors
  23502. * @returns an array of PhysicsImpostor
  23503. */
  23504. getImpostors(): Array<PhysicsImpostor>;
  23505. /**
  23506. * Gets the impostor for a physics enabled object
  23507. * @param object defines the object impersonated by the impostor
  23508. * @returns the PhysicsImpostor or null if not found
  23509. */
  23510. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23511. /**
  23512. * Gets the impostor for a physics body object
  23513. * @param body defines physics body used by the impostor
  23514. * @returns the PhysicsImpostor or null if not found
  23515. */
  23516. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  23517. /**
  23518. * Does a raycast in the physics world
  23519. * @param from when should the ray start?
  23520. * @param to when should the ray end?
  23521. * @returns PhysicsRaycastResult
  23522. */
  23523. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23524. /**
  23525. * Called by the scene. No need to call it.
  23526. * @param delta defines the timespam between frames
  23527. */
  23528. _step(delta: number): void;
  23529. }
  23530. }
  23531. declare module BABYLON {
  23532. /**
  23533. * The interface for the physics imposter parameters
  23534. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23535. */
  23536. export interface PhysicsImpostorParameters {
  23537. /**
  23538. * The mass of the physics imposter
  23539. */
  23540. mass: number;
  23541. /**
  23542. * The friction of the physics imposter
  23543. */
  23544. friction?: number;
  23545. /**
  23546. * The coefficient of restitution of the physics imposter
  23547. */
  23548. restitution?: number;
  23549. /**
  23550. * The native options of the physics imposter
  23551. */
  23552. nativeOptions?: any;
  23553. /**
  23554. * Specifies if the parent should be ignored
  23555. */
  23556. ignoreParent?: boolean;
  23557. /**
  23558. * Specifies if bi-directional transformations should be disabled
  23559. */
  23560. disableBidirectionalTransformation?: boolean;
  23561. /**
  23562. * The pressure inside the physics imposter, soft object only
  23563. */
  23564. pressure?: number;
  23565. /**
  23566. * The stiffness the physics imposter, soft object only
  23567. */
  23568. stiffness?: number;
  23569. /**
  23570. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  23571. */
  23572. velocityIterations?: number;
  23573. /**
  23574. * The number of iterations used in maintaining consistent vertex positions, soft object only
  23575. */
  23576. positionIterations?: number;
  23577. /**
  23578. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  23579. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  23580. * Add to fix multiple points
  23581. */
  23582. fixedPoints?: number;
  23583. /**
  23584. * The collision margin around a soft object
  23585. */
  23586. margin?: number;
  23587. /**
  23588. * The collision margin around a soft object
  23589. */
  23590. damping?: number;
  23591. /**
  23592. * The path for a rope based on an extrusion
  23593. */
  23594. path?: any;
  23595. /**
  23596. * The shape of an extrusion used for a rope based on an extrusion
  23597. */
  23598. shape?: any;
  23599. }
  23600. /**
  23601. * Interface for a physics-enabled object
  23602. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23603. */
  23604. export interface IPhysicsEnabledObject {
  23605. /**
  23606. * The position of the physics-enabled object
  23607. */
  23608. position: Vector3;
  23609. /**
  23610. * The rotation of the physics-enabled object
  23611. */
  23612. rotationQuaternion: Nullable<Quaternion>;
  23613. /**
  23614. * The scale of the physics-enabled object
  23615. */
  23616. scaling: Vector3;
  23617. /**
  23618. * The rotation of the physics-enabled object
  23619. */
  23620. rotation?: Vector3;
  23621. /**
  23622. * The parent of the physics-enabled object
  23623. */
  23624. parent?: any;
  23625. /**
  23626. * The bounding info of the physics-enabled object
  23627. * @returns The bounding info of the physics-enabled object
  23628. */
  23629. getBoundingInfo(): BoundingInfo;
  23630. /**
  23631. * Computes the world matrix
  23632. * @param force Specifies if the world matrix should be computed by force
  23633. * @returns A world matrix
  23634. */
  23635. computeWorldMatrix(force: boolean): Matrix;
  23636. /**
  23637. * Gets the world matrix
  23638. * @returns A world matrix
  23639. */
  23640. getWorldMatrix?(): Matrix;
  23641. /**
  23642. * Gets the child meshes
  23643. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  23644. * @returns An array of abstract meshes
  23645. */
  23646. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  23647. /**
  23648. * Gets the vertex data
  23649. * @param kind The type of vertex data
  23650. * @returns A nullable array of numbers, or a float32 array
  23651. */
  23652. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  23653. /**
  23654. * Gets the indices from the mesh
  23655. * @returns A nullable array of index arrays
  23656. */
  23657. getIndices?(): Nullable<IndicesArray>;
  23658. /**
  23659. * Gets the scene from the mesh
  23660. * @returns the indices array or null
  23661. */
  23662. getScene?(): Scene;
  23663. /**
  23664. * Gets the absolute position from the mesh
  23665. * @returns the absolute position
  23666. */
  23667. getAbsolutePosition(): Vector3;
  23668. /**
  23669. * Gets the absolute pivot point from the mesh
  23670. * @returns the absolute pivot point
  23671. */
  23672. getAbsolutePivotPoint(): Vector3;
  23673. /**
  23674. * Rotates the mesh
  23675. * @param axis The axis of rotation
  23676. * @param amount The amount of rotation
  23677. * @param space The space of the rotation
  23678. * @returns The rotation transform node
  23679. */
  23680. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  23681. /**
  23682. * Translates the mesh
  23683. * @param axis The axis of translation
  23684. * @param distance The distance of translation
  23685. * @param space The space of the translation
  23686. * @returns The transform node
  23687. */
  23688. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  23689. /**
  23690. * Sets the absolute position of the mesh
  23691. * @param absolutePosition The absolute position of the mesh
  23692. * @returns The transform node
  23693. */
  23694. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  23695. /**
  23696. * Gets the class name of the mesh
  23697. * @returns The class name
  23698. */
  23699. getClassName(): string;
  23700. }
  23701. /**
  23702. * Represents a physics imposter
  23703. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23704. */
  23705. export class PhysicsImpostor {
  23706. /**
  23707. * The physics-enabled object used as the physics imposter
  23708. */
  23709. object: IPhysicsEnabledObject;
  23710. /**
  23711. * The type of the physics imposter
  23712. */
  23713. type: number;
  23714. private _options;
  23715. private _scene?;
  23716. /**
  23717. * The default object size of the imposter
  23718. */
  23719. static DEFAULT_OBJECT_SIZE: Vector3;
  23720. /**
  23721. * The identity quaternion of the imposter
  23722. */
  23723. static IDENTITY_QUATERNION: Quaternion;
  23724. /** @hidden */
  23725. _pluginData: any;
  23726. private _physicsEngine;
  23727. private _physicsBody;
  23728. private _bodyUpdateRequired;
  23729. private _onBeforePhysicsStepCallbacks;
  23730. private _onAfterPhysicsStepCallbacks;
  23731. /** @hidden */
  23732. _onPhysicsCollideCallbacks: Array<{
  23733. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  23734. otherImpostors: Array<PhysicsImpostor>;
  23735. }>;
  23736. private _deltaPosition;
  23737. private _deltaRotation;
  23738. private _deltaRotationConjugated;
  23739. /** @hidden */
  23740. _isFromLine: boolean;
  23741. private _parent;
  23742. private _isDisposed;
  23743. private static _tmpVecs;
  23744. private static _tmpQuat;
  23745. /**
  23746. * Specifies if the physics imposter is disposed
  23747. */
  23748. get isDisposed(): boolean;
  23749. /**
  23750. * Gets the mass of the physics imposter
  23751. */
  23752. get mass(): number;
  23753. set mass(value: number);
  23754. /**
  23755. * Gets the coefficient of friction
  23756. */
  23757. get friction(): number;
  23758. /**
  23759. * Sets the coefficient of friction
  23760. */
  23761. set friction(value: number);
  23762. /**
  23763. * Gets the coefficient of restitution
  23764. */
  23765. get restitution(): number;
  23766. /**
  23767. * Sets the coefficient of restitution
  23768. */
  23769. set restitution(value: number);
  23770. /**
  23771. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  23772. */
  23773. get pressure(): number;
  23774. /**
  23775. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  23776. */
  23777. set pressure(value: number);
  23778. /**
  23779. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23780. */
  23781. get stiffness(): number;
  23782. /**
  23783. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23784. */
  23785. set stiffness(value: number);
  23786. /**
  23787. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23788. */
  23789. get velocityIterations(): number;
  23790. /**
  23791. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23792. */
  23793. set velocityIterations(value: number);
  23794. /**
  23795. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23796. */
  23797. get positionIterations(): number;
  23798. /**
  23799. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23800. */
  23801. set positionIterations(value: number);
  23802. /**
  23803. * The unique id of the physics imposter
  23804. * set by the physics engine when adding this impostor to the array
  23805. */
  23806. uniqueId: number;
  23807. /**
  23808. * @hidden
  23809. */
  23810. soft: boolean;
  23811. /**
  23812. * @hidden
  23813. */
  23814. segments: number;
  23815. private _joints;
  23816. /**
  23817. * Initializes the physics imposter
  23818. * @param object The physics-enabled object used as the physics imposter
  23819. * @param type The type of the physics imposter
  23820. * @param _options The options for the physics imposter
  23821. * @param _scene The Babylon scene
  23822. */
  23823. constructor(
  23824. /**
  23825. * The physics-enabled object used as the physics imposter
  23826. */
  23827. object: IPhysicsEnabledObject,
  23828. /**
  23829. * The type of the physics imposter
  23830. */
  23831. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  23832. /**
  23833. * This function will completly initialize this impostor.
  23834. * It will create a new body - but only if this mesh has no parent.
  23835. * If it has, this impostor will not be used other than to define the impostor
  23836. * of the child mesh.
  23837. * @hidden
  23838. */
  23839. _init(): void;
  23840. private _getPhysicsParent;
  23841. /**
  23842. * Should a new body be generated.
  23843. * @returns boolean specifying if body initialization is required
  23844. */
  23845. isBodyInitRequired(): boolean;
  23846. /**
  23847. * Sets the updated scaling
  23848. * @param updated Specifies if the scaling is updated
  23849. */
  23850. setScalingUpdated(): void;
  23851. /**
  23852. * Force a regeneration of this or the parent's impostor's body.
  23853. * Use under cautious - This will remove all joints already implemented.
  23854. */
  23855. forceUpdate(): void;
  23856. /**
  23857. * Gets the body that holds this impostor. Either its own, or its parent.
  23858. */
  23859. get physicsBody(): any;
  23860. /**
  23861. * Get the parent of the physics imposter
  23862. * @returns Physics imposter or null
  23863. */
  23864. get parent(): Nullable<PhysicsImpostor>;
  23865. /**
  23866. * Sets the parent of the physics imposter
  23867. */
  23868. set parent(value: Nullable<PhysicsImpostor>);
  23869. /**
  23870. * Set the physics body. Used mainly by the physics engine/plugin
  23871. */
  23872. set physicsBody(physicsBody: any);
  23873. /**
  23874. * Resets the update flags
  23875. */
  23876. resetUpdateFlags(): void;
  23877. /**
  23878. * Gets the object extend size
  23879. * @returns the object extend size
  23880. */
  23881. getObjectExtendSize(): Vector3;
  23882. /**
  23883. * Gets the object center
  23884. * @returns The object center
  23885. */
  23886. getObjectCenter(): Vector3;
  23887. /**
  23888. * Get a specific parameter from the options parameters
  23889. * @param paramName The object parameter name
  23890. * @returns The object parameter
  23891. */
  23892. getParam(paramName: string): any;
  23893. /**
  23894. * Sets a specific parameter in the options given to the physics plugin
  23895. * @param paramName The parameter name
  23896. * @param value The value of the parameter
  23897. */
  23898. setParam(paramName: string, value: number): void;
  23899. /**
  23900. * Specifically change the body's mass option. Won't recreate the physics body object
  23901. * @param mass The mass of the physics imposter
  23902. */
  23903. setMass(mass: number): void;
  23904. /**
  23905. * Gets the linear velocity
  23906. * @returns linear velocity or null
  23907. */
  23908. getLinearVelocity(): Nullable<Vector3>;
  23909. /**
  23910. * Sets the linear velocity
  23911. * @param velocity linear velocity or null
  23912. */
  23913. setLinearVelocity(velocity: Nullable<Vector3>): void;
  23914. /**
  23915. * Gets the angular velocity
  23916. * @returns angular velocity or null
  23917. */
  23918. getAngularVelocity(): Nullable<Vector3>;
  23919. /**
  23920. * Sets the angular velocity
  23921. * @param velocity The velocity or null
  23922. */
  23923. setAngularVelocity(velocity: Nullable<Vector3>): void;
  23924. /**
  23925. * Execute a function with the physics plugin native code
  23926. * Provide a function the will have two variables - the world object and the physics body object
  23927. * @param func The function to execute with the physics plugin native code
  23928. */
  23929. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  23930. /**
  23931. * Register a function that will be executed before the physics world is stepping forward
  23932. * @param func The function to execute before the physics world is stepped forward
  23933. */
  23934. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23935. /**
  23936. * Unregister a function that will be executed before the physics world is stepping forward
  23937. * @param func The function to execute before the physics world is stepped forward
  23938. */
  23939. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23940. /**
  23941. * Register a function that will be executed after the physics step
  23942. * @param func The function to execute after physics step
  23943. */
  23944. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23945. /**
  23946. * Unregisters a function that will be executed after the physics step
  23947. * @param func The function to execute after physics step
  23948. */
  23949. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23950. /**
  23951. * register a function that will be executed when this impostor collides against a different body
  23952. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  23953. * @param func Callback that is executed on collision
  23954. */
  23955. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  23956. /**
  23957. * Unregisters the physics imposter on contact
  23958. * @param collideAgainst The physics object to collide against
  23959. * @param func Callback to execute on collision
  23960. */
  23961. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  23962. private _tmpQuat;
  23963. private _tmpQuat2;
  23964. /**
  23965. * Get the parent rotation
  23966. * @returns The parent rotation
  23967. */
  23968. getParentsRotation(): Quaternion;
  23969. /**
  23970. * this function is executed by the physics engine.
  23971. */
  23972. beforeStep: () => void;
  23973. /**
  23974. * this function is executed by the physics engine
  23975. */
  23976. afterStep: () => void;
  23977. /**
  23978. * Legacy collision detection event support
  23979. */
  23980. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  23981. /**
  23982. * event and body object due to cannon's event-based architecture.
  23983. */
  23984. onCollide: (e: {
  23985. body: any;
  23986. }) => void;
  23987. /**
  23988. * Apply a force
  23989. * @param force The force to apply
  23990. * @param contactPoint The contact point for the force
  23991. * @returns The physics imposter
  23992. */
  23993. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  23994. /**
  23995. * Apply an impulse
  23996. * @param force The impulse force
  23997. * @param contactPoint The contact point for the impulse force
  23998. * @returns The physics imposter
  23999. */
  24000. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24001. /**
  24002. * A help function to create a joint
  24003. * @param otherImpostor A physics imposter used to create a joint
  24004. * @param jointType The type of joint
  24005. * @param jointData The data for the joint
  24006. * @returns The physics imposter
  24007. */
  24008. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  24009. /**
  24010. * Add a joint to this impostor with a different impostor
  24011. * @param otherImpostor A physics imposter used to add a joint
  24012. * @param joint The joint to add
  24013. * @returns The physics imposter
  24014. */
  24015. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  24016. /**
  24017. * Add an anchor to a cloth impostor
  24018. * @param otherImpostor rigid impostor to anchor to
  24019. * @param width ratio across width from 0 to 1
  24020. * @param height ratio up height from 0 to 1
  24021. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  24022. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  24023. * @returns impostor the soft imposter
  24024. */
  24025. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24026. /**
  24027. * Add a hook to a rope impostor
  24028. * @param otherImpostor rigid impostor to anchor to
  24029. * @param length ratio across rope from 0 to 1
  24030. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  24031. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  24032. * @returns impostor the rope imposter
  24033. */
  24034. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24035. /**
  24036. * Will keep this body still, in a sleep mode.
  24037. * @returns the physics imposter
  24038. */
  24039. sleep(): PhysicsImpostor;
  24040. /**
  24041. * Wake the body up.
  24042. * @returns The physics imposter
  24043. */
  24044. wakeUp(): PhysicsImpostor;
  24045. /**
  24046. * Clones the physics imposter
  24047. * @param newObject The physics imposter clones to this physics-enabled object
  24048. * @returns A nullable physics imposter
  24049. */
  24050. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  24051. /**
  24052. * Disposes the physics imposter
  24053. */
  24054. dispose(): void;
  24055. /**
  24056. * Sets the delta position
  24057. * @param position The delta position amount
  24058. */
  24059. setDeltaPosition(position: Vector3): void;
  24060. /**
  24061. * Sets the delta rotation
  24062. * @param rotation The delta rotation amount
  24063. */
  24064. setDeltaRotation(rotation: Quaternion): void;
  24065. /**
  24066. * Gets the box size of the physics imposter and stores the result in the input parameter
  24067. * @param result Stores the box size
  24068. * @returns The physics imposter
  24069. */
  24070. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  24071. /**
  24072. * Gets the radius of the physics imposter
  24073. * @returns Radius of the physics imposter
  24074. */
  24075. getRadius(): number;
  24076. /**
  24077. * Sync a bone with this impostor
  24078. * @param bone The bone to sync to the impostor.
  24079. * @param boneMesh The mesh that the bone is influencing.
  24080. * @param jointPivot The pivot of the joint / bone in local space.
  24081. * @param distToJoint Optional distance from the impostor to the joint.
  24082. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24083. */
  24084. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  24085. /**
  24086. * Sync impostor to a bone
  24087. * @param bone The bone that the impostor will be synced to.
  24088. * @param boneMesh The mesh that the bone is influencing.
  24089. * @param jointPivot The pivot of the joint / bone in local space.
  24090. * @param distToJoint Optional distance from the impostor to the joint.
  24091. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24092. * @param boneAxis Optional vector3 axis the bone is aligned with
  24093. */
  24094. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  24095. /**
  24096. * No-Imposter type
  24097. */
  24098. static NoImpostor: number;
  24099. /**
  24100. * Sphere-Imposter type
  24101. */
  24102. static SphereImpostor: number;
  24103. /**
  24104. * Box-Imposter type
  24105. */
  24106. static BoxImpostor: number;
  24107. /**
  24108. * Plane-Imposter type
  24109. */
  24110. static PlaneImpostor: number;
  24111. /**
  24112. * Mesh-imposter type
  24113. */
  24114. static MeshImpostor: number;
  24115. /**
  24116. * Capsule-Impostor type (Ammo.js plugin only)
  24117. */
  24118. static CapsuleImpostor: number;
  24119. /**
  24120. * Cylinder-Imposter type
  24121. */
  24122. static CylinderImpostor: number;
  24123. /**
  24124. * Particle-Imposter type
  24125. */
  24126. static ParticleImpostor: number;
  24127. /**
  24128. * Heightmap-Imposter type
  24129. */
  24130. static HeightmapImpostor: number;
  24131. /**
  24132. * ConvexHull-Impostor type (Ammo.js plugin only)
  24133. */
  24134. static ConvexHullImpostor: number;
  24135. /**
  24136. * Custom-Imposter type (Ammo.js plugin only)
  24137. */
  24138. static CustomImpostor: number;
  24139. /**
  24140. * Rope-Imposter type
  24141. */
  24142. static RopeImpostor: number;
  24143. /**
  24144. * Cloth-Imposter type
  24145. */
  24146. static ClothImpostor: number;
  24147. /**
  24148. * Softbody-Imposter type
  24149. */
  24150. static SoftbodyImpostor: number;
  24151. }
  24152. }
  24153. declare module BABYLON {
  24154. /**
  24155. * @hidden
  24156. **/
  24157. export class _CreationDataStorage {
  24158. closePath?: boolean;
  24159. closeArray?: boolean;
  24160. idx: number[];
  24161. dashSize: number;
  24162. gapSize: number;
  24163. path3D: Path3D;
  24164. pathArray: Vector3[][];
  24165. arc: number;
  24166. radius: number;
  24167. cap: number;
  24168. tessellation: number;
  24169. }
  24170. /**
  24171. * @hidden
  24172. **/
  24173. class _InstanceDataStorage {
  24174. visibleInstances: any;
  24175. batchCache: _InstancesBatch;
  24176. instancesBufferSize: number;
  24177. instancesBuffer: Nullable<Buffer>;
  24178. instancesData: Float32Array;
  24179. overridenInstanceCount: number;
  24180. isFrozen: boolean;
  24181. previousBatch: Nullable<_InstancesBatch>;
  24182. hardwareInstancedRendering: boolean;
  24183. sideOrientation: number;
  24184. manualUpdate: boolean;
  24185. }
  24186. /**
  24187. * @hidden
  24188. **/
  24189. export class _InstancesBatch {
  24190. mustReturn: boolean;
  24191. visibleInstances: Nullable<InstancedMesh[]>[];
  24192. renderSelf: boolean[];
  24193. hardwareInstancedRendering: boolean[];
  24194. }
  24195. /**
  24196. * Class used to represent renderable models
  24197. */
  24198. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  24199. /**
  24200. * Mesh side orientation : usually the external or front surface
  24201. */
  24202. static readonly FRONTSIDE: number;
  24203. /**
  24204. * Mesh side orientation : usually the internal or back surface
  24205. */
  24206. static readonly BACKSIDE: number;
  24207. /**
  24208. * Mesh side orientation : both internal and external or front and back surfaces
  24209. */
  24210. static readonly DOUBLESIDE: number;
  24211. /**
  24212. * Mesh side orientation : by default, `FRONTSIDE`
  24213. */
  24214. static readonly DEFAULTSIDE: number;
  24215. /**
  24216. * Mesh cap setting : no cap
  24217. */
  24218. static readonly NO_CAP: number;
  24219. /**
  24220. * Mesh cap setting : one cap at the beginning of the mesh
  24221. */
  24222. static readonly CAP_START: number;
  24223. /**
  24224. * Mesh cap setting : one cap at the end of the mesh
  24225. */
  24226. static readonly CAP_END: number;
  24227. /**
  24228. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  24229. */
  24230. static readonly CAP_ALL: number;
  24231. /**
  24232. * Mesh pattern setting : no flip or rotate
  24233. */
  24234. static readonly NO_FLIP: number;
  24235. /**
  24236. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  24237. */
  24238. static readonly FLIP_TILE: number;
  24239. /**
  24240. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  24241. */
  24242. static readonly ROTATE_TILE: number;
  24243. /**
  24244. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  24245. */
  24246. static readonly FLIP_ROW: number;
  24247. /**
  24248. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  24249. */
  24250. static readonly ROTATE_ROW: number;
  24251. /**
  24252. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  24253. */
  24254. static readonly FLIP_N_ROTATE_TILE: number;
  24255. /**
  24256. * Mesh pattern setting : rotate pattern and rotate
  24257. */
  24258. static readonly FLIP_N_ROTATE_ROW: number;
  24259. /**
  24260. * Mesh tile positioning : part tiles same on left/right or top/bottom
  24261. */
  24262. static readonly CENTER: number;
  24263. /**
  24264. * Mesh tile positioning : part tiles on left
  24265. */
  24266. static readonly LEFT: number;
  24267. /**
  24268. * Mesh tile positioning : part tiles on right
  24269. */
  24270. static readonly RIGHT: number;
  24271. /**
  24272. * Mesh tile positioning : part tiles on top
  24273. */
  24274. static readonly TOP: number;
  24275. /**
  24276. * Mesh tile positioning : part tiles on bottom
  24277. */
  24278. static readonly BOTTOM: number;
  24279. /**
  24280. * Gets the default side orientation.
  24281. * @param orientation the orientation to value to attempt to get
  24282. * @returns the default orientation
  24283. * @hidden
  24284. */
  24285. static _GetDefaultSideOrientation(orientation?: number): number;
  24286. private _internalMeshDataInfo;
  24287. /**
  24288. * An event triggered before rendering the mesh
  24289. */
  24290. get onBeforeRenderObservable(): Observable<Mesh>;
  24291. /**
  24292. * An event triggered before binding the mesh
  24293. */
  24294. get onBeforeBindObservable(): Observable<Mesh>;
  24295. /**
  24296. * An event triggered after rendering the mesh
  24297. */
  24298. get onAfterRenderObservable(): Observable<Mesh>;
  24299. /**
  24300. * An event triggered before drawing the mesh
  24301. */
  24302. get onBeforeDrawObservable(): Observable<Mesh>;
  24303. private _onBeforeDrawObserver;
  24304. /**
  24305. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  24306. */
  24307. set onBeforeDraw(callback: () => void);
  24308. get hasInstances(): boolean;
  24309. /**
  24310. * Gets the delay loading state of the mesh (when delay loading is turned on)
  24311. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  24312. */
  24313. delayLoadState: number;
  24314. /**
  24315. * Gets the list of instances created from this mesh
  24316. * it is not supposed to be modified manually.
  24317. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  24318. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24319. */
  24320. instances: InstancedMesh[];
  24321. /**
  24322. * Gets the file containing delay loading data for this mesh
  24323. */
  24324. delayLoadingFile: string;
  24325. /** @hidden */
  24326. _binaryInfo: any;
  24327. /**
  24328. * User defined function used to change how LOD level selection is done
  24329. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  24330. */
  24331. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  24332. /**
  24333. * Gets or sets the morph target manager
  24334. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  24335. */
  24336. get morphTargetManager(): Nullable<MorphTargetManager>;
  24337. set morphTargetManager(value: Nullable<MorphTargetManager>);
  24338. /** @hidden */
  24339. _creationDataStorage: Nullable<_CreationDataStorage>;
  24340. /** @hidden */
  24341. _geometry: Nullable<Geometry>;
  24342. /** @hidden */
  24343. _delayInfo: Array<string>;
  24344. /** @hidden */
  24345. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  24346. /** @hidden */
  24347. _instanceDataStorage: _InstanceDataStorage;
  24348. private _effectiveMaterial;
  24349. /** @hidden */
  24350. _shouldGenerateFlatShading: boolean;
  24351. /** @hidden */
  24352. _originalBuilderSideOrientation: number;
  24353. /**
  24354. * Use this property to change the original side orientation defined at construction time
  24355. */
  24356. overrideMaterialSideOrientation: Nullable<number>;
  24357. /**
  24358. * Gets the source mesh (the one used to clone this one from)
  24359. */
  24360. get source(): Nullable<Mesh>;
  24361. /**
  24362. * Gets or sets a boolean indicating that this mesh does not use index buffer
  24363. */
  24364. get isUnIndexed(): boolean;
  24365. set isUnIndexed(value: boolean);
  24366. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  24367. get worldMatrixInstancedBuffer(): Float32Array;
  24368. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  24369. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  24370. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  24371. /**
  24372. * @constructor
  24373. * @param name The value used by scene.getMeshByName() to do a lookup.
  24374. * @param scene The scene to add this mesh to.
  24375. * @param parent The parent of this mesh, if it has one
  24376. * @param source An optional Mesh from which geometry is shared, cloned.
  24377. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  24378. * When false, achieved by calling a clone(), also passing False.
  24379. * This will make creation of children, recursive.
  24380. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  24381. */
  24382. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  24383. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  24384. doNotInstantiate: boolean;
  24385. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  24386. /**
  24387. * Gets the class name
  24388. * @returns the string "Mesh".
  24389. */
  24390. getClassName(): string;
  24391. /** @hidden */
  24392. get _isMesh(): boolean;
  24393. /**
  24394. * Returns a description of this mesh
  24395. * @param fullDetails define if full details about this mesh must be used
  24396. * @returns a descriptive string representing this mesh
  24397. */
  24398. toString(fullDetails?: boolean): string;
  24399. /** @hidden */
  24400. _unBindEffect(): void;
  24401. /**
  24402. * Gets a boolean indicating if this mesh has LOD
  24403. */
  24404. get hasLODLevels(): boolean;
  24405. /**
  24406. * Gets the list of MeshLODLevel associated with the current mesh
  24407. * @returns an array of MeshLODLevel
  24408. */
  24409. getLODLevels(): MeshLODLevel[];
  24410. private _sortLODLevels;
  24411. /**
  24412. * Add a mesh as LOD level triggered at the given distance.
  24413. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24414. * @param distance The distance from the center of the object to show this level
  24415. * @param mesh The mesh to be added as LOD level (can be null)
  24416. * @return This mesh (for chaining)
  24417. */
  24418. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  24419. /**
  24420. * Returns the LOD level mesh at the passed distance or null if not found.
  24421. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24422. * @param distance The distance from the center of the object to show this level
  24423. * @returns a Mesh or `null`
  24424. */
  24425. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  24426. /**
  24427. * Remove a mesh from the LOD array
  24428. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24429. * @param mesh defines the mesh to be removed
  24430. * @return This mesh (for chaining)
  24431. */
  24432. removeLODLevel(mesh: Mesh): Mesh;
  24433. /**
  24434. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  24435. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24436. * @param camera defines the camera to use to compute distance
  24437. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  24438. * @return This mesh (for chaining)
  24439. */
  24440. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  24441. /**
  24442. * Gets the mesh internal Geometry object
  24443. */
  24444. get geometry(): Nullable<Geometry>;
  24445. /**
  24446. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  24447. * @returns the total number of vertices
  24448. */
  24449. getTotalVertices(): number;
  24450. /**
  24451. * Returns the content of an associated vertex buffer
  24452. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24453. * - VertexBuffer.PositionKind
  24454. * - VertexBuffer.UVKind
  24455. * - VertexBuffer.UV2Kind
  24456. * - VertexBuffer.UV3Kind
  24457. * - VertexBuffer.UV4Kind
  24458. * - VertexBuffer.UV5Kind
  24459. * - VertexBuffer.UV6Kind
  24460. * - VertexBuffer.ColorKind
  24461. * - VertexBuffer.MatricesIndicesKind
  24462. * - VertexBuffer.MatricesIndicesExtraKind
  24463. * - VertexBuffer.MatricesWeightsKind
  24464. * - VertexBuffer.MatricesWeightsExtraKind
  24465. * @param copyWhenShared defines a boolean indicating that if the mesh geometry is shared among some other meshes, the returned array is a copy of the internal one
  24466. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  24467. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  24468. */
  24469. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  24470. /**
  24471. * Returns the mesh VertexBuffer object from the requested `kind`
  24472. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24473. * - VertexBuffer.PositionKind
  24474. * - VertexBuffer.NormalKind
  24475. * - VertexBuffer.UVKind
  24476. * - VertexBuffer.UV2Kind
  24477. * - VertexBuffer.UV3Kind
  24478. * - VertexBuffer.UV4Kind
  24479. * - VertexBuffer.UV5Kind
  24480. * - VertexBuffer.UV6Kind
  24481. * - VertexBuffer.ColorKind
  24482. * - VertexBuffer.MatricesIndicesKind
  24483. * - VertexBuffer.MatricesIndicesExtraKind
  24484. * - VertexBuffer.MatricesWeightsKind
  24485. * - VertexBuffer.MatricesWeightsExtraKind
  24486. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  24487. */
  24488. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  24489. /**
  24490. * Tests if a specific vertex buffer is associated with this mesh
  24491. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24492. * - VertexBuffer.PositionKind
  24493. * - VertexBuffer.NormalKind
  24494. * - VertexBuffer.UVKind
  24495. * - VertexBuffer.UV2Kind
  24496. * - VertexBuffer.UV3Kind
  24497. * - VertexBuffer.UV4Kind
  24498. * - VertexBuffer.UV5Kind
  24499. * - VertexBuffer.UV6Kind
  24500. * - VertexBuffer.ColorKind
  24501. * - VertexBuffer.MatricesIndicesKind
  24502. * - VertexBuffer.MatricesIndicesExtraKind
  24503. * - VertexBuffer.MatricesWeightsKind
  24504. * - VertexBuffer.MatricesWeightsExtraKind
  24505. * @returns a boolean
  24506. */
  24507. isVerticesDataPresent(kind: string): boolean;
  24508. /**
  24509. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  24510. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24511. * - VertexBuffer.PositionKind
  24512. * - VertexBuffer.UVKind
  24513. * - VertexBuffer.UV2Kind
  24514. * - VertexBuffer.UV3Kind
  24515. * - VertexBuffer.UV4Kind
  24516. * - VertexBuffer.UV5Kind
  24517. * - VertexBuffer.UV6Kind
  24518. * - VertexBuffer.ColorKind
  24519. * - VertexBuffer.MatricesIndicesKind
  24520. * - VertexBuffer.MatricesIndicesExtraKind
  24521. * - VertexBuffer.MatricesWeightsKind
  24522. * - VertexBuffer.MatricesWeightsExtraKind
  24523. * @returns a boolean
  24524. */
  24525. isVertexBufferUpdatable(kind: string): boolean;
  24526. /**
  24527. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  24528. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24529. * - VertexBuffer.PositionKind
  24530. * - VertexBuffer.NormalKind
  24531. * - VertexBuffer.UVKind
  24532. * - VertexBuffer.UV2Kind
  24533. * - VertexBuffer.UV3Kind
  24534. * - VertexBuffer.UV4Kind
  24535. * - VertexBuffer.UV5Kind
  24536. * - VertexBuffer.UV6Kind
  24537. * - VertexBuffer.ColorKind
  24538. * - VertexBuffer.MatricesIndicesKind
  24539. * - VertexBuffer.MatricesIndicesExtraKind
  24540. * - VertexBuffer.MatricesWeightsKind
  24541. * - VertexBuffer.MatricesWeightsExtraKind
  24542. * @returns an array of strings
  24543. */
  24544. getVerticesDataKinds(): string[];
  24545. /**
  24546. * Returns a positive integer : the total number of indices in this mesh geometry.
  24547. * @returns the numner of indices or zero if the mesh has no geometry.
  24548. */
  24549. getTotalIndices(): number;
  24550. /**
  24551. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  24552. * @param copyWhenShared If true (default false) and and if the mesh geometry is shared among some other meshes, the returned array is a copy of the internal one.
  24553. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24554. * @returns the indices array or an empty array if the mesh has no geometry
  24555. */
  24556. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  24557. get isBlocked(): boolean;
  24558. /**
  24559. * Determine if the current mesh is ready to be rendered
  24560. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  24561. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  24562. * @returns true if all associated assets are ready (material, textures, shaders)
  24563. */
  24564. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  24565. /**
  24566. * Gets a boolean indicating if the normals aren't to be recomputed on next mesh `positions` array update. This property is pertinent only for updatable parametric shapes.
  24567. */
  24568. get areNormalsFrozen(): boolean;
  24569. /**
  24570. * This function affects parametric shapes on vertex position update only : ribbons, tubes, etc. It has no effect at all on other shapes. It prevents the mesh normals from being recomputed on next `positions` array update.
  24571. * @returns the current mesh
  24572. */
  24573. freezeNormals(): Mesh;
  24574. /**
  24575. * This function affects parametric shapes on vertex position update only : ribbons, tubes, etc. It has no effect at all on other shapes. It reactivates the mesh normals computation if it was previously frozen
  24576. * @returns the current mesh
  24577. */
  24578. unfreezeNormals(): Mesh;
  24579. /**
  24580. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  24581. */
  24582. set overridenInstanceCount(count: number);
  24583. /** @hidden */
  24584. _preActivate(): Mesh;
  24585. /** @hidden */
  24586. _preActivateForIntermediateRendering(renderId: number): Mesh;
  24587. /** @hidden */
  24588. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  24589. /**
  24590. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  24591. * This means the mesh underlying bounding box and sphere are recomputed.
  24592. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  24593. * @returns the current mesh
  24594. */
  24595. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  24596. /** @hidden */
  24597. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  24598. /**
  24599. * This function will subdivide the mesh into multiple submeshes
  24600. * @param count defines the expected number of submeshes
  24601. */
  24602. subdivide(count: number): void;
  24603. /**
  24604. * Copy a FloatArray into a specific associated vertex buffer
  24605. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24606. * - VertexBuffer.PositionKind
  24607. * - VertexBuffer.UVKind
  24608. * - VertexBuffer.UV2Kind
  24609. * - VertexBuffer.UV3Kind
  24610. * - VertexBuffer.UV4Kind
  24611. * - VertexBuffer.UV5Kind
  24612. * - VertexBuffer.UV6Kind
  24613. * - VertexBuffer.ColorKind
  24614. * - VertexBuffer.MatricesIndicesKind
  24615. * - VertexBuffer.MatricesIndicesExtraKind
  24616. * - VertexBuffer.MatricesWeightsKind
  24617. * - VertexBuffer.MatricesWeightsExtraKind
  24618. * @param data defines the data source
  24619. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24620. * @param stride defines the data stride size (can be null)
  24621. * @returns the current mesh
  24622. */
  24623. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  24624. /**
  24625. * Delete a vertex buffer associated with this mesh
  24626. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  24627. * - VertexBuffer.PositionKind
  24628. * - VertexBuffer.UVKind
  24629. * - VertexBuffer.UV2Kind
  24630. * - VertexBuffer.UV3Kind
  24631. * - VertexBuffer.UV4Kind
  24632. * - VertexBuffer.UV5Kind
  24633. * - VertexBuffer.UV6Kind
  24634. * - VertexBuffer.ColorKind
  24635. * - VertexBuffer.MatricesIndicesKind
  24636. * - VertexBuffer.MatricesIndicesExtraKind
  24637. * - VertexBuffer.MatricesWeightsKind
  24638. * - VertexBuffer.MatricesWeightsExtraKind
  24639. */
  24640. removeVerticesData(kind: string): void;
  24641. /**
  24642. * Flags an associated vertex buffer as updatable
  24643. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  24644. * - VertexBuffer.PositionKind
  24645. * - VertexBuffer.UVKind
  24646. * - VertexBuffer.UV2Kind
  24647. * - VertexBuffer.UV3Kind
  24648. * - VertexBuffer.UV4Kind
  24649. * - VertexBuffer.UV5Kind
  24650. * - VertexBuffer.UV6Kind
  24651. * - VertexBuffer.ColorKind
  24652. * - VertexBuffer.MatricesIndicesKind
  24653. * - VertexBuffer.MatricesIndicesExtraKind
  24654. * - VertexBuffer.MatricesWeightsKind
  24655. * - VertexBuffer.MatricesWeightsExtraKind
  24656. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24657. */
  24658. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  24659. /**
  24660. * Sets the mesh global Vertex Buffer
  24661. * @param buffer defines the buffer to use
  24662. * @returns the current mesh
  24663. */
  24664. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  24665. /**
  24666. * Update a specific associated vertex buffer
  24667. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24668. * - VertexBuffer.PositionKind
  24669. * - VertexBuffer.UVKind
  24670. * - VertexBuffer.UV2Kind
  24671. * - VertexBuffer.UV3Kind
  24672. * - VertexBuffer.UV4Kind
  24673. * - VertexBuffer.UV5Kind
  24674. * - VertexBuffer.UV6Kind
  24675. * - VertexBuffer.ColorKind
  24676. * - VertexBuffer.MatricesIndicesKind
  24677. * - VertexBuffer.MatricesIndicesExtraKind
  24678. * - VertexBuffer.MatricesWeightsKind
  24679. * - VertexBuffer.MatricesWeightsExtraKind
  24680. * @param data defines the data source
  24681. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  24682. * @param makeItUnique defines if the geometry associated with the mesh must be cloned to make the change only for this mesh (and not all meshes associated with the same geometry)
  24683. * @returns the current mesh
  24684. */
  24685. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  24686. /**
  24687. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  24688. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  24689. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  24690. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  24691. * @returns the current mesh
  24692. */
  24693. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  24694. /**
  24695. * Creates a un-shared specific occurence of the geometry for the mesh.
  24696. * @returns the current mesh
  24697. */
  24698. makeGeometryUnique(): Mesh;
  24699. /**
  24700. * Set the index buffer of this mesh
  24701. * @param indices defines the source data
  24702. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  24703. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  24704. * @returns the current mesh
  24705. */
  24706. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  24707. /**
  24708. * Update the current index buffer
  24709. * @param indices defines the source data
  24710. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  24711. * @param gpuMemoryOnly defines a boolean indicating that only the GPU memory must be updated leaving the CPU version of the indices unchanged (false by default)
  24712. * @returns the current mesh
  24713. */
  24714. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  24715. /**
  24716. * Invert the geometry to move from a right handed system to a left handed one.
  24717. * @returns the current mesh
  24718. */
  24719. toLeftHanded(): Mesh;
  24720. /** @hidden */
  24721. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  24722. /** @hidden */
  24723. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  24724. /**
  24725. * Registers for this mesh a javascript function called just before the rendering process
  24726. * @param func defines the function to call before rendering this mesh
  24727. * @returns the current mesh
  24728. */
  24729. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24730. /**
  24731. * Disposes a previously registered javascript function called before the rendering
  24732. * @param func defines the function to remove
  24733. * @returns the current mesh
  24734. */
  24735. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24736. /**
  24737. * Registers for this mesh a javascript function called just after the rendering is complete
  24738. * @param func defines the function to call after rendering this mesh
  24739. * @returns the current mesh
  24740. */
  24741. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24742. /**
  24743. * Disposes a previously registered javascript function called after the rendering.
  24744. * @param func defines the function to remove
  24745. * @returns the current mesh
  24746. */
  24747. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24748. /** @hidden */
  24749. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  24750. /** @hidden */
  24751. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  24752. /** @hidden */
  24753. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  24754. /** @hidden */
  24755. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  24756. /** @hidden */
  24757. _rebuild(): void;
  24758. /** @hidden */
  24759. _freeze(): void;
  24760. /** @hidden */
  24761. _unFreeze(): void;
  24762. /**
  24763. * Triggers the draw call for the mesh. Usually, you don't need to call this method by your own because the mesh rendering is handled by the scene rendering manager
  24764. * @param subMesh defines the subMesh to render
  24765. * @param enableAlphaMode defines if alpha mode can be changed
  24766. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  24767. * @returns the current mesh
  24768. */
  24769. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  24770. private _onBeforeDraw;
  24771. /**
  24772. * Renormalize the mesh and patch it up if there are no weights
  24773. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  24774. * However in the case of zero weights then we set just a single influence to 1.
  24775. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  24776. */
  24777. cleanMatrixWeights(): void;
  24778. private normalizeSkinFourWeights;
  24779. private normalizeSkinWeightsAndExtra;
  24780. /**
  24781. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  24782. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  24783. * the user know there was an issue with importing the mesh
  24784. * @returns a validation object with skinned, valid and report string
  24785. */
  24786. validateSkinning(): {
  24787. skinned: boolean;
  24788. valid: boolean;
  24789. report: string;
  24790. };
  24791. /** @hidden */
  24792. _checkDelayState(): Mesh;
  24793. private _queueLoad;
  24794. /**
  24795. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  24796. * A mesh is in the frustum if its bounding box intersects the frustum
  24797. * @param frustumPlanes defines the frustum to test
  24798. * @returns true if the mesh is in the frustum planes
  24799. */
  24800. isInFrustum(frustumPlanes: Plane[]): boolean;
  24801. /**
  24802. * Sets the mesh material by the material or multiMaterial `id` property
  24803. * @param id is a string identifying the material or the multiMaterial
  24804. * @returns the current mesh
  24805. */
  24806. setMaterialByID(id: string): Mesh;
  24807. /**
  24808. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  24809. * @returns an array of IAnimatable
  24810. */
  24811. getAnimatables(): IAnimatable[];
  24812. /**
  24813. * Modifies the mesh geometry according to the passed transformation matrix.
  24814. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  24815. * The mesh normals are modified using the same transformation.
  24816. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24817. * @param transform defines the transform matrix to use
  24818. * @see http://doc.babylonjs.com/resources/baking_transformations
  24819. * @returns the current mesh
  24820. */
  24821. bakeTransformIntoVertices(transform: Matrix): Mesh;
  24822. /**
  24823. * Modifies the mesh geometry according to its own current World Matrix.
  24824. * The mesh World Matrix is then reset.
  24825. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  24826. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24827. * @see http://doc.babylonjs.com/resources/baking_transformations
  24828. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  24829. * @returns the current mesh
  24830. */
  24831. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  24832. /** @hidden */
  24833. get _positions(): Nullable<Vector3[]>;
  24834. /** @hidden */
  24835. _resetPointsArrayCache(): Mesh;
  24836. /** @hidden */
  24837. _generatePointsArray(): boolean;
  24838. /**
  24839. * Returns a new Mesh object generated from the current mesh properties.
  24840. * This method must not get confused with createInstance()
  24841. * @param name is a string, the name given to the new mesh
  24842. * @param newParent can be any Node object (default `null`)
  24843. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  24844. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  24845. * @returns a new mesh
  24846. */
  24847. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  24848. /**
  24849. * Releases resources associated with this mesh.
  24850. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24851. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24852. */
  24853. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24854. /** @hidden */
  24855. _disposeInstanceSpecificData(): void;
  24856. /**
  24857. * Modifies the mesh geometry according to a displacement map.
  24858. * A displacement map is a colored image. Each pixel color value (actually a gradient computed from red, green, blue values) will give the displacement to apply to each mesh vertex.
  24859. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  24860. * @param url is a string, the URL from the image file is to be downloaded.
  24861. * @param minHeight is the lower limit of the displacement.
  24862. * @param maxHeight is the upper limit of the displacement.
  24863. * @param onSuccess is an optional Javascript function to be called just after the mesh is modified. It is passed the modified mesh and must return nothing.
  24864. * @param uvOffset is an optional vector2 used to offset UV.
  24865. * @param uvScale is an optional vector2 used to scale UV.
  24866. * @param forceUpdate defines whether or not to force an update of the generated buffers. This is useful to apply on a deserialized model for instance.
  24867. * @returns the Mesh.
  24868. */
  24869. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  24870. /**
  24871. * Modifies the mesh geometry according to a displacementMap buffer.
  24872. * A displacement map is a colored image. Each pixel color value (actually a gradient computed from red, green, blue values) will give the displacement to apply to each mesh vertex.
  24873. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  24874. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  24875. * @param heightMapWidth is the width of the buffer image.
  24876. * @param heightMapHeight is the height of the buffer image.
  24877. * @param minHeight is the lower limit of the displacement.
  24878. * @param maxHeight is the upper limit of the displacement.
  24879. * @param onSuccess is an optional Javascript function to be called just after the mesh is modified. It is passed the modified mesh and must return nothing.
  24880. * @param uvOffset is an optional vector2 used to offset UV.
  24881. * @param uvScale is an optional vector2 used to scale UV.
  24882. * @param forceUpdate defines whether or not to force an update of the generated buffers. This is useful to apply on a deserialized model for instance.
  24883. * @returns the Mesh.
  24884. */
  24885. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  24886. /**
  24887. * Modify the mesh to get a flat shading rendering.
  24888. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  24889. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  24890. * @returns current mesh
  24891. */
  24892. convertToFlatShadedMesh(): Mesh;
  24893. /**
  24894. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  24895. * In other words, more vertices, no more indices and a single bigger VBO.
  24896. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  24897. * @returns current mesh
  24898. */
  24899. convertToUnIndexedMesh(): Mesh;
  24900. /**
  24901. * Inverses facet orientations.
  24902. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24903. * @param flipNormals will also inverts the normals
  24904. * @returns current mesh
  24905. */
  24906. flipFaces(flipNormals?: boolean): Mesh;
  24907. /**
  24908. * Increase the number of facets and hence vertices in a mesh
  24909. * Vertex normals are interpolated from existing vertex normals
  24910. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24911. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  24912. */
  24913. increaseVertices(numberPerEdge: number): void;
  24914. /**
  24915. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  24916. * This will undo any application of covertToFlatShadedMesh
  24917. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24918. */
  24919. forceSharedVertices(): void;
  24920. /** @hidden */
  24921. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  24922. /** @hidden */
  24923. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  24924. /**
  24925. * Creates a new InstancedMesh object from the mesh model.
  24926. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24927. * @param name defines the name of the new instance
  24928. * @returns a new InstancedMesh
  24929. */
  24930. createInstance(name: string): InstancedMesh;
  24931. /**
  24932. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  24933. * After this call, all the mesh instances have the same submeshes than the current mesh.
  24934. * @returns the current mesh
  24935. */
  24936. synchronizeInstances(): Mesh;
  24937. /**
  24938. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  24939. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  24940. * This should be used together with the simplification to avoid disappearing triangles.
  24941. * @param successCallback an optional success callback to be called after the optimization finished.
  24942. * @returns the current mesh
  24943. */
  24944. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  24945. /**
  24946. * Serialize current mesh
  24947. * @param serializationObject defines the object which will receive the serialization data
  24948. */
  24949. serialize(serializationObject: any): void;
  24950. /** @hidden */
  24951. _syncGeometryWithMorphTargetManager(): void;
  24952. /** @hidden */
  24953. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  24954. /**
  24955. * Returns a new Mesh object parsed from the source provided.
  24956. * @param parsedMesh is the source
  24957. * @param scene defines the hosting scene
  24958. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  24959. * @returns a new Mesh
  24960. */
  24961. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  24962. /**
  24963. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  24964. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24965. * @param name defines the name of the mesh to create
  24966. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  24967. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  24968. * @param closePath creates a seam between the first and the last points of each path of the path array
  24969. * @param offset is taken in account only if the `pathArray` is containing a single path
  24970. * @param scene defines the hosting scene
  24971. * @param updatable defines if the mesh must be flagged as updatable
  24972. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24973. * @param instance defines an instance of an existing Ribbon object to be updated with the passed `pathArray` parameter (http://doc.babylonjs.com/how_to/How_to_dynamically_morph_a_mesh#ribbon)
  24974. * @returns a new Mesh
  24975. */
  24976. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24977. /**
  24978. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  24979. * @param name defines the name of the mesh to create
  24980. * @param radius sets the radius size (float) of the polygon (default 0.5)
  24981. * @param tessellation sets the number of polygon sides (positive integer, default 64). So a tessellation valued to 3 will build a triangle, to 4 a square, etc
  24982. * @param scene defines the hosting scene
  24983. * @param updatable defines if the mesh must be flagged as updatable
  24984. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24985. * @returns a new Mesh
  24986. */
  24987. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  24988. /**
  24989. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  24990. * @param name defines the name of the mesh to create
  24991. * @param size sets the size (float) of each box side (default 1)
  24992. * @param scene defines the hosting scene
  24993. * @param updatable defines if the mesh must be flagged as updatable
  24994. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24995. * @returns a new Mesh
  24996. */
  24997. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  24998. /**
  24999. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  25000. * @param name defines the name of the mesh to create
  25001. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25002. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25003. * @param scene defines the hosting scene
  25004. * @param updatable defines if the mesh must be flagged as updatable
  25005. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25006. * @returns a new Mesh
  25007. */
  25008. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25009. /**
  25010. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  25011. * @param name defines the name of the mesh to create
  25012. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25013. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25014. * @param scene defines the hosting scene
  25015. * @returns a new Mesh
  25016. */
  25017. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  25018. /**
  25019. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  25020. * @param name defines the name of the mesh to create
  25021. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  25022. * @param diameterTop set the top cap diameter (floats, default 1)
  25023. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  25024. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  25025. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  25026. * @param scene defines the hosting scene
  25027. * @param updatable defines if the mesh must be flagged as updatable
  25028. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25029. * @returns a new Mesh
  25030. */
  25031. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  25032. /**
  25033. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  25034. * @param name defines the name of the mesh to create
  25035. * @param diameter sets the diameter size (float) of the torus (default 1)
  25036. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  25037. * @param tessellation sets the number of torus sides (postive integer, default 16)
  25038. * @param scene defines the hosting scene
  25039. * @param updatable defines if the mesh must be flagged as updatable
  25040. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25041. * @returns a new Mesh
  25042. */
  25043. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25044. /**
  25045. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  25046. * @param name defines the name of the mesh to create
  25047. * @param radius sets the global radius size (float) of the torus knot (default 2)
  25048. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  25049. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  25050. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  25051. * @param p the number of windings on X axis (positive integers, default 2)
  25052. * @param q the number of windings on Y axis (positive integers, default 3)
  25053. * @param scene defines the hosting scene
  25054. * @param updatable defines if the mesh must be flagged as updatable
  25055. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25056. * @returns a new Mesh
  25057. */
  25058. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25059. /**
  25060. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  25061. * @param name defines the name of the mesh to create
  25062. * @param points is an array successive Vector3
  25063. * @param scene defines the hosting scene
  25064. * @param updatable defines if the mesh must be flagged as updatable
  25065. * @param instance is an instance of an existing LineMesh object to be updated with the passed `points` parameter (http://doc.babylonjs.com/how_to/How_to_dynamically_morph_a_mesh#lines-and-dashedlines).
  25066. * @returns a new Mesh
  25067. */
  25068. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  25069. /**
  25070. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  25071. * @param name defines the name of the mesh to create
  25072. * @param points is an array successive Vector3
  25073. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  25074. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  25075. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  25076. * @param scene defines the hosting scene
  25077. * @param updatable defines if the mesh must be flagged as updatable
  25078. * @param instance is an instance of an existing LineMesh object to be updated with the passed `points` parameter (http://doc.babylonjs.com/how_to/How_to_dynamically_morph_a_mesh#lines-and-dashedlines)
  25079. * @returns a new Mesh
  25080. */
  25081. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  25082. /**
  25083. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  25084. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  25085. * The parameter `shape` is a required array of successive Vector3 representing the corners of the polygon in th XoZ plane, that is y = 0 for all vectors.
  25086. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25087. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  25088. * Remember you can only change the shape positions, not their number when updating a polygon.
  25089. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  25090. * @param name defines the name of the mesh to create
  25091. * @param shape is a required array of successive Vector3 representing the corners of the polygon in th XoZ plane, that is y = 0 for all vectors
  25092. * @param scene defines the hosting scene
  25093. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25094. * @param updatable defines if the mesh must be flagged as updatable
  25095. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25096. * @param earcutInjection can be used to inject your own earcut reference
  25097. * @returns a new Mesh
  25098. */
  25099. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25100. /**
  25101. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  25102. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  25103. * @param name defines the name of the mesh to create
  25104. * @param shape is a required array of successive Vector3 representing the corners of the polygon in th XoZ plane, that is y = 0 for all vectors
  25105. * @param depth defines the height of extrusion
  25106. * @param scene defines the hosting scene
  25107. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25108. * @param updatable defines if the mesh must be flagged as updatable
  25109. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25110. * @param earcutInjection can be used to inject your own earcut reference
  25111. * @returns a new Mesh
  25112. */
  25113. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25114. /**
  25115. * Creates an extruded shape mesh.
  25116. * The extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters. Please consider using the same method from the MeshBuilder class instead
  25117. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25118. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25119. * @param name defines the name of the mesh to create
  25120. * @param shape is a required array of successive Vector3. This array depicts the shape to be extruded in its local space : the shape must be designed in the xOy plane and will be extruded along the Z axis
  25121. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25122. * @param scale is the value to scale the shape
  25123. * @param rotation is the angle value to rotate the shape each step (each path point), from the former step (so rotation added each step) along the curve
  25124. * @param cap sets the way the extruded shape is capped. Possible values : Mesh.NO_CAP (default), Mesh.CAP_START, Mesh.CAP_END, Mesh.CAP_ALL
  25125. * @param scene defines the hosting scene
  25126. * @param updatable defines if the mesh must be flagged as updatable
  25127. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25128. * @param instance is an instance of an existing ExtrudedShape object to be updated with the passed `shape`, `path`, `scale` or `rotation` parameters (http://doc.babylonjs.com/how_to/How_to_dynamically_morph_a_mesh#extruded-shape)
  25129. * @returns a new Mesh
  25130. */
  25131. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25132. /**
  25133. * Creates an custom extruded shape mesh.
  25134. * The custom extrusion is a parametric shape.
  25135. * It has no predefined shape. Its final shape will depend on the input parameters.
  25136. * Please consider using the same method from the MeshBuilder class instead
  25137. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25138. * @param name defines the name of the mesh to create
  25139. * @param shape is a required array of successive Vector3. This array depicts the shape to be extruded in its local space : the shape must be designed in the xOy plane and will be extruded along the Z axis
  25140. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25141. * @param scaleFunction is a custom Javascript function called on each path point
  25142. * @param rotationFunction is a custom Javascript function called on each path point
  25143. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  25144. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  25145. * @param cap sets the way the extruded shape is capped. Possible values : Mesh.NO_CAP (default), Mesh.CAP_START, Mesh.CAP_END, Mesh.CAP_ALL
  25146. * @param scene defines the hosting scene
  25147. * @param updatable defines if the mesh must be flagged as updatable
  25148. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25149. * @param instance is an instance of an existing ExtrudedShape object to be updated with the passed `shape`, `path`, `scale` or `rotation` parameters (http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#extruded-shape)
  25150. * @returns a new Mesh
  25151. */
  25152. static ExtrudeShapeCustom(name: string, shape: Vector3[], path: Vector3[], scaleFunction: Function, rotationFunction: Function, ribbonCloseArray: boolean, ribbonClosePath: boolean, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25153. /**
  25154. * Creates lathe mesh.
  25155. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  25156. * Please consider using the same method from the MeshBuilder class instead
  25157. * @param name defines the name of the mesh to create
  25158. * @param shape is a required array of successive Vector3. This array depicts the shape to be rotated in its local space : the shape must be designed in the xOy plane and will be rotated around the Y axis. It's usually a 2D shape, so the Vector3 z coordinates are often set to zero
  25159. * @param radius is the radius value of the lathe
  25160. * @param tessellation is the side number of the lathe.
  25161. * @param scene defines the hosting scene
  25162. * @param updatable defines if the mesh must be flagged as updatable
  25163. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25164. * @returns a new Mesh
  25165. */
  25166. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25167. /**
  25168. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  25169. * @param name defines the name of the mesh to create
  25170. * @param size sets the size (float) of both sides of the plane at once (default 1)
  25171. * @param scene defines the hosting scene
  25172. * @param updatable defines if the mesh must be flagged as updatable
  25173. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25174. * @returns a new Mesh
  25175. */
  25176. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25177. /**
  25178. * Creates a ground mesh.
  25179. * Please consider using the same method from the MeshBuilder class instead
  25180. * @param name defines the name of the mesh to create
  25181. * @param width set the width of the ground
  25182. * @param height set the height of the ground
  25183. * @param subdivisions sets the number of subdivisions per side
  25184. * @param scene defines the hosting scene
  25185. * @param updatable defines if the mesh must be flagged as updatable
  25186. * @returns a new Mesh
  25187. */
  25188. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  25189. /**
  25190. * Creates a tiled ground mesh.
  25191. * Please consider using the same method from the MeshBuilder class instead
  25192. * @param name defines the name of the mesh to create
  25193. * @param xmin set the ground minimum X coordinate
  25194. * @param zmin set the ground minimum Y coordinate
  25195. * @param xmax set the ground maximum X coordinate
  25196. * @param zmax set the ground maximum Z coordinate
  25197. * @param subdivisions is an object `{w: positive integer, h: positive integer}` (default `{w: 6, h: 6}`). `w` and `h` are the numbers of subdivisions on the ground width and height. Each subdivision is called a tile
  25198. * @param precision is an object `{w: positive integer, h: positive integer}` (default `{w: 2, h: 2}`). `w` and `h` are the numbers of subdivisions on the ground width and height of each tile
  25199. * @param scene defines the hosting scene
  25200. * @param updatable defines if the mesh must be flagged as updatable
  25201. * @returns a new Mesh
  25202. */
  25203. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  25204. w: number;
  25205. h: number;
  25206. }, precision: {
  25207. w: number;
  25208. h: number;
  25209. }, scene: Scene, updatable?: boolean): Mesh;
  25210. /**
  25211. * Creates a ground mesh from a height map.
  25212. * Please consider using the same method from the MeshBuilder class instead
  25213. * @see http://doc.babylonjs.com/babylon101/height_map
  25214. * @param name defines the name of the mesh to create
  25215. * @param url sets the URL of the height map image resource
  25216. * @param width set the ground width size
  25217. * @param height set the ground height size
  25218. * @param subdivisions sets the number of subdivision per side
  25219. * @param minHeight is the minimum altitude on the ground
  25220. * @param maxHeight is the maximum altitude on the ground
  25221. * @param scene defines the hosting scene
  25222. * @param updatable defines if the mesh must be flagged as updatable
  25223. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  25224. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  25225. * @returns a new Mesh
  25226. */
  25227. static CreateGroundFromHeightMap(name: string, url: string, width: number, height: number, subdivisions: number, minHeight: number, maxHeight: number, scene: Scene, updatable?: boolean, onReady?: (mesh: GroundMesh) => void, alphaFilter?: number): GroundMesh;
  25228. /**
  25229. * Creates a tube mesh.
  25230. * The tube is a parametric shape.
  25231. * It has no predefined shape. Its final shape will depend on the input parameters.
  25232. * Please consider using the same method from the MeshBuilder class instead
  25233. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25234. * @param name defines the name of the mesh to create
  25235. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  25236. * @param radius sets the tube radius size
  25237. * @param tessellation is the number of sides on the tubular surface
  25238. * @param radiusFunction is a custom function. If it is not null, it overwrittes the parameter `radius`. This function is called on each point of the tube path and is passed the index `i` of the i-th point and the distance of this point from the first point of the path
  25239. * @param cap sets the way the extruded shape is capped. Possible values : Mesh.NO_CAP (default), Mesh.CAP_START, Mesh.CAP_END, Mesh.CAP_ALL
  25240. * @param scene defines the hosting scene
  25241. * @param updatable defines if the mesh must be flagged as updatable
  25242. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25243. * @param instance is an instance of an existing Tube object to be updated with the passed `pathArray` parameter (http://doc.babylonjs.com/how_to/How_to_dynamically_morph_a_mesh#tube)
  25244. * @returns a new Mesh
  25245. */
  25246. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  25247. (i: number, distance: number): number;
  25248. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25249. /**
  25250. * Creates a polyhedron mesh.
  25251. * Please consider using the same method from the MeshBuilder class instead.
  25252. * * The parameter `type` (positive integer, max 14, default 0) sets the polyhedron type to build among the 15 embbeded types. Please refer to the type sheet in the tutorial to choose the wanted type
  25253. * * The parameter `size` (positive float, default 1) sets the polygon size
  25254. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  25255. * * You can build other polyhedron types than the 15 embbeded ones by setting the parameter `custom` (`polyhedronObject`, default null). If you set the parameter `custom`, this overwrittes the parameter `type`
  25256. * * A `polyhedronObject` is a formatted javascript object. You'll find a full file with pre-set polyhedra here : https://github.com/BabylonJS/Extensions/tree/master/Polyhedron
  25257. * * You can set the color and the UV of each side of the polyhedron with the parameters `faceColors` (Color4, default `(1, 1, 1, 1)`) and faceUV (Vector4, default `(0, 0, 1, 1)`)
  25258. * * To understand how to set `faceUV` or `faceColors`, please read this by considering the right number of faces of your polyhedron, instead of only 6 for the box : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  25259. * * The parameter `flat` (boolean, default true). If set to false, it gives the polyhedron a single global face, so less vertices and shared normals. In this case, `faceColors` and `faceUV` are ignored
  25260. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25261. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  25262. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25263. * @param name defines the name of the mesh to create
  25264. * @param options defines the options used to create the mesh
  25265. * @param scene defines the hosting scene
  25266. * @returns a new Mesh
  25267. */
  25268. static CreatePolyhedron(name: string, options: {
  25269. type?: number;
  25270. size?: number;
  25271. sizeX?: number;
  25272. sizeY?: number;
  25273. sizeZ?: number;
  25274. custom?: any;
  25275. faceUV?: Vector4[];
  25276. faceColors?: Color4[];
  25277. updatable?: boolean;
  25278. sideOrientation?: number;
  25279. }, scene: Scene): Mesh;
  25280. /**
  25281. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  25282. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  25283. * * You can set some different icosphere dimensions, for instance to build an ellipsoid, by using the parameters `radiusX`, `radiusY` and `radiusZ` (all by default have the same value than `radius`)
  25284. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  25285. * * The parameter `flat` (boolean, default true) gives each side its own normals. Set it to false to get a smooth continuous light reflection on the surface
  25286. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25287. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  25288. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25289. * @param name defines the name of the mesh
  25290. * @param options defines the options used to create the mesh
  25291. * @param scene defines the hosting scene
  25292. * @returns a new Mesh
  25293. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  25294. */
  25295. static CreateIcoSphere(name: string, options: {
  25296. radius?: number;
  25297. flat?: boolean;
  25298. subdivisions?: number;
  25299. sideOrientation?: number;
  25300. updatable?: boolean;
  25301. }, scene: Scene): Mesh;
  25302. /**
  25303. * Creates a decal mesh.
  25304. * Please consider using the same method from the MeshBuilder class instead.
  25305. * A decal is a mesh usually applied as a model onto the surface of another mesh
  25306. * @param name defines the name of the mesh
  25307. * @param sourceMesh defines the mesh receiving the decal
  25308. * @param position sets the position of the decal in world coordinates
  25309. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  25310. * @param size sets the decal scaling
  25311. * @param angle sets the angle to rotate the decal
  25312. * @returns a new Mesh
  25313. */
  25314. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  25315. /**
  25316. * Prepare internal position array for software CPU skinning
  25317. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  25318. */
  25319. setPositionsForCPUSkinning(): Float32Array;
  25320. /**
  25321. * Prepare internal normal array for software CPU skinning
  25322. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  25323. */
  25324. setNormalsForCPUSkinning(): Float32Array;
  25325. /**
  25326. * Updates the vertex buffer by applying transformation from the bones
  25327. * @param skeleton defines the skeleton to apply to current mesh
  25328. * @returns the current mesh
  25329. */
  25330. applySkeleton(skeleton: Skeleton): Mesh;
  25331. /**
  25332. * Returns an object containing a min and max Vector3 which are the minimum and maximum vectors of each mesh bounding box from the passed array, in the world coordinates
  25333. * @param meshes defines the list of meshes to scan
  25334. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  25335. */
  25336. static MinMax(meshes: AbstractMesh[]): {
  25337. min: Vector3;
  25338. max: Vector3;
  25339. };
  25340. /**
  25341. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  25342. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  25343. * @returns a vector3
  25344. */
  25345. static Center(meshesOrMinMaxVector: {
  25346. min: Vector3;
  25347. max: Vector3;
  25348. } | AbstractMesh[]): Vector3;
  25349. /**
  25350. * Merge the array of meshes into a single mesh for performance reasons.
  25351. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  25352. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  25353. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  25354. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  25355. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  25356. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  25357. * @returns a new mesh
  25358. */
  25359. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  25360. /** @hidden */
  25361. addInstance(instance: InstancedMesh): void;
  25362. /** @hidden */
  25363. removeInstance(instance: InstancedMesh): void;
  25364. }
  25365. }
  25366. declare module BABYLON {
  25367. /**
  25368. * This is the base class of all the camera used in the application.
  25369. * @see http://doc.babylonjs.com/features/cameras
  25370. */
  25371. export class Camera extends Node {
  25372. /** @hidden */
  25373. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  25374. /**
  25375. * This is the default projection mode used by the cameras.
  25376. * It helps recreating a feeling of perspective and better appreciate depth.
  25377. * This is the best way to simulate real life cameras.
  25378. */
  25379. static readonly PERSPECTIVE_CAMERA: number;
  25380. /**
  25381. * This helps creating camera with an orthographic mode.
  25382. * Orthographic is commonly used in engineering as a means to produce object specifications that communicate dimensions unambiguously, each line of 1 unit length (cm, meter..whatever) will appear to have the same length everywhere on the drawing. This allows the drafter to dimension only a subset of lines and let the reader know that other lines of that length on the drawing are also that length in reality. Every parallel line in the drawing is also parallel in the object.
  25383. */
  25384. static readonly ORTHOGRAPHIC_CAMERA: number;
  25385. /**
  25386. * This is the default FOV mode for perspective cameras.
  25387. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  25388. */
  25389. static readonly FOVMODE_VERTICAL_FIXED: number;
  25390. /**
  25391. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  25392. */
  25393. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  25394. /**
  25395. * This specifies ther is no need for a camera rig.
  25396. * Basically only one eye is rendered corresponding to the camera.
  25397. */
  25398. static readonly RIG_MODE_NONE: number;
  25399. /**
  25400. * Simulates a camera Rig with one blue eye and one red eye.
  25401. * This can be use with 3d blue and red glasses.
  25402. */
  25403. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  25404. /**
  25405. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  25406. */
  25407. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  25408. /**
  25409. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  25410. */
  25411. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  25412. /**
  25413. * Defines that both eyes of the camera will be rendered over under each other.
  25414. */
  25415. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  25416. /**
  25417. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  25418. */
  25419. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  25420. /**
  25421. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  25422. */
  25423. static readonly RIG_MODE_VR: number;
  25424. /**
  25425. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  25426. */
  25427. static readonly RIG_MODE_WEBVR: number;
  25428. /**
  25429. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  25430. */
  25431. static readonly RIG_MODE_CUSTOM: number;
  25432. /**
  25433. * Defines if by default attaching controls should prevent the default javascript event to continue.
  25434. */
  25435. static ForceAttachControlToAlwaysPreventDefault: boolean;
  25436. /**
  25437. * Define the input manager associated with the camera.
  25438. */
  25439. inputs: CameraInputsManager<Camera>;
  25440. /** @hidden */
  25441. _position: Vector3;
  25442. /**
  25443. * Define the current local position of the camera in the scene
  25444. */
  25445. get position(): Vector3;
  25446. set position(newPosition: Vector3);
  25447. /**
  25448. * The vector the camera should consider as up.
  25449. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  25450. */
  25451. upVector: Vector3;
  25452. /**
  25453. * Define the current limit on the left side for an orthographic camera
  25454. * In scene unit
  25455. */
  25456. orthoLeft: Nullable<number>;
  25457. /**
  25458. * Define the current limit on the right side for an orthographic camera
  25459. * In scene unit
  25460. */
  25461. orthoRight: Nullable<number>;
  25462. /**
  25463. * Define the current limit on the bottom side for an orthographic camera
  25464. * In scene unit
  25465. */
  25466. orthoBottom: Nullable<number>;
  25467. /**
  25468. * Define the current limit on the top side for an orthographic camera
  25469. * In scene unit
  25470. */
  25471. orthoTop: Nullable<number>;
  25472. /**
  25473. * Field Of View is set in Radians. (default is 0.8)
  25474. */
  25475. fov: number;
  25476. /**
  25477. * Define the minimum distance the camera can see from.
  25478. * This is important to note that the depth buffer are not infinite and the closer it starts
  25479. * the more your scene might encounter depth fighting issue.
  25480. */
  25481. minZ: number;
  25482. /**
  25483. * Define the maximum distance the camera can see to.
  25484. * This is important to note that the depth buffer are not infinite and the further it end
  25485. * the more your scene might encounter depth fighting issue.
  25486. */
  25487. maxZ: number;
  25488. /**
  25489. * Define the default inertia of the camera.
  25490. * This helps giving a smooth feeling to the camera movement.
  25491. */
  25492. inertia: number;
  25493. /**
  25494. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  25495. */
  25496. mode: number;
  25497. /**
  25498. * Define whether the camera is intermediate.
  25499. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  25500. */
  25501. isIntermediate: boolean;
  25502. /**
  25503. * Define the viewport of the camera.
  25504. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  25505. */
  25506. viewport: Viewport;
  25507. /**
  25508. * Restricts the camera to viewing objects with the same layerMask.
  25509. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  25510. */
  25511. layerMask: number;
  25512. /**
  25513. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  25514. */
  25515. fovMode: number;
  25516. /**
  25517. * Rig mode of the camera.
  25518. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  25519. * This is normally controlled byt the camera themselves as internal use.
  25520. */
  25521. cameraRigMode: number;
  25522. /**
  25523. * Defines the distance between both "eyes" in case of a RIG
  25524. */
  25525. interaxialDistance: number;
  25526. /**
  25527. * Defines if stereoscopic rendering is done side by side or over under.
  25528. */
  25529. isStereoscopicSideBySide: boolean;
  25530. /**
  25531. * Defines the list of custom render target which are rendered to and then used as the input to this camera's render. Eg. display another camera view on a TV in the main scene
  25532. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  25533. * else in the scene. (Eg. security camera)
  25534. *
  25535. * To change the final output target of the camera, camera.outputRenderTarget should be used instead (eg. webXR renders to a render target corrisponding to an HMD)
  25536. */
  25537. customRenderTargets: RenderTargetTexture[];
  25538. /**
  25539. * When set, the camera will render to this render target instead of the default canvas
  25540. *
  25541. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  25542. */
  25543. outputRenderTarget: Nullable<RenderTargetTexture>;
  25544. /**
  25545. * Observable triggered when the camera view matrix has changed.
  25546. */
  25547. onViewMatrixChangedObservable: Observable<Camera>;
  25548. /**
  25549. * Observable triggered when the camera Projection matrix has changed.
  25550. */
  25551. onProjectionMatrixChangedObservable: Observable<Camera>;
  25552. /**
  25553. * Observable triggered when the inputs have been processed.
  25554. */
  25555. onAfterCheckInputsObservable: Observable<Camera>;
  25556. /**
  25557. * Observable triggered when reset has been called and applied to the camera.
  25558. */
  25559. onRestoreStateObservable: Observable<Camera>;
  25560. /**
  25561. * Is this camera a part of a rig system?
  25562. */
  25563. isRigCamera: boolean;
  25564. /**
  25565. * If isRigCamera set to true this will be set with the parent camera.
  25566. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  25567. */
  25568. rigParent?: Camera;
  25569. /** @hidden */
  25570. _cameraRigParams: any;
  25571. /** @hidden */
  25572. _rigCameras: Camera[];
  25573. /** @hidden */
  25574. _rigPostProcess: Nullable<PostProcess>;
  25575. protected _webvrViewMatrix: Matrix;
  25576. /** @hidden */
  25577. _skipRendering: boolean;
  25578. /** @hidden */
  25579. _projectionMatrix: Matrix;
  25580. /** @hidden */
  25581. _postProcesses: Nullable<PostProcess>[];
  25582. /** @hidden */
  25583. _activeMeshes: SmartArray<AbstractMesh>;
  25584. protected _globalPosition: Vector3;
  25585. /** @hidden */
  25586. _computedViewMatrix: Matrix;
  25587. private _doNotComputeProjectionMatrix;
  25588. private _transformMatrix;
  25589. private _frustumPlanes;
  25590. private _refreshFrustumPlanes;
  25591. private _storedFov;
  25592. private _stateStored;
  25593. /**
  25594. * Instantiates a new camera object.
  25595. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  25596. * @see http://doc.babylonjs.com/features/cameras
  25597. * @param name Defines the name of the camera in the scene
  25598. * @param position Defines the position of the camera
  25599. * @param scene Defines the scene the camera belongs too
  25600. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  25601. */
  25602. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  25603. /**
  25604. * Store current camera state (fov, position, etc..)
  25605. * @returns the camera
  25606. */
  25607. storeState(): Camera;
  25608. /**
  25609. * Restores the camera state values if it has been stored. You must call storeState() first
  25610. */
  25611. protected _restoreStateValues(): boolean;
  25612. /**
  25613. * Restored camera state. You must call storeState() first.
  25614. * @returns true if restored and false otherwise
  25615. */
  25616. restoreState(): boolean;
  25617. /**
  25618. * Gets the class name of the camera.
  25619. * @returns the class name
  25620. */
  25621. getClassName(): string;
  25622. /** @hidden */
  25623. readonly _isCamera: boolean;
  25624. /**
  25625. * Gets a string representation of the camera useful for debug purpose.
  25626. * @param fullDetails Defines that a more verboe level of logging is required
  25627. * @returns the string representation
  25628. */
  25629. toString(fullDetails?: boolean): string;
  25630. /**
  25631. * Gets the current world space position of the camera.
  25632. */
  25633. get globalPosition(): Vector3;
  25634. /**
  25635. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  25636. * @returns the active meshe list
  25637. */
  25638. getActiveMeshes(): SmartArray<AbstractMesh>;
  25639. /**
  25640. * Check whether a mesh is part of the current active mesh list of the camera
  25641. * @param mesh Defines the mesh to check
  25642. * @returns true if active, false otherwise
  25643. */
  25644. isActiveMesh(mesh: Mesh): boolean;
  25645. /**
  25646. * Is this camera ready to be used/rendered
  25647. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  25648. * @return true if the camera is ready
  25649. */
  25650. isReady(completeCheck?: boolean): boolean;
  25651. /** @hidden */
  25652. _initCache(): void;
  25653. /** @hidden */
  25654. _updateCache(ignoreParentClass?: boolean): void;
  25655. /** @hidden */
  25656. _isSynchronized(): boolean;
  25657. /** @hidden */
  25658. _isSynchronizedViewMatrix(): boolean;
  25659. /** @hidden */
  25660. _isSynchronizedProjectionMatrix(): boolean;
  25661. /**
  25662. * Attach the input controls to a specific dom element to get the input from.
  25663. * @param element Defines the element the controls should be listened from
  25664. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  25665. */
  25666. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  25667. /**
  25668. * Detach the current controls from the specified dom element.
  25669. * @param element Defines the element to stop listening the inputs from
  25670. */
  25671. detachControl(element: HTMLElement): void;
  25672. /**
  25673. * Update the camera state according to the different inputs gathered during the frame.
  25674. */
  25675. update(): void;
  25676. /** @hidden */
  25677. _checkInputs(): void;
  25678. /** @hidden */
  25679. get rigCameras(): Camera[];
  25680. /**
  25681. * Gets the post process used by the rig cameras
  25682. */
  25683. get rigPostProcess(): Nullable<PostProcess>;
  25684. /**
  25685. * Internal, gets the first post proces.
  25686. * @returns the first post process to be run on this camera.
  25687. */
  25688. _getFirstPostProcess(): Nullable<PostProcess>;
  25689. private _cascadePostProcessesToRigCams;
  25690. /**
  25691. * Attach a post process to the camera.
  25692. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25693. * @param postProcess The post process to attach to the camera
  25694. * @param insertAt The position of the post process in case several of them are in use in the scene
  25695. * @returns the position the post process has been inserted at
  25696. */
  25697. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  25698. /**
  25699. * Detach a post process to the camera.
  25700. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25701. * @param postProcess The post process to detach from the camera
  25702. */
  25703. detachPostProcess(postProcess: PostProcess): void;
  25704. /**
  25705. * Gets the current world matrix of the camera
  25706. */
  25707. getWorldMatrix(): Matrix;
  25708. /** @hidden */
  25709. _getViewMatrix(): Matrix;
  25710. /**
  25711. * Gets the current view matrix of the camera.
  25712. * @param force forces the camera to recompute the matrix without looking at the cached state
  25713. * @returns the view matrix
  25714. */
  25715. getViewMatrix(force?: boolean): Matrix;
  25716. /**
  25717. * Freeze the projection matrix.
  25718. * It will prevent the cache check of the camera projection compute and can speed up perf
  25719. * if no parameter of the camera are meant to change
  25720. * @param projection Defines manually a projection if necessary
  25721. */
  25722. freezeProjectionMatrix(projection?: Matrix): void;
  25723. /**
  25724. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  25725. */
  25726. unfreezeProjectionMatrix(): void;
  25727. /**
  25728. * Gets the current projection matrix of the camera.
  25729. * @param force forces the camera to recompute the matrix without looking at the cached state
  25730. * @returns the projection matrix
  25731. */
  25732. getProjectionMatrix(force?: boolean): Matrix;
  25733. /**
  25734. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  25735. * @returns a Matrix
  25736. */
  25737. getTransformationMatrix(): Matrix;
  25738. private _updateFrustumPlanes;
  25739. /**
  25740. * Checks if a cullable object (mesh...) is in the camera frustum
  25741. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  25742. * @param target The object to check
  25743. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  25744. * @returns true if the object is in frustum otherwise false
  25745. */
  25746. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  25747. /**
  25748. * Checks if a cullable object (mesh...) is in the camera frustum
  25749. * Unlike isInFrustum this cheks the full bounding box
  25750. * @param target The object to check
  25751. * @returns true if the object is in frustum otherwise false
  25752. */
  25753. isCompletelyInFrustum(target: ICullable): boolean;
  25754. /**
  25755. * Gets a ray in the forward direction from the camera.
  25756. * @param length Defines the length of the ray to create
  25757. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  25758. * @param origin Defines the start point of the ray which defaults to the camera position
  25759. * @returns the forward ray
  25760. */
  25761. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  25762. /**
  25763. * Releases resources associated with this node.
  25764. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25765. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25766. */
  25767. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25768. /** @hidden */
  25769. _isLeftCamera: boolean;
  25770. /**
  25771. * Gets the left camera of a rig setup in case of Rigged Camera
  25772. */
  25773. get isLeftCamera(): boolean;
  25774. /** @hidden */
  25775. _isRightCamera: boolean;
  25776. /**
  25777. * Gets the right camera of a rig setup in case of Rigged Camera
  25778. */
  25779. get isRightCamera(): boolean;
  25780. /**
  25781. * Gets the left camera of a rig setup in case of Rigged Camera
  25782. */
  25783. get leftCamera(): Nullable<FreeCamera>;
  25784. /**
  25785. * Gets the right camera of a rig setup in case of Rigged Camera
  25786. */
  25787. get rightCamera(): Nullable<FreeCamera>;
  25788. /**
  25789. * Gets the left camera target of a rig setup in case of Rigged Camera
  25790. * @returns the target position
  25791. */
  25792. getLeftTarget(): Nullable<Vector3>;
  25793. /**
  25794. * Gets the right camera target of a rig setup in case of Rigged Camera
  25795. * @returns the target position
  25796. */
  25797. getRightTarget(): Nullable<Vector3>;
  25798. /**
  25799. * @hidden
  25800. */
  25801. setCameraRigMode(mode: number, rigParams: any): void;
  25802. /** @hidden */
  25803. static _setStereoscopicRigMode(camera: Camera): void;
  25804. /** @hidden */
  25805. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  25806. /** @hidden */
  25807. static _setVRRigMode(camera: Camera, rigParams: any): void;
  25808. /** @hidden */
  25809. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  25810. /** @hidden */
  25811. _getVRProjectionMatrix(): Matrix;
  25812. protected _updateCameraRotationMatrix(): void;
  25813. protected _updateWebVRCameraRotationMatrix(): void;
  25814. /**
  25815. * This function MUST be overwritten by the different WebVR cameras available.
  25816. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25817. * @hidden
  25818. */
  25819. _getWebVRProjectionMatrix(): Matrix;
  25820. /**
  25821. * This function MUST be overwritten by the different WebVR cameras available.
  25822. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25823. * @hidden
  25824. */
  25825. _getWebVRViewMatrix(): Matrix;
  25826. /** @hidden */
  25827. setCameraRigParameter(name: string, value: any): void;
  25828. /**
  25829. * needs to be overridden by children so sub has required properties to be copied
  25830. * @hidden
  25831. */
  25832. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  25833. /**
  25834. * May need to be overridden by children
  25835. * @hidden
  25836. */
  25837. _updateRigCameras(): void;
  25838. /** @hidden */
  25839. _setupInputs(): void;
  25840. /**
  25841. * Serialiaze the camera setup to a json represention
  25842. * @returns the JSON representation
  25843. */
  25844. serialize(): any;
  25845. /**
  25846. * Clones the current camera.
  25847. * @param name The cloned camera name
  25848. * @returns the cloned camera
  25849. */
  25850. clone(name: string): Camera;
  25851. /**
  25852. * Gets the direction of the camera relative to a given local axis.
  25853. * @param localAxis Defines the reference axis to provide a relative direction.
  25854. * @return the direction
  25855. */
  25856. getDirection(localAxis: Vector3): Vector3;
  25857. /**
  25858. * Returns the current camera absolute rotation
  25859. */
  25860. get absoluteRotation(): Quaternion;
  25861. /**
  25862. * Gets the direction of the camera relative to a given local axis into a passed vector.
  25863. * @param localAxis Defines the reference axis to provide a relative direction.
  25864. * @param result Defines the vector to store the result in
  25865. */
  25866. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  25867. /**
  25868. * Gets a camera constructor for a given camera type
  25869. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  25870. * @param name The name of the camera the result will be able to instantiate
  25871. * @param scene The scene the result will construct the camera in
  25872. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  25873. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  25874. * @returns a factory method to construc the camera
  25875. */
  25876. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  25877. /**
  25878. * Compute the world matrix of the camera.
  25879. * @returns the camera world matrix
  25880. */
  25881. computeWorldMatrix(): Matrix;
  25882. /**
  25883. * Parse a JSON and creates the camera from the parsed information
  25884. * @param parsedCamera The JSON to parse
  25885. * @param scene The scene to instantiate the camera in
  25886. * @returns the newly constructed camera
  25887. */
  25888. static Parse(parsedCamera: any, scene: Scene): Camera;
  25889. }
  25890. }
  25891. declare module BABYLON {
  25892. /**
  25893. * Class containing static functions to help procedurally build meshes
  25894. */
  25895. export class DiscBuilder {
  25896. /**
  25897. * Creates a plane polygonal mesh. By default, this is a disc
  25898. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  25899. * * The parameter `tessellation` sets the number of polygon sides (positive integer, default 64). So a tessellation valued to 3 will build a triangle, to 4 a square, etc
  25900. * * You can create an unclosed polygon with the parameter `arc` (positive float, default 1), valued between 0 and 1, what is the ratio of the circumference : 2 x PI x ratio
  25901. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  25902. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  25903. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25904. * @param name defines the name of the mesh
  25905. * @param options defines the options used to create the mesh
  25906. * @param scene defines the hosting scene
  25907. * @returns the plane polygonal mesh
  25908. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  25909. */
  25910. static CreateDisc(name: string, options: {
  25911. radius?: number;
  25912. tessellation?: number;
  25913. arc?: number;
  25914. updatable?: boolean;
  25915. sideOrientation?: number;
  25916. frontUVs?: Vector4;
  25917. backUVs?: Vector4;
  25918. }, scene?: Nullable<Scene>): Mesh;
  25919. }
  25920. }
  25921. declare module BABYLON {
  25922. /**
  25923. * This represents all the required information to add a fresnel effect on a material:
  25924. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  25925. */
  25926. export class FresnelParameters {
  25927. private _isEnabled;
  25928. /**
  25929. * Define if the fresnel effect is enable or not.
  25930. */
  25931. get isEnabled(): boolean;
  25932. set isEnabled(value: boolean);
  25933. /**
  25934. * Define the color used on edges (grazing angle)
  25935. */
  25936. leftColor: Color3;
  25937. /**
  25938. * Define the color used on center
  25939. */
  25940. rightColor: Color3;
  25941. /**
  25942. * Define bias applied to computed fresnel term
  25943. */
  25944. bias: number;
  25945. /**
  25946. * Defined the power exponent applied to fresnel term
  25947. */
  25948. power: number;
  25949. /**
  25950. * Clones the current fresnel and its valuues
  25951. * @returns a clone fresnel configuration
  25952. */
  25953. clone(): FresnelParameters;
  25954. /**
  25955. * Serializes the current fresnel parameters to a JSON representation.
  25956. * @return the JSON serialization
  25957. */
  25958. serialize(): any;
  25959. /**
  25960. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  25961. * @param parsedFresnelParameters Define the JSON representation
  25962. * @returns the parsed parameters
  25963. */
  25964. static Parse(parsedFresnelParameters: any): FresnelParameters;
  25965. }
  25966. }
  25967. declare module BABYLON {
  25968. /**
  25969. * Base class of materials working in push mode in babylon JS
  25970. * @hidden
  25971. */
  25972. export class PushMaterial extends Material {
  25973. protected _activeEffect: Effect;
  25974. protected _normalMatrix: Matrix;
  25975. /**
  25976. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  25977. * This means that the material can keep using a previous shader while a new one is being compiled.
  25978. * This is mostly used when shader parallel compilation is supported (true by default)
  25979. */
  25980. allowShaderHotSwapping: boolean;
  25981. constructor(name: string, scene: Scene);
  25982. getEffect(): Effect;
  25983. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  25984. /**
  25985. * Binds the given world matrix to the active effect
  25986. *
  25987. * @param world the matrix to bind
  25988. */
  25989. bindOnlyWorldMatrix(world: Matrix): void;
  25990. /**
  25991. * Binds the given normal matrix to the active effect
  25992. *
  25993. * @param normalMatrix the matrix to bind
  25994. */
  25995. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  25996. bind(world: Matrix, mesh?: Mesh): void;
  25997. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  25998. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  25999. }
  26000. }
  26001. declare module BABYLON {
  26002. /**
  26003. * This groups all the flags used to control the materials channel.
  26004. */
  26005. export class MaterialFlags {
  26006. private static _DiffuseTextureEnabled;
  26007. /**
  26008. * Are diffuse textures enabled in the application.
  26009. */
  26010. static get DiffuseTextureEnabled(): boolean;
  26011. static set DiffuseTextureEnabled(value: boolean);
  26012. private static _AmbientTextureEnabled;
  26013. /**
  26014. * Are ambient textures enabled in the application.
  26015. */
  26016. static get AmbientTextureEnabled(): boolean;
  26017. static set AmbientTextureEnabled(value: boolean);
  26018. private static _OpacityTextureEnabled;
  26019. /**
  26020. * Are opacity textures enabled in the application.
  26021. */
  26022. static get OpacityTextureEnabled(): boolean;
  26023. static set OpacityTextureEnabled(value: boolean);
  26024. private static _ReflectionTextureEnabled;
  26025. /**
  26026. * Are reflection textures enabled in the application.
  26027. */
  26028. static get ReflectionTextureEnabled(): boolean;
  26029. static set ReflectionTextureEnabled(value: boolean);
  26030. private static _EmissiveTextureEnabled;
  26031. /**
  26032. * Are emissive textures enabled in the application.
  26033. */
  26034. static get EmissiveTextureEnabled(): boolean;
  26035. static set EmissiveTextureEnabled(value: boolean);
  26036. private static _SpecularTextureEnabled;
  26037. /**
  26038. * Are specular textures enabled in the application.
  26039. */
  26040. static get SpecularTextureEnabled(): boolean;
  26041. static set SpecularTextureEnabled(value: boolean);
  26042. private static _BumpTextureEnabled;
  26043. /**
  26044. * Are bump textures enabled in the application.
  26045. */
  26046. static get BumpTextureEnabled(): boolean;
  26047. static set BumpTextureEnabled(value: boolean);
  26048. private static _LightmapTextureEnabled;
  26049. /**
  26050. * Are lightmap textures enabled in the application.
  26051. */
  26052. static get LightmapTextureEnabled(): boolean;
  26053. static set LightmapTextureEnabled(value: boolean);
  26054. private static _RefractionTextureEnabled;
  26055. /**
  26056. * Are refraction textures enabled in the application.
  26057. */
  26058. static get RefractionTextureEnabled(): boolean;
  26059. static set RefractionTextureEnabled(value: boolean);
  26060. private static _ColorGradingTextureEnabled;
  26061. /**
  26062. * Are color grading textures enabled in the application.
  26063. */
  26064. static get ColorGradingTextureEnabled(): boolean;
  26065. static set ColorGradingTextureEnabled(value: boolean);
  26066. private static _FresnelEnabled;
  26067. /**
  26068. * Are fresnels enabled in the application.
  26069. */
  26070. static get FresnelEnabled(): boolean;
  26071. static set FresnelEnabled(value: boolean);
  26072. private static _ClearCoatTextureEnabled;
  26073. /**
  26074. * Are clear coat textures enabled in the application.
  26075. */
  26076. static get ClearCoatTextureEnabled(): boolean;
  26077. static set ClearCoatTextureEnabled(value: boolean);
  26078. private static _ClearCoatBumpTextureEnabled;
  26079. /**
  26080. * Are clear coat bump textures enabled in the application.
  26081. */
  26082. static get ClearCoatBumpTextureEnabled(): boolean;
  26083. static set ClearCoatBumpTextureEnabled(value: boolean);
  26084. private static _ClearCoatTintTextureEnabled;
  26085. /**
  26086. * Are clear coat tint textures enabled in the application.
  26087. */
  26088. static get ClearCoatTintTextureEnabled(): boolean;
  26089. static set ClearCoatTintTextureEnabled(value: boolean);
  26090. private static _SheenTextureEnabled;
  26091. /**
  26092. * Are sheen textures enabled in the application.
  26093. */
  26094. static get SheenTextureEnabled(): boolean;
  26095. static set SheenTextureEnabled(value: boolean);
  26096. private static _AnisotropicTextureEnabled;
  26097. /**
  26098. * Are anisotropic textures enabled in the application.
  26099. */
  26100. static get AnisotropicTextureEnabled(): boolean;
  26101. static set AnisotropicTextureEnabled(value: boolean);
  26102. private static _ThicknessTextureEnabled;
  26103. /**
  26104. * Are thickness textures enabled in the application.
  26105. */
  26106. static get ThicknessTextureEnabled(): boolean;
  26107. static set ThicknessTextureEnabled(value: boolean);
  26108. }
  26109. }
  26110. declare module BABYLON {
  26111. /** @hidden */
  26112. export var defaultFragmentDeclaration: {
  26113. name: string;
  26114. shader: string;
  26115. };
  26116. }
  26117. declare module BABYLON {
  26118. /** @hidden */
  26119. export var defaultUboDeclaration: {
  26120. name: string;
  26121. shader: string;
  26122. };
  26123. }
  26124. declare module BABYLON {
  26125. /** @hidden */
  26126. export var lightFragmentDeclaration: {
  26127. name: string;
  26128. shader: string;
  26129. };
  26130. }
  26131. declare module BABYLON {
  26132. /** @hidden */
  26133. export var lightUboDeclaration: {
  26134. name: string;
  26135. shader: string;
  26136. };
  26137. }
  26138. declare module BABYLON {
  26139. /** @hidden */
  26140. export var lightsFragmentFunctions: {
  26141. name: string;
  26142. shader: string;
  26143. };
  26144. }
  26145. declare module BABYLON {
  26146. /** @hidden */
  26147. export var shadowsFragmentFunctions: {
  26148. name: string;
  26149. shader: string;
  26150. };
  26151. }
  26152. declare module BABYLON {
  26153. /** @hidden */
  26154. export var fresnelFunction: {
  26155. name: string;
  26156. shader: string;
  26157. };
  26158. }
  26159. declare module BABYLON {
  26160. /** @hidden */
  26161. export var reflectionFunction: {
  26162. name: string;
  26163. shader: string;
  26164. };
  26165. }
  26166. declare module BABYLON {
  26167. /** @hidden */
  26168. export var bumpFragmentFunctions: {
  26169. name: string;
  26170. shader: string;
  26171. };
  26172. }
  26173. declare module BABYLON {
  26174. /** @hidden */
  26175. export var logDepthDeclaration: {
  26176. name: string;
  26177. shader: string;
  26178. };
  26179. }
  26180. declare module BABYLON {
  26181. /** @hidden */
  26182. export var bumpFragment: {
  26183. name: string;
  26184. shader: string;
  26185. };
  26186. }
  26187. declare module BABYLON {
  26188. /** @hidden */
  26189. export var depthPrePass: {
  26190. name: string;
  26191. shader: string;
  26192. };
  26193. }
  26194. declare module BABYLON {
  26195. /** @hidden */
  26196. export var lightFragment: {
  26197. name: string;
  26198. shader: string;
  26199. };
  26200. }
  26201. declare module BABYLON {
  26202. /** @hidden */
  26203. export var logDepthFragment: {
  26204. name: string;
  26205. shader: string;
  26206. };
  26207. }
  26208. declare module BABYLON {
  26209. /** @hidden */
  26210. export var defaultPixelShader: {
  26211. name: string;
  26212. shader: string;
  26213. };
  26214. }
  26215. declare module BABYLON {
  26216. /** @hidden */
  26217. export var defaultVertexDeclaration: {
  26218. name: string;
  26219. shader: string;
  26220. };
  26221. }
  26222. declare module BABYLON {
  26223. /** @hidden */
  26224. export var bumpVertexDeclaration: {
  26225. name: string;
  26226. shader: string;
  26227. };
  26228. }
  26229. declare module BABYLON {
  26230. /** @hidden */
  26231. export var bumpVertex: {
  26232. name: string;
  26233. shader: string;
  26234. };
  26235. }
  26236. declare module BABYLON {
  26237. /** @hidden */
  26238. export var fogVertex: {
  26239. name: string;
  26240. shader: string;
  26241. };
  26242. }
  26243. declare module BABYLON {
  26244. /** @hidden */
  26245. export var shadowsVertex: {
  26246. name: string;
  26247. shader: string;
  26248. };
  26249. }
  26250. declare module BABYLON {
  26251. /** @hidden */
  26252. export var pointCloudVertex: {
  26253. name: string;
  26254. shader: string;
  26255. };
  26256. }
  26257. declare module BABYLON {
  26258. /** @hidden */
  26259. export var logDepthVertex: {
  26260. name: string;
  26261. shader: string;
  26262. };
  26263. }
  26264. declare module BABYLON {
  26265. /** @hidden */
  26266. export var defaultVertexShader: {
  26267. name: string;
  26268. shader: string;
  26269. };
  26270. }
  26271. declare module BABYLON {
  26272. /** @hidden */
  26273. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  26274. MAINUV1: boolean;
  26275. MAINUV2: boolean;
  26276. DIFFUSE: boolean;
  26277. DIFFUSEDIRECTUV: number;
  26278. AMBIENT: boolean;
  26279. AMBIENTDIRECTUV: number;
  26280. OPACITY: boolean;
  26281. OPACITYDIRECTUV: number;
  26282. OPACITYRGB: boolean;
  26283. REFLECTION: boolean;
  26284. EMISSIVE: boolean;
  26285. EMISSIVEDIRECTUV: number;
  26286. SPECULAR: boolean;
  26287. SPECULARDIRECTUV: number;
  26288. BUMP: boolean;
  26289. BUMPDIRECTUV: number;
  26290. PARALLAX: boolean;
  26291. PARALLAXOCCLUSION: boolean;
  26292. SPECULAROVERALPHA: boolean;
  26293. CLIPPLANE: boolean;
  26294. CLIPPLANE2: boolean;
  26295. CLIPPLANE3: boolean;
  26296. CLIPPLANE4: boolean;
  26297. CLIPPLANE5: boolean;
  26298. CLIPPLANE6: boolean;
  26299. ALPHATEST: boolean;
  26300. DEPTHPREPASS: boolean;
  26301. ALPHAFROMDIFFUSE: boolean;
  26302. POINTSIZE: boolean;
  26303. FOG: boolean;
  26304. SPECULARTERM: boolean;
  26305. DIFFUSEFRESNEL: boolean;
  26306. OPACITYFRESNEL: boolean;
  26307. REFLECTIONFRESNEL: boolean;
  26308. REFRACTIONFRESNEL: boolean;
  26309. EMISSIVEFRESNEL: boolean;
  26310. FRESNEL: boolean;
  26311. NORMAL: boolean;
  26312. UV1: boolean;
  26313. UV2: boolean;
  26314. VERTEXCOLOR: boolean;
  26315. VERTEXALPHA: boolean;
  26316. NUM_BONE_INFLUENCERS: number;
  26317. BonesPerMesh: number;
  26318. BONETEXTURE: boolean;
  26319. INSTANCES: boolean;
  26320. GLOSSINESS: boolean;
  26321. ROUGHNESS: boolean;
  26322. EMISSIVEASILLUMINATION: boolean;
  26323. LINKEMISSIVEWITHDIFFUSE: boolean;
  26324. REFLECTIONFRESNELFROMSPECULAR: boolean;
  26325. LIGHTMAP: boolean;
  26326. LIGHTMAPDIRECTUV: number;
  26327. OBJECTSPACE_NORMALMAP: boolean;
  26328. USELIGHTMAPASSHADOWMAP: boolean;
  26329. REFLECTIONMAP_3D: boolean;
  26330. REFLECTIONMAP_SPHERICAL: boolean;
  26331. REFLECTIONMAP_PLANAR: boolean;
  26332. REFLECTIONMAP_CUBIC: boolean;
  26333. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  26334. REFLECTIONMAP_PROJECTION: boolean;
  26335. REFLECTIONMAP_SKYBOX: boolean;
  26336. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  26337. REFLECTIONMAP_EXPLICIT: boolean;
  26338. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  26339. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  26340. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  26341. INVERTCUBICMAP: boolean;
  26342. LOGARITHMICDEPTH: boolean;
  26343. REFRACTION: boolean;
  26344. REFRACTIONMAP_3D: boolean;
  26345. REFLECTIONOVERALPHA: boolean;
  26346. TWOSIDEDLIGHTING: boolean;
  26347. SHADOWFLOAT: boolean;
  26348. MORPHTARGETS: boolean;
  26349. MORPHTARGETS_NORMAL: boolean;
  26350. MORPHTARGETS_TANGENT: boolean;
  26351. MORPHTARGETS_UV: boolean;
  26352. NUM_MORPH_INFLUENCERS: number;
  26353. NONUNIFORMSCALING: boolean;
  26354. PREMULTIPLYALPHA: boolean;
  26355. IMAGEPROCESSING: boolean;
  26356. VIGNETTE: boolean;
  26357. VIGNETTEBLENDMODEMULTIPLY: boolean;
  26358. VIGNETTEBLENDMODEOPAQUE: boolean;
  26359. TONEMAPPING: boolean;
  26360. TONEMAPPING_ACES: boolean;
  26361. CONTRAST: boolean;
  26362. COLORCURVES: boolean;
  26363. COLORGRADING: boolean;
  26364. COLORGRADING3D: boolean;
  26365. SAMPLER3DGREENDEPTH: boolean;
  26366. SAMPLER3DBGRMAP: boolean;
  26367. IMAGEPROCESSINGPOSTPROCESS: boolean;
  26368. MULTIVIEW: boolean;
  26369. /**
  26370. * If the reflection texture on this material is in linear color space
  26371. * @hidden
  26372. */
  26373. IS_REFLECTION_LINEAR: boolean;
  26374. /**
  26375. * If the refraction texture on this material is in linear color space
  26376. * @hidden
  26377. */
  26378. IS_REFRACTION_LINEAR: boolean;
  26379. EXPOSURE: boolean;
  26380. constructor();
  26381. setReflectionMode(modeToEnable: string): void;
  26382. }
  26383. /**
  26384. * This is the default material used in Babylon. It is the best trade off between quality
  26385. * and performances.
  26386. * @see http://doc.babylonjs.com/babylon101/materials
  26387. */
  26388. export class StandardMaterial extends PushMaterial {
  26389. private _diffuseTexture;
  26390. /**
  26391. * The basic texture of the material as viewed under a light.
  26392. */
  26393. diffuseTexture: Nullable<BaseTexture>;
  26394. private _ambientTexture;
  26395. /**
  26396. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  26397. */
  26398. ambientTexture: Nullable<BaseTexture>;
  26399. private _opacityTexture;
  26400. /**
  26401. * Define the transparency of the material from a texture.
  26402. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  26403. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  26404. */
  26405. opacityTexture: Nullable<BaseTexture>;
  26406. private _reflectionTexture;
  26407. /**
  26408. * Define the texture used to display the reflection.
  26409. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26410. */
  26411. reflectionTexture: Nullable<BaseTexture>;
  26412. private _emissiveTexture;
  26413. /**
  26414. * Define texture of the material as if self lit.
  26415. * This will be mixed in the final result even in the absence of light.
  26416. */
  26417. emissiveTexture: Nullable<BaseTexture>;
  26418. private _specularTexture;
  26419. /**
  26420. * Define how the color and intensity of the highlight given by the light in the material.
  26421. */
  26422. specularTexture: Nullable<BaseTexture>;
  26423. private _bumpTexture;
  26424. /**
  26425. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  26426. * These are made by creating a normal map from an image. The means to do this can be found on the web, a search for 'normal map generator' will bring up free and paid for methods of doing this.
  26427. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  26428. */
  26429. bumpTexture: Nullable<BaseTexture>;
  26430. private _lightmapTexture;
  26431. /**
  26432. * Complex lighting can be computationally expensive to compute at runtime.
  26433. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  26434. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  26435. */
  26436. lightmapTexture: Nullable<BaseTexture>;
  26437. private _refractionTexture;
  26438. /**
  26439. * Define the texture used to display the refraction.
  26440. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26441. */
  26442. refractionTexture: Nullable<BaseTexture>;
  26443. /**
  26444. * The color of the material lit by the environmental background lighting.
  26445. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  26446. */
  26447. ambientColor: Color3;
  26448. /**
  26449. * The basic color of the material as viewed under a light.
  26450. */
  26451. diffuseColor: Color3;
  26452. /**
  26453. * Define how the color and intensity of the highlight given by the light in the material.
  26454. */
  26455. specularColor: Color3;
  26456. /**
  26457. * Define the color of the material as if self lit.
  26458. * This will be mixed in the final result even in the absence of light.
  26459. */
  26460. emissiveColor: Color3;
  26461. /**
  26462. * Defines how sharp are the highlights in the material.
  26463. * The bigger the value the sharper giving a more glossy feeling to the result.
  26464. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  26465. */
  26466. specularPower: number;
  26467. private _useAlphaFromDiffuseTexture;
  26468. /**
  26469. * Does the transparency come from the diffuse texture alpha channel.
  26470. */
  26471. useAlphaFromDiffuseTexture: boolean;
  26472. private _useEmissiveAsIllumination;
  26473. /**
  26474. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  26475. */
  26476. useEmissiveAsIllumination: boolean;
  26477. private _linkEmissiveWithDiffuse;
  26478. /**
  26479. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  26480. * the emissive level when the final color is close to one.
  26481. */
  26482. linkEmissiveWithDiffuse: boolean;
  26483. private _useSpecularOverAlpha;
  26484. /**
  26485. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  26486. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  26487. */
  26488. useSpecularOverAlpha: boolean;
  26489. private _useReflectionOverAlpha;
  26490. /**
  26491. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  26492. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  26493. */
  26494. useReflectionOverAlpha: boolean;
  26495. private _disableLighting;
  26496. /**
  26497. * Does lights from the scene impacts this material.
  26498. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  26499. */
  26500. disableLighting: boolean;
  26501. private _useObjectSpaceNormalMap;
  26502. /**
  26503. * Allows using an object space normal map (instead of tangent space).
  26504. */
  26505. useObjectSpaceNormalMap: boolean;
  26506. private _useParallax;
  26507. /**
  26508. * Is parallax enabled or not.
  26509. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  26510. */
  26511. useParallax: boolean;
  26512. private _useParallaxOcclusion;
  26513. /**
  26514. * Is parallax occlusion enabled or not.
  26515. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  26516. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  26517. */
  26518. useParallaxOcclusion: boolean;
  26519. /**
  26520. * Apply a scaling factor that determine which "depth" the height map should reprensent. A value between 0.05 and 0.1 is reasonnable in Parallax, you can reach 0.2 using Parallax Occlusion.
  26521. */
  26522. parallaxScaleBias: number;
  26523. private _roughness;
  26524. /**
  26525. * Helps to define how blurry the reflections should appears in the material.
  26526. */
  26527. roughness: number;
  26528. /**
  26529. * In case of refraction, define the value of the index of refraction.
  26530. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26531. */
  26532. indexOfRefraction: number;
  26533. /**
  26534. * Invert the refraction texture alongside the y axis.
  26535. * It can be useful with procedural textures or probe for instance.
  26536. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26537. */
  26538. invertRefractionY: boolean;
  26539. /**
  26540. * Defines the alpha limits in alpha test mode.
  26541. */
  26542. alphaCutOff: number;
  26543. private _useLightmapAsShadowmap;
  26544. /**
  26545. * In case of light mapping, define whether the map contains light or shadow informations.
  26546. */
  26547. useLightmapAsShadowmap: boolean;
  26548. private _diffuseFresnelParameters;
  26549. /**
  26550. * Define the diffuse fresnel parameters of the material.
  26551. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26552. */
  26553. diffuseFresnelParameters: FresnelParameters;
  26554. private _opacityFresnelParameters;
  26555. /**
  26556. * Define the opacity fresnel parameters of the material.
  26557. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26558. */
  26559. opacityFresnelParameters: FresnelParameters;
  26560. private _reflectionFresnelParameters;
  26561. /**
  26562. * Define the reflection fresnel parameters of the material.
  26563. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26564. */
  26565. reflectionFresnelParameters: FresnelParameters;
  26566. private _refractionFresnelParameters;
  26567. /**
  26568. * Define the refraction fresnel parameters of the material.
  26569. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26570. */
  26571. refractionFresnelParameters: FresnelParameters;
  26572. private _emissiveFresnelParameters;
  26573. /**
  26574. * Define the emissive fresnel parameters of the material.
  26575. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26576. */
  26577. emissiveFresnelParameters: FresnelParameters;
  26578. private _useReflectionFresnelFromSpecular;
  26579. /**
  26580. * If true automatically deducts the fresnels values from the material specularity.
  26581. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26582. */
  26583. useReflectionFresnelFromSpecular: boolean;
  26584. private _useGlossinessFromSpecularMapAlpha;
  26585. /**
  26586. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  26587. */
  26588. useGlossinessFromSpecularMapAlpha: boolean;
  26589. private _maxSimultaneousLights;
  26590. /**
  26591. * Defines the maximum number of lights that can be used in the material
  26592. */
  26593. maxSimultaneousLights: number;
  26594. private _invertNormalMapX;
  26595. /**
  26596. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  26597. */
  26598. invertNormalMapX: boolean;
  26599. private _invertNormalMapY;
  26600. /**
  26601. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  26602. */
  26603. invertNormalMapY: boolean;
  26604. private _twoSidedLighting;
  26605. /**
  26606. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  26607. */
  26608. twoSidedLighting: boolean;
  26609. /**
  26610. * Default configuration related to image processing available in the standard Material.
  26611. */
  26612. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  26613. /**
  26614. * Gets the image processing configuration used either in this material.
  26615. */
  26616. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  26617. /**
  26618. * Sets the Default image processing configuration used either in the this material.
  26619. *
  26620. * If sets to null, the scene one is in use.
  26621. */
  26622. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  26623. /**
  26624. * Keep track of the image processing observer to allow dispose and replace.
  26625. */
  26626. private _imageProcessingObserver;
  26627. /**
  26628. * Attaches a new image processing configuration to the Standard Material.
  26629. * @param configuration
  26630. */
  26631. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  26632. /**
  26633. * Gets wether the color curves effect is enabled.
  26634. */
  26635. get cameraColorCurvesEnabled(): boolean;
  26636. /**
  26637. * Sets wether the color curves effect is enabled.
  26638. */
  26639. set cameraColorCurvesEnabled(value: boolean);
  26640. /**
  26641. * Gets wether the color grading effect is enabled.
  26642. */
  26643. get cameraColorGradingEnabled(): boolean;
  26644. /**
  26645. * Gets wether the color grading effect is enabled.
  26646. */
  26647. set cameraColorGradingEnabled(value: boolean);
  26648. /**
  26649. * Gets wether tonemapping is enabled or not.
  26650. */
  26651. get cameraToneMappingEnabled(): boolean;
  26652. /**
  26653. * Sets wether tonemapping is enabled or not
  26654. */
  26655. set cameraToneMappingEnabled(value: boolean);
  26656. /**
  26657. * The camera exposure used on this material.
  26658. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  26659. * This corresponds to a photographic exposure.
  26660. */
  26661. get cameraExposure(): number;
  26662. /**
  26663. * The camera exposure used on this material.
  26664. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  26665. * This corresponds to a photographic exposure.
  26666. */
  26667. set cameraExposure(value: number);
  26668. /**
  26669. * Gets The camera contrast used on this material.
  26670. */
  26671. get cameraContrast(): number;
  26672. /**
  26673. * Sets The camera contrast used on this material.
  26674. */
  26675. set cameraContrast(value: number);
  26676. /**
  26677. * Gets the Color Grading 2D Lookup Texture.
  26678. */
  26679. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  26680. /**
  26681. * Sets the Color Grading 2D Lookup Texture.
  26682. */
  26683. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  26684. /**
  26685. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  26686. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  26687. * These are similar to controls found in many professional imaging or colorist software. The global controls are applied to the entire image. For advanced tuning, extra controls are provided to adjust the shadow, midtone and highlight areas of the image;
  26688. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  26689. */
  26690. get cameraColorCurves(): Nullable<ColorCurves>;
  26691. /**
  26692. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  26693. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  26694. * These are similar to controls found in many professional imaging or colorist software. The global controls are applied to the entire image. For advanced tuning, extra controls are provided to adjust the shadow, midtone and highlight areas of the image;
  26695. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  26696. */
  26697. set cameraColorCurves(value: Nullable<ColorCurves>);
  26698. /**
  26699. * Custom callback helping to override the default shader used in the material.
  26700. */
  26701. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  26702. protected _renderTargets: SmartArray<RenderTargetTexture>;
  26703. protected _worldViewProjectionMatrix: Matrix;
  26704. protected _globalAmbientColor: Color3;
  26705. protected _useLogarithmicDepth: boolean;
  26706. protected _rebuildInParallel: boolean;
  26707. /**
  26708. * Instantiates a new standard material.
  26709. * This is the default material used in Babylon. It is the best trade off between quality
  26710. * and performances.
  26711. * @see http://doc.babylonjs.com/babylon101/materials
  26712. * @param name Define the name of the material in the scene
  26713. * @param scene Define the scene the material belong to
  26714. */
  26715. constructor(name: string, scene: Scene);
  26716. /**
  26717. * Gets a boolean indicating that current material needs to register RTT
  26718. */
  26719. get hasRenderTargetTextures(): boolean;
  26720. /**
  26721. * Gets the current class name of the material e.g. "StandardMaterial"
  26722. * Mainly use in serialization.
  26723. * @returns the class name
  26724. */
  26725. getClassName(): string;
  26726. /**
  26727. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  26728. * You can try switching to logarithmic depth.
  26729. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  26730. */
  26731. get useLogarithmicDepth(): boolean;
  26732. set useLogarithmicDepth(value: boolean);
  26733. /**
  26734. * Specifies if the material will require alpha blending
  26735. * @returns a boolean specifying if alpha blending is needed
  26736. */
  26737. needAlphaBlending(): boolean;
  26738. /**
  26739. * Specifies if this material should be rendered in alpha test mode
  26740. * @returns a boolean specifying if an alpha test is needed.
  26741. */
  26742. needAlphaTesting(): boolean;
  26743. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  26744. /**
  26745. * Get the texture used for alpha test purpose.
  26746. * @returns the diffuse texture in case of the standard material.
  26747. */
  26748. getAlphaTestTexture(): Nullable<BaseTexture>;
  26749. /**
  26750. * Get if the submesh is ready to be used and all its information available.
  26751. * Child classes can use it to update shaders
  26752. * @param mesh defines the mesh to check
  26753. * @param subMesh defines which submesh to check
  26754. * @param useInstances specifies that instances should be used
  26755. * @returns a boolean indicating that the submesh is ready or not
  26756. */
  26757. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  26758. /**
  26759. * Builds the material UBO layouts.
  26760. * Used internally during the effect preparation.
  26761. */
  26762. buildUniformLayout(): void;
  26763. /**
  26764. * Unbinds the material from the mesh
  26765. */
  26766. unbind(): void;
  26767. /**
  26768. * Binds the submesh to this material by preparing the effect and shader to draw
  26769. * @param world defines the world transformation matrix
  26770. * @param mesh defines the mesh containing the submesh
  26771. * @param subMesh defines the submesh to bind the material to
  26772. */
  26773. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  26774. /**
  26775. * Get the list of animatables in the material.
  26776. * @returns the list of animatables object used in the material
  26777. */
  26778. getAnimatables(): IAnimatable[];
  26779. /**
  26780. * Gets the active textures from the material
  26781. * @returns an array of textures
  26782. */
  26783. getActiveTextures(): BaseTexture[];
  26784. /**
  26785. * Specifies if the material uses a texture
  26786. * @param texture defines the texture to check against the material
  26787. * @returns a boolean specifying if the material uses the texture
  26788. */
  26789. hasTexture(texture: BaseTexture): boolean;
  26790. /**
  26791. * Disposes the material
  26792. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  26793. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  26794. */
  26795. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  26796. /**
  26797. * Makes a duplicate of the material, and gives it a new name
  26798. * @param name defines the new name for the duplicated material
  26799. * @returns the cloned material
  26800. */
  26801. clone(name: string): StandardMaterial;
  26802. /**
  26803. * Serializes this material in a JSON representation
  26804. * @returns the serialized material object
  26805. */
  26806. serialize(): any;
  26807. /**
  26808. * Creates a standard material from parsed material data
  26809. * @param source defines the JSON representation of the material
  26810. * @param scene defines the hosting scene
  26811. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  26812. * @returns a new standard material
  26813. */
  26814. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  26815. /**
  26816. * Are diffuse textures enabled in the application.
  26817. */
  26818. static get DiffuseTextureEnabled(): boolean;
  26819. static set DiffuseTextureEnabled(value: boolean);
  26820. /**
  26821. * Are ambient textures enabled in the application.
  26822. */
  26823. static get AmbientTextureEnabled(): boolean;
  26824. static set AmbientTextureEnabled(value: boolean);
  26825. /**
  26826. * Are opacity textures enabled in the application.
  26827. */
  26828. static get OpacityTextureEnabled(): boolean;
  26829. static set OpacityTextureEnabled(value: boolean);
  26830. /**
  26831. * Are reflection textures enabled in the application.
  26832. */
  26833. static get ReflectionTextureEnabled(): boolean;
  26834. static set ReflectionTextureEnabled(value: boolean);
  26835. /**
  26836. * Are emissive textures enabled in the application.
  26837. */
  26838. static get EmissiveTextureEnabled(): boolean;
  26839. static set EmissiveTextureEnabled(value: boolean);
  26840. /**
  26841. * Are specular textures enabled in the application.
  26842. */
  26843. static get SpecularTextureEnabled(): boolean;
  26844. static set SpecularTextureEnabled(value: boolean);
  26845. /**
  26846. * Are bump textures enabled in the application.
  26847. */
  26848. static get BumpTextureEnabled(): boolean;
  26849. static set BumpTextureEnabled(value: boolean);
  26850. /**
  26851. * Are lightmap textures enabled in the application.
  26852. */
  26853. static get LightmapTextureEnabled(): boolean;
  26854. static set LightmapTextureEnabled(value: boolean);
  26855. /**
  26856. * Are refraction textures enabled in the application.
  26857. */
  26858. static get RefractionTextureEnabled(): boolean;
  26859. static set RefractionTextureEnabled(value: boolean);
  26860. /**
  26861. * Are color grading textures enabled in the application.
  26862. */
  26863. static get ColorGradingTextureEnabled(): boolean;
  26864. static set ColorGradingTextureEnabled(value: boolean);
  26865. /**
  26866. * Are fresnels enabled in the application.
  26867. */
  26868. static get FresnelEnabled(): boolean;
  26869. static set FresnelEnabled(value: boolean);
  26870. }
  26871. }
  26872. declare module BABYLON {
  26873. /**
  26874. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  26875. *As it is just a mesh, the SPS has all the same properties than any other BJS mesh : not more, not less. It can be scaled, rotated, translated, enlighted, textured, moved, etc.
  26876. * The SPS is also a particle system. It provides some methods to manage the particles.
  26877. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  26878. *
  26879. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  26880. */
  26881. export class SolidParticleSystem implements IDisposable {
  26882. /**
  26883. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  26884. * Example : var p = SPS.particles[i];
  26885. */
  26886. particles: SolidParticle[];
  26887. /**
  26888. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  26889. */
  26890. nbParticles: number;
  26891. /**
  26892. * If the particles must ever face the camera (default false). Useful for planar particles.
  26893. */
  26894. billboard: boolean;
  26895. /**
  26896. * Recompute normals when adding a shape
  26897. */
  26898. recomputeNormals: boolean;
  26899. /**
  26900. * This a counter ofr your own usage. It's not set by any SPS functions.
  26901. */
  26902. counter: number;
  26903. /**
  26904. * The SPS name. This name is also given to the underlying mesh.
  26905. */
  26906. name: string;
  26907. /**
  26908. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  26909. */
  26910. mesh: Mesh;
  26911. /**
  26912. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  26913. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  26914. */
  26915. vars: any;
  26916. /**
  26917. * This array is populated when the SPS is set as 'pickable'.
  26918. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  26919. * Each element of this array is an object `{idx: int, faceId: int}`.
  26920. * `idx` is the picked particle index in the `SPS.particles` array
  26921. * `faceId` is the picked face index counted within this particle.
  26922. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  26923. */
  26924. pickedParticles: {
  26925. idx: number;
  26926. faceId: number;
  26927. }[];
  26928. /**
  26929. * This array is populated when `enableDepthSort` is set to true.
  26930. * Each element of this array is an instance of the class DepthSortedParticle.
  26931. */
  26932. depthSortedParticles: DepthSortedParticle[];
  26933. /**
  26934. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  26935. * @hidden
  26936. */
  26937. _bSphereOnly: boolean;
  26938. /**
  26939. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  26940. * @hidden
  26941. */
  26942. _bSphereRadiusFactor: number;
  26943. private _scene;
  26944. private _positions;
  26945. private _indices;
  26946. private _normals;
  26947. private _colors;
  26948. private _uvs;
  26949. private _indices32;
  26950. private _positions32;
  26951. private _normals32;
  26952. private _fixedNormal32;
  26953. private _colors32;
  26954. private _uvs32;
  26955. private _index;
  26956. private _updatable;
  26957. private _pickable;
  26958. private _isVisibilityBoxLocked;
  26959. private _alwaysVisible;
  26960. private _depthSort;
  26961. private _expandable;
  26962. private _shapeCounter;
  26963. private _copy;
  26964. private _color;
  26965. private _computeParticleColor;
  26966. private _computeParticleTexture;
  26967. private _computeParticleRotation;
  26968. private _computeParticleVertex;
  26969. private _computeBoundingBox;
  26970. private _depthSortParticles;
  26971. private _camera;
  26972. private _mustUnrotateFixedNormals;
  26973. private _particlesIntersect;
  26974. private _needs32Bits;
  26975. private _isNotBuilt;
  26976. private _lastParticleId;
  26977. private _idxOfId;
  26978. private _multimaterialEnabled;
  26979. private _useModelMaterial;
  26980. private _indicesByMaterial;
  26981. private _materialIndexes;
  26982. private _depthSortFunction;
  26983. private _materialSortFunction;
  26984. private _materials;
  26985. private _multimaterial;
  26986. private _materialIndexesById;
  26987. private _defaultMaterial;
  26988. private _autoUpdateSubMeshes;
  26989. /**
  26990. * Creates a SPS (Solid Particle System) object.
  26991. * @param name (String) is the SPS name, this will be the underlying mesh name.
  26992. * @param scene (Scene) is the scene in which the SPS is added.
  26993. * @param options defines the options of the sps e.g.
  26994. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  26995. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  26996. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  26997. * * useModelMaterial (optional boolean, defaut false) : if the model materials must be used to create the SPS multimaterial. This enables the multimaterial supports of the SPS.
  26998. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  26999. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  27000. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  27001. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  27002. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  27003. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  27004. */
  27005. constructor(name: string, scene: Scene, options?: {
  27006. updatable?: boolean;
  27007. isPickable?: boolean;
  27008. enableDepthSort?: boolean;
  27009. particleIntersection?: boolean;
  27010. boundingSphereOnly?: boolean;
  27011. bSphereRadiusFactor?: number;
  27012. expandable?: boolean;
  27013. useModelMaterial?: boolean;
  27014. enableMultiMaterial?: boolean;
  27015. });
  27016. /**
  27017. * Builds the SPS underlying mesh. Returns a standard Mesh.
  27018. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  27019. * @returns the created mesh
  27020. */
  27021. buildMesh(): Mesh;
  27022. /**
  27023. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  27024. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  27025. * Thus the particles generated from `digest()` have their property `position` set yet.
  27026. * @param mesh ( Mesh ) is the mesh to be digested
  27027. * @param options {facetNb} (optional integer, default 1) is the number of mesh facets per particle, this parameter is overriden by the parameter `number` if any
  27028. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  27029. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  27030. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  27031. * @returns the current SPS
  27032. */
  27033. digest(mesh: Mesh, options?: {
  27034. facetNb?: number;
  27035. number?: number;
  27036. delta?: number;
  27037. storage?: [];
  27038. }): SolidParticleSystem;
  27039. /**
  27040. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  27041. * @hidden
  27042. */
  27043. private _unrotateFixedNormals;
  27044. /**
  27045. * Resets the temporary working copy particle
  27046. * @hidden
  27047. */
  27048. private _resetCopy;
  27049. /**
  27050. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  27051. * @param p the current index in the positions array to be updated
  27052. * @param ind the current index in the indices array
  27053. * @param shape a Vector3 array, the shape geometry
  27054. * @param positions the positions array to be updated
  27055. * @param meshInd the shape indices array
  27056. * @param indices the indices array to be updated
  27057. * @param meshUV the shape uv array
  27058. * @param uvs the uv array to be updated
  27059. * @param meshCol the shape color array
  27060. * @param colors the color array to be updated
  27061. * @param meshNor the shape normals array
  27062. * @param normals the normals array to be updated
  27063. * @param idx the particle index
  27064. * @param idxInShape the particle index in its shape
  27065. * @param options the addShape() method passed options
  27066. * @model the particle model
  27067. * @hidden
  27068. */
  27069. private _meshBuilder;
  27070. /**
  27071. * Returns a shape Vector3 array from positions float array
  27072. * @param positions float array
  27073. * @returns a vector3 array
  27074. * @hidden
  27075. */
  27076. private _posToShape;
  27077. /**
  27078. * Returns a shapeUV array from a float uvs (array deep copy)
  27079. * @param uvs as a float array
  27080. * @returns a shapeUV array
  27081. * @hidden
  27082. */
  27083. private _uvsToShapeUV;
  27084. /**
  27085. * Adds a new particle object in the particles array
  27086. * @param idx particle index in particles array
  27087. * @param id particle id
  27088. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  27089. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  27090. * @param model particle ModelShape object
  27091. * @param shapeId model shape identifier
  27092. * @param idxInShape index of the particle in the current model
  27093. * @param bInfo model bounding info object
  27094. * @param storage target storage array, if any
  27095. * @hidden
  27096. */
  27097. private _addParticle;
  27098. /**
  27099. * Adds some particles to the SPS from the model shape. Returns the shape id.
  27100. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  27101. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  27102. * @param nb (positive integer) the number of particles to be created from this model
  27103. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  27104. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  27105. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  27106. * @returns the number of shapes in the system
  27107. */
  27108. addShape(mesh: Mesh, nb: number, options?: {
  27109. positionFunction?: any;
  27110. vertexFunction?: any;
  27111. storage?: [];
  27112. }): number;
  27113. /**
  27114. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  27115. * @hidden
  27116. */
  27117. private _rebuildParticle;
  27118. /**
  27119. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  27120. * @param reset boolean, default false : if the particles must be reset at position and rotation zero, scaling 1, color white, initial UVs and not parented.
  27121. * @returns the SPS.
  27122. */
  27123. rebuildMesh(reset?: boolean): SolidParticleSystem;
  27124. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  27125. * Returns an array with the removed particles.
  27126. * If the number of particles to remove is lower than zero or greater than the global remaining particle number, then an empty array is returned.
  27127. * The SPS can't be empty so at least one particle needs to remain in place.
  27128. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  27129. * @param start index of the first particle to remove
  27130. * @param end index of the last particle to remove (included)
  27131. * @returns an array populated with the removed particles
  27132. */
  27133. removeParticles(start: number, end: number): SolidParticle[];
  27134. /**
  27135. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  27136. * @param solidParticleArray an array populated with Solid Particles objects
  27137. * @returns the SPS
  27138. */
  27139. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  27140. /**
  27141. * Creates a new particle and modifies the SPS mesh geometry :
  27142. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  27143. * - calls _addParticle() to populate the particle array
  27144. * factorized code from addShape() and insertParticlesFromArray()
  27145. * @param idx particle index in the particles array
  27146. * @param i particle index in its shape
  27147. * @param modelShape particle ModelShape object
  27148. * @param shape shape vertex array
  27149. * @param meshInd shape indices array
  27150. * @param meshUV shape uv array
  27151. * @param meshCol shape color array
  27152. * @param meshNor shape normals array
  27153. * @param bbInfo shape bounding info
  27154. * @param storage target particle storage
  27155. * @options addShape() passed options
  27156. * @hidden
  27157. */
  27158. private _insertNewParticle;
  27159. /**
  27160. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  27161. * This method calls `updateParticle()` for each particle of the SPS.
  27162. * For an animated SPS, it is usually called within the render loop.
  27163. * This methods does nothing if called on a non updatable or not yet built SPS. Example : buildMesh() not called after having added or removed particles from an expandable SPS.
  27164. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  27165. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  27166. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  27167. * @returns the SPS.
  27168. */
  27169. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  27170. /**
  27171. * Disposes the SPS.
  27172. */
  27173. dispose(): void;
  27174. /**
  27175. * Returns a SolidParticle object from its identifier : particle.id
  27176. * @param id (integer) the particle Id
  27177. * @returns the searched particle or null if not found in the SPS.
  27178. */
  27179. getParticleById(id: number): Nullable<SolidParticle>;
  27180. /**
  27181. * Returns a new array populated with the particles having the passed shapeId.
  27182. * @param shapeId (integer) the shape identifier
  27183. * @returns a new solid particle array
  27184. */
  27185. getParticlesByShapeId(shapeId: number): SolidParticle[];
  27186. /**
  27187. * Populates the passed array "ref" with the particles having the passed shapeId.
  27188. * @param shapeId the shape identifier
  27189. * @returns the SPS
  27190. * @param ref
  27191. */
  27192. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  27193. /**
  27194. * Computes the required SubMeshes according the materials assigned to the particles.
  27195. * @returns the solid particle system.
  27196. * Does nothing if called before the SPS mesh is built.
  27197. */
  27198. computeSubMeshes(): SolidParticleSystem;
  27199. /**
  27200. * Sorts the solid particles by material when MultiMaterial is enabled.
  27201. * Updates the indices32 array.
  27202. * Updates the indicesByMaterial array.
  27203. * Updates the mesh indices array.
  27204. * @returns the SPS
  27205. * @hidden
  27206. */
  27207. private _sortParticlesByMaterial;
  27208. /**
  27209. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  27210. * @hidden
  27211. */
  27212. private _setMaterialIndexesById;
  27213. /**
  27214. * Returns an array with unique values of Materials from the passed array
  27215. * @param array the material array to be checked and filtered
  27216. * @hidden
  27217. */
  27218. private _filterUniqueMaterialId;
  27219. /**
  27220. * Sets a new Standard Material as _defaultMaterial if not already set.
  27221. * @hidden
  27222. */
  27223. private _setDefaultMaterial;
  27224. /**
  27225. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  27226. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27227. * @returns the SPS.
  27228. */
  27229. refreshVisibleSize(): SolidParticleSystem;
  27230. /**
  27231. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  27232. * @param size the size (float) of the visibility box
  27233. * note : this doesn't lock the SPS mesh bounding box.
  27234. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27235. */
  27236. setVisibilityBox(size: number): void;
  27237. /**
  27238. * Gets whether the SPS as always visible or not
  27239. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27240. */
  27241. get isAlwaysVisible(): boolean;
  27242. /**
  27243. * Sets the SPS as always visible or not
  27244. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27245. */
  27246. set isAlwaysVisible(val: boolean);
  27247. /**
  27248. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  27249. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27250. */
  27251. set isVisibilityBoxLocked(val: boolean);
  27252. /**
  27253. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  27254. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27255. */
  27256. get isVisibilityBoxLocked(): boolean;
  27257. /**
  27258. * Tells to `setParticles()` to compute the particle rotations or not.
  27259. * Default value : true. The SPS is faster when it's set to false.
  27260. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  27261. */
  27262. set computeParticleRotation(val: boolean);
  27263. /**
  27264. * Tells to `setParticles()` to compute the particle colors or not.
  27265. * Default value : true. The SPS is faster when it's set to false.
  27266. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  27267. */
  27268. set computeParticleColor(val: boolean);
  27269. set computeParticleTexture(val: boolean);
  27270. /**
  27271. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  27272. * Default value : false. The SPS is faster when it's set to false.
  27273. * Note : the particle custom vertex positions aren't stored values.
  27274. */
  27275. set computeParticleVertex(val: boolean);
  27276. /**
  27277. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  27278. */
  27279. set computeBoundingBox(val: boolean);
  27280. /**
  27281. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  27282. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  27283. * Default : `true`
  27284. */
  27285. set depthSortParticles(val: boolean);
  27286. /**
  27287. * Gets if `setParticles()` computes the particle rotations or not.
  27288. * Default value : true. The SPS is faster when it's set to false.
  27289. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  27290. */
  27291. get computeParticleRotation(): boolean;
  27292. /**
  27293. * Gets if `setParticles()` computes the particle colors or not.
  27294. * Default value : true. The SPS is faster when it's set to false.
  27295. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  27296. */
  27297. get computeParticleColor(): boolean;
  27298. /**
  27299. * Gets if `setParticles()` computes the particle textures or not.
  27300. * Default value : true. The SPS is faster when it's set to false.
  27301. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  27302. */
  27303. get computeParticleTexture(): boolean;
  27304. /**
  27305. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  27306. * Default value : false. The SPS is faster when it's set to false.
  27307. * Note : the particle custom vertex positions aren't stored values.
  27308. */
  27309. get computeParticleVertex(): boolean;
  27310. /**
  27311. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  27312. */
  27313. get computeBoundingBox(): boolean;
  27314. /**
  27315. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  27316. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  27317. * Default : `true`
  27318. */
  27319. get depthSortParticles(): boolean;
  27320. /**
  27321. * Gets if the SPS is created as expandable at construction time.
  27322. * Default : `false`
  27323. */
  27324. get expandable(): boolean;
  27325. /**
  27326. * Gets if the SPS supports the Multi Materials
  27327. */
  27328. get multimaterialEnabled(): boolean;
  27329. /**
  27330. * Gets if the SPS uses the model materials for its own multimaterial.
  27331. */
  27332. get useModelMaterial(): boolean;
  27333. /**
  27334. * The SPS used material array.
  27335. */
  27336. get materials(): Material[];
  27337. /**
  27338. * Sets the SPS MultiMaterial from the passed materials.
  27339. * Note : the passed array is internally copied and not used then by reference.
  27340. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  27341. */
  27342. setMultiMaterial(materials: Material[]): void;
  27343. /**
  27344. * The SPS computed multimaterial object
  27345. */
  27346. get multimaterial(): MultiMaterial;
  27347. set multimaterial(mm: MultiMaterial);
  27348. /**
  27349. * If the subMeshes must be updated on the next call to setParticles()
  27350. */
  27351. get autoUpdateSubMeshes(): boolean;
  27352. set autoUpdateSubMeshes(val: boolean);
  27353. /**
  27354. * This function does nothing. It may be overwritten to set all the particle first values.
  27355. * The SPS doesn't call this function, you may have to call it by your own.
  27356. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  27357. */
  27358. initParticles(): void;
  27359. /**
  27360. * This function does nothing. It may be overwritten to recycle a particle.
  27361. * The SPS doesn't call this function, you may have to call it by your own.
  27362. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  27363. * @param particle The particle to recycle
  27364. * @returns the recycled particle
  27365. */
  27366. recycleParticle(particle: SolidParticle): SolidParticle;
  27367. /**
  27368. * Updates a particle : this function should be overwritten by the user.
  27369. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  27370. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  27371. * @example : just set a particle position or velocity and recycle conditions
  27372. * @param particle The particle to update
  27373. * @returns the updated particle
  27374. */
  27375. updateParticle(particle: SolidParticle): SolidParticle;
  27376. /**
  27377. * Updates a vertex of a particle : it can be overwritten by the user.
  27378. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  27379. * @param particle the current particle
  27380. * @param vertex the current index of the current particle
  27381. * @param pt the index of the current vertex in the particle shape
  27382. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  27383. * @example : just set a vertex particle position
  27384. * @returns the updated vertex
  27385. */
  27386. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  27387. /**
  27388. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  27389. * This does nothing and may be overwritten by the user.
  27390. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27391. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27392. * @param update the boolean update value actually passed to setParticles()
  27393. */
  27394. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  27395. /**
  27396. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  27397. * This will be passed three parameters.
  27398. * This does nothing and may be overwritten by the user.
  27399. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27400. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27401. * @param update the boolean update value actually passed to setParticles()
  27402. */
  27403. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  27404. }
  27405. }
  27406. declare module BABYLON {
  27407. /**
  27408. * Represents one particle of a solid particle system.
  27409. */
  27410. export class SolidParticle {
  27411. /**
  27412. * particle global index
  27413. */
  27414. idx: number;
  27415. /**
  27416. * particle identifier
  27417. */
  27418. id: number;
  27419. /**
  27420. * The color of the particle
  27421. */
  27422. color: Nullable<Color4>;
  27423. /**
  27424. * The world space position of the particle.
  27425. */
  27426. position: Vector3;
  27427. /**
  27428. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  27429. */
  27430. rotation: Vector3;
  27431. /**
  27432. * The world space rotation quaternion of the particle.
  27433. */
  27434. rotationQuaternion: Nullable<Quaternion>;
  27435. /**
  27436. * The scaling of the particle.
  27437. */
  27438. scaling: Vector3;
  27439. /**
  27440. * The uvs of the particle.
  27441. */
  27442. uvs: Vector4;
  27443. /**
  27444. * The current speed of the particle.
  27445. */
  27446. velocity: Vector3;
  27447. /**
  27448. * The pivot point in the particle local space.
  27449. */
  27450. pivot: Vector3;
  27451. /**
  27452. * Must the particle be translated from its pivot point in its local space ?
  27453. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  27454. * Default : false
  27455. */
  27456. translateFromPivot: boolean;
  27457. /**
  27458. * Is the particle active or not ?
  27459. */
  27460. alive: boolean;
  27461. /**
  27462. * Is the particle visible or not ?
  27463. */
  27464. isVisible: boolean;
  27465. /**
  27466. * Index of this particle in the global "positions" array (Internal use)
  27467. * @hidden
  27468. */
  27469. _pos: number;
  27470. /**
  27471. * @hidden Index of this particle in the global "indices" array (Internal use)
  27472. */
  27473. _ind: number;
  27474. /**
  27475. * @hidden ModelShape of this particle (Internal use)
  27476. */
  27477. _model: ModelShape;
  27478. /**
  27479. * ModelShape id of this particle
  27480. */
  27481. shapeId: number;
  27482. /**
  27483. * Index of the particle in its shape id
  27484. */
  27485. idxInShape: number;
  27486. /**
  27487. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  27488. */
  27489. _modelBoundingInfo: BoundingInfo;
  27490. /**
  27491. * @hidden Particle BoundingInfo object (Internal use)
  27492. */
  27493. _boundingInfo: BoundingInfo;
  27494. /**
  27495. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  27496. */
  27497. _sps: SolidParticleSystem;
  27498. /**
  27499. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  27500. */
  27501. _stillInvisible: boolean;
  27502. /**
  27503. * @hidden Last computed particle rotation matrix
  27504. */
  27505. _rotationMatrix: number[];
  27506. /**
  27507. * Parent particle Id, if any.
  27508. * Default null.
  27509. */
  27510. parentId: Nullable<number>;
  27511. /**
  27512. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  27513. */
  27514. materialIndex: Nullable<number>;
  27515. /**
  27516. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  27517. * The possible values are :
  27518. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  27519. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  27520. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  27521. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  27522. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  27523. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  27524. * */
  27525. cullingStrategy: number;
  27526. /**
  27527. * @hidden Internal global position in the SPS.
  27528. */
  27529. _globalPosition: Vector3;
  27530. /**
  27531. * Creates a Solid Particle object.
  27532. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  27533. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  27534. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  27535. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  27536. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  27537. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  27538. * @param shapeId (integer) is the model shape identifier in the SPS.
  27539. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  27540. * @param sps defines the sps it is associated to
  27541. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  27542. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  27543. */
  27544. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  27545. /**
  27546. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  27547. * @param target the particle target
  27548. * @returns the current particle
  27549. */
  27550. copyToRef(target: SolidParticle): SolidParticle;
  27551. /**
  27552. * Legacy support, changed scale to scaling
  27553. */
  27554. get scale(): Vector3;
  27555. /**
  27556. * Legacy support, changed scale to scaling
  27557. */
  27558. set scale(scale: Vector3);
  27559. /**
  27560. * Legacy support, changed quaternion to rotationQuaternion
  27561. */
  27562. get quaternion(): Nullable<Quaternion>;
  27563. /**
  27564. * Legacy support, changed quaternion to rotationQuaternion
  27565. */
  27566. set quaternion(q: Nullable<Quaternion>);
  27567. /**
  27568. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  27569. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  27570. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  27571. * @returns true if it intersects
  27572. */
  27573. intersectsMesh(target: Mesh | SolidParticle): boolean;
  27574. /**
  27575. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  27576. * A particle is in the frustum if its bounding box intersects the frustum
  27577. * @param frustumPlanes defines the frustum to test
  27578. * @returns true if the particle is in the frustum planes
  27579. */
  27580. isInFrustum(frustumPlanes: Plane[]): boolean;
  27581. /**
  27582. * get the rotation matrix of the particle
  27583. * @hidden
  27584. */
  27585. getRotationMatrix(m: Matrix): void;
  27586. }
  27587. /**
  27588. * Represents the shape of the model used by one particle of a solid particle system.
  27589. * SPS internal tool, don't use it manually.
  27590. */
  27591. export class ModelShape {
  27592. /**
  27593. * The shape id
  27594. * @hidden
  27595. */
  27596. shapeID: number;
  27597. /**
  27598. * flat array of model positions (internal use)
  27599. * @hidden
  27600. */
  27601. _shape: Vector3[];
  27602. /**
  27603. * flat array of model UVs (internal use)
  27604. * @hidden
  27605. */
  27606. _shapeUV: number[];
  27607. /**
  27608. * color array of the model
  27609. * @hidden
  27610. */
  27611. _shapeColors: number[];
  27612. /**
  27613. * indices array of the model
  27614. * @hidden
  27615. */
  27616. _indices: number[];
  27617. /**
  27618. * normals array of the model
  27619. * @hidden
  27620. */
  27621. _normals: number[];
  27622. /**
  27623. * length of the shape in the model indices array (internal use)
  27624. * @hidden
  27625. */
  27626. _indicesLength: number;
  27627. /**
  27628. * Custom position function (internal use)
  27629. * @hidden
  27630. */
  27631. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  27632. /**
  27633. * Custom vertex function (internal use)
  27634. * @hidden
  27635. */
  27636. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  27637. /**
  27638. * Model material (internal use)
  27639. * @hidden
  27640. */
  27641. _material: Nullable<Material>;
  27642. /**
  27643. * Creates a ModelShape object. This is an internal simplified reference to a mesh used as for a model to replicate particles from by the SPS.
  27644. * SPS internal tool, don't use it manually.
  27645. * @hidden
  27646. */
  27647. constructor(id: number, shape: Vector3[], indices: number[], normals: number[], colors: number[], shapeUV: number[], posFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>, vtxFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>, material: Nullable<Material>);
  27648. }
  27649. /**
  27650. * Represents a Depth Sorted Particle in the solid particle system.
  27651. * @hidden
  27652. */
  27653. export class DepthSortedParticle {
  27654. /**
  27655. * Index of the particle in the "indices" array
  27656. */
  27657. ind: number;
  27658. /**
  27659. * Length of the particle shape in the "indices" array
  27660. */
  27661. indicesLength: number;
  27662. /**
  27663. * Squared distance from the particle to the camera
  27664. */
  27665. sqDistance: number;
  27666. /**
  27667. * Material index when used with MultiMaterials
  27668. */
  27669. materialIndex: number;
  27670. /**
  27671. * Creates a new sorted particle
  27672. * @param materialIndex
  27673. */
  27674. constructor(ind: number, indLength: number, materialIndex: number);
  27675. }
  27676. }
  27677. declare module BABYLON {
  27678. /**
  27679. * @hidden
  27680. */
  27681. export class _MeshCollisionData {
  27682. _checkCollisions: boolean;
  27683. _collisionMask: number;
  27684. _collisionGroup: number;
  27685. _collider: Nullable<Collider>;
  27686. _oldPositionForCollisions: Vector3;
  27687. _diffPositionForCollisions: Vector3;
  27688. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  27689. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  27690. }
  27691. }
  27692. declare module BABYLON {
  27693. /** @hidden */
  27694. class _FacetDataStorage {
  27695. facetPositions: Vector3[];
  27696. facetNormals: Vector3[];
  27697. facetPartitioning: number[][];
  27698. facetNb: number;
  27699. partitioningSubdivisions: number;
  27700. partitioningBBoxRatio: number;
  27701. facetDataEnabled: boolean;
  27702. facetParameters: any;
  27703. bbSize: Vector3;
  27704. subDiv: {
  27705. max: number;
  27706. X: number;
  27707. Y: number;
  27708. Z: number;
  27709. };
  27710. facetDepthSort: boolean;
  27711. facetDepthSortEnabled: boolean;
  27712. depthSortedIndices: IndicesArray;
  27713. depthSortedFacets: {
  27714. ind: number;
  27715. sqDistance: number;
  27716. }[];
  27717. facetDepthSortFunction: (f1: {
  27718. ind: number;
  27719. sqDistance: number;
  27720. }, f2: {
  27721. ind: number;
  27722. sqDistance: number;
  27723. }) => number;
  27724. facetDepthSortFrom: Vector3;
  27725. facetDepthSortOrigin: Vector3;
  27726. invertedMatrix: Matrix;
  27727. }
  27728. /**
  27729. * @hidden
  27730. **/
  27731. class _InternalAbstractMeshDataInfo {
  27732. _hasVertexAlpha: boolean;
  27733. _useVertexColors: boolean;
  27734. _numBoneInfluencers: number;
  27735. _applyFog: boolean;
  27736. _receiveShadows: boolean;
  27737. _facetData: _FacetDataStorage;
  27738. _visibility: number;
  27739. _skeleton: Nullable<Skeleton>;
  27740. _layerMask: number;
  27741. _computeBonesUsingShaders: boolean;
  27742. _isActive: boolean;
  27743. _onlyForInstances: boolean;
  27744. _isActiveIntermediate: boolean;
  27745. _onlyForInstancesIntermediate: boolean;
  27746. _actAsRegularMesh: boolean;
  27747. }
  27748. /**
  27749. * Class used to store all common mesh properties
  27750. */
  27751. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  27752. /** No occlusion */
  27753. static OCCLUSION_TYPE_NONE: number;
  27754. /** Occlusion set to optimisitic */
  27755. static OCCLUSION_TYPE_OPTIMISTIC: number;
  27756. /** Occlusion set to strict */
  27757. static OCCLUSION_TYPE_STRICT: number;
  27758. /** Use an accurante occlusion algorithm */
  27759. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  27760. /** Use a conservative occlusion algorithm */
  27761. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  27762. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  27763. * Test order :
  27764. * Is the bounding sphere outside the frustum ?
  27765. * If not, are the bounding box vertices outside the frustum ?
  27766. * It not, then the cullable object is in the frustum.
  27767. */
  27768. static readonly CULLINGSTRATEGY_STANDARD: number;
  27769. /** Culling strategy : Bounding Sphere Only.
  27770. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  27771. * It's also less accurate than the standard because some not visible objects can still be selected.
  27772. * Test : is the bounding sphere outside the frustum ?
  27773. * If not, then the cullable object is in the frustum.
  27774. */
  27775. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  27776. /** Culling strategy : Optimistic Inclusion.
  27777. * This in an inclusion test first, then the standard exclusion test.
  27778. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  27779. * This could also be a little slower than the standard test when the tested object center is not the frustum but one of its bounding box vertex is still inside.
  27780. * Anyway, it's as accurate as the standard strategy.
  27781. * Test :
  27782. * Is the cullable object bounding sphere center in the frustum ?
  27783. * If not, apply the default culling strategy.
  27784. */
  27785. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  27786. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  27787. * This in an inclusion test first, then the bounding sphere only exclusion test.
  27788. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  27789. * This could also be a little slower than the BoundingSphereOnly strategy when the tested object center is not in the frustum but its bounding sphere still intersects it.
  27790. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  27791. * Test :
  27792. * Is the cullable object bounding sphere center in the frustum ?
  27793. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  27794. */
  27795. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  27796. /**
  27797. * No billboard
  27798. */
  27799. static get BILLBOARDMODE_NONE(): number;
  27800. /** Billboard on X axis */
  27801. static get BILLBOARDMODE_X(): number;
  27802. /** Billboard on Y axis */
  27803. static get BILLBOARDMODE_Y(): number;
  27804. /** Billboard on Z axis */
  27805. static get BILLBOARDMODE_Z(): number;
  27806. /** Billboard on all axes */
  27807. static get BILLBOARDMODE_ALL(): number;
  27808. /** Billboard on using position instead of orientation */
  27809. static get BILLBOARDMODE_USE_POSITION(): number;
  27810. /** @hidden */
  27811. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  27812. /**
  27813. * The culling strategy to use to check whether the mesh must be rendered or not.
  27814. * This value can be changed at any time and will be used on the next render mesh selection.
  27815. * The possible values are :
  27816. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  27817. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  27818. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  27819. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  27820. * Please read each static variable documentation to get details about the culling process.
  27821. * */
  27822. cullingStrategy: number;
  27823. /**
  27824. * Gets the number of facets in the mesh
  27825. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  27826. */
  27827. get facetNb(): number;
  27828. /**
  27829. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  27830. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  27831. */
  27832. get partitioningSubdivisions(): number;
  27833. set partitioningSubdivisions(nb: number);
  27834. /**
  27835. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  27836. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  27837. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  27838. */
  27839. get partitioningBBoxRatio(): number;
  27840. set partitioningBBoxRatio(ratio: number);
  27841. /**
  27842. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  27843. * Works only for updatable meshes.
  27844. * Doesn't work with multi-materials
  27845. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  27846. */
  27847. get mustDepthSortFacets(): boolean;
  27848. set mustDepthSortFacets(sort: boolean);
  27849. /**
  27850. * The location (Vector3) where the facet depth sort must be computed from.
  27851. * By default, the active camera position.
  27852. * Used only when facet depth sort is enabled
  27853. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  27854. */
  27855. get facetDepthSortFrom(): Vector3;
  27856. set facetDepthSortFrom(location: Vector3);
  27857. /**
  27858. * gets a boolean indicating if facetData is enabled
  27859. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  27860. */
  27861. get isFacetDataEnabled(): boolean;
  27862. /** @hidden */
  27863. _updateNonUniformScalingState(value: boolean): boolean;
  27864. /**
  27865. * An event triggered when this mesh collides with another one
  27866. */
  27867. onCollideObservable: Observable<AbstractMesh>;
  27868. /** Set a function to call when this mesh collides with another one */
  27869. set onCollide(callback: () => void);
  27870. /**
  27871. * An event triggered when the collision's position changes
  27872. */
  27873. onCollisionPositionChangeObservable: Observable<Vector3>;
  27874. /** Set a function to call when the collision's position changes */
  27875. set onCollisionPositionChange(callback: () => void);
  27876. /**
  27877. * An event triggered when material is changed
  27878. */
  27879. onMaterialChangedObservable: Observable<AbstractMesh>;
  27880. /**
  27881. * Gets or sets the orientation for POV movement & rotation
  27882. */
  27883. definedFacingForward: boolean;
  27884. /** @hidden */
  27885. _occlusionQuery: Nullable<WebGLQuery>;
  27886. /** @hidden */
  27887. _renderingGroup: Nullable<RenderingGroup>;
  27888. /**
  27889. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  27890. */
  27891. get visibility(): number;
  27892. /**
  27893. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  27894. */
  27895. set visibility(value: number);
  27896. /** Gets or sets the alpha index used to sort transparent meshes
  27897. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  27898. */
  27899. alphaIndex: number;
  27900. /**
  27901. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  27902. */
  27903. isVisible: boolean;
  27904. /**
  27905. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  27906. */
  27907. isPickable: boolean;
  27908. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  27909. showSubMeshesBoundingBox: boolean;
  27910. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  27911. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  27912. */
  27913. isBlocker: boolean;
  27914. /**
  27915. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  27916. */
  27917. enablePointerMoveEvents: boolean;
  27918. /**
  27919. * Specifies the rendering group id for this mesh (0 by default)
  27920. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  27921. */
  27922. renderingGroupId: number;
  27923. private _material;
  27924. /** Gets or sets current material */
  27925. get material(): Nullable<Material>;
  27926. set material(value: Nullable<Material>);
  27927. /**
  27928. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  27929. * @see http://doc.babylonjs.com/babylon101/shadows
  27930. */
  27931. get receiveShadows(): boolean;
  27932. set receiveShadows(value: boolean);
  27933. /** Defines color to use when rendering outline */
  27934. outlineColor: Color3;
  27935. /** Define width to use when rendering outline */
  27936. outlineWidth: number;
  27937. /** Defines color to use when rendering overlay */
  27938. overlayColor: Color3;
  27939. /** Defines alpha to use when rendering overlay */
  27940. overlayAlpha: number;
  27941. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  27942. get hasVertexAlpha(): boolean;
  27943. set hasVertexAlpha(value: boolean);
  27944. /** Gets or sets a boolean indicating that this mesh needs to use vertex color data to render (if this kind of vertex data is available in the geometry) */
  27945. get useVertexColors(): boolean;
  27946. set useVertexColors(value: boolean);
  27947. /**
  27948. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  27949. */
  27950. get computeBonesUsingShaders(): boolean;
  27951. set computeBonesUsingShaders(value: boolean);
  27952. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  27953. get numBoneInfluencers(): number;
  27954. set numBoneInfluencers(value: number);
  27955. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  27956. get applyFog(): boolean;
  27957. set applyFog(value: boolean);
  27958. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  27959. useOctreeForRenderingSelection: boolean;
  27960. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  27961. useOctreeForPicking: boolean;
  27962. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  27963. useOctreeForCollisions: boolean;
  27964. /**
  27965. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  27966. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  27967. */
  27968. get layerMask(): number;
  27969. set layerMask(value: number);
  27970. /**
  27971. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  27972. */
  27973. alwaysSelectAsActiveMesh: boolean;
  27974. /**
  27975. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  27976. */
  27977. doNotSyncBoundingInfo: boolean;
  27978. /**
  27979. * Gets or sets the current action manager
  27980. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  27981. */
  27982. actionManager: Nullable<AbstractActionManager>;
  27983. private _meshCollisionData;
  27984. /**
  27985. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  27986. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27987. */
  27988. ellipsoid: Vector3;
  27989. /**
  27990. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  27991. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27992. */
  27993. ellipsoidOffset: Vector3;
  27994. /**
  27995. * Gets or sets a collision mask used to mask collisions (default is -1).
  27996. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  27997. */
  27998. get collisionMask(): number;
  27999. set collisionMask(mask: number);
  28000. /**
  28001. * Gets or sets the current collision group mask (-1 by default).
  28002. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  28003. */
  28004. get collisionGroup(): number;
  28005. set collisionGroup(mask: number);
  28006. /**
  28007. * Defines edge width used when edgesRenderer is enabled
  28008. * @see https://www.babylonjs-playground.com/#10OJSG#13
  28009. */
  28010. edgesWidth: number;
  28011. /**
  28012. * Defines edge color used when edgesRenderer is enabled
  28013. * @see https://www.babylonjs-playground.com/#10OJSG#13
  28014. */
  28015. edgesColor: Color4;
  28016. /** @hidden */
  28017. _edgesRenderer: Nullable<IEdgesRenderer>;
  28018. /** @hidden */
  28019. _masterMesh: Nullable<AbstractMesh>;
  28020. /** @hidden */
  28021. _boundingInfo: Nullable<BoundingInfo>;
  28022. /** @hidden */
  28023. _renderId: number;
  28024. /**
  28025. * Gets or sets the list of subMeshes
  28026. * @see http://doc.babylonjs.com/how_to/multi_materials
  28027. */
  28028. subMeshes: SubMesh[];
  28029. /** @hidden */
  28030. _intersectionsInProgress: AbstractMesh[];
  28031. /** @hidden */
  28032. _unIndexed: boolean;
  28033. /** @hidden */
  28034. _lightSources: Light[];
  28035. /** Gets the list of lights affecting that mesh */
  28036. get lightSources(): Light[];
  28037. /** @hidden */
  28038. get _positions(): Nullable<Vector3[]>;
  28039. /** @hidden */
  28040. _waitingData: {
  28041. lods: Nullable<any>;
  28042. actions: Nullable<any>;
  28043. freezeWorldMatrix: Nullable<boolean>;
  28044. };
  28045. /** @hidden */
  28046. _bonesTransformMatrices: Nullable<Float32Array>;
  28047. /** @hidden */
  28048. _transformMatrixTexture: Nullable<RawTexture>;
  28049. /**
  28050. * Gets or sets a skeleton to apply skining transformations
  28051. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  28052. */
  28053. set skeleton(value: Nullable<Skeleton>);
  28054. get skeleton(): Nullable<Skeleton>;
  28055. /**
  28056. * An event triggered when the mesh is rebuilt.
  28057. */
  28058. onRebuildObservable: Observable<AbstractMesh>;
  28059. /**
  28060. * Creates a new AbstractMesh
  28061. * @param name defines the name of the mesh
  28062. * @param scene defines the hosting scene
  28063. */
  28064. constructor(name: string, scene?: Nullable<Scene>);
  28065. /**
  28066. * Returns the string "AbstractMesh"
  28067. * @returns "AbstractMesh"
  28068. */
  28069. getClassName(): string;
  28070. /**
  28071. * Gets a string representation of the current mesh
  28072. * @param fullDetails defines a boolean indicating if full details must be included
  28073. * @returns a string representation of the current mesh
  28074. */
  28075. toString(fullDetails?: boolean): string;
  28076. /**
  28077. * @hidden
  28078. */
  28079. protected _getEffectiveParent(): Nullable<Node>;
  28080. /** @hidden */
  28081. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  28082. /** @hidden */
  28083. _rebuild(): void;
  28084. /** @hidden */
  28085. _resyncLightSources(): void;
  28086. /** @hidden */
  28087. _resyncLightSource(light: Light): void;
  28088. /** @hidden */
  28089. _unBindEffect(): void;
  28090. /** @hidden */
  28091. _removeLightSource(light: Light, dispose: boolean): void;
  28092. private _markSubMeshesAsDirty;
  28093. /** @hidden */
  28094. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  28095. /** @hidden */
  28096. _markSubMeshesAsAttributesDirty(): void;
  28097. /** @hidden */
  28098. _markSubMeshesAsMiscDirty(): void;
  28099. /**
  28100. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  28101. */
  28102. get scaling(): Vector3;
  28103. set scaling(newScaling: Vector3);
  28104. /**
  28105. * Returns true if the mesh is blocked. Implemented by child classes
  28106. */
  28107. get isBlocked(): boolean;
  28108. /**
  28109. * Returns the mesh itself by default. Implemented by child classes
  28110. * @param camera defines the camera to use to pick the right LOD level
  28111. * @returns the currentAbstractMesh
  28112. */
  28113. getLOD(camera: Camera): Nullable<AbstractMesh>;
  28114. /**
  28115. * Returns 0 by default. Implemented by child classes
  28116. * @returns an integer
  28117. */
  28118. getTotalVertices(): number;
  28119. /**
  28120. * Returns a positive integer : the total number of indices in this mesh geometry.
  28121. * @returns the numner of indices or zero if the mesh has no geometry.
  28122. */
  28123. getTotalIndices(): number;
  28124. /**
  28125. * Returns null by default. Implemented by child classes
  28126. * @returns null
  28127. */
  28128. getIndices(): Nullable<IndicesArray>;
  28129. /**
  28130. * Returns the array of the requested vertex data kind. Implemented by child classes
  28131. * @param kind defines the vertex data kind to use
  28132. * @returns null
  28133. */
  28134. getVerticesData(kind: string): Nullable<FloatArray>;
  28135. /**
  28136. * Sets the vertex data of the mesh geometry for the requested `kind`.
  28137. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  28138. * Note that a new underlying VertexBuffer object is created each call.
  28139. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  28140. * @param kind defines vertex data kind:
  28141. * * VertexBuffer.PositionKind
  28142. * * VertexBuffer.UVKind
  28143. * * VertexBuffer.UV2Kind
  28144. * * VertexBuffer.UV3Kind
  28145. * * VertexBuffer.UV4Kind
  28146. * * VertexBuffer.UV5Kind
  28147. * * VertexBuffer.UV6Kind
  28148. * * VertexBuffer.ColorKind
  28149. * * VertexBuffer.MatricesIndicesKind
  28150. * * VertexBuffer.MatricesIndicesExtraKind
  28151. * * VertexBuffer.MatricesWeightsKind
  28152. * * VertexBuffer.MatricesWeightsExtraKind
  28153. * @param data defines the data source
  28154. * @param updatable defines if the data must be flagged as updatable (or static)
  28155. * @param stride defines the vertex stride (size of an entire vertex). Can be null and in this case will be deduced from vertex data kind
  28156. * @returns the current mesh
  28157. */
  28158. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  28159. /**
  28160. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  28161. * If the mesh has no geometry, it is simply returned as it is.
  28162. * @param kind defines vertex data kind:
  28163. * * VertexBuffer.PositionKind
  28164. * * VertexBuffer.UVKind
  28165. * * VertexBuffer.UV2Kind
  28166. * * VertexBuffer.UV3Kind
  28167. * * VertexBuffer.UV4Kind
  28168. * * VertexBuffer.UV5Kind
  28169. * * VertexBuffer.UV6Kind
  28170. * * VertexBuffer.ColorKind
  28171. * * VertexBuffer.MatricesIndicesKind
  28172. * * VertexBuffer.MatricesIndicesExtraKind
  28173. * * VertexBuffer.MatricesWeightsKind
  28174. * * VertexBuffer.MatricesWeightsExtraKind
  28175. * @param data defines the data source
  28176. * @param updateExtends If `kind` is `PositionKind` and if `updateExtends` is true, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed
  28177. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  28178. * @returns the current mesh
  28179. */
  28180. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  28181. /**
  28182. * Sets the mesh indices,
  28183. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  28184. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  28185. * @param totalVertices Defines the total number of vertices
  28186. * @returns the current mesh
  28187. */
  28188. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  28189. /**
  28190. * Gets a boolean indicating if specific vertex data is present
  28191. * @param kind defines the vertex data kind to use
  28192. * @returns true is data kind is present
  28193. */
  28194. isVerticesDataPresent(kind: string): boolean;
  28195. /**
  28196. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  28197. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  28198. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  28199. * @returns a BoundingInfo
  28200. */
  28201. getBoundingInfo(): BoundingInfo;
  28202. /**
  28203. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  28204. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  28205. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  28206. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  28207. * @returns the current mesh
  28208. */
  28209. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  28210. /**
  28211. * Overwrite the current bounding info
  28212. * @param boundingInfo defines the new bounding info
  28213. * @returns the current mesh
  28214. */
  28215. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  28216. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  28217. get useBones(): boolean;
  28218. /** @hidden */
  28219. _preActivate(): void;
  28220. /** @hidden */
  28221. _preActivateForIntermediateRendering(renderId: number): void;
  28222. /** @hidden */
  28223. _activate(renderId: number, intermediateRendering: boolean): boolean;
  28224. /** @hidden */
  28225. _postActivate(): void;
  28226. /** @hidden */
  28227. _freeze(): void;
  28228. /** @hidden */
  28229. _unFreeze(): void;
  28230. /**
  28231. * Gets the current world matrix
  28232. * @returns a Matrix
  28233. */
  28234. getWorldMatrix(): Matrix;
  28235. /** @hidden */
  28236. _getWorldMatrixDeterminant(): number;
  28237. /**
  28238. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  28239. */
  28240. get isAnInstance(): boolean;
  28241. /**
  28242. * Gets a boolean indicating if this mesh has instances
  28243. */
  28244. get hasInstances(): boolean;
  28245. /**
  28246. * Perform relative position change from the point of view of behind the front of the mesh.
  28247. * This is performed taking into account the meshes current rotation, so you do not have to care.
  28248. * Supports definition of mesh facing forward or backward
  28249. * @param amountRight defines the distance on the right axis
  28250. * @param amountUp defines the distance on the up axis
  28251. * @param amountForward defines the distance on the forward axis
  28252. * @returns the current mesh
  28253. */
  28254. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  28255. /**
  28256. * Calculate relative position change from the point of view of behind the front of the mesh.
  28257. * This is performed taking into account the meshes current rotation, so you do not have to care.
  28258. * Supports definition of mesh facing forward or backward
  28259. * @param amountRight defines the distance on the right axis
  28260. * @param amountUp defines the distance on the up axis
  28261. * @param amountForward defines the distance on the forward axis
  28262. * @returns the new displacement vector
  28263. */
  28264. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  28265. /**
  28266. * Perform relative rotation change from the point of view of behind the front of the mesh.
  28267. * Supports definition of mesh facing forward or backward
  28268. * @param flipBack defines the flip
  28269. * @param twirlClockwise defines the twirl
  28270. * @param tiltRight defines the tilt
  28271. * @returns the current mesh
  28272. */
  28273. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  28274. /**
  28275. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  28276. * Supports definition of mesh facing forward or backward.
  28277. * @param flipBack defines the flip
  28278. * @param twirlClockwise defines the twirl
  28279. * @param tiltRight defines the tilt
  28280. * @returns the new rotation vector
  28281. */
  28282. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  28283. /**
  28284. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  28285. * This means the mesh underlying bounding box and sphere are recomputed.
  28286. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  28287. * @returns the current mesh
  28288. */
  28289. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  28290. /** @hidden */
  28291. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  28292. /** @hidden */
  28293. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  28294. /** @hidden */
  28295. _updateBoundingInfo(): AbstractMesh;
  28296. /** @hidden */
  28297. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  28298. /** @hidden */
  28299. protected _afterComputeWorldMatrix(): void;
  28300. /** @hidden */
  28301. get _effectiveMesh(): AbstractMesh;
  28302. /**
  28303. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  28304. * A mesh is in the frustum if its bounding box intersects the frustum
  28305. * @param frustumPlanes defines the frustum to test
  28306. * @returns true if the mesh is in the frustum planes
  28307. */
  28308. isInFrustum(frustumPlanes: Plane[]): boolean;
  28309. /**
  28310. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  28311. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  28312. * @param frustumPlanes defines the frustum to test
  28313. * @returns true if the mesh is completely in the frustum planes
  28314. */
  28315. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  28316. /**
  28317. * True if the mesh intersects another mesh or a SolidParticle object
  28318. * @param mesh defines a target mesh or SolidParticle to test
  28319. * @param precise Unless the parameter `precise` is set to `true` the intersection is computed according to Axis Aligned Bounding Boxes (AABB), else according to OBB (Oriented BBoxes)
  28320. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  28321. * @returns true if there is an intersection
  28322. */
  28323. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  28324. /**
  28325. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  28326. * @param point defines the point to test
  28327. * @returns true if there is an intersection
  28328. */
  28329. intersectsPoint(point: Vector3): boolean;
  28330. /**
  28331. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  28332. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28333. */
  28334. get checkCollisions(): boolean;
  28335. set checkCollisions(collisionEnabled: boolean);
  28336. /**
  28337. * Gets Collider object used to compute collisions (not physics)
  28338. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28339. */
  28340. get collider(): Nullable<Collider>;
  28341. /**
  28342. * Move the mesh using collision engine
  28343. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28344. * @param displacement defines the requested displacement vector
  28345. * @returns the current mesh
  28346. */
  28347. moveWithCollisions(displacement: Vector3): AbstractMesh;
  28348. private _onCollisionPositionChange;
  28349. /** @hidden */
  28350. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  28351. /** @hidden */
  28352. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  28353. /** @hidden */
  28354. _checkCollision(collider: Collider): AbstractMesh;
  28355. /** @hidden */
  28356. _generatePointsArray(): boolean;
  28357. /**
  28358. * Checks if the passed Ray intersects with the mesh
  28359. * @param ray defines the ray to use
  28360. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  28361. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  28362. * @returns the picking info
  28363. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  28364. */
  28365. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  28366. /**
  28367. * Clones the current mesh
  28368. * @param name defines the mesh name
  28369. * @param newParent defines the new mesh parent
  28370. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  28371. * @returns the new mesh
  28372. */
  28373. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  28374. /**
  28375. * Disposes all the submeshes of the current meshnp
  28376. * @returns the current mesh
  28377. */
  28378. releaseSubMeshes(): AbstractMesh;
  28379. /**
  28380. * Releases resources associated with this abstract mesh.
  28381. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  28382. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  28383. */
  28384. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  28385. /**
  28386. * Adds the passed mesh as a child to the current mesh
  28387. * @param mesh defines the child mesh
  28388. * @returns the current mesh
  28389. */
  28390. addChild(mesh: AbstractMesh): AbstractMesh;
  28391. /**
  28392. * Removes the passed mesh from the current mesh children list
  28393. * @param mesh defines the child mesh
  28394. * @returns the current mesh
  28395. */
  28396. removeChild(mesh: AbstractMesh): AbstractMesh;
  28397. /** @hidden */
  28398. private _initFacetData;
  28399. /**
  28400. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  28401. * This method can be called within the render loop.
  28402. * You don't need to call this method by yourself in the render loop when you update/morph a mesh with the methods CreateXXX() as they automatically manage this computation
  28403. * @returns the current mesh
  28404. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28405. */
  28406. updateFacetData(): AbstractMesh;
  28407. /**
  28408. * Returns the facetLocalNormals array.
  28409. * The normals are expressed in the mesh local spac
  28410. * @returns an array of Vector3
  28411. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28412. */
  28413. getFacetLocalNormals(): Vector3[];
  28414. /**
  28415. * Returns the facetLocalPositions array.
  28416. * The facet positions are expressed in the mesh local space
  28417. * @returns an array of Vector3
  28418. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28419. */
  28420. getFacetLocalPositions(): Vector3[];
  28421. /**
  28422. * Returns the facetLocalPartioning array
  28423. * @returns an array of array of numbers
  28424. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28425. */
  28426. getFacetLocalPartitioning(): number[][];
  28427. /**
  28428. * Returns the i-th facet position in the world system.
  28429. * This method allocates a new Vector3 per call
  28430. * @param i defines the facet index
  28431. * @returns a new Vector3
  28432. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28433. */
  28434. getFacetPosition(i: number): Vector3;
  28435. /**
  28436. * Sets the reference Vector3 with the i-th facet position in the world system
  28437. * @param i defines the facet index
  28438. * @param ref defines the target vector
  28439. * @returns the current mesh
  28440. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28441. */
  28442. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  28443. /**
  28444. * Returns the i-th facet normal in the world system.
  28445. * This method allocates a new Vector3 per call
  28446. * @param i defines the facet index
  28447. * @returns a new Vector3
  28448. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28449. */
  28450. getFacetNormal(i: number): Vector3;
  28451. /**
  28452. * Sets the reference Vector3 with the i-th facet normal in the world system
  28453. * @param i defines the facet index
  28454. * @param ref defines the target vector
  28455. * @returns the current mesh
  28456. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28457. */
  28458. getFacetNormalToRef(i: number, ref: Vector3): this;
  28459. /**
  28460. * Returns the facets (in an array) in the same partitioning block than the one the passed coordinates are located (expressed in the mesh local system)
  28461. * @param x defines x coordinate
  28462. * @param y defines y coordinate
  28463. * @param z defines z coordinate
  28464. * @returns the array of facet indexes
  28465. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28466. */
  28467. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  28468. /**
  28469. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  28470. * @param projected sets as the (x,y,z) world projection on the facet
  28471. * @param checkFace if true (default false), only the facet "facing" to (x,y,z) or only the ones "turning their backs", according to the parameter "facing" are returned
  28472. * @param facing if facing and checkFace are true, only the facet "facing" to (x, y, z) are returned : positive dot (x, y, z) * facet position. If facing si false and checkFace is true, only the facet "turning their backs" to (x, y, z) are returned : negative dot (x, y, z) * facet position
  28473. * @param x defines x coordinate
  28474. * @param y defines y coordinate
  28475. * @param z defines z coordinate
  28476. * @returns the face index if found (or null instead)
  28477. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28478. */
  28479. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  28480. /**
  28481. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  28482. * @param projected sets as the (x,y,z) local projection on the facet
  28483. * @param checkFace if true (default false), only the facet "facing" to (x,y,z) or only the ones "turning their backs", according to the parameter "facing" are returned
  28484. * @param facing if facing and checkFace are true, only the facet "facing" to (x, y, z) are returned : positive dot (x, y, z) * facet position. If facing si false and checkFace is true, only the facet "turning their backs" to (x, y, z) are returned : negative dot (x, y, z) * facet position
  28485. * @param x defines x coordinate
  28486. * @param y defines y coordinate
  28487. * @param z defines z coordinate
  28488. * @returns the face index if found (or null instead)
  28489. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28490. */
  28491. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  28492. /**
  28493. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  28494. * @returns the parameters
  28495. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28496. */
  28497. getFacetDataParameters(): any;
  28498. /**
  28499. * Disables the feature FacetData and frees the related memory
  28500. * @returns the current mesh
  28501. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28502. */
  28503. disableFacetData(): AbstractMesh;
  28504. /**
  28505. * Updates the AbstractMesh indices array
  28506. * @param indices defines the data source
  28507. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  28508. * @param gpuMemoryOnly defines a boolean indicating that only the GPU memory must be updated leaving the CPU version of the indices unchanged (false by default)
  28509. * @returns the current mesh
  28510. */
  28511. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  28512. /**
  28513. * Creates new normals data for the mesh
  28514. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  28515. * @returns the current mesh
  28516. */
  28517. createNormals(updatable: boolean): AbstractMesh;
  28518. /**
  28519. * Align the mesh with a normal
  28520. * @param normal defines the normal to use
  28521. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  28522. * @returns the current mesh
  28523. */
  28524. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  28525. /** @hidden */
  28526. _checkOcclusionQuery(): boolean;
  28527. /**
  28528. * Disables the mesh edge rendering mode
  28529. * @returns the currentAbstractMesh
  28530. */
  28531. disableEdgesRendering(): AbstractMesh;
  28532. /**
  28533. * Enables the edge rendering mode on the mesh.
  28534. * This mode makes the mesh edges visible
  28535. * @param epsilon defines the maximal distance between two angles to detect a face
  28536. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  28537. * @returns the currentAbstractMesh
  28538. * @see https://www.babylonjs-playground.com/#19O9TU#0
  28539. */
  28540. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  28541. }
  28542. }
  28543. declare module BABYLON {
  28544. /**
  28545. * Interface used to define ActionEvent
  28546. */
  28547. export interface IActionEvent {
  28548. /** The mesh or sprite that triggered the action */
  28549. source: any;
  28550. /** The X mouse cursor position at the time of the event */
  28551. pointerX: number;
  28552. /** The Y mouse cursor position at the time of the event */
  28553. pointerY: number;
  28554. /** The mesh that is currently pointed at (can be null) */
  28555. meshUnderPointer: Nullable<AbstractMesh>;
  28556. /** the original (browser) event that triggered the ActionEvent */
  28557. sourceEvent?: any;
  28558. /** additional data for the event */
  28559. additionalData?: any;
  28560. }
  28561. /**
  28562. * ActionEvent is the event being sent when an action is triggered.
  28563. */
  28564. export class ActionEvent implements IActionEvent {
  28565. /** The mesh or sprite that triggered the action */
  28566. source: any;
  28567. /** The X mouse cursor position at the time of the event */
  28568. pointerX: number;
  28569. /** The Y mouse cursor position at the time of the event */
  28570. pointerY: number;
  28571. /** The mesh that is currently pointed at (can be null) */
  28572. meshUnderPointer: Nullable<AbstractMesh>;
  28573. /** the original (browser) event that triggered the ActionEvent */
  28574. sourceEvent?: any;
  28575. /** additional data for the event */
  28576. additionalData?: any;
  28577. /**
  28578. * Creates a new ActionEvent
  28579. * @param source The mesh or sprite that triggered the action
  28580. * @param pointerX The X mouse cursor position at the time of the event
  28581. * @param pointerY The Y mouse cursor position at the time of the event
  28582. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  28583. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  28584. * @param additionalData additional data for the event
  28585. */
  28586. constructor(
  28587. /** The mesh or sprite that triggered the action */
  28588. source: any,
  28589. /** The X mouse cursor position at the time of the event */
  28590. pointerX: number,
  28591. /** The Y mouse cursor position at the time of the event */
  28592. pointerY: number,
  28593. /** The mesh that is currently pointed at (can be null) */
  28594. meshUnderPointer: Nullable<AbstractMesh>,
  28595. /** the original (browser) event that triggered the ActionEvent */
  28596. sourceEvent?: any,
  28597. /** additional data for the event */
  28598. additionalData?: any);
  28599. /**
  28600. * Helper function to auto-create an ActionEvent from a source mesh.
  28601. * @param source The source mesh that triggered the event
  28602. * @param evt The original (browser) event
  28603. * @param additionalData additional data for the event
  28604. * @returns the new ActionEvent
  28605. */
  28606. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  28607. /**
  28608. * Helper function to auto-create an ActionEvent from a source sprite
  28609. * @param source The source sprite that triggered the event
  28610. * @param scene Scene associated with the sprite
  28611. * @param evt The original (browser) event
  28612. * @param additionalData additional data for the event
  28613. * @returns the new ActionEvent
  28614. */
  28615. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  28616. /**
  28617. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  28618. * @param scene the scene where the event occurred
  28619. * @param evt The original (browser) event
  28620. * @returns the new ActionEvent
  28621. */
  28622. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  28623. /**
  28624. * Helper function to auto-create an ActionEvent from a primitive
  28625. * @param prim defines the target primitive
  28626. * @param pointerPos defines the pointer position
  28627. * @param evt The original (browser) event
  28628. * @param additionalData additional data for the event
  28629. * @returns the new ActionEvent
  28630. */
  28631. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  28632. }
  28633. }
  28634. declare module BABYLON {
  28635. /**
  28636. * Abstract class used to decouple action Manager from scene and meshes.
  28637. * Do not instantiate.
  28638. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  28639. */
  28640. export abstract class AbstractActionManager implements IDisposable {
  28641. /** Gets the list of active triggers */
  28642. static Triggers: {
  28643. [key: string]: number;
  28644. };
  28645. /** Gets the cursor to use when hovering items */
  28646. hoverCursor: string;
  28647. /** Gets the list of actions */
  28648. actions: IAction[];
  28649. /**
  28650. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  28651. */
  28652. isRecursive: boolean;
  28653. /**
  28654. * Releases all associated resources
  28655. */
  28656. abstract dispose(): void;
  28657. /**
  28658. * Does this action manager has pointer triggers
  28659. */
  28660. abstract get hasPointerTriggers(): boolean;
  28661. /**
  28662. * Does this action manager has pick triggers
  28663. */
  28664. abstract get hasPickTriggers(): boolean;
  28665. /**
  28666. * Process a specific trigger
  28667. * @param trigger defines the trigger to process
  28668. * @param evt defines the event details to be processed
  28669. */
  28670. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  28671. /**
  28672. * Does this action manager handles actions of any of the given triggers
  28673. * @param triggers defines the triggers to be tested
  28674. * @return a boolean indicating whether one (or more) of the triggers is handled
  28675. */
  28676. abstract hasSpecificTriggers(triggers: number[]): boolean;
  28677. /**
  28678. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  28679. * speed.
  28680. * @param triggerA defines the trigger to be tested
  28681. * @param triggerB defines the trigger to be tested
  28682. * @return a boolean indicating whether one (or more) of the triggers is handled
  28683. */
  28684. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  28685. /**
  28686. * Does this action manager handles actions of a given trigger
  28687. * @param trigger defines the trigger to be tested
  28688. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  28689. * @return whether the trigger is handled
  28690. */
  28691. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  28692. /**
  28693. * Serialize this manager to a JSON object
  28694. * @param name defines the property name to store this manager
  28695. * @returns a JSON representation of this manager
  28696. */
  28697. abstract serialize(name: string): any;
  28698. /**
  28699. * Registers an action to this action manager
  28700. * @param action defines the action to be registered
  28701. * @return the action amended (prepared) after registration
  28702. */
  28703. abstract registerAction(action: IAction): Nullable<IAction>;
  28704. /**
  28705. * Unregisters an action to this action manager
  28706. * @param action defines the action to be unregistered
  28707. * @return a boolean indicating whether the action has been unregistered
  28708. */
  28709. abstract unregisterAction(action: IAction): Boolean;
  28710. /**
  28711. * Does exist one action manager with at least one trigger
  28712. **/
  28713. static get HasTriggers(): boolean;
  28714. /**
  28715. * Does exist one action manager with at least one pick trigger
  28716. **/
  28717. static get HasPickTriggers(): boolean;
  28718. /**
  28719. * Does exist one action manager that handles actions of a given trigger
  28720. * @param trigger defines the trigger to be tested
  28721. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  28722. **/
  28723. static HasSpecificTrigger(trigger: number): boolean;
  28724. }
  28725. }
  28726. declare module BABYLON {
  28727. /**
  28728. * Defines how a node can be built from a string name.
  28729. */
  28730. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  28731. /**
  28732. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  28733. */
  28734. export class Node implements IBehaviorAware<Node> {
  28735. /** @hidden */
  28736. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  28737. private static _NodeConstructors;
  28738. /**
  28739. * Add a new node constructor
  28740. * @param type defines the type name of the node to construct
  28741. * @param constructorFunc defines the constructor function
  28742. */
  28743. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  28744. /**
  28745. * Returns a node constructor based on type name
  28746. * @param type defines the type name
  28747. * @param name defines the new node name
  28748. * @param scene defines the hosting scene
  28749. * @param options defines optional options to transmit to constructors
  28750. * @returns the new constructor or null
  28751. */
  28752. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  28753. /**
  28754. * Gets or sets the name of the node
  28755. */
  28756. name: string;
  28757. /**
  28758. * Gets or sets the id of the node
  28759. */
  28760. id: string;
  28761. /**
  28762. * Gets or sets the unique id of the node
  28763. */
  28764. uniqueId: number;
  28765. /**
  28766. * Gets or sets a string used to store user defined state for the node
  28767. */
  28768. state: string;
  28769. /**
  28770. * Gets or sets an object used to store user defined information for the node
  28771. */
  28772. metadata: any;
  28773. /**
  28774. * For internal use only. Please do not use.
  28775. */
  28776. reservedDataStore: any;
  28777. /**
  28778. * List of inspectable custom properties (used by the Inspector)
  28779. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  28780. */
  28781. inspectableCustomProperties: IInspectable[];
  28782. private _doNotSerialize;
  28783. /**
  28784. * Gets or sets a boolean used to define if the node must be serialized
  28785. */
  28786. get doNotSerialize(): boolean;
  28787. set doNotSerialize(value: boolean);
  28788. /** @hidden */
  28789. _isDisposed: boolean;
  28790. /**
  28791. * Gets a list of Animations associated with the node
  28792. */
  28793. animations: Animation[];
  28794. protected _ranges: {
  28795. [name: string]: Nullable<AnimationRange>;
  28796. };
  28797. /**
  28798. * Callback raised when the node is ready to be used
  28799. */
  28800. onReady: Nullable<(node: Node) => void>;
  28801. private _isEnabled;
  28802. private _isParentEnabled;
  28803. private _isReady;
  28804. /** @hidden */
  28805. _currentRenderId: number;
  28806. private _parentUpdateId;
  28807. /** @hidden */
  28808. _childUpdateId: number;
  28809. /** @hidden */
  28810. _waitingParentId: Nullable<string>;
  28811. /** @hidden */
  28812. _scene: Scene;
  28813. /** @hidden */
  28814. _cache: any;
  28815. private _parentNode;
  28816. private _children;
  28817. /** @hidden */
  28818. _worldMatrix: Matrix;
  28819. /** @hidden */
  28820. _worldMatrixDeterminant: number;
  28821. /** @hidden */
  28822. _worldMatrixDeterminantIsDirty: boolean;
  28823. /** @hidden */
  28824. private _sceneRootNodesIndex;
  28825. /**
  28826. * Gets a boolean indicating if the node has been disposed
  28827. * @returns true if the node was disposed
  28828. */
  28829. isDisposed(): boolean;
  28830. /**
  28831. * Gets or sets the parent of the node (without keeping the current position in the scene)
  28832. * @see https://doc.babylonjs.com/how_to/parenting
  28833. */
  28834. set parent(parent: Nullable<Node>);
  28835. get parent(): Nullable<Node>;
  28836. /** @hidden */
  28837. _addToSceneRootNodes(): void;
  28838. /** @hidden */
  28839. _removeFromSceneRootNodes(): void;
  28840. private _animationPropertiesOverride;
  28841. /**
  28842. * Gets or sets the animation properties override
  28843. */
  28844. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  28845. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  28846. /**
  28847. * Gets a string idenfifying the name of the class
  28848. * @returns "Node" string
  28849. */
  28850. getClassName(): string;
  28851. /** @hidden */
  28852. readonly _isNode: boolean;
  28853. /**
  28854. * An event triggered when the mesh is disposed
  28855. */
  28856. onDisposeObservable: Observable<Node>;
  28857. private _onDisposeObserver;
  28858. /**
  28859. * Sets a callback that will be raised when the node will be disposed
  28860. */
  28861. set onDispose(callback: () => void);
  28862. /**
  28863. * Creates a new Node
  28864. * @param name the name and id to be given to this node
  28865. * @param scene the scene this node will be added to
  28866. */
  28867. constructor(name: string, scene?: Nullable<Scene>);
  28868. /**
  28869. * Gets the scene of the node
  28870. * @returns a scene
  28871. */
  28872. getScene(): Scene;
  28873. /**
  28874. * Gets the engine of the node
  28875. * @returns a Engine
  28876. */
  28877. getEngine(): Engine;
  28878. private _behaviors;
  28879. /**
  28880. * Attach a behavior to the node
  28881. * @see http://doc.babylonjs.com/features/behaviour
  28882. * @param behavior defines the behavior to attach
  28883. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  28884. * @returns the current Node
  28885. */
  28886. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  28887. /**
  28888. * Remove an attached behavior
  28889. * @see http://doc.babylonjs.com/features/behaviour
  28890. * @param behavior defines the behavior to attach
  28891. * @returns the current Node
  28892. */
  28893. removeBehavior(behavior: Behavior<Node>): Node;
  28894. /**
  28895. * Gets the list of attached behaviors
  28896. * @see http://doc.babylonjs.com/features/behaviour
  28897. */
  28898. get behaviors(): Behavior<Node>[];
  28899. /**
  28900. * Gets an attached behavior by name
  28901. * @param name defines the name of the behavior to look for
  28902. * @see http://doc.babylonjs.com/features/behaviour
  28903. * @returns null if behavior was not found else the requested behavior
  28904. */
  28905. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  28906. /**
  28907. * Returns the latest update of the World matrix
  28908. * @returns a Matrix
  28909. */
  28910. getWorldMatrix(): Matrix;
  28911. /** @hidden */
  28912. _getWorldMatrixDeterminant(): number;
  28913. /**
  28914. * Returns directly the latest state of the mesh World matrix.
  28915. * A Matrix is returned.
  28916. */
  28917. get worldMatrixFromCache(): Matrix;
  28918. /** @hidden */
  28919. _initCache(): void;
  28920. /** @hidden */
  28921. updateCache(force?: boolean): void;
  28922. /** @hidden */
  28923. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  28924. /** @hidden */
  28925. _updateCache(ignoreParentClass?: boolean): void;
  28926. /** @hidden */
  28927. _isSynchronized(): boolean;
  28928. /** @hidden */
  28929. _markSyncedWithParent(): void;
  28930. /** @hidden */
  28931. isSynchronizedWithParent(): boolean;
  28932. /** @hidden */
  28933. isSynchronized(): boolean;
  28934. /**
  28935. * Is this node ready to be used/rendered
  28936. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  28937. * @return true if the node is ready
  28938. */
  28939. isReady(completeCheck?: boolean): boolean;
  28940. /**
  28941. * Is this node enabled?
  28942. * If the node has a parent, all ancestors will be checked and false will be returned if any are false (not enabled), otherwise will return true
  28943. * @param checkAncestors indicates if this method should check the ancestors. The default is to check the ancestors. If set to false, the method will return the value of this node without checking ancestors
  28944. * @return whether this node (and its parent) is enabled
  28945. */
  28946. isEnabled(checkAncestors?: boolean): boolean;
  28947. /** @hidden */
  28948. protected _syncParentEnabledState(): void;
  28949. /**
  28950. * Set the enabled state of this node
  28951. * @param value defines the new enabled state
  28952. */
  28953. setEnabled(value: boolean): void;
  28954. /**
  28955. * Is this node a descendant of the given node?
  28956. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  28957. * @param ancestor defines the parent node to inspect
  28958. * @returns a boolean indicating if this node is a descendant of the given node
  28959. */
  28960. isDescendantOf(ancestor: Node): boolean;
  28961. /** @hidden */
  28962. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  28963. /**
  28964. * Will return all nodes that have this node as ascendant
  28965. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered
  28966. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  28967. * @return all children nodes of all types
  28968. */
  28969. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  28970. /**
  28971. * Get all child-meshes of this node
  28972. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered (Default: false)
  28973. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  28974. * @returns an array of AbstractMesh
  28975. */
  28976. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  28977. /**
  28978. * Get all direct children of this node
  28979. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  28980. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered (Default: true)
  28981. * @returns an array of Node
  28982. */
  28983. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  28984. /** @hidden */
  28985. _setReady(state: boolean): void;
  28986. /**
  28987. * Get an animation by name
  28988. * @param name defines the name of the animation to look for
  28989. * @returns null if not found else the requested animation
  28990. */
  28991. getAnimationByName(name: string): Nullable<Animation>;
  28992. /**
  28993. * Creates an animation range for this node
  28994. * @param name defines the name of the range
  28995. * @param from defines the starting key
  28996. * @param to defines the end key
  28997. */
  28998. createAnimationRange(name: string, from: number, to: number): void;
  28999. /**
  29000. * Delete a specific animation range
  29001. * @param name defines the name of the range to delete
  29002. * @param deleteFrames defines if animation frames from the range must be deleted as well
  29003. */
  29004. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  29005. /**
  29006. * Get an animation range by name
  29007. * @param name defines the name of the animation range to look for
  29008. * @returns null if not found else the requested animation range
  29009. */
  29010. getAnimationRange(name: string): Nullable<AnimationRange>;
  29011. /**
  29012. * Gets the list of all animation ranges defined on this node
  29013. * @returns an array
  29014. */
  29015. getAnimationRanges(): Nullable<AnimationRange>[];
  29016. /**
  29017. * Will start the animation sequence
  29018. * @param name defines the range frames for animation sequence
  29019. * @param loop defines if the animation should loop (false by default)
  29020. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  29021. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  29022. * @returns the object created for this animation. If range does not exist, it will return null
  29023. */
  29024. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  29025. /**
  29026. * Serialize animation ranges into a JSON compatible object
  29027. * @returns serialization object
  29028. */
  29029. serializeAnimationRanges(): any;
  29030. /**
  29031. * Computes the world matrix of the node
  29032. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  29033. * @returns the world matrix
  29034. */
  29035. computeWorldMatrix(force?: boolean): Matrix;
  29036. /**
  29037. * Releases resources associated with this node.
  29038. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29039. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29040. */
  29041. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29042. /**
  29043. * Parse animation range data from a serialization object and store them into a given node
  29044. * @param node defines where to store the animation ranges
  29045. * @param parsedNode defines the serialization object to read data from
  29046. * @param scene defines the hosting scene
  29047. */
  29048. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  29049. /**
  29050. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  29051. * @param includeDescendants Include bounding info from descendants as well (true by default)
  29052. * @param predicate defines a callback function that can be customize to filter what meshes should be included in the list used to compute the bounding vectors
  29053. * @returns the new bounding vectors
  29054. */
  29055. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  29056. min: Vector3;
  29057. max: Vector3;
  29058. };
  29059. }
  29060. }
  29061. declare module BABYLON {
  29062. /**
  29063. * @hidden
  29064. */
  29065. export class _IAnimationState {
  29066. key: number;
  29067. repeatCount: number;
  29068. workValue?: any;
  29069. loopMode?: number;
  29070. offsetValue?: any;
  29071. highLimitValue?: any;
  29072. }
  29073. /**
  29074. * Class used to store any kind of animation
  29075. */
  29076. export class Animation {
  29077. /**Name of the animation */
  29078. name: string;
  29079. /**Property to animate */
  29080. targetProperty: string;
  29081. /**The frames per second of the animation */
  29082. framePerSecond: number;
  29083. /**The data type of the animation */
  29084. dataType: number;
  29085. /**The loop mode of the animation */
  29086. loopMode?: number | undefined;
  29087. /**Specifies if blending should be enabled */
  29088. enableBlending?: boolean | undefined;
  29089. /**
  29090. * Use matrix interpolation instead of using direct key value when animating matrices
  29091. */
  29092. static AllowMatricesInterpolation: boolean;
  29093. /**
  29094. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  29095. */
  29096. static AllowMatrixDecomposeForInterpolation: boolean;
  29097. /**
  29098. * Stores the key frames of the animation
  29099. */
  29100. private _keys;
  29101. /**
  29102. * Stores the easing function of the animation
  29103. */
  29104. private _easingFunction;
  29105. /**
  29106. * @hidden Internal use only
  29107. */
  29108. _runtimeAnimations: RuntimeAnimation[];
  29109. /**
  29110. * The set of event that will be linked to this animation
  29111. */
  29112. private _events;
  29113. /**
  29114. * Stores an array of target property paths
  29115. */
  29116. targetPropertyPath: string[];
  29117. /**
  29118. * Stores the blending speed of the animation
  29119. */
  29120. blendingSpeed: number;
  29121. /**
  29122. * Stores the animation ranges for the animation
  29123. */
  29124. private _ranges;
  29125. /**
  29126. * @hidden Internal use
  29127. */
  29128. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  29129. /**
  29130. * Sets up an animation
  29131. * @param property The property to animate
  29132. * @param animationType The animation type to apply
  29133. * @param framePerSecond The frames per second of the animation
  29134. * @param easingFunction The easing function used in the animation
  29135. * @returns The created animation
  29136. */
  29137. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  29138. /**
  29139. * Create and start an animation on a node
  29140. * @param name defines the name of the global animation that will be run on all nodes
  29141. * @param node defines the root node where the animation will take place
  29142. * @param targetProperty defines property to animate
  29143. * @param framePerSecond defines the number of frame per second yo use
  29144. * @param totalFrame defines the number of frames in total
  29145. * @param from defines the initial value
  29146. * @param to defines the final value
  29147. * @param loopMode defines which loop mode you want to use (off by default)
  29148. * @param easingFunction defines the easing function to use (linear by default)
  29149. * @param onAnimationEnd defines the callback to call when animation end
  29150. * @returns the animatable created for this animation
  29151. */
  29152. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  29153. /**
  29154. * Create and start an animation on a node and its descendants
  29155. * @param name defines the name of the global animation that will be run on all nodes
  29156. * @param node defines the root node where the animation will take place
  29157. * @param directDescendantsOnly if true only direct descendants will be used, if false direct and also indirect (children of children, an so on in a recursive manner) descendants will be used
  29158. * @param targetProperty defines property to animate
  29159. * @param framePerSecond defines the number of frame per second to use
  29160. * @param totalFrame defines the number of frames in total
  29161. * @param from defines the initial value
  29162. * @param to defines the final value
  29163. * @param loopMode defines which loop mode you want to use (off by default)
  29164. * @param easingFunction defines the easing function to use (linear by default)
  29165. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  29166. * @returns the list of animatables created for all nodes
  29167. * @example https://www.babylonjs-playground.com/#MH0VLI
  29168. */
  29169. static CreateAndStartHierarchyAnimation(name: string, node: Node, directDescendantsOnly: boolean, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable[]>;
  29170. /**
  29171. * Creates a new animation, merges it with the existing animations and starts it
  29172. * @param name Name of the animation
  29173. * @param node Node which contains the scene that begins the animations
  29174. * @param targetProperty Specifies which property to animate
  29175. * @param framePerSecond The frames per second of the animation
  29176. * @param totalFrame The total number of frames
  29177. * @param from The frame at the beginning of the animation
  29178. * @param to The frame at the end of the animation
  29179. * @param loopMode Specifies the loop mode of the animation
  29180. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  29181. * @param onAnimationEnd Callback to run once the animation is complete
  29182. * @returns Nullable animation
  29183. */
  29184. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  29185. /**
  29186. * Transition property of an host to the target Value
  29187. * @param property The property to transition
  29188. * @param targetValue The target Value of the property
  29189. * @param host The object where the property to animate belongs
  29190. * @param scene Scene used to run the animation
  29191. * @param frameRate Framerate (in frame/s) to use
  29192. * @param transition The transition type we want to use
  29193. * @param duration The duration of the animation, in milliseconds
  29194. * @param onAnimationEnd Callback trigger at the end of the animation
  29195. * @returns Nullable animation
  29196. */
  29197. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  29198. /**
  29199. * Return the array of runtime animations currently using this animation
  29200. */
  29201. get runtimeAnimations(): RuntimeAnimation[];
  29202. /**
  29203. * Specifies if any of the runtime animations are currently running
  29204. */
  29205. get hasRunningRuntimeAnimations(): boolean;
  29206. /**
  29207. * Initializes the animation
  29208. * @param name Name of the animation
  29209. * @param targetProperty Property to animate
  29210. * @param framePerSecond The frames per second of the animation
  29211. * @param dataType The data type of the animation
  29212. * @param loopMode The loop mode of the animation
  29213. * @param enableBlending Specifies if blending should be enabled
  29214. */
  29215. constructor(
  29216. /**Name of the animation */
  29217. name: string,
  29218. /**Property to animate */
  29219. targetProperty: string,
  29220. /**The frames per second of the animation */
  29221. framePerSecond: number,
  29222. /**The data type of the animation */
  29223. dataType: number,
  29224. /**The loop mode of the animation */
  29225. loopMode?: number | undefined,
  29226. /**Specifies if blending should be enabled */
  29227. enableBlending?: boolean | undefined);
  29228. /**
  29229. * Converts the animation to a string
  29230. * @param fullDetails support for multiple levels of logging within scene loading
  29231. * @returns String form of the animation
  29232. */
  29233. toString(fullDetails?: boolean): string;
  29234. /**
  29235. * Add an event to this animation
  29236. * @param event Event to add
  29237. */
  29238. addEvent(event: AnimationEvent): void;
  29239. /**
  29240. * Remove all events found at the given frame
  29241. * @param frame The frame to remove events from
  29242. */
  29243. removeEvents(frame: number): void;
  29244. /**
  29245. * Retrieves all the events from the animation
  29246. * @returns Events from the animation
  29247. */
  29248. getEvents(): AnimationEvent[];
  29249. /**
  29250. * Creates an animation range
  29251. * @param name Name of the animation range
  29252. * @param from Starting frame of the animation range
  29253. * @param to Ending frame of the animation
  29254. */
  29255. createRange(name: string, from: number, to: number): void;
  29256. /**
  29257. * Deletes an animation range by name
  29258. * @param name Name of the animation range to delete
  29259. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  29260. */
  29261. deleteRange(name: string, deleteFrames?: boolean): void;
  29262. /**
  29263. * Gets the animation range by name, or null if not defined
  29264. * @param name Name of the animation range
  29265. * @returns Nullable animation range
  29266. */
  29267. getRange(name: string): Nullable<AnimationRange>;
  29268. /**
  29269. * Gets the key frames from the animation
  29270. * @returns The key frames of the animation
  29271. */
  29272. getKeys(): Array<IAnimationKey>;
  29273. /**
  29274. * Gets the highest frame rate of the animation
  29275. * @returns Highest frame rate of the animation
  29276. */
  29277. getHighestFrame(): number;
  29278. /**
  29279. * Gets the easing function of the animation
  29280. * @returns Easing function of the animation
  29281. */
  29282. getEasingFunction(): IEasingFunction;
  29283. /**
  29284. * Sets the easing function of the animation
  29285. * @param easingFunction A custom mathematical formula for animation
  29286. */
  29287. setEasingFunction(easingFunction: EasingFunction): void;
  29288. /**
  29289. * Interpolates a scalar linearly
  29290. * @param startValue Start value of the animation curve
  29291. * @param endValue End value of the animation curve
  29292. * @param gradient Scalar amount to interpolate
  29293. * @returns Interpolated scalar value
  29294. */
  29295. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  29296. /**
  29297. * Interpolates a scalar cubically
  29298. * @param startValue Start value of the animation curve
  29299. * @param outTangent End tangent of the animation
  29300. * @param endValue End value of the animation curve
  29301. * @param inTangent Start tangent of the animation curve
  29302. * @param gradient Scalar amount to interpolate
  29303. * @returns Interpolated scalar value
  29304. */
  29305. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  29306. /**
  29307. * Interpolates a quaternion using a spherical linear interpolation
  29308. * @param startValue Start value of the animation curve
  29309. * @param endValue End value of the animation curve
  29310. * @param gradient Scalar amount to interpolate
  29311. * @returns Interpolated quaternion value
  29312. */
  29313. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  29314. /**
  29315. * Interpolates a quaternion cubically
  29316. * @param startValue Start value of the animation curve
  29317. * @param outTangent End tangent of the animation curve
  29318. * @param endValue End value of the animation curve
  29319. * @param inTangent Start tangent of the animation curve
  29320. * @param gradient Scalar amount to interpolate
  29321. * @returns Interpolated quaternion value
  29322. */
  29323. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  29324. /**
  29325. * Interpolates a Vector3 linearl
  29326. * @param startValue Start value of the animation curve
  29327. * @param endValue End value of the animation curve
  29328. * @param gradient Scalar amount to interpolate
  29329. * @returns Interpolated scalar value
  29330. */
  29331. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  29332. /**
  29333. * Interpolates a Vector3 cubically
  29334. * @param startValue Start value of the animation curve
  29335. * @param outTangent End tangent of the animation
  29336. * @param endValue End value of the animation curve
  29337. * @param inTangent Start tangent of the animation curve
  29338. * @param gradient Scalar amount to interpolate
  29339. * @returns InterpolatedVector3 value
  29340. */
  29341. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  29342. /**
  29343. * Interpolates a Vector2 linearly
  29344. * @param startValue Start value of the animation curve
  29345. * @param endValue End value of the animation curve
  29346. * @param gradient Scalar amount to interpolate
  29347. * @returns Interpolated Vector2 value
  29348. */
  29349. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  29350. /**
  29351. * Interpolates a Vector2 cubically
  29352. * @param startValue Start value of the animation curve
  29353. * @param outTangent End tangent of the animation
  29354. * @param endValue End value of the animation curve
  29355. * @param inTangent Start tangent of the animation curve
  29356. * @param gradient Scalar amount to interpolate
  29357. * @returns Interpolated Vector2 value
  29358. */
  29359. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  29360. /**
  29361. * Interpolates a size linearly
  29362. * @param startValue Start value of the animation curve
  29363. * @param endValue End value of the animation curve
  29364. * @param gradient Scalar amount to interpolate
  29365. * @returns Interpolated Size value
  29366. */
  29367. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  29368. /**
  29369. * Interpolates a Color3 linearly
  29370. * @param startValue Start value of the animation curve
  29371. * @param endValue End value of the animation curve
  29372. * @param gradient Scalar amount to interpolate
  29373. * @returns Interpolated Color3 value
  29374. */
  29375. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  29376. /**
  29377. * Interpolates a Color4 linearly
  29378. * @param startValue Start value of the animation curve
  29379. * @param endValue End value of the animation curve
  29380. * @param gradient Scalar amount to interpolate
  29381. * @returns Interpolated Color3 value
  29382. */
  29383. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  29384. /**
  29385. * @hidden Internal use only
  29386. */
  29387. _getKeyValue(value: any): any;
  29388. /**
  29389. * @hidden Internal use only
  29390. */
  29391. _interpolate(currentFrame: number, state: _IAnimationState): any;
  29392. /**
  29393. * Defines the function to use to interpolate matrices
  29394. * @param startValue defines the start matrix
  29395. * @param endValue defines the end matrix
  29396. * @param gradient defines the gradient between both matrices
  29397. * @param result defines an optional target matrix where to store the interpolation
  29398. * @returns the interpolated matrix
  29399. */
  29400. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  29401. /**
  29402. * Makes a copy of the animation
  29403. * @returns Cloned animation
  29404. */
  29405. clone(): Animation;
  29406. /**
  29407. * Sets the key frames of the animation
  29408. * @param values The animation key frames to set
  29409. */
  29410. setKeys(values: Array<IAnimationKey>): void;
  29411. /**
  29412. * Serializes the animation to an object
  29413. * @returns Serialized object
  29414. */
  29415. serialize(): any;
  29416. /**
  29417. * Float animation type
  29418. */
  29419. static readonly ANIMATIONTYPE_FLOAT: number;
  29420. /**
  29421. * Vector3 animation type
  29422. */
  29423. static readonly ANIMATIONTYPE_VECTOR3: number;
  29424. /**
  29425. * Quaternion animation type
  29426. */
  29427. static readonly ANIMATIONTYPE_QUATERNION: number;
  29428. /**
  29429. * Matrix animation type
  29430. */
  29431. static readonly ANIMATIONTYPE_MATRIX: number;
  29432. /**
  29433. * Color3 animation type
  29434. */
  29435. static readonly ANIMATIONTYPE_COLOR3: number;
  29436. /**
  29437. * Color3 animation type
  29438. */
  29439. static readonly ANIMATIONTYPE_COLOR4: number;
  29440. /**
  29441. * Vector2 animation type
  29442. */
  29443. static readonly ANIMATIONTYPE_VECTOR2: number;
  29444. /**
  29445. * Size animation type
  29446. */
  29447. static readonly ANIMATIONTYPE_SIZE: number;
  29448. /**
  29449. * Relative Loop Mode
  29450. */
  29451. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  29452. /**
  29453. * Cycle Loop Mode
  29454. */
  29455. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  29456. /**
  29457. * Constant Loop Mode
  29458. */
  29459. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  29460. /** @hidden */
  29461. static _UniversalLerp(left: any, right: any, amount: number): any;
  29462. /**
  29463. * Parses an animation object and creates an animation
  29464. * @param parsedAnimation Parsed animation object
  29465. * @returns Animation object
  29466. */
  29467. static Parse(parsedAnimation: any): Animation;
  29468. /**
  29469. * Appends the serialized animations from the source animations
  29470. * @param source Source containing the animations
  29471. * @param destination Target to store the animations
  29472. */
  29473. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  29474. }
  29475. }
  29476. declare module BABYLON {
  29477. /**
  29478. * Interface containing an array of animations
  29479. */
  29480. export interface IAnimatable {
  29481. /**
  29482. * Array of animations
  29483. */
  29484. animations: Nullable<Array<Animation>>;
  29485. }
  29486. }
  29487. declare module BABYLON {
  29488. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  29489. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29490. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29491. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29492. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29493. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29494. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29495. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29496. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29497. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29498. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29499. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29500. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29501. /**
  29502. * Decorator used to define property that can be serialized as reference to a camera
  29503. * @param sourceName defines the name of the property to decorate
  29504. */
  29505. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29506. /**
  29507. * Class used to help serialization objects
  29508. */
  29509. export class SerializationHelper {
  29510. /** @hidden */
  29511. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  29512. /** @hidden */
  29513. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  29514. /** @hidden */
  29515. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  29516. /** @hidden */
  29517. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  29518. /**
  29519. * Appends the serialized animations from the source animations
  29520. * @param source Source containing the animations
  29521. * @param destination Target to store the animations
  29522. */
  29523. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  29524. /**
  29525. * Static function used to serialized a specific entity
  29526. * @param entity defines the entity to serialize
  29527. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  29528. * @returns a JSON compatible object representing the serialization of the entity
  29529. */
  29530. static Serialize<T>(entity: T, serializationObject?: any): any;
  29531. /**
  29532. * Creates a new entity from a serialization data object
  29533. * @param creationFunction defines a function used to instanciated the new entity
  29534. * @param source defines the source serialization data
  29535. * @param scene defines the hosting scene
  29536. * @param rootUrl defines the root url for resources
  29537. * @returns a new entity
  29538. */
  29539. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  29540. /**
  29541. * Clones an object
  29542. * @param creationFunction defines the function used to instanciate the new object
  29543. * @param source defines the source object
  29544. * @returns the cloned object
  29545. */
  29546. static Clone<T>(creationFunction: () => T, source: T): T;
  29547. /**
  29548. * Instanciates a new object based on a source one (some data will be shared between both object)
  29549. * @param creationFunction defines the function used to instanciate the new object
  29550. * @param source defines the source object
  29551. * @returns the new object
  29552. */
  29553. static Instanciate<T>(creationFunction: () => T, source: T): T;
  29554. }
  29555. }
  29556. declare module BABYLON {
  29557. /**
  29558. * Class used to manipulate GUIDs
  29559. */
  29560. export class GUID {
  29561. /**
  29562. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  29563. * Be aware Math.random() could cause collisions, but:
  29564. * "All but 6 of the 128 bits of the ID are randomly generated, which means that for any two ids, there's a 1 in 2^^122 (or 5.3x10^^36) chance they'll collide"
  29565. * @returns a pseudo random id
  29566. */
  29567. static RandomId(): string;
  29568. }
  29569. }
  29570. declare module BABYLON {
  29571. /**
  29572. * Base class of all the textures in babylon.
  29573. * It groups all the common properties the materials, post process, lights... might need
  29574. * in order to make a correct use of the texture.
  29575. */
  29576. export class BaseTexture implements IAnimatable {
  29577. /**
  29578. * Default anisotropic filtering level for the application.
  29579. * It is set to 4 as a good tradeoff between perf and quality.
  29580. */
  29581. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  29582. /**
  29583. * Gets or sets the unique id of the texture
  29584. */
  29585. uniqueId: number;
  29586. /**
  29587. * Define the name of the texture.
  29588. */
  29589. name: string;
  29590. /**
  29591. * Gets or sets an object used to store user defined information.
  29592. */
  29593. metadata: any;
  29594. /**
  29595. * For internal use only. Please do not use.
  29596. */
  29597. reservedDataStore: any;
  29598. private _hasAlpha;
  29599. /**
  29600. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  29601. */
  29602. set hasAlpha(value: boolean);
  29603. get hasAlpha(): boolean;
  29604. /**
  29605. * Defines if the alpha value should be determined via the rgb values.
  29606. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  29607. */
  29608. getAlphaFromRGB: boolean;
  29609. /**
  29610. * Intensity or strength of the texture.
  29611. * It is commonly used by materials to fine tune the intensity of the texture
  29612. */
  29613. level: number;
  29614. /**
  29615. * Define the UV chanel to use starting from 0 and defaulting to 0.
  29616. * This is part of the texture as textures usually maps to one uv set.
  29617. */
  29618. coordinatesIndex: number;
  29619. private _coordinatesMode;
  29620. /**
  29621. * How a texture is mapped.
  29622. *
  29623. * | Value | Type | Description |
  29624. * | ----- | ----------------------------------- | ----------- |
  29625. * | 0 | EXPLICIT_MODE | |
  29626. * | 1 | SPHERICAL_MODE | |
  29627. * | 2 | PLANAR_MODE | |
  29628. * | 3 | CUBIC_MODE | |
  29629. * | 4 | PROJECTION_MODE | |
  29630. * | 5 | SKYBOX_MODE | |
  29631. * | 6 | INVCUBIC_MODE | |
  29632. * | 7 | EQUIRECTANGULAR_MODE | |
  29633. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  29634. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  29635. */
  29636. set coordinatesMode(value: number);
  29637. get coordinatesMode(): number;
  29638. /**
  29639. * | Value | Type | Description |
  29640. * | ----- | ------------------ | ----------- |
  29641. * | 0 | CLAMP_ADDRESSMODE | |
  29642. * | 1 | WRAP_ADDRESSMODE | |
  29643. * | 2 | MIRROR_ADDRESSMODE | |
  29644. */
  29645. wrapU: number;
  29646. /**
  29647. * | Value | Type | Description |
  29648. * | ----- | ------------------ | ----------- |
  29649. * | 0 | CLAMP_ADDRESSMODE | |
  29650. * | 1 | WRAP_ADDRESSMODE | |
  29651. * | 2 | MIRROR_ADDRESSMODE | |
  29652. */
  29653. wrapV: number;
  29654. /**
  29655. * | Value | Type | Description |
  29656. * | ----- | ------------------ | ----------- |
  29657. * | 0 | CLAMP_ADDRESSMODE | |
  29658. * | 1 | WRAP_ADDRESSMODE | |
  29659. * | 2 | MIRROR_ADDRESSMODE | |
  29660. */
  29661. wrapR: number;
  29662. /**
  29663. * With compliant hardware and browser (supporting anisotropic filtering)
  29664. * this defines the level of anisotropic filtering in the texture.
  29665. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  29666. */
  29667. anisotropicFilteringLevel: number;
  29668. /**
  29669. * Define if the texture is a cube texture or if false a 2d texture.
  29670. */
  29671. get isCube(): boolean;
  29672. set isCube(value: boolean);
  29673. /**
  29674. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  29675. */
  29676. get is3D(): boolean;
  29677. set is3D(value: boolean);
  29678. /**
  29679. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  29680. */
  29681. get is2DArray(): boolean;
  29682. set is2DArray(value: boolean);
  29683. /**
  29684. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  29685. * HDR texture are usually stored in linear space.
  29686. * This only impacts the PBR and Background materials
  29687. */
  29688. gammaSpace: boolean;
  29689. /**
  29690. * Gets or sets whether or not the texture contains RGBD data.
  29691. */
  29692. get isRGBD(): boolean;
  29693. set isRGBD(value: boolean);
  29694. /**
  29695. * Is Z inverted in the texture (useful in a cube texture).
  29696. */
  29697. invertZ: boolean;
  29698. /**
  29699. * Are mip maps generated for this texture or not.
  29700. */
  29701. get noMipmap(): boolean;
  29702. /**
  29703. * @hidden
  29704. */
  29705. lodLevelInAlpha: boolean;
  29706. /**
  29707. * With prefiltered texture, defined the offset used during the prefiltering steps.
  29708. */
  29709. get lodGenerationOffset(): number;
  29710. set lodGenerationOffset(value: number);
  29711. /**
  29712. * With prefiltered texture, defined the scale used during the prefiltering steps.
  29713. */
  29714. get lodGenerationScale(): number;
  29715. set lodGenerationScale(value: number);
  29716. /**
  29717. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  29718. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  29719. * average roughness values.
  29720. */
  29721. get linearSpecularLOD(): boolean;
  29722. set linearSpecularLOD(value: boolean);
  29723. /**
  29724. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  29725. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  29726. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  29727. */
  29728. get irradianceTexture(): Nullable<BaseTexture>;
  29729. set irradianceTexture(value: Nullable<BaseTexture>);
  29730. /**
  29731. * Define if the texture is a render target.
  29732. */
  29733. isRenderTarget: boolean;
  29734. /**
  29735. * Define the unique id of the texture in the scene.
  29736. */
  29737. get uid(): string;
  29738. /**
  29739. * Return a string representation of the texture.
  29740. * @returns the texture as a string
  29741. */
  29742. toString(): string;
  29743. /**
  29744. * Get the class name of the texture.
  29745. * @returns "BaseTexture"
  29746. */
  29747. getClassName(): string;
  29748. /**
  29749. * Define the list of animation attached to the texture.
  29750. */
  29751. animations: Animation[];
  29752. /**
  29753. * An event triggered when the texture is disposed.
  29754. */
  29755. onDisposeObservable: Observable<BaseTexture>;
  29756. private _onDisposeObserver;
  29757. /**
  29758. * Callback triggered when the texture has been disposed.
  29759. * Kept for back compatibility, you can use the onDisposeObservable instead.
  29760. */
  29761. set onDispose(callback: () => void);
  29762. /**
  29763. * Define the current state of the loading sequence when in delayed load mode.
  29764. */
  29765. delayLoadState: number;
  29766. private _scene;
  29767. /** @hidden */
  29768. _texture: Nullable<InternalTexture>;
  29769. private _uid;
  29770. /**
  29771. * Define if the texture is preventinga material to render or not.
  29772. * If not and the texture is not ready, the engine will use a default black texture instead.
  29773. */
  29774. get isBlocking(): boolean;
  29775. /**
  29776. * Instantiates a new BaseTexture.
  29777. * Base class of all the textures in babylon.
  29778. * It groups all the common properties the materials, post process, lights... might need
  29779. * in order to make a correct use of the texture.
  29780. * @param scene Define the scene the texture blongs to
  29781. */
  29782. constructor(scene: Nullable<Scene>);
  29783. /**
  29784. * Get the scene the texture belongs to.
  29785. * @returns the scene or null if undefined
  29786. */
  29787. getScene(): Nullable<Scene>;
  29788. /**
  29789. * Get the texture transform matrix used to offset tile the texture for istance.
  29790. * @returns the transformation matrix
  29791. */
  29792. getTextureMatrix(): Matrix;
  29793. /**
  29794. * Get the texture reflection matrix used to rotate/transform the reflection.
  29795. * @returns the reflection matrix
  29796. */
  29797. getReflectionTextureMatrix(): Matrix;
  29798. /**
  29799. * Get the underlying lower level texture from Babylon.
  29800. * @returns the insternal texture
  29801. */
  29802. getInternalTexture(): Nullable<InternalTexture>;
  29803. /**
  29804. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  29805. * @returns true if ready or not blocking
  29806. */
  29807. isReadyOrNotBlocking(): boolean;
  29808. /**
  29809. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  29810. * @returns true if fully ready
  29811. */
  29812. isReady(): boolean;
  29813. private _cachedSize;
  29814. /**
  29815. * Get the size of the texture.
  29816. * @returns the texture size.
  29817. */
  29818. getSize(): ISize;
  29819. /**
  29820. * Get the base size of the texture.
  29821. * It can be different from the size if the texture has been resized for POT for instance
  29822. * @returns the base size
  29823. */
  29824. getBaseSize(): ISize;
  29825. /**
  29826. * Update the sampling mode of the texture.
  29827. * Default is Trilinear mode.
  29828. *
  29829. * | Value | Type | Description |
  29830. * | ----- | ------------------ | ----------- |
  29831. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  29832. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  29833. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  29834. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  29835. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  29836. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  29837. * | 7 | NEAREST_LINEAR | |
  29838. * | 8 | NEAREST_NEAREST | |
  29839. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  29840. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  29841. * | 11 | LINEAR_LINEAR | |
  29842. * | 12 | LINEAR_NEAREST | |
  29843. *
  29844. * > _mag_: magnification filter (close to the viewer)
  29845. * > _min_: minification filter (far from the viewer)
  29846. * > _mip_: filter used between mip map levels
  29847. *@param samplingMode Define the new sampling mode of the texture
  29848. */
  29849. updateSamplingMode(samplingMode: number): void;
  29850. /**
  29851. * Scales the texture if is `canRescale()`
  29852. * @param ratio the resize factor we want to use to rescale
  29853. */
  29854. scale(ratio: number): void;
  29855. /**
  29856. * Get if the texture can rescale.
  29857. */
  29858. get canRescale(): boolean;
  29859. /** @hidden */
  29860. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  29861. /** @hidden */
  29862. _rebuild(): void;
  29863. /**
  29864. * Triggers the load sequence in delayed load mode.
  29865. */
  29866. delayLoad(): void;
  29867. /**
  29868. * Clones the texture.
  29869. * @returns the cloned texture
  29870. */
  29871. clone(): Nullable<BaseTexture>;
  29872. /**
  29873. * Get the texture underlying type (INT, FLOAT...)
  29874. */
  29875. get textureType(): number;
  29876. /**
  29877. * Get the texture underlying format (RGB, RGBA...)
  29878. */
  29879. get textureFormat(): number;
  29880. /**
  29881. * Indicates that textures need to be re-calculated for all materials
  29882. */
  29883. protected _markAllSubMeshesAsTexturesDirty(): void;
  29884. /**
  29885. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  29886. * This will returns an RGBA array buffer containing either in values (0-255) or
  29887. * float values (0-1) depending of the underlying buffer type.
  29888. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  29889. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  29890. * @param buffer defines a user defined buffer to fill with data (can be null)
  29891. * @returns The Array buffer containing the pixels data.
  29892. */
  29893. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  29894. /**
  29895. * Release and destroy the underlying lower level texture aka internalTexture.
  29896. */
  29897. releaseInternalTexture(): void;
  29898. /** @hidden */
  29899. get _lodTextureHigh(): Nullable<BaseTexture>;
  29900. /** @hidden */
  29901. get _lodTextureMid(): Nullable<BaseTexture>;
  29902. /** @hidden */
  29903. get _lodTextureLow(): Nullable<BaseTexture>;
  29904. /**
  29905. * Dispose the texture and release its associated resources.
  29906. */
  29907. dispose(): void;
  29908. /**
  29909. * Serialize the texture into a JSON representation that can be parsed later on.
  29910. * @returns the JSON representation of the texture
  29911. */
  29912. serialize(): any;
  29913. /**
  29914. * Helper function to be called back once a list of texture contains only ready textures.
  29915. * @param textures Define the list of textures to wait for
  29916. * @param callback Define the callback triggered once the entire list will be ready
  29917. */
  29918. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  29919. }
  29920. }
  29921. declare module BABYLON {
  29922. /**
  29923. * Options to be used when creating an effect.
  29924. */
  29925. export interface IEffectCreationOptions {
  29926. /**
  29927. * Atrributes that will be used in the shader.
  29928. */
  29929. attributes: string[];
  29930. /**
  29931. * Uniform varible names that will be set in the shader.
  29932. */
  29933. uniformsNames: string[];
  29934. /**
  29935. * Uniform buffer variable names that will be set in the shader.
  29936. */
  29937. uniformBuffersNames: string[];
  29938. /**
  29939. * Sampler texture variable names that will be set in the shader.
  29940. */
  29941. samplers: string[];
  29942. /**
  29943. * Define statements that will be set in the shader.
  29944. */
  29945. defines: any;
  29946. /**
  29947. * Possible fallbacks for this effect to improve performance when needed.
  29948. */
  29949. fallbacks: Nullable<IEffectFallbacks>;
  29950. /**
  29951. * Callback that will be called when the shader is compiled.
  29952. */
  29953. onCompiled: Nullable<(effect: Effect) => void>;
  29954. /**
  29955. * Callback that will be called if an error occurs during shader compilation.
  29956. */
  29957. onError: Nullable<(effect: Effect, errors: string) => void>;
  29958. /**
  29959. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29960. */
  29961. indexParameters?: any;
  29962. /**
  29963. * Max number of lights that can be used in the shader.
  29964. */
  29965. maxSimultaneousLights?: number;
  29966. /**
  29967. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  29968. */
  29969. transformFeedbackVaryings?: Nullable<string[]>;
  29970. }
  29971. /**
  29972. * Effect containing vertex and fragment shader that can be executed on an object.
  29973. */
  29974. export class Effect implements IDisposable {
  29975. /**
  29976. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  29977. */
  29978. static ShadersRepository: string;
  29979. /**
  29980. * Name of the effect.
  29981. */
  29982. name: any;
  29983. /**
  29984. * String container all the define statements that should be set on the shader.
  29985. */
  29986. defines: string;
  29987. /**
  29988. * Callback that will be called when the shader is compiled.
  29989. */
  29990. onCompiled: Nullable<(effect: Effect) => void>;
  29991. /**
  29992. * Callback that will be called if an error occurs during shader compilation.
  29993. */
  29994. onError: Nullable<(effect: Effect, errors: string) => void>;
  29995. /**
  29996. * Callback that will be called when effect is bound.
  29997. */
  29998. onBind: Nullable<(effect: Effect) => void>;
  29999. /**
  30000. * Unique ID of the effect.
  30001. */
  30002. uniqueId: number;
  30003. /**
  30004. * Observable that will be called when the shader is compiled.
  30005. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  30006. */
  30007. onCompileObservable: Observable<Effect>;
  30008. /**
  30009. * Observable that will be called if an error occurs during shader compilation.
  30010. */
  30011. onErrorObservable: Observable<Effect>;
  30012. /** @hidden */
  30013. _onBindObservable: Nullable<Observable<Effect>>;
  30014. /**
  30015. * @hidden
  30016. * Specifies if the effect was previously ready
  30017. */
  30018. _wasPreviouslyReady: boolean;
  30019. /**
  30020. * Observable that will be called when effect is bound.
  30021. */
  30022. get onBindObservable(): Observable<Effect>;
  30023. /** @hidden */
  30024. _bonesComputationForcedToCPU: boolean;
  30025. private static _uniqueIdSeed;
  30026. private _engine;
  30027. private _uniformBuffersNames;
  30028. private _uniformsNames;
  30029. private _samplerList;
  30030. private _samplers;
  30031. private _isReady;
  30032. private _compilationError;
  30033. private _allFallbacksProcessed;
  30034. private _attributesNames;
  30035. private _attributes;
  30036. private _attributeLocationByName;
  30037. private _uniforms;
  30038. /**
  30039. * Key for the effect.
  30040. * @hidden
  30041. */
  30042. _key: string;
  30043. private _indexParameters;
  30044. private _fallbacks;
  30045. private _vertexSourceCode;
  30046. private _fragmentSourceCode;
  30047. private _vertexSourceCodeOverride;
  30048. private _fragmentSourceCodeOverride;
  30049. private _transformFeedbackVaryings;
  30050. /**
  30051. * Compiled shader to webGL program.
  30052. * @hidden
  30053. */
  30054. _pipelineContext: Nullable<IPipelineContext>;
  30055. private _valueCache;
  30056. private static _baseCache;
  30057. /**
  30058. * Instantiates an effect.
  30059. * An effect can be used to create/manage/execute vertex and fragment shaders.
  30060. * @param baseName Name of the effect.
  30061. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  30062. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  30063. * @param samplers List of sampler variables that will be passed to the shader.
  30064. * @param engine Engine to be used to render the effect
  30065. * @param defines Define statements to be added to the shader.
  30066. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  30067. * @param onCompiled Callback that will be called when the shader is compiled.
  30068. * @param onError Callback that will be called if an error occurs during shader compilation.
  30069. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  30070. */
  30071. constructor(baseName: any, attributesNamesOrOptions: string[] | IEffectCreationOptions, uniformsNamesOrEngine: string[] | ThinEngine, samplers?: Nullable<string[]>, engine?: ThinEngine, defines?: Nullable<string>, fallbacks?: Nullable<IEffectFallbacks>, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any);
  30072. private _useFinalCode;
  30073. /**
  30074. * Unique key for this effect
  30075. */
  30076. get key(): string;
  30077. /**
  30078. * If the effect has been compiled and prepared.
  30079. * @returns if the effect is compiled and prepared.
  30080. */
  30081. isReady(): boolean;
  30082. private _isReadyInternal;
  30083. /**
  30084. * The engine the effect was initialized with.
  30085. * @returns the engine.
  30086. */
  30087. getEngine(): Engine;
  30088. /**
  30089. * The pipeline context for this effect
  30090. * @returns the associated pipeline context
  30091. */
  30092. getPipelineContext(): Nullable<IPipelineContext>;
  30093. /**
  30094. * The set of names of attribute variables for the shader.
  30095. * @returns An array of attribute names.
  30096. */
  30097. getAttributesNames(): string[];
  30098. /**
  30099. * Returns the attribute at the given index.
  30100. * @param index The index of the attribute.
  30101. * @returns The location of the attribute.
  30102. */
  30103. getAttributeLocation(index: number): number;
  30104. /**
  30105. * Returns the attribute based on the name of the variable.
  30106. * @param name of the attribute to look up.
  30107. * @returns the attribute location.
  30108. */
  30109. getAttributeLocationByName(name: string): number;
  30110. /**
  30111. * The number of attributes.
  30112. * @returns the numnber of attributes.
  30113. */
  30114. getAttributesCount(): number;
  30115. /**
  30116. * Gets the index of a uniform variable.
  30117. * @param uniformName of the uniform to look up.
  30118. * @returns the index.
  30119. */
  30120. getUniformIndex(uniformName: string): number;
  30121. /**
  30122. * Returns the attribute based on the name of the variable.
  30123. * @param uniformName of the uniform to look up.
  30124. * @returns the location of the uniform.
  30125. */
  30126. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  30127. /**
  30128. * Returns an array of sampler variable names
  30129. * @returns The array of sampler variable neames.
  30130. */
  30131. getSamplers(): string[];
  30132. /**
  30133. * The error from the last compilation.
  30134. * @returns the error string.
  30135. */
  30136. getCompilationError(): string;
  30137. /**
  30138. * Gets a boolean indicating that all fallbacks were used during compilation
  30139. * @returns true if all fallbacks were used
  30140. */
  30141. allFallbacksProcessed(): boolean;
  30142. /**
  30143. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  30144. * @param func The callback to be used.
  30145. */
  30146. executeWhenCompiled(func: (effect: Effect) => void): void;
  30147. private _checkIsReady;
  30148. private _loadShader;
  30149. /**
  30150. * Recompiles the webGL program
  30151. * @param vertexSourceCode The source code for the vertex shader.
  30152. * @param fragmentSourceCode The source code for the fragment shader.
  30153. * @param onCompiled Callback called when completed.
  30154. * @param onError Callback called on error.
  30155. * @hidden
  30156. */
  30157. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  30158. /**
  30159. * Prepares the effect
  30160. * @hidden
  30161. */
  30162. _prepareEffect(): void;
  30163. private _processCompilationErrors;
  30164. /**
  30165. * Checks if the effect is supported. (Must be called after compilation)
  30166. */
  30167. get isSupported(): boolean;
  30168. /**
  30169. * Binds a texture to the engine to be used as output of the shader.
  30170. * @param channel Name of the output variable.
  30171. * @param texture Texture to bind.
  30172. * @hidden
  30173. */
  30174. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  30175. /**
  30176. * Sets a texture on the engine to be used in the shader.
  30177. * @param channel Name of the sampler variable.
  30178. * @param texture Texture to set.
  30179. */
  30180. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  30181. /**
  30182. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  30183. * @param channel Name of the sampler variable.
  30184. * @param texture Texture to set.
  30185. */
  30186. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  30187. /**
  30188. * Sets an array of textures on the engine to be used in the shader.
  30189. * @param channel Name of the variable.
  30190. * @param textures Textures to set.
  30191. */
  30192. setTextureArray(channel: string, textures: BaseTexture[]): void;
  30193. /**
  30194. * Sets a texture to be the input of the specified post process. (To use the output, pass in the next post process in the pipeline)
  30195. * @param channel Name of the sampler variable.
  30196. * @param postProcess Post process to get the input texture from.
  30197. */
  30198. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  30199. /**
  30200. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  30201. * Sets the input texture of the passed in post process to be input of this effect. (To use the output of the passed in post process use setTextureFromPostProcessOutput)
  30202. * @param channel Name of the sampler variable.
  30203. * @param postProcess Post process to get the output texture from.
  30204. */
  30205. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  30206. /** @hidden */
  30207. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  30208. /** @hidden */
  30209. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  30210. /** @hidden */
  30211. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  30212. /** @hidden */
  30213. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  30214. /**
  30215. * Binds a buffer to a uniform.
  30216. * @param buffer Buffer to bind.
  30217. * @param name Name of the uniform variable to bind to.
  30218. */
  30219. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  30220. /**
  30221. * Binds block to a uniform.
  30222. * @param blockName Name of the block to bind.
  30223. * @param index Index to bind.
  30224. */
  30225. bindUniformBlock(blockName: string, index: number): void;
  30226. /**
  30227. * Sets an interger value on a uniform variable.
  30228. * @param uniformName Name of the variable.
  30229. * @param value Value to be set.
  30230. * @returns this effect.
  30231. */
  30232. setInt(uniformName: string, value: number): Effect;
  30233. /**
  30234. * Sets an int array on a uniform variable.
  30235. * @param uniformName Name of the variable.
  30236. * @param array array to be set.
  30237. * @returns this effect.
  30238. */
  30239. setIntArray(uniformName: string, array: Int32Array): Effect;
  30240. /**
  30241. * Sets an int array 2 on a uniform variable. (Array is specified as single array eg. [1,2,3,4] will result in [[1,2],[3,4]] in the shader)
  30242. * @param uniformName Name of the variable.
  30243. * @param array array to be set.
  30244. * @returns this effect.
  30245. */
  30246. setIntArray2(uniformName: string, array: Int32Array): Effect;
  30247. /**
  30248. * Sets an int array 3 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6] will result in [[1,2,3],[4,5,6]] in the shader)
  30249. * @param uniformName Name of the variable.
  30250. * @param array array to be set.
  30251. * @returns this effect.
  30252. */
  30253. setIntArray3(uniformName: string, array: Int32Array): Effect;
  30254. /**
  30255. * Sets an int array 4 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6,7,8] will result in [[1,2,3,4],[5,6,7,8]] in the shader)
  30256. * @param uniformName Name of the variable.
  30257. * @param array array to be set.
  30258. * @returns this effect.
  30259. */
  30260. setIntArray4(uniformName: string, array: Int32Array): Effect;
  30261. /**
  30262. * Sets an float array on a uniform variable.
  30263. * @param uniformName Name of the variable.
  30264. * @param array array to be set.
  30265. * @returns this effect.
  30266. */
  30267. setFloatArray(uniformName: string, array: Float32Array): Effect;
  30268. /**
  30269. * Sets an float array 2 on a uniform variable. (Array is specified as single array eg. [1,2,3,4] will result in [[1,2],[3,4]] in the shader)
  30270. * @param uniformName Name of the variable.
  30271. * @param array array to be set.
  30272. * @returns this effect.
  30273. */
  30274. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  30275. /**
  30276. * Sets an float array 3 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6] will result in [[1,2,3],[4,5,6]] in the shader)
  30277. * @param uniformName Name of the variable.
  30278. * @param array array to be set.
  30279. * @returns this effect.
  30280. */
  30281. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  30282. /**
  30283. * Sets an float array 4 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6,7,8] will result in [[1,2,3,4],[5,6,7,8]] in the shader)
  30284. * @param uniformName Name of the variable.
  30285. * @param array array to be set.
  30286. * @returns this effect.
  30287. */
  30288. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  30289. /**
  30290. * Sets an array on a uniform variable.
  30291. * @param uniformName Name of the variable.
  30292. * @param array array to be set.
  30293. * @returns this effect.
  30294. */
  30295. setArray(uniformName: string, array: number[]): Effect;
  30296. /**
  30297. * Sets an array 2 on a uniform variable. (Array is specified as single array eg. [1,2,3,4] will result in [[1,2],[3,4]] in the shader)
  30298. * @param uniformName Name of the variable.
  30299. * @param array array to be set.
  30300. * @returns this effect.
  30301. */
  30302. setArray2(uniformName: string, array: number[]): Effect;
  30303. /**
  30304. * Sets an array 3 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6] will result in [[1,2,3],[4,5,6]] in the shader)
  30305. * @param uniformName Name of the variable.
  30306. * @param array array to be set.
  30307. * @returns this effect.
  30308. */
  30309. setArray3(uniformName: string, array: number[]): Effect;
  30310. /**
  30311. * Sets an array 4 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6,7,8] will result in [[1,2,3,4],[5,6,7,8]] in the shader)
  30312. * @param uniformName Name of the variable.
  30313. * @param array array to be set.
  30314. * @returns this effect.
  30315. */
  30316. setArray4(uniformName: string, array: number[]): Effect;
  30317. /**
  30318. * Sets matrices on a uniform variable.
  30319. * @param uniformName Name of the variable.
  30320. * @param matrices matrices to be set.
  30321. * @returns this effect.
  30322. */
  30323. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  30324. /**
  30325. * Sets matrix on a uniform variable.
  30326. * @param uniformName Name of the variable.
  30327. * @param matrix matrix to be set.
  30328. * @returns this effect.
  30329. */
  30330. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  30331. /**
  30332. * Sets a 3x3 matrix on a uniform variable. (Speicified as [1,2,3,4,5,6,7,8,9] will result in [1,2,3][4,5,6][7,8,9] matrix)
  30333. * @param uniformName Name of the variable.
  30334. * @param matrix matrix to be set.
  30335. * @returns this effect.
  30336. */
  30337. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  30338. /**
  30339. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  30340. * @param uniformName Name of the variable.
  30341. * @param matrix matrix to be set.
  30342. * @returns this effect.
  30343. */
  30344. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  30345. /**
  30346. * Sets a float on a uniform variable.
  30347. * @param uniformName Name of the variable.
  30348. * @param value value to be set.
  30349. * @returns this effect.
  30350. */
  30351. setFloat(uniformName: string, value: number): Effect;
  30352. /**
  30353. * Sets a boolean on a uniform variable.
  30354. * @param uniformName Name of the variable.
  30355. * @param bool value to be set.
  30356. * @returns this effect.
  30357. */
  30358. setBool(uniformName: string, bool: boolean): Effect;
  30359. /**
  30360. * Sets a Vector2 on a uniform variable.
  30361. * @param uniformName Name of the variable.
  30362. * @param vector2 vector2 to be set.
  30363. * @returns this effect.
  30364. */
  30365. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  30366. /**
  30367. * Sets a float2 on a uniform variable.
  30368. * @param uniformName Name of the variable.
  30369. * @param x First float in float2.
  30370. * @param y Second float in float2.
  30371. * @returns this effect.
  30372. */
  30373. setFloat2(uniformName: string, x: number, y: number): Effect;
  30374. /**
  30375. * Sets a Vector3 on a uniform variable.
  30376. * @param uniformName Name of the variable.
  30377. * @param vector3 Value to be set.
  30378. * @returns this effect.
  30379. */
  30380. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  30381. /**
  30382. * Sets a float3 on a uniform variable.
  30383. * @param uniformName Name of the variable.
  30384. * @param x First float in float3.
  30385. * @param y Second float in float3.
  30386. * @param z Third float in float3.
  30387. * @returns this effect.
  30388. */
  30389. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  30390. /**
  30391. * Sets a Vector4 on a uniform variable.
  30392. * @param uniformName Name of the variable.
  30393. * @param vector4 Value to be set.
  30394. * @returns this effect.
  30395. */
  30396. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  30397. /**
  30398. * Sets a float4 on a uniform variable.
  30399. * @param uniformName Name of the variable.
  30400. * @param x First float in float4.
  30401. * @param y Second float in float4.
  30402. * @param z Third float in float4.
  30403. * @param w Fourth float in float4.
  30404. * @returns this effect.
  30405. */
  30406. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  30407. /**
  30408. * Sets a Color3 on a uniform variable.
  30409. * @param uniformName Name of the variable.
  30410. * @param color3 Value to be set.
  30411. * @returns this effect.
  30412. */
  30413. setColor3(uniformName: string, color3: IColor3Like): Effect;
  30414. /**
  30415. * Sets a Color4 on a uniform variable.
  30416. * @param uniformName Name of the variable.
  30417. * @param color3 Value to be set.
  30418. * @param alpha Alpha value to be set.
  30419. * @returns this effect.
  30420. */
  30421. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  30422. /**
  30423. * Sets a Color4 on a uniform variable
  30424. * @param uniformName defines the name of the variable
  30425. * @param color4 defines the value to be set
  30426. * @returns this effect.
  30427. */
  30428. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  30429. /** Release all associated resources */
  30430. dispose(): void;
  30431. /**
  30432. * This function will add a new shader to the shader store
  30433. * @param name the name of the shader
  30434. * @param pixelShader optional pixel shader content
  30435. * @param vertexShader optional vertex shader content
  30436. */
  30437. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  30438. /**
  30439. * Store of each shader (The can be looked up using effect.key)
  30440. */
  30441. static ShadersStore: {
  30442. [key: string]: string;
  30443. };
  30444. /**
  30445. * Store of each included file for a shader (The can be looked up using effect.key)
  30446. */
  30447. static IncludesShadersStore: {
  30448. [key: string]: string;
  30449. };
  30450. /**
  30451. * Resets the cache of effects.
  30452. */
  30453. static ResetCache(): void;
  30454. }
  30455. }
  30456. declare module BABYLON {
  30457. /**
  30458. * Interface used to describe the capabilities of the engine relatively to the current browser
  30459. */
  30460. export interface EngineCapabilities {
  30461. /** Maximum textures units per fragment shader */
  30462. maxTexturesImageUnits: number;
  30463. /** Maximum texture units per vertex shader */
  30464. maxVertexTextureImageUnits: number;
  30465. /** Maximum textures units in the entire pipeline */
  30466. maxCombinedTexturesImageUnits: number;
  30467. /** Maximum texture size */
  30468. maxTextureSize: number;
  30469. /** Maximum texture samples */
  30470. maxSamples?: number;
  30471. /** Maximum cube texture size */
  30472. maxCubemapTextureSize: number;
  30473. /** Maximum render texture size */
  30474. maxRenderTextureSize: number;
  30475. /** Maximum number of vertex attributes */
  30476. maxVertexAttribs: number;
  30477. /** Maximum number of varyings */
  30478. maxVaryingVectors: number;
  30479. /** Maximum number of uniforms per vertex shader */
  30480. maxVertexUniformVectors: number;
  30481. /** Maximum number of uniforms per fragment shader */
  30482. maxFragmentUniformVectors: number;
  30483. /** Defines if standard derivates (dx/dy) are supported */
  30484. standardDerivatives: boolean;
  30485. /** Defines if s3tc texture compression is supported */
  30486. s3tc?: WEBGL_compressed_texture_s3tc;
  30487. /** Defines if pvrtc texture compression is supported */
  30488. pvrtc: any;
  30489. /** Defines if etc1 texture compression is supported */
  30490. etc1: any;
  30491. /** Defines if etc2 texture compression is supported */
  30492. etc2: any;
  30493. /** Defines if astc texture compression is supported */
  30494. astc: any;
  30495. /** Defines if float textures are supported */
  30496. textureFloat: boolean;
  30497. /** Defines if vertex array objects are supported */
  30498. vertexArrayObject: boolean;
  30499. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  30500. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  30501. /** Gets the maximum level of anisotropy supported */
  30502. maxAnisotropy: number;
  30503. /** Defines if instancing is supported */
  30504. instancedArrays: boolean;
  30505. /** Defines if 32 bits indices are supported */
  30506. uintIndices: boolean;
  30507. /** Defines if high precision shaders are supported */
  30508. highPrecisionShaderSupported: boolean;
  30509. /** Defines if depth reading in the fragment shader is supported */
  30510. fragmentDepthSupported: boolean;
  30511. /** Defines if float texture linear filtering is supported*/
  30512. textureFloatLinearFiltering: boolean;
  30513. /** Defines if rendering to float textures is supported */
  30514. textureFloatRender: boolean;
  30515. /** Defines if half float textures are supported*/
  30516. textureHalfFloat: boolean;
  30517. /** Defines if half float texture linear filtering is supported*/
  30518. textureHalfFloatLinearFiltering: boolean;
  30519. /** Defines if rendering to half float textures is supported */
  30520. textureHalfFloatRender: boolean;
  30521. /** Defines if textureLOD shader command is supported */
  30522. textureLOD: boolean;
  30523. /** Defines if draw buffers extension is supported */
  30524. drawBuffersExtension: boolean;
  30525. /** Defines if depth textures are supported */
  30526. depthTextureExtension: boolean;
  30527. /** Defines if float color buffer are supported */
  30528. colorBufferFloat: boolean;
  30529. /** Gets disjoint timer query extension (null if not supported) */
  30530. timerQuery?: EXT_disjoint_timer_query;
  30531. /** Defines if timestamp can be used with timer query */
  30532. canUseTimestampForTimerQuery: boolean;
  30533. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  30534. multiview?: any;
  30535. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  30536. oculusMultiview?: any;
  30537. /** Function used to let the system compiles shaders in background */
  30538. parallelShaderCompile?: {
  30539. COMPLETION_STATUS_KHR: number;
  30540. };
  30541. /** Max number of texture samples for MSAA */
  30542. maxMSAASamples: number;
  30543. /** Defines if the blend min max extension is supported */
  30544. blendMinMax: boolean;
  30545. }
  30546. }
  30547. declare module BABYLON {
  30548. /**
  30549. * @hidden
  30550. **/
  30551. export class DepthCullingState {
  30552. private _isDepthTestDirty;
  30553. private _isDepthMaskDirty;
  30554. private _isDepthFuncDirty;
  30555. private _isCullFaceDirty;
  30556. private _isCullDirty;
  30557. private _isZOffsetDirty;
  30558. private _isFrontFaceDirty;
  30559. private _depthTest;
  30560. private _depthMask;
  30561. private _depthFunc;
  30562. private _cull;
  30563. private _cullFace;
  30564. private _zOffset;
  30565. private _frontFace;
  30566. /**
  30567. * Initializes the state.
  30568. */
  30569. constructor();
  30570. get isDirty(): boolean;
  30571. get zOffset(): number;
  30572. set zOffset(value: number);
  30573. get cullFace(): Nullable<number>;
  30574. set cullFace(value: Nullable<number>);
  30575. get cull(): Nullable<boolean>;
  30576. set cull(value: Nullable<boolean>);
  30577. get depthFunc(): Nullable<number>;
  30578. set depthFunc(value: Nullable<number>);
  30579. get depthMask(): boolean;
  30580. set depthMask(value: boolean);
  30581. get depthTest(): boolean;
  30582. set depthTest(value: boolean);
  30583. get frontFace(): Nullable<number>;
  30584. set frontFace(value: Nullable<number>);
  30585. reset(): void;
  30586. apply(gl: WebGLRenderingContext): void;
  30587. }
  30588. }
  30589. declare module BABYLON {
  30590. /**
  30591. * @hidden
  30592. **/
  30593. export class StencilState {
  30594. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  30595. static readonly ALWAYS: number;
  30596. /** Passed to stencilOperation to specify that stencil value must be kept */
  30597. static readonly KEEP: number;
  30598. /** Passed to stencilOperation to specify that stencil value must be replaced */
  30599. static readonly REPLACE: number;
  30600. private _isStencilTestDirty;
  30601. private _isStencilMaskDirty;
  30602. private _isStencilFuncDirty;
  30603. private _isStencilOpDirty;
  30604. private _stencilTest;
  30605. private _stencilMask;
  30606. private _stencilFunc;
  30607. private _stencilFuncRef;
  30608. private _stencilFuncMask;
  30609. private _stencilOpStencilFail;
  30610. private _stencilOpDepthFail;
  30611. private _stencilOpStencilDepthPass;
  30612. get isDirty(): boolean;
  30613. get stencilFunc(): number;
  30614. set stencilFunc(value: number);
  30615. get stencilFuncRef(): number;
  30616. set stencilFuncRef(value: number);
  30617. get stencilFuncMask(): number;
  30618. set stencilFuncMask(value: number);
  30619. get stencilOpStencilFail(): number;
  30620. set stencilOpStencilFail(value: number);
  30621. get stencilOpDepthFail(): number;
  30622. set stencilOpDepthFail(value: number);
  30623. get stencilOpStencilDepthPass(): number;
  30624. set stencilOpStencilDepthPass(value: number);
  30625. get stencilMask(): number;
  30626. set stencilMask(value: number);
  30627. get stencilTest(): boolean;
  30628. set stencilTest(value: boolean);
  30629. constructor();
  30630. reset(): void;
  30631. apply(gl: WebGLRenderingContext): void;
  30632. }
  30633. }
  30634. declare module BABYLON {
  30635. /**
  30636. * @hidden
  30637. **/
  30638. export class AlphaState {
  30639. private _isAlphaBlendDirty;
  30640. private _isBlendFunctionParametersDirty;
  30641. private _isBlendEquationParametersDirty;
  30642. private _isBlendConstantsDirty;
  30643. private _alphaBlend;
  30644. private _blendFunctionParameters;
  30645. private _blendEquationParameters;
  30646. private _blendConstants;
  30647. /**
  30648. * Initializes the state.
  30649. */
  30650. constructor();
  30651. get isDirty(): boolean;
  30652. get alphaBlend(): boolean;
  30653. set alphaBlend(value: boolean);
  30654. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  30655. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  30656. setAlphaEquationParameters(rgb: number, alpha: number): void;
  30657. reset(): void;
  30658. apply(gl: WebGLRenderingContext): void;
  30659. }
  30660. }
  30661. declare module BABYLON {
  30662. /** @hidden */
  30663. export class WebGL2ShaderProcessor implements IShaderProcessor {
  30664. attributeProcessor(attribute: string): string;
  30665. varyingProcessor(varying: string, isFragment: boolean): string;
  30666. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  30667. }
  30668. }
  30669. declare module BABYLON {
  30670. /**
  30671. * Interface for attribute information associated with buffer instanciation
  30672. */
  30673. export interface InstancingAttributeInfo {
  30674. /**
  30675. * Name of the GLSL attribute
  30676. * if attribute index is not specified, this is used to retrieve the index from the effect
  30677. */
  30678. attributeName: string;
  30679. /**
  30680. * Index/offset of the attribute in the vertex shader
  30681. * if not specified, this will be computes from the name.
  30682. */
  30683. index?: number;
  30684. /**
  30685. * size of the attribute, 1, 2, 3 or 4
  30686. */
  30687. attributeSize: number;
  30688. /**
  30689. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  30690. */
  30691. offset: number;
  30692. /**
  30693. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  30694. * default to 1
  30695. */
  30696. divisor?: number;
  30697. /**
  30698. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  30699. * default is FLOAT
  30700. */
  30701. attributeType?: number;
  30702. /**
  30703. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  30704. */
  30705. normalized?: boolean;
  30706. }
  30707. }
  30708. declare module BABYLON {
  30709. interface ThinEngine {
  30710. /**
  30711. * Update a video texture
  30712. * @param texture defines the texture to update
  30713. * @param video defines the video element to use
  30714. * @param invertY defines if data must be stored with Y axis inverted
  30715. */
  30716. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  30717. }
  30718. }
  30719. declare module BABYLON {
  30720. /**
  30721. * Settings for finer control over video usage
  30722. */
  30723. export interface VideoTextureSettings {
  30724. /**
  30725. * Applies `autoplay` to video, if specified
  30726. */
  30727. autoPlay?: boolean;
  30728. /**
  30729. * Applies `loop` to video, if specified
  30730. */
  30731. loop?: boolean;
  30732. /**
  30733. * Automatically updates internal texture from video at every frame in the render loop
  30734. */
  30735. autoUpdateTexture: boolean;
  30736. /**
  30737. * Image src displayed during the video loading or until the user interacts with the video.
  30738. */
  30739. poster?: string;
  30740. }
  30741. /**
  30742. * If you want to display a video in your scene, this is the special texture for that.
  30743. * This special texture works similar to other textures, with the exception of a few parameters.
  30744. * @see https://doc.babylonjs.com/how_to/video_texture
  30745. */
  30746. export class VideoTexture extends Texture {
  30747. /**
  30748. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  30749. */
  30750. readonly autoUpdateTexture: boolean;
  30751. /**
  30752. * The video instance used by the texture internally
  30753. */
  30754. readonly video: HTMLVideoElement;
  30755. private _onUserActionRequestedObservable;
  30756. /**
  30757. * Event triggerd when a dom action is required by the user to play the video.
  30758. * This happens due to recent changes in browser policies preventing video to auto start.
  30759. */
  30760. get onUserActionRequestedObservable(): Observable<Texture>;
  30761. private _generateMipMaps;
  30762. private _engine;
  30763. private _stillImageCaptured;
  30764. private _displayingPosterTexture;
  30765. private _settings;
  30766. private _createInternalTextureOnEvent;
  30767. private _frameId;
  30768. private _currentSrc;
  30769. /**
  30770. * Creates a video texture.
  30771. * If you want to display a video in your scene, this is the special texture for that.
  30772. * This special texture works similar to other textures, with the exception of a few parameters.
  30773. * @see https://doc.babylonjs.com/how_to/video_texture
  30774. * @param name optional name, will detect from video source, if not defined
  30775. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  30776. * @param scene is obviously the current scene.
  30777. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  30778. * @param invertY is false by default but can be used to invert video on Y axis
  30779. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  30780. * @param settings allows finer control over video usage
  30781. */
  30782. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  30783. private _getName;
  30784. private _getVideo;
  30785. private _createInternalTexture;
  30786. private reset;
  30787. /**
  30788. * @hidden Internal method to initiate `update`.
  30789. */
  30790. _rebuild(): void;
  30791. /**
  30792. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  30793. */
  30794. update(): void;
  30795. /**
  30796. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  30797. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  30798. */
  30799. updateTexture(isVisible: boolean): void;
  30800. protected _updateInternalTexture: () => void;
  30801. /**
  30802. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  30803. * @param url New url.
  30804. */
  30805. updateURL(url: string): void;
  30806. /**
  30807. * Clones the texture.
  30808. * @returns the cloned texture
  30809. */
  30810. clone(): VideoTexture;
  30811. /**
  30812. * Dispose the texture and release its associated resources.
  30813. */
  30814. dispose(): void;
  30815. /**
  30816. * Creates a video texture straight from a stream.
  30817. * @param scene Define the scene the texture should be created in
  30818. * @param stream Define the stream the texture should be created from
  30819. * @returns The created video texture as a promise
  30820. */
  30821. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  30822. /**
  30823. * Creates a video texture straight from your WebCam video feed.
  30824. * @param scene Define the scene the texture should be created in
  30825. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  30826. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  30827. * @returns The created video texture as a promise
  30828. */
  30829. static CreateFromWebCamAsync(scene: Scene, constraints: {
  30830. minWidth: number;
  30831. maxWidth: number;
  30832. minHeight: number;
  30833. maxHeight: number;
  30834. deviceId: string;
  30835. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  30836. /**
  30837. * Creates a video texture straight from your WebCam video feed.
  30838. * @param scene Define the scene the texture should be created in
  30839. * @param onReady Define a callback to triggered once the texture will be ready
  30840. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  30841. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  30842. */
  30843. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  30844. minWidth: number;
  30845. maxWidth: number;
  30846. minHeight: number;
  30847. maxHeight: number;
  30848. deviceId: string;
  30849. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  30850. }
  30851. }
  30852. declare module BABYLON {
  30853. /**
  30854. * Defines the interface used by objects working like Scene
  30855. * @hidden
  30856. */
  30857. interface ISceneLike {
  30858. _addPendingData(data: any): void;
  30859. _removePendingData(data: any): void;
  30860. offlineProvider: IOfflineProvider;
  30861. }
  30862. /** Interface defining initialization parameters for Engine class */
  30863. export interface EngineOptions extends WebGLContextAttributes {
  30864. /**
  30865. * Defines if the engine should no exceed a specified device ratio
  30866. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  30867. */
  30868. limitDeviceRatio?: number;
  30869. /**
  30870. * Defines if webvr should be enabled automatically
  30871. * @see http://doc.babylonjs.com/how_to/webvr_camera
  30872. */
  30873. autoEnableWebVR?: boolean;
  30874. /**
  30875. * Defines if webgl2 should be turned off even if supported
  30876. * @see http://doc.babylonjs.com/features/webgl2
  30877. */
  30878. disableWebGL2Support?: boolean;
  30879. /**
  30880. * Defines if webaudio should be initialized as well
  30881. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  30882. */
  30883. audioEngine?: boolean;
  30884. /**
  30885. * Defines if animations should run using a deterministic lock step
  30886. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  30887. */
  30888. deterministicLockstep?: boolean;
  30889. /** Defines the maximum steps to use with deterministic lock step mode */
  30890. lockstepMaxSteps?: number;
  30891. /** Defines the seconds between each deterministic lock step */
  30892. timeStep?: number;
  30893. /**
  30894. * Defines that engine should ignore context lost events
  30895. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  30896. */
  30897. doNotHandleContextLost?: boolean;
  30898. /**
  30899. * Defines that engine should ignore modifying touch action attribute and style
  30900. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  30901. */
  30902. doNotHandleTouchAction?: boolean;
  30903. /**
  30904. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  30905. */
  30906. useHighPrecisionFloats?: boolean;
  30907. }
  30908. /**
  30909. * The base engine class (root of all engines)
  30910. */
  30911. export class ThinEngine {
  30912. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  30913. static ExceptionList: ({
  30914. key: string;
  30915. capture: string;
  30916. captureConstraint: number;
  30917. targets: string[];
  30918. } | {
  30919. key: string;
  30920. capture: null;
  30921. captureConstraint: null;
  30922. targets: string[];
  30923. })[];
  30924. /** @hidden */
  30925. static _TextureLoaders: IInternalTextureLoader[];
  30926. /**
  30927. * Returns the current npm package of the sdk
  30928. */
  30929. static get NpmPackage(): string;
  30930. /**
  30931. * Returns the current version of the framework
  30932. */
  30933. static get Version(): string;
  30934. /**
  30935. * Returns a string describing the current engine
  30936. */
  30937. get description(): string;
  30938. /**
  30939. * Gets or sets the epsilon value used by collision engine
  30940. */
  30941. static CollisionsEpsilon: number;
  30942. /**
  30943. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  30944. */
  30945. static get ShadersRepository(): string;
  30946. static set ShadersRepository(value: string);
  30947. /**
  30948. * Gets or sets the textures that the engine should not attempt to load as compressed
  30949. */
  30950. protected _excludedCompressedTextures: string[];
  30951. /**
  30952. * Filters the compressed texture formats to only include
  30953. * files that are not included in the skippable list
  30954. *
  30955. * @param url the current extension
  30956. * @param textureFormatInUse the current compressed texture format
  30957. * @returns "format" string
  30958. */
  30959. excludedCompressedTextureFormats(url: Nullable<string>, textureFormatInUse: Nullable<string>): Nullable<string>;
  30960. /** @hidden */
  30961. _shaderProcessor: IShaderProcessor;
  30962. /**
  30963. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  30964. */
  30965. forcePOTTextures: boolean;
  30966. /**
  30967. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  30968. */
  30969. isFullscreen: boolean;
  30970. /**
  30971. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  30972. */
  30973. cullBackFaces: boolean;
  30974. /**
  30975. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  30976. */
  30977. renderEvenInBackground: boolean;
  30978. /**
  30979. * Gets or sets a boolean indicating that cache can be kept between frames
  30980. */
  30981. preventCacheWipeBetweenFrames: boolean;
  30982. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  30983. validateShaderPrograms: boolean;
  30984. /**
  30985. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  30986. * This can provide greater z depth for distant objects.
  30987. */
  30988. useReverseDepthBuffer: boolean;
  30989. /**
  30990. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  30991. */
  30992. disableUniformBuffers: boolean;
  30993. /** @hidden */
  30994. _uniformBuffers: UniformBuffer[];
  30995. /**
  30996. * Gets a boolean indicating that the engine supports uniform buffers
  30997. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  30998. */
  30999. get supportsUniformBuffers(): boolean;
  31000. /** @hidden */
  31001. _gl: WebGLRenderingContext;
  31002. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  31003. protected _windowIsBackground: boolean;
  31004. protected _webGLVersion: number;
  31005. protected _creationOptions: EngineOptions;
  31006. protected _highPrecisionShadersAllowed: boolean;
  31007. /** @hidden */
  31008. get _shouldUseHighPrecisionShader(): boolean;
  31009. /**
  31010. * Gets a boolean indicating that only power of 2 textures are supported
  31011. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  31012. */
  31013. get needPOTTextures(): boolean;
  31014. /** @hidden */
  31015. _badOS: boolean;
  31016. /** @hidden */
  31017. _badDesktopOS: boolean;
  31018. private _hardwareScalingLevel;
  31019. /** @hidden */
  31020. _caps: EngineCapabilities;
  31021. private _isStencilEnable;
  31022. private _glVersion;
  31023. private _glRenderer;
  31024. private _glVendor;
  31025. /** @hidden */
  31026. _videoTextureSupported: boolean;
  31027. protected _renderingQueueLaunched: boolean;
  31028. protected _activeRenderLoops: (() => void)[];
  31029. /**
  31030. * Observable signaled when a context lost event is raised
  31031. */
  31032. onContextLostObservable: Observable<ThinEngine>;
  31033. /**
  31034. * Observable signaled when a context restored event is raised
  31035. */
  31036. onContextRestoredObservable: Observable<ThinEngine>;
  31037. private _onContextLost;
  31038. private _onContextRestored;
  31039. protected _contextWasLost: boolean;
  31040. /** @hidden */
  31041. _doNotHandleContextLost: boolean;
  31042. /**
  31043. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  31044. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  31045. */
  31046. get doNotHandleContextLost(): boolean;
  31047. set doNotHandleContextLost(value: boolean);
  31048. /**
  31049. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  31050. */
  31051. disableVertexArrayObjects: boolean;
  31052. /** @hidden */
  31053. protected _colorWrite: boolean;
  31054. /** @hidden */
  31055. protected _colorWriteChanged: boolean;
  31056. /** @hidden */
  31057. protected _depthCullingState: DepthCullingState;
  31058. /** @hidden */
  31059. protected _stencilState: StencilState;
  31060. /** @hidden */
  31061. _alphaState: AlphaState;
  31062. /** @hidden */
  31063. _alphaMode: number;
  31064. /** @hidden */
  31065. _alphaEquation: number;
  31066. /** @hidden */
  31067. _internalTexturesCache: InternalTexture[];
  31068. /** @hidden */
  31069. protected _activeChannel: number;
  31070. private _currentTextureChannel;
  31071. /** @hidden */
  31072. protected _boundTexturesCache: {
  31073. [key: string]: Nullable<InternalTexture>;
  31074. };
  31075. /** @hidden */
  31076. protected _currentEffect: Nullable<Effect>;
  31077. /** @hidden */
  31078. protected _currentProgram: Nullable<WebGLProgram>;
  31079. private _compiledEffects;
  31080. private _vertexAttribArraysEnabled;
  31081. /** @hidden */
  31082. protected _cachedViewport: Nullable<IViewportLike>;
  31083. private _cachedVertexArrayObject;
  31084. /** @hidden */
  31085. protected _cachedVertexBuffers: any;
  31086. /** @hidden */
  31087. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  31088. /** @hidden */
  31089. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  31090. /** @hidden */
  31091. _currentRenderTarget: Nullable<InternalTexture>;
  31092. private _uintIndicesCurrentlySet;
  31093. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  31094. /** @hidden */
  31095. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  31096. private _currentBufferPointers;
  31097. private _currentInstanceLocations;
  31098. private _currentInstanceBuffers;
  31099. private _textureUnits;
  31100. /** @hidden */
  31101. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  31102. /** @hidden */
  31103. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  31104. /** @hidden */
  31105. _boundRenderFunction: any;
  31106. private _vaoRecordInProgress;
  31107. private _mustWipeVertexAttributes;
  31108. private _emptyTexture;
  31109. private _emptyCubeTexture;
  31110. private _emptyTexture3D;
  31111. private _emptyTexture2DArray;
  31112. /** @hidden */
  31113. _frameHandler: number;
  31114. private _nextFreeTextureSlots;
  31115. private _maxSimultaneousTextures;
  31116. private _activeRequests;
  31117. protected _texturesSupported: string[];
  31118. /** @hidden */
  31119. _textureFormatInUse: Nullable<string>;
  31120. protected get _supportsHardwareTextureRescaling(): boolean;
  31121. /**
  31122. * Gets the list of texture formats supported
  31123. */
  31124. get texturesSupported(): Array<string>;
  31125. /**
  31126. * Gets the list of texture formats in use
  31127. */
  31128. get textureFormatInUse(): Nullable<string>;
  31129. /**
  31130. * Gets the current viewport
  31131. */
  31132. get currentViewport(): Nullable<IViewportLike>;
  31133. /**
  31134. * Gets the default empty texture
  31135. */
  31136. get emptyTexture(): InternalTexture;
  31137. /**
  31138. * Gets the default empty 3D texture
  31139. */
  31140. get emptyTexture3D(): InternalTexture;
  31141. /**
  31142. * Gets the default empty 2D array texture
  31143. */
  31144. get emptyTexture2DArray(): InternalTexture;
  31145. /**
  31146. * Gets the default empty cube texture
  31147. */
  31148. get emptyCubeTexture(): InternalTexture;
  31149. /**
  31150. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  31151. */
  31152. readonly premultipliedAlpha: boolean;
  31153. /**
  31154. * Observable event triggered before each texture is initialized
  31155. */
  31156. onBeforeTextureInitObservable: Observable<Texture>;
  31157. /**
  31158. * Creates a new engine
  31159. * @param canvasOrContext defines the canvas or WebGL context to use for rendering. If you provide a WebGL context, Babylon.js will not hook events on the canvas (like pointers, keyboards, etc...) so no event observables will be available. This is mostly used when Babylon.js is used as a plugin on a system which alreay used the WebGL context
  31160. * @param antialias defines enable antialiasing (default: false)
  31161. * @param options defines further options to be sent to the getContext() function
  31162. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  31163. */
  31164. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  31165. private _rebuildInternalTextures;
  31166. private _rebuildEffects;
  31167. /**
  31168. * Gets a boolean indicating if all created effects are ready
  31169. * @returns true if all effects are ready
  31170. */
  31171. areAllEffectsReady(): boolean;
  31172. protected _rebuildBuffers(): void;
  31173. private _initGLContext;
  31174. /**
  31175. * Gets version of the current webGL context
  31176. */
  31177. get webGLVersion(): number;
  31178. /**
  31179. * Gets a string idenfifying the name of the class
  31180. * @returns "Engine" string
  31181. */
  31182. getClassName(): string;
  31183. /**
  31184. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  31185. */
  31186. get isStencilEnable(): boolean;
  31187. /** @hidden */
  31188. _prepareWorkingCanvas(): void;
  31189. /**
  31190. * Reset the texture cache to empty state
  31191. */
  31192. resetTextureCache(): void;
  31193. /**
  31194. * Gets an object containing information about the current webGL context
  31195. * @returns an object containing the vender, the renderer and the version of the current webGL context
  31196. */
  31197. getGlInfo(): {
  31198. vendor: string;
  31199. renderer: string;
  31200. version: string;
  31201. };
  31202. /**
  31203. * Defines the hardware scaling level.
  31204. * By default the hardware scaling level is computed from the window device ratio.
  31205. * if level = 1 then the engine will render at the exact resolution of the canvas. If level = 0.5 then the engine will render at twice the size of the canvas.
  31206. * @param level defines the level to use
  31207. */
  31208. setHardwareScalingLevel(level: number): void;
  31209. /**
  31210. * Gets the current hardware scaling level.
  31211. * By default the hardware scaling level is computed from the window device ratio.
  31212. * if level = 1 then the engine will render at the exact resolution of the canvas. If level = 0.5 then the engine will render at twice the size of the canvas.
  31213. * @returns a number indicating the current hardware scaling level
  31214. */
  31215. getHardwareScalingLevel(): number;
  31216. /**
  31217. * Gets the list of loaded textures
  31218. * @returns an array containing all loaded textures
  31219. */
  31220. getLoadedTexturesCache(): InternalTexture[];
  31221. /**
  31222. * Gets the object containing all engine capabilities
  31223. * @returns the EngineCapabilities object
  31224. */
  31225. getCaps(): EngineCapabilities;
  31226. /**
  31227. * stop executing a render loop function and remove it from the execution array
  31228. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  31229. */
  31230. stopRenderLoop(renderFunction?: () => void): void;
  31231. /** @hidden */
  31232. _renderLoop(): void;
  31233. /**
  31234. * Gets the HTML canvas attached with the current webGL context
  31235. * @returns a HTML canvas
  31236. */
  31237. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  31238. /**
  31239. * Gets host window
  31240. * @returns the host window object
  31241. */
  31242. getHostWindow(): Nullable<Window>;
  31243. /**
  31244. * Gets the current render width
  31245. * @param useScreen defines if screen size must be used (or the current render target if any)
  31246. * @returns a number defining the current render width
  31247. */
  31248. getRenderWidth(useScreen?: boolean): number;
  31249. /**
  31250. * Gets the current render height
  31251. * @param useScreen defines if screen size must be used (or the current render target if any)
  31252. * @returns a number defining the current render height
  31253. */
  31254. getRenderHeight(useScreen?: boolean): number;
  31255. /**
  31256. * Can be used to override the current requestAnimationFrame requester.
  31257. * @hidden
  31258. */
  31259. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  31260. /**
  31261. * Register and execute a render loop. The engine can have more than one render function
  31262. * @param renderFunction defines the function to continuously execute
  31263. */
  31264. runRenderLoop(renderFunction: () => void): void;
  31265. /**
  31266. * Clear the current render buffer or the current render target (if any is set up)
  31267. * @param color defines the color to use
  31268. * @param backBuffer defines if the back buffer must be cleared
  31269. * @param depth defines if the depth buffer must be cleared
  31270. * @param stencil defines if the stencil buffer must be cleared
  31271. */
  31272. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  31273. private _viewportCached;
  31274. /** @hidden */
  31275. _viewport(x: number, y: number, width: number, height: number): void;
  31276. /**
  31277. * Set the WebGL's viewport
  31278. * @param viewport defines the viewport element to be used
  31279. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  31280. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  31281. */
  31282. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  31283. /**
  31284. * Begin a new frame
  31285. */
  31286. beginFrame(): void;
  31287. /**
  31288. * Enf the current frame
  31289. */
  31290. endFrame(): void;
  31291. /**
  31292. * Resize the view according to the canvas' size
  31293. */
  31294. resize(): void;
  31295. /**
  31296. * Force a specific size of the canvas
  31297. * @param width defines the new canvas' width
  31298. * @param height defines the new canvas' height
  31299. */
  31300. setSize(width: number, height: number): void;
  31301. /**
  31302. * Binds the frame buffer to the specified texture.
  31303. * @param texture The texture to render to or null for the default canvas
  31304. * @param faceIndex The face of the texture to render to in case of cube texture
  31305. * @param requiredWidth The width of the target to render to
  31306. * @param requiredHeight The height of the target to render to
  31307. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  31308. * @param lodLevel defines the lod level to bind to the frame buffer
  31309. * @param layer defines the 2d array index to bind to frame buffer to
  31310. */
  31311. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  31312. /** @hidden */
  31313. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  31314. /**
  31315. * Unbind the current render target texture from the webGL context
  31316. * @param texture defines the render target texture to unbind
  31317. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  31318. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  31319. */
  31320. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  31321. /**
  31322. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  31323. */
  31324. flushFramebuffer(): void;
  31325. /**
  31326. * Unbind the current render target and bind the default framebuffer
  31327. */
  31328. restoreDefaultFramebuffer(): void;
  31329. /** @hidden */
  31330. protected _resetVertexBufferBinding(): void;
  31331. /**
  31332. * Creates a vertex buffer
  31333. * @param data the data for the vertex buffer
  31334. * @returns the new WebGL static buffer
  31335. */
  31336. createVertexBuffer(data: DataArray): DataBuffer;
  31337. private _createVertexBuffer;
  31338. /**
  31339. * Creates a dynamic vertex buffer
  31340. * @param data the data for the dynamic vertex buffer
  31341. * @returns the new WebGL dynamic buffer
  31342. */
  31343. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  31344. protected _resetIndexBufferBinding(): void;
  31345. /**
  31346. * Creates a new index buffer
  31347. * @param indices defines the content of the index buffer
  31348. * @param updatable defines if the index buffer must be updatable
  31349. * @returns a new webGL buffer
  31350. */
  31351. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  31352. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  31353. /**
  31354. * Bind a webGL buffer to the webGL context
  31355. * @param buffer defines the buffer to bind
  31356. */
  31357. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  31358. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  31359. private bindBuffer;
  31360. /**
  31361. * update the bound buffer with the given data
  31362. * @param data defines the data to update
  31363. */
  31364. updateArrayBuffer(data: Float32Array): void;
  31365. private _vertexAttribPointer;
  31366. /** @hidden */
  31367. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  31368. private _bindVertexBuffersAttributes;
  31369. /**
  31370. * Records a vertex array object
  31371. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  31372. * @param vertexBuffers defines the list of vertex buffers to store
  31373. * @param indexBuffer defines the index buffer to store
  31374. * @param effect defines the effect to store
  31375. * @returns the new vertex array object
  31376. */
  31377. recordVertexArrayObject(vertexBuffers: {
  31378. [key: string]: VertexBuffer;
  31379. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  31380. /**
  31381. * Bind a specific vertex array object
  31382. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  31383. * @param vertexArrayObject defines the vertex array object to bind
  31384. * @param indexBuffer defines the index buffer to bind
  31385. */
  31386. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  31387. /**
  31388. * Bind webGl buffers directly to the webGL context
  31389. * @param vertexBuffer defines the vertex buffer to bind
  31390. * @param indexBuffer defines the index buffer to bind
  31391. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  31392. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  31393. * @param effect defines the effect associated with the vertex buffer
  31394. */
  31395. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  31396. private _unbindVertexArrayObject;
  31397. /**
  31398. * Bind a list of vertex buffers to the webGL context
  31399. * @param vertexBuffers defines the list of vertex buffers to bind
  31400. * @param indexBuffer defines the index buffer to bind
  31401. * @param effect defines the effect associated with the vertex buffers
  31402. */
  31403. bindBuffers(vertexBuffers: {
  31404. [key: string]: Nullable<VertexBuffer>;
  31405. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  31406. /**
  31407. * Unbind all instance attributes
  31408. */
  31409. unbindInstanceAttributes(): void;
  31410. /**
  31411. * Release and free the memory of a vertex array object
  31412. * @param vao defines the vertex array object to delete
  31413. */
  31414. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  31415. /** @hidden */
  31416. _releaseBuffer(buffer: DataBuffer): boolean;
  31417. protected _deleteBuffer(buffer: DataBuffer): void;
  31418. /**
  31419. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  31420. * @param instancesBuffer defines the webGL buffer to update and bind
  31421. * @param data defines the data to store in the buffer
  31422. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  31423. */
  31424. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  31425. /**
  31426. * Bind the content of a webGL buffer used with instantiation
  31427. * @param instancesBuffer defines the webGL buffer to bind
  31428. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  31429. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  31430. */
  31431. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  31432. /**
  31433. * Disable the instance attribute corresponding to the name in parameter
  31434. * @param name defines the name of the attribute to disable
  31435. */
  31436. disableInstanceAttributeByName(name: string): void;
  31437. /**
  31438. * Disable the instance attribute corresponding to the location in parameter
  31439. * @param attributeLocation defines the attribute location of the attribute to disable
  31440. */
  31441. disableInstanceAttribute(attributeLocation: number): void;
  31442. /**
  31443. * Disable the attribute corresponding to the location in parameter
  31444. * @param attributeLocation defines the attribute location of the attribute to disable
  31445. */
  31446. disableAttributeByIndex(attributeLocation: number): void;
  31447. /**
  31448. * Send a draw order
  31449. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  31450. * @param indexStart defines the starting index
  31451. * @param indexCount defines the number of index to draw
  31452. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31453. */
  31454. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  31455. /**
  31456. * Draw a list of points
  31457. * @param verticesStart defines the index of first vertex to draw
  31458. * @param verticesCount defines the count of vertices to draw
  31459. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31460. */
  31461. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31462. /**
  31463. * Draw a list of unindexed primitives
  31464. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  31465. * @param verticesStart defines the index of first vertex to draw
  31466. * @param verticesCount defines the count of vertices to draw
  31467. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31468. */
  31469. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31470. /**
  31471. * Draw a list of indexed primitives
  31472. * @param fillMode defines the primitive to use
  31473. * @param indexStart defines the starting index
  31474. * @param indexCount defines the number of index to draw
  31475. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31476. */
  31477. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  31478. /**
  31479. * Draw a list of unindexed primitives
  31480. * @param fillMode defines the primitive to use
  31481. * @param verticesStart defines the index of first vertex to draw
  31482. * @param verticesCount defines the count of vertices to draw
  31483. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31484. */
  31485. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31486. private _drawMode;
  31487. /** @hidden */
  31488. protected _reportDrawCall(): void;
  31489. /** @hidden */
  31490. _releaseEffect(effect: Effect): void;
  31491. /** @hidden */
  31492. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  31493. /**
  31494. * Create a new effect (used to store vertex/fragment shaders)
  31495. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  31496. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  31497. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  31498. * @param samplers defines an array of string used to represent textures
  31499. * @param defines defines the string containing the defines to use to compile the shaders
  31500. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  31501. * @param onCompiled defines a function to call when the effect creation is successful
  31502. * @param onError defines a function to call when the effect creation has failed
  31503. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  31504. * @returns the new Effect
  31505. */
  31506. createEffect(baseName: any, attributesNamesOrOptions: string[] | IEffectCreationOptions, uniformsNamesOrEngine: string[] | ThinEngine, samplers?: string[], defines?: string, fallbacks?: IEffectFallbacks, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any): Effect;
  31507. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  31508. private _compileShader;
  31509. private _compileRawShader;
  31510. /**
  31511. * Directly creates a webGL program
  31512. * @param pipelineContext defines the pipeline context to attach to
  31513. * @param vertexCode defines the vertex shader code to use
  31514. * @param fragmentCode defines the fragment shader code to use
  31515. * @param context defines the webGL context to use (if not set, the current one will be used)
  31516. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  31517. * @returns the new webGL program
  31518. */
  31519. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31520. /**
  31521. * Creates a webGL program
  31522. * @param pipelineContext defines the pipeline context to attach to
  31523. * @param vertexCode defines the vertex shader code to use
  31524. * @param fragmentCode defines the fragment shader code to use
  31525. * @param defines defines the string containing the defines to use to compile the shaders
  31526. * @param context defines the webGL context to use (if not set, the current one will be used)
  31527. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  31528. * @returns the new webGL program
  31529. */
  31530. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31531. /**
  31532. * Creates a new pipeline context
  31533. * @returns the new pipeline
  31534. */
  31535. createPipelineContext(): IPipelineContext;
  31536. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31537. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  31538. /** @hidden */
  31539. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  31540. /** @hidden */
  31541. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  31542. /** @hidden */
  31543. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  31544. /**
  31545. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  31546. * @param pipelineContext defines the pipeline context to use
  31547. * @param uniformsNames defines the list of uniform names
  31548. * @returns an array of webGL uniform locations
  31549. */
  31550. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  31551. /**
  31552. * Gets the lsit of active attributes for a given webGL program
  31553. * @param pipelineContext defines the pipeline context to use
  31554. * @param attributesNames defines the list of attribute names to get
  31555. * @returns an array of indices indicating the offset of each attribute
  31556. */
  31557. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  31558. /**
  31559. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  31560. * @param effect defines the effect to activate
  31561. */
  31562. enableEffect(effect: Nullable<Effect>): void;
  31563. /**
  31564. * Set the value of an uniform to a number (int)
  31565. * @param uniform defines the webGL uniform location where to store the value
  31566. * @param value defines the int number to store
  31567. */
  31568. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  31569. /**
  31570. * Set the value of an uniform to an array of int32
  31571. * @param uniform defines the webGL uniform location where to store the value
  31572. * @param array defines the array of int32 to store
  31573. */
  31574. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31575. /**
  31576. * Set the value of an uniform to an array of int32 (stored as vec2)
  31577. * @param uniform defines the webGL uniform location where to store the value
  31578. * @param array defines the array of int32 to store
  31579. */
  31580. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31581. /**
  31582. * Set the value of an uniform to an array of int32 (stored as vec3)
  31583. * @param uniform defines the webGL uniform location where to store the value
  31584. * @param array defines the array of int32 to store
  31585. */
  31586. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31587. /**
  31588. * Set the value of an uniform to an array of int32 (stored as vec4)
  31589. * @param uniform defines the webGL uniform location where to store the value
  31590. * @param array defines the array of int32 to store
  31591. */
  31592. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31593. /**
  31594. * Set the value of an uniform to an array of number
  31595. * @param uniform defines the webGL uniform location where to store the value
  31596. * @param array defines the array of number to store
  31597. */
  31598. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  31599. /**
  31600. * Set the value of an uniform to an array of number (stored as vec2)
  31601. * @param uniform defines the webGL uniform location where to store the value
  31602. * @param array defines the array of number to store
  31603. */
  31604. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  31605. /**
  31606. * Set the value of an uniform to an array of number (stored as vec3)
  31607. * @param uniform defines the webGL uniform location where to store the value
  31608. * @param array defines the array of number to store
  31609. */
  31610. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  31611. /**
  31612. * Set the value of an uniform to an array of number (stored as vec4)
  31613. * @param uniform defines the webGL uniform location where to store the value
  31614. * @param array defines the array of number to store
  31615. */
  31616. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  31617. /**
  31618. * Set the value of an uniform to an array of float32 (stored as matrices)
  31619. * @param uniform defines the webGL uniform location where to store the value
  31620. * @param matrices defines the array of float32 to store
  31621. */
  31622. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  31623. /**
  31624. * Set the value of an uniform to a matrix (3x3)
  31625. * @param uniform defines the webGL uniform location where to store the value
  31626. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  31627. */
  31628. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  31629. /**
  31630. * Set the value of an uniform to a matrix (2x2)
  31631. * @param uniform defines the webGL uniform location where to store the value
  31632. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  31633. */
  31634. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  31635. /**
  31636. * Set the value of an uniform to a number (float)
  31637. * @param uniform defines the webGL uniform location where to store the value
  31638. * @param value defines the float number to store
  31639. */
  31640. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  31641. /**
  31642. * Set the value of an uniform to a vec2
  31643. * @param uniform defines the webGL uniform location where to store the value
  31644. * @param x defines the 1st component of the value
  31645. * @param y defines the 2nd component of the value
  31646. */
  31647. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  31648. /**
  31649. * Set the value of an uniform to a vec3
  31650. * @param uniform defines the webGL uniform location where to store the value
  31651. * @param x defines the 1st component of the value
  31652. * @param y defines the 2nd component of the value
  31653. * @param z defines the 3rd component of the value
  31654. */
  31655. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  31656. /**
  31657. * Set the value of an uniform to a vec4
  31658. * @param uniform defines the webGL uniform location where to store the value
  31659. * @param x defines the 1st component of the value
  31660. * @param y defines the 2nd component of the value
  31661. * @param z defines the 3rd component of the value
  31662. * @param w defines the 4th component of the value
  31663. */
  31664. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  31665. /**
  31666. * Apply all cached states (depth, culling, stencil and alpha)
  31667. */
  31668. applyStates(): void;
  31669. /**
  31670. * Enable or disable color writing
  31671. * @param enable defines the state to set
  31672. */
  31673. setColorWrite(enable: boolean): void;
  31674. /**
  31675. * Gets a boolean indicating if color writing is enabled
  31676. * @returns the current color writing state
  31677. */
  31678. getColorWrite(): boolean;
  31679. /**
  31680. * Gets the depth culling state manager
  31681. */
  31682. get depthCullingState(): DepthCullingState;
  31683. /**
  31684. * Gets the alpha state manager
  31685. */
  31686. get alphaState(): AlphaState;
  31687. /**
  31688. * Gets the stencil state manager
  31689. */
  31690. get stencilState(): StencilState;
  31691. /**
  31692. * Clears the list of texture accessible through engine.
  31693. * This can help preventing texture load conflict due to name collision.
  31694. */
  31695. clearInternalTexturesCache(): void;
  31696. /**
  31697. * Force the entire cache to be cleared
  31698. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  31699. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  31700. */
  31701. wipeCaches(bruteForce?: boolean): void;
  31702. /** @hidden */
  31703. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  31704. min: number;
  31705. mag: number;
  31706. };
  31707. /** @hidden */
  31708. _createTexture(): WebGLTexture;
  31709. /**
  31710. * Usually called from Texture.ts.
  31711. * Passed information to create a WebGLTexture
  31712. * @param urlArg defines a value which contains one of the following:
  31713. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  31714. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  31715. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  31716. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  31717. * @param invertY when true, image is flipped when loaded. You probably want true. Certain compressed textures may invert this if their default is inverted (eg. ktx)
  31718. * @param scene needed for loading to the correct scene
  31719. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  31720. * @param onLoad optional callback to be called upon successful completion
  31721. * @param onError optional callback to be called upon failure
  31722. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), HTMLImageElement (image format), or a Blob
  31723. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  31724. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  31725. * @param forcedExtension defines the extension to use to pick the right loader
  31726. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  31727. * @param mimeType defines an optional mime type
  31728. * @returns a InternalTexture for assignment back into BABYLON.Texture
  31729. */
  31730. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, excludeLoaders?: Array<IInternalTextureLoader>, mimeType?: string): InternalTexture;
  31731. /**
  31732. * Loads an image as an HTMLImageElement.
  31733. * @param input url string, ArrayBuffer, or Blob to load
  31734. * @param onLoad callback called when the image successfully loads
  31735. * @param onError callback called when the image fails to load
  31736. * @param offlineProvider offline provider for caching
  31737. * @param mimeType optional mime type
  31738. * @returns the HTMLImageElement of the loaded image
  31739. * @hidden
  31740. */
  31741. static _FileToolsLoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  31742. /**
  31743. * @hidden
  31744. */
  31745. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  31746. /**
  31747. * Creates a raw texture
  31748. * @param data defines the data to store in the texture
  31749. * @param width defines the width of the texture
  31750. * @param height defines the height of the texture
  31751. * @param format defines the format of the data
  31752. * @param generateMipMaps defines if the engine should generate the mip levels
  31753. * @param invertY defines if data must be stored with Y axis inverted
  31754. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  31755. * @param compression defines the compression used (null by default)
  31756. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  31757. * @returns the raw texture inside an InternalTexture
  31758. */
  31759. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  31760. /**
  31761. * Creates a new raw cube texture
  31762. * @param data defines the array of data to use to create each face
  31763. * @param size defines the size of the textures
  31764. * @param format defines the format of the data
  31765. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  31766. * @param generateMipMaps defines if the engine should generate the mip levels
  31767. * @param invertY defines if data must be stored with Y axis inverted
  31768. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  31769. * @param compression defines the compression used (null by default)
  31770. * @returns the cube texture as an InternalTexture
  31771. */
  31772. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  31773. /**
  31774. * Creates a new raw 3D texture
  31775. * @param data defines the data used to create the texture
  31776. * @param width defines the width of the texture
  31777. * @param height defines the height of the texture
  31778. * @param depth defines the depth of the texture
  31779. * @param format defines the format of the texture
  31780. * @param generateMipMaps defines if the engine must generate mip levels
  31781. * @param invertY defines if data must be stored with Y axis inverted
  31782. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  31783. * @param compression defines the compressed used (can be null)
  31784. * @param textureType defines the compressed used (can be null)
  31785. * @returns a new raw 3D texture (stored in an InternalTexture)
  31786. */
  31787. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  31788. /**
  31789. * Creates a new raw 2D array texture
  31790. * @param data defines the data used to create the texture
  31791. * @param width defines the width of the texture
  31792. * @param height defines the height of the texture
  31793. * @param depth defines the number of layers of the texture
  31794. * @param format defines the format of the texture
  31795. * @param generateMipMaps defines if the engine must generate mip levels
  31796. * @param invertY defines if data must be stored with Y axis inverted
  31797. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  31798. * @param compression defines the compressed used (can be null)
  31799. * @param textureType defines the compressed used (can be null)
  31800. * @returns a new raw 2D array texture (stored in an InternalTexture)
  31801. */
  31802. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  31803. private _unpackFlipYCached;
  31804. /**
  31805. * In case you are sharing the context with other applications, it might
  31806. * be interested to not cache the unpack flip y state to ensure a consistent
  31807. * value would be set.
  31808. */
  31809. enableUnpackFlipYCached: boolean;
  31810. /** @hidden */
  31811. _unpackFlipY(value: boolean): void;
  31812. /** @hidden */
  31813. _getUnpackAlignement(): number;
  31814. private _getTextureTarget;
  31815. /**
  31816. * Update the sampling mode of a given texture
  31817. * @param samplingMode defines the required sampling mode
  31818. * @param texture defines the texture to update
  31819. * @param generateMipMaps defines whether to generate mipmaps for the texture
  31820. */
  31821. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  31822. /**
  31823. * Update the sampling mode of a given texture
  31824. * @param texture defines the texture to update
  31825. * @param wrapU defines the texture wrap mode of the u coordinates
  31826. * @param wrapV defines the texture wrap mode of the v coordinates
  31827. * @param wrapR defines the texture wrap mode of the r coordinates
  31828. */
  31829. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  31830. /** @hidden */
  31831. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  31832. width: number;
  31833. height: number;
  31834. layers?: number;
  31835. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  31836. /** @hidden */
  31837. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  31838. /** @hidden */
  31839. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  31840. /**
  31841. * Update a portion of an internal texture
  31842. * @param texture defines the texture to update
  31843. * @param imageData defines the data to store into the texture
  31844. * @param xOffset defines the x coordinates of the update rectangle
  31845. * @param yOffset defines the y coordinates of the update rectangle
  31846. * @param width defines the width of the update rectangle
  31847. * @param height defines the height of the update rectangle
  31848. * @param faceIndex defines the face index if texture is a cube (0 by default)
  31849. * @param lod defines the lod level to update (0 by default)
  31850. */
  31851. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  31852. /** @hidden */
  31853. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  31854. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  31855. private _prepareWebGLTexture;
  31856. /** @hidden */
  31857. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  31858. private _getDepthStencilBuffer;
  31859. /** @hidden */
  31860. _releaseFramebufferObjects(texture: InternalTexture): void;
  31861. /** @hidden */
  31862. _releaseTexture(texture: InternalTexture): void;
  31863. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  31864. protected _setProgram(program: WebGLProgram): void;
  31865. protected _boundUniforms: {
  31866. [key: number]: WebGLUniformLocation;
  31867. };
  31868. /**
  31869. * Binds an effect to the webGL context
  31870. * @param effect defines the effect to bind
  31871. */
  31872. bindSamplers(effect: Effect): void;
  31873. private _activateCurrentTexture;
  31874. /** @hidden */
  31875. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  31876. /** @hidden */
  31877. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  31878. /**
  31879. * Unbind all textures from the webGL context
  31880. */
  31881. unbindAllTextures(): void;
  31882. /**
  31883. * Sets a texture to the according uniform.
  31884. * @param channel The texture channel
  31885. * @param uniform The uniform to set
  31886. * @param texture The texture to apply
  31887. */
  31888. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  31889. private _bindSamplerUniformToChannel;
  31890. private _getTextureWrapMode;
  31891. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  31892. /**
  31893. * Sets an array of texture to the webGL context
  31894. * @param channel defines the channel where the texture array must be set
  31895. * @param uniform defines the associated uniform location
  31896. * @param textures defines the array of textures to bind
  31897. */
  31898. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  31899. /** @hidden */
  31900. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  31901. private _setTextureParameterFloat;
  31902. private _setTextureParameterInteger;
  31903. /**
  31904. * Unbind all vertex attributes from the webGL context
  31905. */
  31906. unbindAllAttributes(): void;
  31907. /**
  31908. * Force the engine to release all cached effects. This means that next effect compilation will have to be done completely even if a similar effect was already compiled
  31909. */
  31910. releaseEffects(): void;
  31911. /**
  31912. * Dispose and release all associated resources
  31913. */
  31914. dispose(): void;
  31915. /**
  31916. * Attach a new callback raised when context lost event is fired
  31917. * @param callback defines the callback to call
  31918. */
  31919. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  31920. /**
  31921. * Attach a new callback raised when context restored event is fired
  31922. * @param callback defines the callback to call
  31923. */
  31924. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  31925. /**
  31926. * Get the current error code of the webGL context
  31927. * @returns the error code
  31928. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  31929. */
  31930. getError(): number;
  31931. private _canRenderToFloatFramebuffer;
  31932. private _canRenderToHalfFloatFramebuffer;
  31933. private _canRenderToFramebuffer;
  31934. /** @hidden */
  31935. _getWebGLTextureType(type: number): number;
  31936. /** @hidden */
  31937. _getInternalFormat(format: number): number;
  31938. /** @hidden */
  31939. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  31940. /** @hidden */
  31941. _getRGBAMultiSampleBufferFormat(type: number): number;
  31942. /** @hidden */
  31943. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: IWebRequest, exception?: any) => void): IFileRequest;
  31944. /**
  31945. * Loads a file from a url
  31946. * @param url url to load
  31947. * @param onSuccess callback called when the file successfully loads
  31948. * @param onProgress callback called while file is loading (if the server supports this mode)
  31949. * @param offlineProvider defines the offline provider for caching
  31950. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  31951. * @param onError callback called when the file fails to load
  31952. * @returns a file request object
  31953. * @hidden
  31954. */
  31955. static _FileToolsLoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  31956. /**
  31957. * Reads pixels from the current frame buffer. Please note that this function can be slow
  31958. * @param x defines the x coordinate of the rectangle where pixels must be read
  31959. * @param y defines the y coordinate of the rectangle where pixels must be read
  31960. * @param width defines the width of the rectangle where pixels must be read
  31961. * @param height defines the height of the rectangle where pixels must be read
  31962. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  31963. * @returns a Uint8Array containing RGBA colors
  31964. */
  31965. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  31966. private static _isSupported;
  31967. /**
  31968. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  31969. * @returns true if the engine can be created
  31970. * @ignorenaming
  31971. */
  31972. static isSupported(): boolean;
  31973. /**
  31974. * Find the next highest power of two.
  31975. * @param x Number to start search from.
  31976. * @return Next highest power of two.
  31977. */
  31978. static CeilingPOT(x: number): number;
  31979. /**
  31980. * Find the next lowest power of two.
  31981. * @param x Number to start search from.
  31982. * @return Next lowest power of two.
  31983. */
  31984. static FloorPOT(x: number): number;
  31985. /**
  31986. * Find the nearest power of two.
  31987. * @param x Number to start search from.
  31988. * @return Next nearest power of two.
  31989. */
  31990. static NearestPOT(x: number): number;
  31991. /**
  31992. * Get the closest exponent of two
  31993. * @param value defines the value to approximate
  31994. * @param max defines the maximum value to return
  31995. * @param mode defines how to define the closest value
  31996. * @returns closest exponent of two of the given value
  31997. */
  31998. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  31999. /**
  32000. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  32001. * @param func - the function to be called
  32002. * @param requester - the object that will request the next frame. Falls back to window.
  32003. * @returns frame number
  32004. */
  32005. static QueueNewFrame(func: () => void, requester?: any): number;
  32006. /**
  32007. * Gets host document
  32008. * @returns the host document object
  32009. */
  32010. getHostDocument(): Nullable<Document>;
  32011. }
  32012. }
  32013. declare module BABYLON {
  32014. /**
  32015. * Class representing spherical harmonics coefficients to the 3rd degree
  32016. */
  32017. export class SphericalHarmonics {
  32018. /**
  32019. * Defines whether or not the harmonics have been prescaled for rendering.
  32020. */
  32021. preScaled: boolean;
  32022. /**
  32023. * The l0,0 coefficients of the spherical harmonics
  32024. */
  32025. l00: Vector3;
  32026. /**
  32027. * The l1,-1 coefficients of the spherical harmonics
  32028. */
  32029. l1_1: Vector3;
  32030. /**
  32031. * The l1,0 coefficients of the spherical harmonics
  32032. */
  32033. l10: Vector3;
  32034. /**
  32035. * The l1,1 coefficients of the spherical harmonics
  32036. */
  32037. l11: Vector3;
  32038. /**
  32039. * The l2,-2 coefficients of the spherical harmonics
  32040. */
  32041. l2_2: Vector3;
  32042. /**
  32043. * The l2,-1 coefficients of the spherical harmonics
  32044. */
  32045. l2_1: Vector3;
  32046. /**
  32047. * The l2,0 coefficients of the spherical harmonics
  32048. */
  32049. l20: Vector3;
  32050. /**
  32051. * The l2,1 coefficients of the spherical harmonics
  32052. */
  32053. l21: Vector3;
  32054. /**
  32055. * The l2,2 coefficients of the spherical harmonics
  32056. */
  32057. l22: Vector3;
  32058. /**
  32059. * Adds a light to the spherical harmonics
  32060. * @param direction the direction of the light
  32061. * @param color the color of the light
  32062. * @param deltaSolidAngle the delta solid angle of the light
  32063. */
  32064. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  32065. /**
  32066. * Scales the spherical harmonics by the given amount
  32067. * @param scale the amount to scale
  32068. */
  32069. scaleInPlace(scale: number): void;
  32070. /**
  32071. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  32072. *
  32073. * ```
  32074. * E_lm = A_l * L_lm
  32075. * ```
  32076. *
  32077. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  32078. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  32079. * the scaling factors are given in equation 9.
  32080. */
  32081. convertIncidentRadianceToIrradiance(): void;
  32082. /**
  32083. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  32084. *
  32085. * ```
  32086. * L = (1/pi) * E * rho
  32087. * ```
  32088. *
  32089. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  32090. */
  32091. convertIrradianceToLambertianRadiance(): void;
  32092. /**
  32093. * Integrates the reconstruction coefficients directly in to the SH preventing further
  32094. * required operations at run time.
  32095. *
  32096. * This is simply done by scaling back the SH with Ylm constants parameter.
  32097. * The trigonometric part being applied by the shader at run time.
  32098. */
  32099. preScaleForRendering(): void;
  32100. /**
  32101. * Constructs a spherical harmonics from an array.
  32102. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  32103. * @returns the spherical harmonics
  32104. */
  32105. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  32106. /**
  32107. * Gets the spherical harmonics from polynomial
  32108. * @param polynomial the spherical polynomial
  32109. * @returns the spherical harmonics
  32110. */
  32111. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  32112. }
  32113. /**
  32114. * Class representing spherical polynomial coefficients to the 3rd degree
  32115. */
  32116. export class SphericalPolynomial {
  32117. private _harmonics;
  32118. /**
  32119. * The spherical harmonics used to create the polynomials.
  32120. */
  32121. get preScaledHarmonics(): SphericalHarmonics;
  32122. /**
  32123. * The x coefficients of the spherical polynomial
  32124. */
  32125. x: Vector3;
  32126. /**
  32127. * The y coefficients of the spherical polynomial
  32128. */
  32129. y: Vector3;
  32130. /**
  32131. * The z coefficients of the spherical polynomial
  32132. */
  32133. z: Vector3;
  32134. /**
  32135. * The xx coefficients of the spherical polynomial
  32136. */
  32137. xx: Vector3;
  32138. /**
  32139. * The yy coefficients of the spherical polynomial
  32140. */
  32141. yy: Vector3;
  32142. /**
  32143. * The zz coefficients of the spherical polynomial
  32144. */
  32145. zz: Vector3;
  32146. /**
  32147. * The xy coefficients of the spherical polynomial
  32148. */
  32149. xy: Vector3;
  32150. /**
  32151. * The yz coefficients of the spherical polynomial
  32152. */
  32153. yz: Vector3;
  32154. /**
  32155. * The zx coefficients of the spherical polynomial
  32156. */
  32157. zx: Vector3;
  32158. /**
  32159. * Adds an ambient color to the spherical polynomial
  32160. * @param color the color to add
  32161. */
  32162. addAmbient(color: Color3): void;
  32163. /**
  32164. * Scales the spherical polynomial by the given amount
  32165. * @param scale the amount to scale
  32166. */
  32167. scaleInPlace(scale: number): void;
  32168. /**
  32169. * Gets the spherical polynomial from harmonics
  32170. * @param harmonics the spherical harmonics
  32171. * @returns the spherical polynomial
  32172. */
  32173. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  32174. /**
  32175. * Constructs a spherical polynomial from an array.
  32176. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  32177. * @returns the spherical polynomial
  32178. */
  32179. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  32180. }
  32181. }
  32182. declare module BABYLON {
  32183. /**
  32184. * Defines the source of the internal texture
  32185. */
  32186. export enum InternalTextureSource {
  32187. /**
  32188. * The source of the texture data is unknown
  32189. */
  32190. Unknown = 0,
  32191. /**
  32192. * Texture data comes from an URL
  32193. */
  32194. Url = 1,
  32195. /**
  32196. * Texture data is only used for temporary storage
  32197. */
  32198. Temp = 2,
  32199. /**
  32200. * Texture data comes from raw data (ArrayBuffer)
  32201. */
  32202. Raw = 3,
  32203. /**
  32204. * Texture content is dynamic (video or dynamic texture)
  32205. */
  32206. Dynamic = 4,
  32207. /**
  32208. * Texture content is generated by rendering to it
  32209. */
  32210. RenderTarget = 5,
  32211. /**
  32212. * Texture content is part of a multi render target process
  32213. */
  32214. MultiRenderTarget = 6,
  32215. /**
  32216. * Texture data comes from a cube data file
  32217. */
  32218. Cube = 7,
  32219. /**
  32220. * Texture data comes from a raw cube data
  32221. */
  32222. CubeRaw = 8,
  32223. /**
  32224. * Texture data come from a prefiltered cube data file
  32225. */
  32226. CubePrefiltered = 9,
  32227. /**
  32228. * Texture content is raw 3D data
  32229. */
  32230. Raw3D = 10,
  32231. /**
  32232. * Texture content is raw 2D array data
  32233. */
  32234. Raw2DArray = 11,
  32235. /**
  32236. * Texture content is a depth texture
  32237. */
  32238. Depth = 12,
  32239. /**
  32240. * Texture data comes from a raw cube data encoded with RGBD
  32241. */
  32242. CubeRawRGBD = 13
  32243. }
  32244. /**
  32245. * Class used to store data associated with WebGL texture data for the engine
  32246. * This class should not be used directly
  32247. */
  32248. export class InternalTexture {
  32249. /** @hidden */
  32250. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  32251. /**
  32252. * Defines if the texture is ready
  32253. */
  32254. isReady: boolean;
  32255. /**
  32256. * Defines if the texture is a cube texture
  32257. */
  32258. isCube: boolean;
  32259. /**
  32260. * Defines if the texture contains 3D data
  32261. */
  32262. is3D: boolean;
  32263. /**
  32264. * Defines if the texture contains 2D array data
  32265. */
  32266. is2DArray: boolean;
  32267. /**
  32268. * Defines if the texture contains multiview data
  32269. */
  32270. isMultiview: boolean;
  32271. /**
  32272. * Gets the URL used to load this texture
  32273. */
  32274. url: string;
  32275. /**
  32276. * Gets the sampling mode of the texture
  32277. */
  32278. samplingMode: number;
  32279. /**
  32280. * Gets a boolean indicating if the texture needs mipmaps generation
  32281. */
  32282. generateMipMaps: boolean;
  32283. /**
  32284. * Gets the number of samples used by the texture (WebGL2+ only)
  32285. */
  32286. samples: number;
  32287. /**
  32288. * Gets the type of the texture (int, float...)
  32289. */
  32290. type: number;
  32291. /**
  32292. * Gets the format of the texture (RGB, RGBA...)
  32293. */
  32294. format: number;
  32295. /**
  32296. * Observable called when the texture is loaded
  32297. */
  32298. onLoadedObservable: Observable<InternalTexture>;
  32299. /**
  32300. * Gets the width of the texture
  32301. */
  32302. width: number;
  32303. /**
  32304. * Gets the height of the texture
  32305. */
  32306. height: number;
  32307. /**
  32308. * Gets the depth of the texture
  32309. */
  32310. depth: number;
  32311. /**
  32312. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  32313. */
  32314. baseWidth: number;
  32315. /**
  32316. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  32317. */
  32318. baseHeight: number;
  32319. /**
  32320. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  32321. */
  32322. baseDepth: number;
  32323. /**
  32324. * Gets a boolean indicating if the texture is inverted on Y axis
  32325. */
  32326. invertY: boolean;
  32327. /** @hidden */
  32328. _invertVScale: boolean;
  32329. /** @hidden */
  32330. _associatedChannel: number;
  32331. /** @hidden */
  32332. _source: InternalTextureSource;
  32333. /** @hidden */
  32334. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  32335. /** @hidden */
  32336. _bufferView: Nullable<ArrayBufferView>;
  32337. /** @hidden */
  32338. _bufferViewArray: Nullable<ArrayBufferView[]>;
  32339. /** @hidden */
  32340. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  32341. /** @hidden */
  32342. _size: number;
  32343. /** @hidden */
  32344. _extension: string;
  32345. /** @hidden */
  32346. _files: Nullable<string[]>;
  32347. /** @hidden */
  32348. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  32349. /** @hidden */
  32350. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  32351. /** @hidden */
  32352. _framebuffer: Nullable<WebGLFramebuffer>;
  32353. /** @hidden */
  32354. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  32355. /** @hidden */
  32356. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  32357. /** @hidden */
  32358. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  32359. /** @hidden */
  32360. _attachments: Nullable<number[]>;
  32361. /** @hidden */
  32362. _cachedCoordinatesMode: Nullable<number>;
  32363. /** @hidden */
  32364. _cachedWrapU: Nullable<number>;
  32365. /** @hidden */
  32366. _cachedWrapV: Nullable<number>;
  32367. /** @hidden */
  32368. _cachedWrapR: Nullable<number>;
  32369. /** @hidden */
  32370. _cachedAnisotropicFilteringLevel: Nullable<number>;
  32371. /** @hidden */
  32372. _isDisabled: boolean;
  32373. /** @hidden */
  32374. _compression: Nullable<string>;
  32375. /** @hidden */
  32376. _generateStencilBuffer: boolean;
  32377. /** @hidden */
  32378. _generateDepthBuffer: boolean;
  32379. /** @hidden */
  32380. _comparisonFunction: number;
  32381. /** @hidden */
  32382. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  32383. /** @hidden */
  32384. _lodGenerationScale: number;
  32385. /** @hidden */
  32386. _lodGenerationOffset: number;
  32387. /** @hidden */
  32388. _depthStencilTexture: Nullable<InternalTexture>;
  32389. /** @hidden */
  32390. _colorTextureArray: Nullable<WebGLTexture>;
  32391. /** @hidden */
  32392. _depthStencilTextureArray: Nullable<WebGLTexture>;
  32393. /** @hidden */
  32394. _lodTextureHigh: Nullable<BaseTexture>;
  32395. /** @hidden */
  32396. _lodTextureMid: Nullable<BaseTexture>;
  32397. /** @hidden */
  32398. _lodTextureLow: Nullable<BaseTexture>;
  32399. /** @hidden */
  32400. _isRGBD: boolean;
  32401. /** @hidden */
  32402. _linearSpecularLOD: boolean;
  32403. /** @hidden */
  32404. _irradianceTexture: Nullable<BaseTexture>;
  32405. /** @hidden */
  32406. _webGLTexture: Nullable<WebGLTexture>;
  32407. /** @hidden */
  32408. _references: number;
  32409. private _engine;
  32410. /**
  32411. * Gets the Engine the texture belongs to.
  32412. * @returns The babylon engine
  32413. */
  32414. getEngine(): ThinEngine;
  32415. /**
  32416. * Gets the data source type of the texture
  32417. */
  32418. get source(): InternalTextureSource;
  32419. /**
  32420. * Creates a new InternalTexture
  32421. * @param engine defines the engine to use
  32422. * @param source defines the type of data that will be used
  32423. * @param delayAllocation if the texture allocation should be delayed (default: false)
  32424. */
  32425. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  32426. /**
  32427. * Increments the number of references (ie. the number of Texture that point to it)
  32428. */
  32429. incrementReferences(): void;
  32430. /**
  32431. * Change the size of the texture (not the size of the content)
  32432. * @param width defines the new width
  32433. * @param height defines the new height
  32434. * @param depth defines the new depth (1 by default)
  32435. */
  32436. updateSize(width: int, height: int, depth?: int): void;
  32437. /** @hidden */
  32438. _rebuild(): void;
  32439. /** @hidden */
  32440. _swapAndDie(target: InternalTexture): void;
  32441. /**
  32442. * Dispose the current allocated resources
  32443. */
  32444. dispose(): void;
  32445. }
  32446. }
  32447. declare module BABYLON {
  32448. /**
  32449. * Class used to work with sound analyzer using fast fourier transform (FFT)
  32450. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32451. */
  32452. export class Analyser {
  32453. /**
  32454. * Gets or sets the smoothing
  32455. * @ignorenaming
  32456. */
  32457. SMOOTHING: number;
  32458. /**
  32459. * Gets or sets the FFT table size
  32460. * @ignorenaming
  32461. */
  32462. FFT_SIZE: number;
  32463. /**
  32464. * Gets or sets the bar graph amplitude
  32465. * @ignorenaming
  32466. */
  32467. BARGRAPHAMPLITUDE: number;
  32468. /**
  32469. * Gets or sets the position of the debug canvas
  32470. * @ignorenaming
  32471. */
  32472. DEBUGCANVASPOS: {
  32473. x: number;
  32474. y: number;
  32475. };
  32476. /**
  32477. * Gets or sets the debug canvas size
  32478. * @ignorenaming
  32479. */
  32480. DEBUGCANVASSIZE: {
  32481. width: number;
  32482. height: number;
  32483. };
  32484. private _byteFreqs;
  32485. private _byteTime;
  32486. private _floatFreqs;
  32487. private _webAudioAnalyser;
  32488. private _debugCanvas;
  32489. private _debugCanvasContext;
  32490. private _scene;
  32491. private _registerFunc;
  32492. private _audioEngine;
  32493. /**
  32494. * Creates a new analyser
  32495. * @param scene defines hosting scene
  32496. */
  32497. constructor(scene: Scene);
  32498. /**
  32499. * Get the number of data values you will have to play with for the visualization
  32500. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  32501. * @returns a number
  32502. */
  32503. getFrequencyBinCount(): number;
  32504. /**
  32505. * Gets the current frequency data as a byte array
  32506. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  32507. * @returns a Uint8Array
  32508. */
  32509. getByteFrequencyData(): Uint8Array;
  32510. /**
  32511. * Gets the current waveform as a byte array
  32512. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  32513. * @returns a Uint8Array
  32514. */
  32515. getByteTimeDomainData(): Uint8Array;
  32516. /**
  32517. * Gets the current frequency data as a float array
  32518. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  32519. * @returns a Float32Array
  32520. */
  32521. getFloatFrequencyData(): Float32Array;
  32522. /**
  32523. * Renders the debug canvas
  32524. */
  32525. drawDebugCanvas(): void;
  32526. /**
  32527. * Stops rendering the debug canvas and removes it
  32528. */
  32529. stopDebugCanvas(): void;
  32530. /**
  32531. * Connects two audio nodes
  32532. * @param inputAudioNode defines first node to connect
  32533. * @param outputAudioNode defines second node to connect
  32534. */
  32535. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  32536. /**
  32537. * Releases all associated resources
  32538. */
  32539. dispose(): void;
  32540. }
  32541. }
  32542. declare module BABYLON {
  32543. /**
  32544. * This represents an audio engine and it is responsible
  32545. * to play, synchronize and analyse sounds throughout the application.
  32546. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32547. */
  32548. export interface IAudioEngine extends IDisposable {
  32549. /**
  32550. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  32551. */
  32552. readonly canUseWebAudio: boolean;
  32553. /**
  32554. * Gets the current AudioContext if available.
  32555. */
  32556. readonly audioContext: Nullable<AudioContext>;
  32557. /**
  32558. * The master gain node defines the global audio volume of your audio engine.
  32559. */
  32560. readonly masterGain: GainNode;
  32561. /**
  32562. * Gets whether or not mp3 are supported by your browser.
  32563. */
  32564. readonly isMP3supported: boolean;
  32565. /**
  32566. * Gets whether or not ogg are supported by your browser.
  32567. */
  32568. readonly isOGGsupported: boolean;
  32569. /**
  32570. * Defines if Babylon should emit a warning if WebAudio is not supported.
  32571. * @ignoreNaming
  32572. */
  32573. WarnedWebAudioUnsupported: boolean;
  32574. /**
  32575. * Defines if the audio engine relies on a custom unlocked button.
  32576. * In this case, the embedded button will not be displayed.
  32577. */
  32578. useCustomUnlockedButton: boolean;
  32579. /**
  32580. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  32581. */
  32582. readonly unlocked: boolean;
  32583. /**
  32584. * Event raised when audio has been unlocked on the browser.
  32585. */
  32586. onAudioUnlockedObservable: Observable<AudioEngine>;
  32587. /**
  32588. * Event raised when audio has been locked on the browser.
  32589. */
  32590. onAudioLockedObservable: Observable<AudioEngine>;
  32591. /**
  32592. * Flags the audio engine in Locked state.
  32593. * This happens due to new browser policies preventing audio to autoplay.
  32594. */
  32595. lock(): void;
  32596. /**
  32597. * Unlocks the audio engine once a user action has been done on the dom.
  32598. * This is helpful to resume play once browser policies have been satisfied.
  32599. */
  32600. unlock(): void;
  32601. }
  32602. /**
  32603. * This represents the default audio engine used in babylon.
  32604. * It is responsible to play, synchronize and analyse sounds throughout the application.
  32605. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32606. */
  32607. export class AudioEngine implements IAudioEngine {
  32608. private _audioContext;
  32609. private _audioContextInitialized;
  32610. private _muteButton;
  32611. private _hostElement;
  32612. /**
  32613. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  32614. */
  32615. canUseWebAudio: boolean;
  32616. /**
  32617. * The master gain node defines the global audio volume of your audio engine.
  32618. */
  32619. masterGain: GainNode;
  32620. /**
  32621. * Defines if Babylon should emit a warning if WebAudio is not supported.
  32622. * @ignoreNaming
  32623. */
  32624. WarnedWebAudioUnsupported: boolean;
  32625. /**
  32626. * Gets whether or not mp3 are supported by your browser.
  32627. */
  32628. isMP3supported: boolean;
  32629. /**
  32630. * Gets whether or not ogg are supported by your browser.
  32631. */
  32632. isOGGsupported: boolean;
  32633. /**
  32634. * Gets whether audio has been unlocked on the device.
  32635. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  32636. * a user interaction has happened.
  32637. */
  32638. unlocked: boolean;
  32639. /**
  32640. * Defines if the audio engine relies on a custom unlocked button.
  32641. * In this case, the embedded button will not be displayed.
  32642. */
  32643. useCustomUnlockedButton: boolean;
  32644. /**
  32645. * Event raised when audio has been unlocked on the browser.
  32646. */
  32647. onAudioUnlockedObservable: Observable<AudioEngine>;
  32648. /**
  32649. * Event raised when audio has been locked on the browser.
  32650. */
  32651. onAudioLockedObservable: Observable<AudioEngine>;
  32652. /**
  32653. * Gets the current AudioContext if available.
  32654. */
  32655. get audioContext(): Nullable<AudioContext>;
  32656. private _connectedAnalyser;
  32657. /**
  32658. * Instantiates a new audio engine.
  32659. *
  32660. * There should be only one per page as some browsers restrict the number
  32661. * of audio contexts you can create.
  32662. * @param hostElement defines the host element where to display the mute icon if necessary
  32663. */
  32664. constructor(hostElement?: Nullable<HTMLElement>);
  32665. /**
  32666. * Flags the audio engine in Locked state.
  32667. * This happens due to new browser policies preventing audio to autoplay.
  32668. */
  32669. lock(): void;
  32670. /**
  32671. * Unlocks the audio engine once a user action has been done on the dom.
  32672. * This is helpful to resume play once browser policies have been satisfied.
  32673. */
  32674. unlock(): void;
  32675. private _resumeAudioContext;
  32676. private _initializeAudioContext;
  32677. private _tryToRun;
  32678. private _triggerRunningState;
  32679. private _triggerSuspendedState;
  32680. private _displayMuteButton;
  32681. private _moveButtonToTopLeft;
  32682. private _onResize;
  32683. private _hideMuteButton;
  32684. /**
  32685. * Destroy and release the resources associated with the audio ccontext.
  32686. */
  32687. dispose(): void;
  32688. /**
  32689. * Gets the global volume sets on the master gain.
  32690. * @returns the global volume if set or -1 otherwise
  32691. */
  32692. getGlobalVolume(): number;
  32693. /**
  32694. * Sets the global volume of your experience (sets on the master gain).
  32695. * @param newVolume Defines the new global volume of the application
  32696. */
  32697. setGlobalVolume(newVolume: number): void;
  32698. /**
  32699. * Connect the audio engine to an audio analyser allowing some amazing
  32700. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  32701. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  32702. * @param analyser The analyser to connect to the engine
  32703. */
  32704. connectToAnalyser(analyser: Analyser): void;
  32705. }
  32706. }
  32707. declare module BABYLON {
  32708. /**
  32709. * Interface used to present a loading screen while loading a scene
  32710. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32711. */
  32712. export interface ILoadingScreen {
  32713. /**
  32714. * Function called to display the loading screen
  32715. */
  32716. displayLoadingUI: () => void;
  32717. /**
  32718. * Function called to hide the loading screen
  32719. */
  32720. hideLoadingUI: () => void;
  32721. /**
  32722. * Gets or sets the color to use for the background
  32723. */
  32724. loadingUIBackgroundColor: string;
  32725. /**
  32726. * Gets or sets the text to display while loading
  32727. */
  32728. loadingUIText: string;
  32729. }
  32730. /**
  32731. * Class used for the default loading screen
  32732. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32733. */
  32734. export class DefaultLoadingScreen implements ILoadingScreen {
  32735. private _renderingCanvas;
  32736. private _loadingText;
  32737. private _loadingDivBackgroundColor;
  32738. private _loadingDiv;
  32739. private _loadingTextDiv;
  32740. /** Gets or sets the logo url to use for the default loading screen */
  32741. static DefaultLogoUrl: string;
  32742. /** Gets or sets the spinner url to use for the default loading screen */
  32743. static DefaultSpinnerUrl: string;
  32744. /**
  32745. * Creates a new default loading screen
  32746. * @param _renderingCanvas defines the canvas used to render the scene
  32747. * @param _loadingText defines the default text to display
  32748. * @param _loadingDivBackgroundColor defines the default background color
  32749. */
  32750. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  32751. /**
  32752. * Function called to display the loading screen
  32753. */
  32754. displayLoadingUI(): void;
  32755. /**
  32756. * Function called to hide the loading screen
  32757. */
  32758. hideLoadingUI(): void;
  32759. /**
  32760. * Gets or sets the text to display while loading
  32761. */
  32762. set loadingUIText(text: string);
  32763. get loadingUIText(): string;
  32764. /**
  32765. * Gets or sets the color to use for the background
  32766. */
  32767. get loadingUIBackgroundColor(): string;
  32768. set loadingUIBackgroundColor(color: string);
  32769. private _resizeLoadingUI;
  32770. }
  32771. }
  32772. declare module BABYLON {
  32773. /**
  32774. * Interface for any object that can request an animation frame
  32775. */
  32776. export interface ICustomAnimationFrameRequester {
  32777. /**
  32778. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  32779. */
  32780. renderFunction?: Function;
  32781. /**
  32782. * Called to request the next frame to render to
  32783. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  32784. */
  32785. requestAnimationFrame: Function;
  32786. /**
  32787. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  32788. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  32789. */
  32790. requestID?: number;
  32791. }
  32792. }
  32793. declare module BABYLON {
  32794. /**
  32795. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  32796. */
  32797. export class PerformanceMonitor {
  32798. private _enabled;
  32799. private _rollingFrameTime;
  32800. private _lastFrameTimeMs;
  32801. /**
  32802. * constructor
  32803. * @param frameSampleSize The number of samples required to saturate the sliding window
  32804. */
  32805. constructor(frameSampleSize?: number);
  32806. /**
  32807. * Samples current frame
  32808. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  32809. */
  32810. sampleFrame(timeMs?: number): void;
  32811. /**
  32812. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  32813. */
  32814. get averageFrameTime(): number;
  32815. /**
  32816. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  32817. */
  32818. get averageFrameTimeVariance(): number;
  32819. /**
  32820. * Returns the frame time of the most recent frame
  32821. */
  32822. get instantaneousFrameTime(): number;
  32823. /**
  32824. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  32825. */
  32826. get averageFPS(): number;
  32827. /**
  32828. * Returns the average framerate in frames per second using the most recent frame time
  32829. */
  32830. get instantaneousFPS(): number;
  32831. /**
  32832. * Returns true if enough samples have been taken to completely fill the sliding window
  32833. */
  32834. get isSaturated(): boolean;
  32835. /**
  32836. * Enables contributions to the sliding window sample set
  32837. */
  32838. enable(): void;
  32839. /**
  32840. * Disables contributions to the sliding window sample set
  32841. * Samples will not be interpolated over the disabled period
  32842. */
  32843. disable(): void;
  32844. /**
  32845. * Returns true if sampling is enabled
  32846. */
  32847. get isEnabled(): boolean;
  32848. /**
  32849. * Resets performance monitor
  32850. */
  32851. reset(): void;
  32852. }
  32853. /**
  32854. * RollingAverage
  32855. *
  32856. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  32857. */
  32858. export class RollingAverage {
  32859. /**
  32860. * Current average
  32861. */
  32862. average: number;
  32863. /**
  32864. * Current variance
  32865. */
  32866. variance: number;
  32867. protected _samples: Array<number>;
  32868. protected _sampleCount: number;
  32869. protected _pos: number;
  32870. protected _m2: number;
  32871. /**
  32872. * constructor
  32873. * @param length The number of samples required to saturate the sliding window
  32874. */
  32875. constructor(length: number);
  32876. /**
  32877. * Adds a sample to the sample set
  32878. * @param v The sample value
  32879. */
  32880. add(v: number): void;
  32881. /**
  32882. * Returns previously added values or null if outside of history or outside the sliding window domain
  32883. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  32884. * @return Value previously recorded with add() or null if outside of range
  32885. */
  32886. history(i: number): number;
  32887. /**
  32888. * Returns true if enough samples have been taken to completely fill the sliding window
  32889. * @return true if sample-set saturated
  32890. */
  32891. isSaturated(): boolean;
  32892. /**
  32893. * Resets the rolling average (equivalent to 0 samples taken so far)
  32894. */
  32895. reset(): void;
  32896. /**
  32897. * Wraps a value around the sample range boundaries
  32898. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  32899. * @return Wrapped position in sample range
  32900. */
  32901. protected _wrapPosition(i: number): number;
  32902. }
  32903. }
  32904. declare module BABYLON {
  32905. /**
  32906. * This class is used to track a performance counter which is number based.
  32907. * The user has access to many properties which give statistics of different nature.
  32908. *
  32909. * The implementer can track two kinds of Performance Counter: time and count.
  32910. * For time you can optionally call fetchNewFrame() to notify the start of a new frame to monitor, then call beginMonitoring() to start and endMonitoring() to record the lapsed time. endMonitoring takes a newFrame parameter for you to specify if the monitored time should be set for a new frame or accumulated to the current frame being monitored.
  32911. * For count you first have to call fetchNewFrame() to notify the start of a new frame to monitor, then call addCount() how many time required to increment the count value you monitor.
  32912. */
  32913. export class PerfCounter {
  32914. /**
  32915. * Gets or sets a global boolean to turn on and off all the counters
  32916. */
  32917. static Enabled: boolean;
  32918. /**
  32919. * Returns the smallest value ever
  32920. */
  32921. get min(): number;
  32922. /**
  32923. * Returns the biggest value ever
  32924. */
  32925. get max(): number;
  32926. /**
  32927. * Returns the average value since the performance counter is running
  32928. */
  32929. get average(): number;
  32930. /**
  32931. * Returns the average value of the last second the counter was monitored
  32932. */
  32933. get lastSecAverage(): number;
  32934. /**
  32935. * Returns the current value
  32936. */
  32937. get current(): number;
  32938. /**
  32939. * Gets the accumulated total
  32940. */
  32941. get total(): number;
  32942. /**
  32943. * Gets the total value count
  32944. */
  32945. get count(): number;
  32946. /**
  32947. * Creates a new counter
  32948. */
  32949. constructor();
  32950. /**
  32951. * Call this method to start monitoring a new frame.
  32952. * This scenario is typically used when you accumulate monitoring time many times for a single frame, you call this method at the start of the frame, then beginMonitoring to start recording and endMonitoring(false) to accumulated the recorded time to the PerfCounter or addCount() to accumulate a monitored count.
  32953. */
  32954. fetchNewFrame(): void;
  32955. /**
  32956. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  32957. * @param newCount the count value to add to the monitored count
  32958. * @param fetchResult true when it's the last time in the frame you add to the counter and you wish to update the statistics properties (min/max/average), false if you only want to update statistics.
  32959. */
  32960. addCount(newCount: number, fetchResult: boolean): void;
  32961. /**
  32962. * Start monitoring this performance counter
  32963. */
  32964. beginMonitoring(): void;
  32965. /**
  32966. * Compute the time lapsed since the previous beginMonitoring() call.
  32967. * @param newFrame true by default to fetch the result and monitor a new frame, if false the time monitored will be added to the current frame counter
  32968. */
  32969. endMonitoring(newFrame?: boolean): void;
  32970. private _fetchResult;
  32971. private _startMonitoringTime;
  32972. private _min;
  32973. private _max;
  32974. private _average;
  32975. private _current;
  32976. private _totalValueCount;
  32977. private _totalAccumulated;
  32978. private _lastSecAverage;
  32979. private _lastSecAccumulated;
  32980. private _lastSecTime;
  32981. private _lastSecValueCount;
  32982. }
  32983. }
  32984. declare module BABYLON {
  32985. interface ThinEngine {
  32986. /**
  32987. * Sets alpha constants used by some alpha blending modes
  32988. * @param r defines the red component
  32989. * @param g defines the green component
  32990. * @param b defines the blue component
  32991. * @param a defines the alpha component
  32992. */
  32993. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  32994. /**
  32995. * Sets the current alpha mode
  32996. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  32997. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  32998. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  32999. */
  33000. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  33001. /**
  33002. * Gets the current alpha mode
  33003. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  33004. * @returns the current alpha mode
  33005. */
  33006. getAlphaMode(): number;
  33007. /**
  33008. * Sets the current alpha equation
  33009. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  33010. */
  33011. setAlphaEquation(equation: number): void;
  33012. /**
  33013. * Gets the current alpha equation.
  33014. * @returns the current alpha equation
  33015. */
  33016. getAlphaEquation(): number;
  33017. }
  33018. }
  33019. declare module BABYLON {
  33020. /**
  33021. * Defines the interface used by display changed events
  33022. */
  33023. export interface IDisplayChangedEventArgs {
  33024. /** Gets the vrDisplay object (if any) */
  33025. vrDisplay: Nullable<any>;
  33026. /** Gets a boolean indicating if webVR is supported */
  33027. vrSupported: boolean;
  33028. }
  33029. /**
  33030. * Defines the interface used by objects containing a viewport (like a camera)
  33031. */
  33032. interface IViewportOwnerLike {
  33033. /**
  33034. * Gets or sets the viewport
  33035. */
  33036. viewport: IViewportLike;
  33037. }
  33038. /**
  33039. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  33040. */
  33041. export class Engine extends ThinEngine {
  33042. /** Defines that alpha blending is disabled */
  33043. static readonly ALPHA_DISABLE: number;
  33044. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  33045. static readonly ALPHA_ADD: number;
  33046. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  33047. static readonly ALPHA_COMBINE: number;
  33048. /** Defines that alpha blending to DEST - SRC * DEST */
  33049. static readonly ALPHA_SUBTRACT: number;
  33050. /** Defines that alpha blending to SRC * DEST */
  33051. static readonly ALPHA_MULTIPLY: number;
  33052. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  33053. static readonly ALPHA_MAXIMIZED: number;
  33054. /** Defines that alpha blending to SRC + DEST */
  33055. static readonly ALPHA_ONEONE: number;
  33056. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  33057. static readonly ALPHA_PREMULTIPLIED: number;
  33058. /**
  33059. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  33060. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  33061. */
  33062. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  33063. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  33064. static readonly ALPHA_INTERPOLATE: number;
  33065. /**
  33066. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  33067. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  33068. */
  33069. static readonly ALPHA_SCREENMODE: number;
  33070. /** Defines that the ressource is not delayed*/
  33071. static readonly DELAYLOADSTATE_NONE: number;
  33072. /** Defines that the ressource was successfully delay loaded */
  33073. static readonly DELAYLOADSTATE_LOADED: number;
  33074. /** Defines that the ressource is currently delay loading */
  33075. static readonly DELAYLOADSTATE_LOADING: number;
  33076. /** Defines that the ressource is delayed and has not started loading */
  33077. static readonly DELAYLOADSTATE_NOTLOADED: number;
  33078. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  33079. static readonly NEVER: number;
  33080. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  33081. static readonly ALWAYS: number;
  33082. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  33083. static readonly LESS: number;
  33084. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  33085. static readonly EQUAL: number;
  33086. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than or equal to the stored value */
  33087. static readonly LEQUAL: number;
  33088. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  33089. static readonly GREATER: number;
  33090. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than or equal to the stored value */
  33091. static readonly GEQUAL: number;
  33092. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is not equal to the stored value */
  33093. static readonly NOTEQUAL: number;
  33094. /** Passed to stencilOperation to specify that stencil value must be kept */
  33095. static readonly KEEP: number;
  33096. /** Passed to stencilOperation to specify that stencil value must be replaced */
  33097. static readonly REPLACE: number;
  33098. /** Passed to stencilOperation to specify that stencil value must be incremented */
  33099. static readonly INCR: number;
  33100. /** Passed to stencilOperation to specify that stencil value must be decremented */
  33101. static readonly DECR: number;
  33102. /** Passed to stencilOperation to specify that stencil value must be inverted */
  33103. static readonly INVERT: number;
  33104. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  33105. static readonly INCR_WRAP: number;
  33106. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  33107. static readonly DECR_WRAP: number;
  33108. /** Texture is not repeating outside of 0..1 UVs */
  33109. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  33110. /** Texture is repeating outside of 0..1 UVs */
  33111. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  33112. /** Texture is repeating and mirrored */
  33113. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  33114. /** ALPHA */
  33115. static readonly TEXTUREFORMAT_ALPHA: number;
  33116. /** LUMINANCE */
  33117. static readonly TEXTUREFORMAT_LUMINANCE: number;
  33118. /** LUMINANCE_ALPHA */
  33119. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  33120. /** RGB */
  33121. static readonly TEXTUREFORMAT_RGB: number;
  33122. /** RGBA */
  33123. static readonly TEXTUREFORMAT_RGBA: number;
  33124. /** RED */
  33125. static readonly TEXTUREFORMAT_RED: number;
  33126. /** RED (2nd reference) */
  33127. static readonly TEXTUREFORMAT_R: number;
  33128. /** RG */
  33129. static readonly TEXTUREFORMAT_RG: number;
  33130. /** RED_INTEGER */
  33131. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  33132. /** RED_INTEGER (2nd reference) */
  33133. static readonly TEXTUREFORMAT_R_INTEGER: number;
  33134. /** RG_INTEGER */
  33135. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  33136. /** RGB_INTEGER */
  33137. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  33138. /** RGBA_INTEGER */
  33139. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  33140. /** UNSIGNED_BYTE */
  33141. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  33142. /** UNSIGNED_BYTE (2nd reference) */
  33143. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  33144. /** FLOAT */
  33145. static readonly TEXTURETYPE_FLOAT: number;
  33146. /** HALF_FLOAT */
  33147. static readonly TEXTURETYPE_HALF_FLOAT: number;
  33148. /** BYTE */
  33149. static readonly TEXTURETYPE_BYTE: number;
  33150. /** SHORT */
  33151. static readonly TEXTURETYPE_SHORT: number;
  33152. /** UNSIGNED_SHORT */
  33153. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  33154. /** INT */
  33155. static readonly TEXTURETYPE_INT: number;
  33156. /** UNSIGNED_INT */
  33157. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  33158. /** UNSIGNED_SHORT_4_4_4_4 */
  33159. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  33160. /** UNSIGNED_SHORT_5_5_5_1 */
  33161. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  33162. /** UNSIGNED_SHORT_5_6_5 */
  33163. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  33164. /** UNSIGNED_INT_2_10_10_10_REV */
  33165. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  33166. /** UNSIGNED_INT_24_8 */
  33167. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  33168. /** UNSIGNED_INT_10F_11F_11F_REV */
  33169. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  33170. /** UNSIGNED_INT_5_9_9_9_REV */
  33171. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  33172. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  33173. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  33174. /** nearest is mag = nearest and min = nearest and mip = linear */
  33175. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  33176. /** Bilinear is mag = linear and min = linear and mip = nearest */
  33177. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  33178. /** Trilinear is mag = linear and min = linear and mip = linear */
  33179. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  33180. /** nearest is mag = nearest and min = nearest and mip = linear */
  33181. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  33182. /** Bilinear is mag = linear and min = linear and mip = nearest */
  33183. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  33184. /** Trilinear is mag = linear and min = linear and mip = linear */
  33185. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  33186. /** mag = nearest and min = nearest and mip = nearest */
  33187. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  33188. /** mag = nearest and min = linear and mip = nearest */
  33189. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  33190. /** mag = nearest and min = linear and mip = linear */
  33191. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  33192. /** mag = nearest and min = linear and mip = none */
  33193. static readonly TEXTURE_NEAREST_LINEAR: number;
  33194. /** mag = nearest and min = nearest and mip = none */
  33195. static readonly TEXTURE_NEAREST_NEAREST: number;
  33196. /** mag = linear and min = nearest and mip = nearest */
  33197. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  33198. /** mag = linear and min = nearest and mip = linear */
  33199. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  33200. /** mag = linear and min = linear and mip = none */
  33201. static readonly TEXTURE_LINEAR_LINEAR: number;
  33202. /** mag = linear and min = nearest and mip = none */
  33203. static readonly TEXTURE_LINEAR_NEAREST: number;
  33204. /** Explicit coordinates mode */
  33205. static readonly TEXTURE_EXPLICIT_MODE: number;
  33206. /** Spherical coordinates mode */
  33207. static readonly TEXTURE_SPHERICAL_MODE: number;
  33208. /** Planar coordinates mode */
  33209. static readonly TEXTURE_PLANAR_MODE: number;
  33210. /** Cubic coordinates mode */
  33211. static readonly TEXTURE_CUBIC_MODE: number;
  33212. /** Projection coordinates mode */
  33213. static readonly TEXTURE_PROJECTION_MODE: number;
  33214. /** Skybox coordinates mode */
  33215. static readonly TEXTURE_SKYBOX_MODE: number;
  33216. /** Inverse Cubic coordinates mode */
  33217. static readonly TEXTURE_INVCUBIC_MODE: number;
  33218. /** Equirectangular coordinates mode */
  33219. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  33220. /** Equirectangular Fixed coordinates mode */
  33221. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  33222. /** Equirectangular Fixed Mirrored coordinates mode */
  33223. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  33224. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  33225. static readonly SCALEMODE_FLOOR: number;
  33226. /** Defines that texture rescaling will look for the nearest power of 2 size */
  33227. static readonly SCALEMODE_NEAREST: number;
  33228. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  33229. static readonly SCALEMODE_CEILING: number;
  33230. /**
  33231. * Returns the current npm package of the sdk
  33232. */
  33233. static get NpmPackage(): string;
  33234. /**
  33235. * Returns the current version of the framework
  33236. */
  33237. static get Version(): string;
  33238. /** Gets the list of created engines */
  33239. static get Instances(): Engine[];
  33240. /**
  33241. * Gets the latest created engine
  33242. */
  33243. static get LastCreatedEngine(): Nullable<Engine>;
  33244. /**
  33245. * Gets the latest created scene
  33246. */
  33247. static get LastCreatedScene(): Nullable<Scene>;
  33248. /**
  33249. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  33250. * @param flag defines which part of the materials must be marked as dirty
  33251. * @param predicate defines a predicate used to filter which materials should be affected
  33252. */
  33253. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  33254. /**
  33255. * Method called to create the default loading screen.
  33256. * This can be overriden in your own app.
  33257. * @param canvas The rendering canvas element
  33258. * @returns The loading screen
  33259. */
  33260. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  33261. /**
  33262. * Method called to create the default rescale post process on each engine.
  33263. */
  33264. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  33265. /**
  33266. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  33267. **/
  33268. enableOfflineSupport: boolean;
  33269. /**
  33270. * Gets or sets a boolean to enable/disable checking manifest if IndexedDB support is enabled (js will always consider the database is up to date)
  33271. **/
  33272. disableManifestCheck: boolean;
  33273. /**
  33274. * Gets the list of created scenes
  33275. */
  33276. scenes: Scene[];
  33277. /**
  33278. * Event raised when a new scene is created
  33279. */
  33280. onNewSceneAddedObservable: Observable<Scene>;
  33281. /**
  33282. * Gets the list of created postprocesses
  33283. */
  33284. postProcesses: PostProcess[];
  33285. /**
  33286. * Gets a boolean indicating if the pointer is currently locked
  33287. */
  33288. isPointerLock: boolean;
  33289. /**
  33290. * Observable event triggered each time the rendering canvas is resized
  33291. */
  33292. onResizeObservable: Observable<Engine>;
  33293. /**
  33294. * Observable event triggered each time the canvas loses focus
  33295. */
  33296. onCanvasBlurObservable: Observable<Engine>;
  33297. /**
  33298. * Observable event triggered each time the canvas gains focus
  33299. */
  33300. onCanvasFocusObservable: Observable<Engine>;
  33301. /**
  33302. * Observable event triggered each time the canvas receives pointerout event
  33303. */
  33304. onCanvasPointerOutObservable: Observable<PointerEvent>;
  33305. /**
  33306. * Observable raised when the engine begins a new frame
  33307. */
  33308. onBeginFrameObservable: Observable<Engine>;
  33309. /**
  33310. * If set, will be used to request the next animation frame for the render loop
  33311. */
  33312. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  33313. /**
  33314. * Observable raised when the engine ends the current frame
  33315. */
  33316. onEndFrameObservable: Observable<Engine>;
  33317. /**
  33318. * Observable raised when the engine is about to compile a shader
  33319. */
  33320. onBeforeShaderCompilationObservable: Observable<Engine>;
  33321. /**
  33322. * Observable raised when the engine has jsut compiled a shader
  33323. */
  33324. onAfterShaderCompilationObservable: Observable<Engine>;
  33325. /**
  33326. * Gets the audio engine
  33327. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33328. * @ignorenaming
  33329. */
  33330. static audioEngine: IAudioEngine;
  33331. /**
  33332. * Default AudioEngine factory responsible of creating the Audio Engine.
  33333. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  33334. */
  33335. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  33336. /**
  33337. * Default offline support factory responsible of creating a tool used to store data locally.
  33338. * By default, this will create a Database object if the workload has been embedded.
  33339. */
  33340. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  33341. private _loadingScreen;
  33342. private _pointerLockRequested;
  33343. private _dummyFramebuffer;
  33344. private _rescalePostProcess;
  33345. private _deterministicLockstep;
  33346. private _lockstepMaxSteps;
  33347. private _timeStep;
  33348. protected get _supportsHardwareTextureRescaling(): boolean;
  33349. private _fps;
  33350. private _deltaTime;
  33351. /** @hidden */
  33352. _drawCalls: PerfCounter;
  33353. /** Gets or sets the tab index to set to the rendering canvas. 1 is the minimum value to set to be able to capture keyboard events */
  33354. canvasTabIndex: number;
  33355. /**
  33356. * Turn this value on if you want to pause FPS computation when in background
  33357. */
  33358. disablePerformanceMonitorInBackground: boolean;
  33359. private _performanceMonitor;
  33360. /**
  33361. * Gets the performance monitor attached to this engine
  33362. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  33363. */
  33364. get performanceMonitor(): PerformanceMonitor;
  33365. private _onFocus;
  33366. private _onBlur;
  33367. private _onCanvasPointerOut;
  33368. private _onCanvasBlur;
  33369. private _onCanvasFocus;
  33370. private _onFullscreenChange;
  33371. private _onPointerLockChange;
  33372. /**
  33373. * Gets the HTML element used to attach event listeners
  33374. * @returns a HTML element
  33375. */
  33376. getInputElement(): Nullable<HTMLElement>;
  33377. /**
  33378. * Creates a new engine
  33379. * @param canvasOrContext defines the canvas or WebGL context to use for rendering. If you provide a WebGL context, Babylon.js will not hook events on the canvas (like pointers, keyboards, etc...) so no event observables will be available. This is mostly used when Babylon.js is used as a plugin on a system which alreay used the WebGL context
  33380. * @param antialias defines enable antialiasing (default: false)
  33381. * @param options defines further options to be sent to the getContext() function
  33382. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  33383. */
  33384. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  33385. /**
  33386. * Gets current aspect ratio
  33387. * @param viewportOwner defines the camera to use to get the aspect ratio
  33388. * @param useScreen defines if screen size must be used (or the current render target if any)
  33389. * @returns a number defining the aspect ratio
  33390. */
  33391. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  33392. /**
  33393. * Gets current screen aspect ratio
  33394. * @returns a number defining the aspect ratio
  33395. */
  33396. getScreenAspectRatio(): number;
  33397. /**
  33398. * Gets the client rect of the HTML canvas attached with the current webGL context
  33399. * @returns a client rectanglee
  33400. */
  33401. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  33402. /**
  33403. * Gets the client rect of the HTML element used for events
  33404. * @returns a client rectanglee
  33405. */
  33406. getInputElementClientRect(): Nullable<ClientRect>;
  33407. /**
  33408. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  33409. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33410. * @returns true if engine is in deterministic lock step mode
  33411. */
  33412. isDeterministicLockStep(): boolean;
  33413. /**
  33414. * Gets the max steps when engine is running in deterministic lock step
  33415. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33416. * @returns the max steps
  33417. */
  33418. getLockstepMaxSteps(): number;
  33419. /**
  33420. * Returns the time in ms between steps when using deterministic lock step.
  33421. * @returns time step in (ms)
  33422. */
  33423. getTimeStep(): number;
  33424. /**
  33425. * Force the mipmap generation for the given render target texture
  33426. * @param texture defines the render target texture to use
  33427. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  33428. */
  33429. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  33430. /** States */
  33431. /**
  33432. * Set various states to the webGL context
  33433. * @param culling defines backface culling state
  33434. * @param zOffset defines the value to apply to zOffset (0 by default)
  33435. * @param force defines if states must be applied even if cache is up to date
  33436. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  33437. */
  33438. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  33439. /**
  33440. * Set the z offset to apply to current rendering
  33441. * @param value defines the offset to apply
  33442. */
  33443. setZOffset(value: number): void;
  33444. /**
  33445. * Gets the current value of the zOffset
  33446. * @returns the current zOffset state
  33447. */
  33448. getZOffset(): number;
  33449. /**
  33450. * Enable or disable depth buffering
  33451. * @param enable defines the state to set
  33452. */
  33453. setDepthBuffer(enable: boolean): void;
  33454. /**
  33455. * Gets a boolean indicating if depth writing is enabled
  33456. * @returns the current depth writing state
  33457. */
  33458. getDepthWrite(): boolean;
  33459. /**
  33460. * Enable or disable depth writing
  33461. * @param enable defines the state to set
  33462. */
  33463. setDepthWrite(enable: boolean): void;
  33464. /**
  33465. * Gets a boolean indicating if stencil buffer is enabled
  33466. * @returns the current stencil buffer state
  33467. */
  33468. getStencilBuffer(): boolean;
  33469. /**
  33470. * Enable or disable the stencil buffer
  33471. * @param enable defines if the stencil buffer must be enabled or disabled
  33472. */
  33473. setStencilBuffer(enable: boolean): void;
  33474. /**
  33475. * Gets the current stencil mask
  33476. * @returns a number defining the new stencil mask to use
  33477. */
  33478. getStencilMask(): number;
  33479. /**
  33480. * Sets the current stencil mask
  33481. * @param mask defines the new stencil mask to use
  33482. */
  33483. setStencilMask(mask: number): void;
  33484. /**
  33485. * Gets the current stencil function
  33486. * @returns a number defining the stencil function to use
  33487. */
  33488. getStencilFunction(): number;
  33489. /**
  33490. * Gets the current stencil reference value
  33491. * @returns a number defining the stencil reference value to use
  33492. */
  33493. getStencilFunctionReference(): number;
  33494. /**
  33495. * Gets the current stencil mask
  33496. * @returns a number defining the stencil mask to use
  33497. */
  33498. getStencilFunctionMask(): number;
  33499. /**
  33500. * Sets the current stencil function
  33501. * @param stencilFunc defines the new stencil function to use
  33502. */
  33503. setStencilFunction(stencilFunc: number): void;
  33504. /**
  33505. * Sets the current stencil reference
  33506. * @param reference defines the new stencil reference to use
  33507. */
  33508. setStencilFunctionReference(reference: number): void;
  33509. /**
  33510. * Sets the current stencil mask
  33511. * @param mask defines the new stencil mask to use
  33512. */
  33513. setStencilFunctionMask(mask: number): void;
  33514. /**
  33515. * Gets the current stencil operation when stencil fails
  33516. * @returns a number defining stencil operation to use when stencil fails
  33517. */
  33518. getStencilOperationFail(): number;
  33519. /**
  33520. * Gets the current stencil operation when depth fails
  33521. * @returns a number defining stencil operation to use when depth fails
  33522. */
  33523. getStencilOperationDepthFail(): number;
  33524. /**
  33525. * Gets the current stencil operation when stencil passes
  33526. * @returns a number defining stencil operation to use when stencil passes
  33527. */
  33528. getStencilOperationPass(): number;
  33529. /**
  33530. * Sets the stencil operation to use when stencil fails
  33531. * @param operation defines the stencil operation to use when stencil fails
  33532. */
  33533. setStencilOperationFail(operation: number): void;
  33534. /**
  33535. * Sets the stencil operation to use when depth fails
  33536. * @param operation defines the stencil operation to use when depth fails
  33537. */
  33538. setStencilOperationDepthFail(operation: number): void;
  33539. /**
  33540. * Sets the stencil operation to use when stencil passes
  33541. * @param operation defines the stencil operation to use when stencil passes
  33542. */
  33543. setStencilOperationPass(operation: number): void;
  33544. /**
  33545. * Sets a boolean indicating if the dithering state is enabled or disabled
  33546. * @param value defines the dithering state
  33547. */
  33548. setDitheringState(value: boolean): void;
  33549. /**
  33550. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  33551. * @param value defines the rasterizer state
  33552. */
  33553. setRasterizerState(value: boolean): void;
  33554. /**
  33555. * Gets the current depth function
  33556. * @returns a number defining the depth function
  33557. */
  33558. getDepthFunction(): Nullable<number>;
  33559. /**
  33560. * Sets the current depth function
  33561. * @param depthFunc defines the function to use
  33562. */
  33563. setDepthFunction(depthFunc: number): void;
  33564. /**
  33565. * Sets the current depth function to GREATER
  33566. */
  33567. setDepthFunctionToGreater(): void;
  33568. /**
  33569. * Sets the current depth function to GEQUAL
  33570. */
  33571. setDepthFunctionToGreaterOrEqual(): void;
  33572. /**
  33573. * Sets the current depth function to LESS
  33574. */
  33575. setDepthFunctionToLess(): void;
  33576. /**
  33577. * Sets the current depth function to LEQUAL
  33578. */
  33579. setDepthFunctionToLessOrEqual(): void;
  33580. private _cachedStencilBuffer;
  33581. private _cachedStencilFunction;
  33582. private _cachedStencilMask;
  33583. private _cachedStencilOperationPass;
  33584. private _cachedStencilOperationFail;
  33585. private _cachedStencilOperationDepthFail;
  33586. private _cachedStencilReference;
  33587. /**
  33588. * Caches the the state of the stencil buffer
  33589. */
  33590. cacheStencilState(): void;
  33591. /**
  33592. * Restores the state of the stencil buffer
  33593. */
  33594. restoreStencilState(): void;
  33595. /**
  33596. * Directly set the WebGL Viewport
  33597. * @param x defines the x coordinate of the viewport (in screen space)
  33598. * @param y defines the y coordinate of the viewport (in screen space)
  33599. * @param width defines the width of the viewport (in screen space)
  33600. * @param height defines the height of the viewport (in screen space)
  33601. * @return the current viewport Object (if any) that is being replaced by this call. You can restore this viewport later on to go back to the original state
  33602. */
  33603. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  33604. /**
  33605. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  33606. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  33607. * @param y defines the y-coordinate of the corner of the clear rectangle
  33608. * @param width defines the width of the clear rectangle
  33609. * @param height defines the height of the clear rectangle
  33610. * @param clearColor defines the clear color
  33611. */
  33612. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  33613. /**
  33614. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  33615. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  33616. * @param y defines the y-coordinate of the corner of the clear rectangle
  33617. * @param width defines the width of the clear rectangle
  33618. * @param height defines the height of the clear rectangle
  33619. */
  33620. enableScissor(x: number, y: number, width: number, height: number): void;
  33621. /**
  33622. * Disable previously set scissor test rectangle
  33623. */
  33624. disableScissor(): void;
  33625. protected _reportDrawCall(): void;
  33626. /**
  33627. * Initializes a webVR display and starts listening to display change events
  33628. * The onVRDisplayChangedObservable will be notified upon these changes
  33629. * @returns The onVRDisplayChangedObservable
  33630. */
  33631. initWebVR(): Observable<IDisplayChangedEventArgs>;
  33632. /** @hidden */
  33633. _prepareVRComponent(): void;
  33634. /** @hidden */
  33635. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  33636. /** @hidden */
  33637. _submitVRFrame(): void;
  33638. /**
  33639. * Call this function to leave webVR mode
  33640. * Will do nothing if webVR is not supported or if there is no webVR device
  33641. * @see http://doc.babylonjs.com/how_to/webvr_camera
  33642. */
  33643. disableVR(): void;
  33644. /**
  33645. * Gets a boolean indicating that the system is in VR mode and is presenting
  33646. * @returns true if VR mode is engaged
  33647. */
  33648. isVRPresenting(): boolean;
  33649. /** @hidden */
  33650. _requestVRFrame(): void;
  33651. /** @hidden */
  33652. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  33653. /**
  33654. * Gets the source code of the vertex shader associated with a specific webGL program
  33655. * @param program defines the program to use
  33656. * @returns a string containing the source code of the vertex shader associated with the program
  33657. */
  33658. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  33659. /**
  33660. * Gets the source code of the fragment shader associated with a specific webGL program
  33661. * @param program defines the program to use
  33662. * @returns a string containing the source code of the fragment shader associated with the program
  33663. */
  33664. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  33665. /**
  33666. * Sets a depth stencil texture from a render target to the according uniform.
  33667. * @param channel The texture channel
  33668. * @param uniform The uniform to set
  33669. * @param texture The render target texture containing the depth stencil texture to apply
  33670. */
  33671. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  33672. /**
  33673. * Sets a texture to the webGL context from a postprocess
  33674. * @param channel defines the channel to use
  33675. * @param postProcess defines the source postprocess
  33676. */
  33677. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  33678. /**
  33679. * Binds the output of the passed in post process to the texture channel specified
  33680. * @param channel The channel the texture should be bound to
  33681. * @param postProcess The post process which's output should be bound
  33682. */
  33683. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  33684. /** @hidden */
  33685. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  33686. protected _rebuildBuffers(): void;
  33687. /** @hidden */
  33688. _renderFrame(): void;
  33689. _renderLoop(): void;
  33690. /** @hidden */
  33691. _renderViews(): boolean;
  33692. /**
  33693. * Toggle full screen mode
  33694. * @param requestPointerLock defines if a pointer lock should be requested from the user
  33695. */
  33696. switchFullscreen(requestPointerLock: boolean): void;
  33697. /**
  33698. * Enters full screen mode
  33699. * @param requestPointerLock defines if a pointer lock should be requested from the user
  33700. */
  33701. enterFullscreen(requestPointerLock: boolean): void;
  33702. /**
  33703. * Exits full screen mode
  33704. */
  33705. exitFullscreen(): void;
  33706. /**
  33707. * Enters Pointerlock mode
  33708. */
  33709. enterPointerlock(): void;
  33710. /**
  33711. * Exits Pointerlock mode
  33712. */
  33713. exitPointerlock(): void;
  33714. /**
  33715. * Begin a new frame
  33716. */
  33717. beginFrame(): void;
  33718. /**
  33719. * Enf the current frame
  33720. */
  33721. endFrame(): void;
  33722. resize(): void;
  33723. /**
  33724. * Set the compressed texture format to use, based on the formats you have, and the formats
  33725. * supported by the hardware / browser.
  33726. *
  33727. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  33728. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  33729. * to API arguments needed to compressed textures. This puts the burden on the container
  33730. * generator to house the arcane code for determining these for current & future formats.
  33731. *
  33732. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  33733. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  33734. *
  33735. * Note: The result of this call is not taken into account when a texture is base64.
  33736. *
  33737. * @param formatsAvailable defines the list of those format families you have created
  33738. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  33739. *
  33740. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  33741. * @returns The extension selected.
  33742. */
  33743. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  33744. /**
  33745. * Set the compressed texture extensions or file names to skip.
  33746. *
  33747. * @param skippedFiles defines the list of those texture files you want to skip
  33748. * Example: [".dds", ".env", "myfile.png"]
  33749. */
  33750. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  33751. /**
  33752. * Force a specific size of the canvas
  33753. * @param width defines the new canvas' width
  33754. * @param height defines the new canvas' height
  33755. */
  33756. setSize(width: number, height: number): void;
  33757. /**
  33758. * Updates a dynamic vertex buffer.
  33759. * @param vertexBuffer the vertex buffer to update
  33760. * @param data the data used to update the vertex buffer
  33761. * @param byteOffset the byte offset of the data
  33762. * @param byteLength the byte length of the data
  33763. */
  33764. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  33765. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  33766. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  33767. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  33768. _releaseTexture(texture: InternalTexture): void;
  33769. /**
  33770. * @hidden
  33771. * Rescales a texture
  33772. * @param source input texutre
  33773. * @param destination destination texture
  33774. * @param scene scene to use to render the resize
  33775. * @param internalFormat format to use when resizing
  33776. * @param onComplete callback to be called when resize has completed
  33777. */
  33778. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  33779. /**
  33780. * Gets the current framerate
  33781. * @returns a number representing the framerate
  33782. */
  33783. getFps(): number;
  33784. /**
  33785. * Gets the time spent between current and previous frame
  33786. * @returns a number representing the delta time in ms
  33787. */
  33788. getDeltaTime(): number;
  33789. private _measureFps;
  33790. /** @hidden */
  33791. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  33792. /**
  33793. * Update a dynamic index buffer
  33794. * @param indexBuffer defines the target index buffer
  33795. * @param indices defines the data to update
  33796. * @param offset defines the offset in the target index buffer where update should start
  33797. */
  33798. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  33799. /**
  33800. * Updates the sample count of a render target texture
  33801. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  33802. * @param texture defines the texture to update
  33803. * @param samples defines the sample count to set
  33804. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  33805. */
  33806. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  33807. /**
  33808. * Updates a depth texture Comparison Mode and Function.
  33809. * If the comparison Function is equal to 0, the mode will be set to none.
  33810. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  33811. * @param texture The texture to set the comparison function for
  33812. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  33813. */
  33814. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  33815. /**
  33816. * Creates a webGL buffer to use with instanciation
  33817. * @param capacity defines the size of the buffer
  33818. * @returns the webGL buffer
  33819. */
  33820. createInstancesBuffer(capacity: number): DataBuffer;
  33821. /**
  33822. * Delete a webGL buffer used with instanciation
  33823. * @param buffer defines the webGL buffer to delete
  33824. */
  33825. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  33826. /** @hidden */
  33827. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  33828. dispose(): void;
  33829. private _disableTouchAction;
  33830. /**
  33831. * Display the loading screen
  33832. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33833. */
  33834. displayLoadingUI(): void;
  33835. /**
  33836. * Hide the loading screen
  33837. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33838. */
  33839. hideLoadingUI(): void;
  33840. /**
  33841. * Gets the current loading screen object
  33842. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33843. */
  33844. get loadingScreen(): ILoadingScreen;
  33845. /**
  33846. * Sets the current loading screen object
  33847. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33848. */
  33849. set loadingScreen(loadingScreen: ILoadingScreen);
  33850. /**
  33851. * Sets the current loading screen text
  33852. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33853. */
  33854. set loadingUIText(text: string);
  33855. /**
  33856. * Sets the current loading screen background color
  33857. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33858. */
  33859. set loadingUIBackgroundColor(color: string);
  33860. /** Pointerlock and fullscreen */
  33861. /**
  33862. * Ask the browser to promote the current element to pointerlock mode
  33863. * @param element defines the DOM element to promote
  33864. */
  33865. static _RequestPointerlock(element: HTMLElement): void;
  33866. /**
  33867. * Asks the browser to exit pointerlock mode
  33868. */
  33869. static _ExitPointerlock(): void;
  33870. /**
  33871. * Ask the browser to promote the current element to fullscreen rendering mode
  33872. * @param element defines the DOM element to promote
  33873. */
  33874. static _RequestFullscreen(element: HTMLElement): void;
  33875. /**
  33876. * Asks the browser to exit fullscreen mode
  33877. */
  33878. static _ExitFullscreen(): void;
  33879. }
  33880. }
  33881. declare module BABYLON {
  33882. /**
  33883. * The engine store class is responsible to hold all the instances of Engine and Scene created
  33884. * during the life time of the application.
  33885. */
  33886. export class EngineStore {
  33887. /** Gets the list of created engines */
  33888. static Instances: Engine[];
  33889. /** @hidden */
  33890. static _LastCreatedScene: Nullable<Scene>;
  33891. /**
  33892. * Gets the latest created engine
  33893. */
  33894. static get LastCreatedEngine(): Nullable<Engine>;
  33895. /**
  33896. * Gets the latest created scene
  33897. */
  33898. static get LastCreatedScene(): Nullable<Scene>;
  33899. /**
  33900. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  33901. * @ignorenaming
  33902. */
  33903. static UseFallbackTexture: boolean;
  33904. /**
  33905. * Texture content used if a texture cannot loaded
  33906. * @ignorenaming
  33907. */
  33908. static FallbackTexture: string;
  33909. }
  33910. }
  33911. declare module BABYLON {
  33912. /**
  33913. * Helper class that provides a small promise polyfill
  33914. */
  33915. export class PromisePolyfill {
  33916. /**
  33917. * Static function used to check if the polyfill is required
  33918. * If this is the case then the function will inject the polyfill to window.Promise
  33919. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  33920. */
  33921. static Apply(force?: boolean): void;
  33922. }
  33923. }
  33924. declare module BABYLON {
  33925. /**
  33926. * Interface for screenshot methods with describe argument called `size` as object with options
  33927. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  33928. */
  33929. export interface IScreenshotSize {
  33930. /**
  33931. * number in pixels for canvas height
  33932. */
  33933. height?: number;
  33934. /**
  33935. * multiplier allowing render at a higher or lower resolution
  33936. * If value is defined then height and width will be ignored and taken from camera
  33937. */
  33938. precision?: number;
  33939. /**
  33940. * number in pixels for canvas width
  33941. */
  33942. width?: number;
  33943. }
  33944. }
  33945. declare module BABYLON {
  33946. interface IColor4Like {
  33947. r: float;
  33948. g: float;
  33949. b: float;
  33950. a: float;
  33951. }
  33952. /**
  33953. * Class containing a set of static utilities functions
  33954. */
  33955. export class Tools {
  33956. /**
  33957. * Gets or sets the base URL to use to load assets
  33958. */
  33959. static get BaseUrl(): string;
  33960. static set BaseUrl(value: string);
  33961. /**
  33962. * Enable/Disable Custom HTTP Request Headers globally.
  33963. * default = false
  33964. * @see CustomRequestHeaders
  33965. */
  33966. static UseCustomRequestHeaders: boolean;
  33967. /**
  33968. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  33969. * i.e. when loading files, where the server/service expects an Authorization header
  33970. */
  33971. static CustomRequestHeaders: {
  33972. [key: string]: string;
  33973. };
  33974. /**
  33975. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  33976. */
  33977. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  33978. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  33979. /**
  33980. * Default behaviour for cors in the application.
  33981. * It can be a string if the expected behavior is identical in the entire app.
  33982. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  33983. */
  33984. static CorsBehavior: string | ((url: string | string[]) => string);
  33985. /**
  33986. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  33987. * @ignorenaming
  33988. */
  33989. static get UseFallbackTexture(): boolean;
  33990. static set UseFallbackTexture(value: boolean);
  33991. /**
  33992. * Use this object to register external classes like custom textures or material
  33993. * to allow the laoders to instantiate them
  33994. */
  33995. static get RegisteredExternalClasses(): {
  33996. [key: string]: Object;
  33997. };
  33998. static set RegisteredExternalClasses(classes: {
  33999. [key: string]: Object;
  34000. });
  34001. /**
  34002. * Texture content used if a texture cannot loaded
  34003. * @ignorenaming
  34004. */
  34005. static get fallbackTexture(): string;
  34006. static set fallbackTexture(value: string);
  34007. /**
  34008. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  34009. * @param u defines the coordinate on X axis
  34010. * @param v defines the coordinate on Y axis
  34011. * @param width defines the width of the source data
  34012. * @param height defines the height of the source data
  34013. * @param pixels defines the source byte array
  34014. * @param color defines the output color
  34015. */
  34016. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  34017. /**
  34018. * Interpolates between a and b via alpha
  34019. * @param a The lower value (returned when alpha = 0)
  34020. * @param b The upper value (returned when alpha = 1)
  34021. * @param alpha The interpolation-factor
  34022. * @return The mixed value
  34023. */
  34024. static Mix(a: number, b: number, alpha: number): number;
  34025. /**
  34026. * Tries to instantiate a new object from a given class name
  34027. * @param className defines the class name to instantiate
  34028. * @returns the new object or null if the system was not able to do the instantiation
  34029. */
  34030. static Instantiate(className: string): any;
  34031. /**
  34032. * Provides a slice function that will work even on IE
  34033. * @param data defines the array to slice
  34034. * @param start defines the start of the data (optional)
  34035. * @param end defines the end of the data (optional)
  34036. * @returns the new sliced array
  34037. */
  34038. static Slice<T>(data: T, start?: number, end?: number): T;
  34039. /**
  34040. * Polyfill for setImmediate
  34041. * @param action defines the action to execute after the current execution block
  34042. */
  34043. static SetImmediate(action: () => void): void;
  34044. /**
  34045. * Function indicating if a number is an exponent of 2
  34046. * @param value defines the value to test
  34047. * @returns true if the value is an exponent of 2
  34048. */
  34049. static IsExponentOfTwo(value: number): boolean;
  34050. private static _tmpFloatArray;
  34051. /**
  34052. * Returns the nearest 32-bit single precision float representation of a Number
  34053. * @param value A Number. If the parameter is of a different type, it will get converted
  34054. * to a number or to NaN if it cannot be converted
  34055. * @returns number
  34056. */
  34057. static FloatRound(value: number): number;
  34058. /**
  34059. * Extracts the filename from a path
  34060. * @param path defines the path to use
  34061. * @returns the filename
  34062. */
  34063. static GetFilename(path: string): string;
  34064. /**
  34065. * Extracts the "folder" part of a path (everything before the filename).
  34066. * @param uri The URI to extract the info from
  34067. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  34068. * @returns The "folder" part of the path
  34069. */
  34070. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  34071. /**
  34072. * Extracts text content from a DOM element hierarchy
  34073. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  34074. */
  34075. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  34076. /**
  34077. * Convert an angle in radians to degrees
  34078. * @param angle defines the angle to convert
  34079. * @returns the angle in degrees
  34080. */
  34081. static ToDegrees(angle: number): number;
  34082. /**
  34083. * Convert an angle in degrees to radians
  34084. * @param angle defines the angle to convert
  34085. * @returns the angle in radians
  34086. */
  34087. static ToRadians(angle: number): number;
  34088. /**
  34089. * Returns an array if obj is not an array
  34090. * @param obj defines the object to evaluate as an array
  34091. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  34092. * @returns either obj directly if obj is an array or a new array containing obj
  34093. */
  34094. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  34095. /**
  34096. * Gets the pointer prefix to use
  34097. * @returns "pointer" if touch is enabled. Else returns "mouse"
  34098. */
  34099. static GetPointerPrefix(): string;
  34100. /**
  34101. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  34102. * @param url define the url we are trying
  34103. * @param element define the dom element where to configure the cors policy
  34104. */
  34105. static SetCorsBehavior(url: string | string[], element: {
  34106. crossOrigin: string | null;
  34107. }): void;
  34108. /**
  34109. * Removes unwanted characters from an url
  34110. * @param url defines the url to clean
  34111. * @returns the cleaned url
  34112. */
  34113. static CleanUrl(url: string): string;
  34114. /**
  34115. * Gets or sets a function used to pre-process url before using them to load assets
  34116. */
  34117. static get PreprocessUrl(): (url: string) => string;
  34118. static set PreprocessUrl(processor: (url: string) => string);
  34119. /**
  34120. * Loads an image as an HTMLImageElement.
  34121. * @param input url string, ArrayBuffer, or Blob to load
  34122. * @param onLoad callback called when the image successfully loads
  34123. * @param onError callback called when the image fails to load
  34124. * @param offlineProvider offline provider for caching
  34125. * @param mimeType optional mime type
  34126. * @returns the HTMLImageElement of the loaded image
  34127. */
  34128. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  34129. /**
  34130. * Loads a file from a url
  34131. * @param url url string, ArrayBuffer, or Blob to load
  34132. * @param onSuccess callback called when the file successfully loads
  34133. * @param onProgress callback called while file is loading (if the server supports this mode)
  34134. * @param offlineProvider defines the offline provider for caching
  34135. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  34136. * @param onError callback called when the file fails to load
  34137. * @returns a file request object
  34138. */
  34139. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: any) => void): IFileRequest;
  34140. /**
  34141. * Loads a file from a url
  34142. * @param url the file url to load
  34143. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  34144. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  34145. */
  34146. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  34147. /**
  34148. * Load a script (identified by an url). When the url returns, the
  34149. * content of this file is added into a new script element, attached to the DOM (body element)
  34150. * @param scriptUrl defines the url of the script to laod
  34151. * @param onSuccess defines the callback called when the script is loaded
  34152. * @param onError defines the callback to call if an error occurs
  34153. * @param scriptId defines the id of the script element
  34154. */
  34155. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  34156. /**
  34157. * Load an asynchronous script (identified by an url). When the url returns, the
  34158. * content of this file is added into a new script element, attached to the DOM (body element)
  34159. * @param scriptUrl defines the url of the script to laod
  34160. * @param scriptId defines the id of the script element
  34161. * @returns a promise request object
  34162. */
  34163. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  34164. /**
  34165. * Loads a file from a blob
  34166. * @param fileToLoad defines the blob to use
  34167. * @param callback defines the callback to call when data is loaded
  34168. * @param progressCallback defines the callback to call during loading process
  34169. * @returns a file request object
  34170. */
  34171. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  34172. /**
  34173. * Reads a file from a File object
  34174. * @param file defines the file to load
  34175. * @param onSuccess defines the callback to call when data is loaded
  34176. * @param onProgress defines the callback to call during loading process
  34177. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  34178. * @param onError defines the callback to call when an error occurs
  34179. * @returns a file request object
  34180. */
  34181. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  34182. /**
  34183. * Creates a data url from a given string content
  34184. * @param content defines the content to convert
  34185. * @returns the new data url link
  34186. */
  34187. static FileAsURL(content: string): string;
  34188. /**
  34189. * Format the given number to a specific decimal format
  34190. * @param value defines the number to format
  34191. * @param decimals defines the number of decimals to use
  34192. * @returns the formatted string
  34193. */
  34194. static Format(value: number, decimals?: number): string;
  34195. /**
  34196. * Tries to copy an object by duplicating every property
  34197. * @param source defines the source object
  34198. * @param destination defines the target object
  34199. * @param doNotCopyList defines a list of properties to avoid
  34200. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  34201. */
  34202. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  34203. /**
  34204. * Gets a boolean indicating if the given object has no own property
  34205. * @param obj defines the object to test
  34206. * @returns true if object has no own property
  34207. */
  34208. static IsEmpty(obj: any): boolean;
  34209. /**
  34210. * Function used to register events at window level
  34211. * @param windowElement defines the Window object to use
  34212. * @param events defines the events to register
  34213. */
  34214. static RegisterTopRootEvents(windowElement: Window, events: {
  34215. name: string;
  34216. handler: Nullable<(e: FocusEvent) => any>;
  34217. }[]): void;
  34218. /**
  34219. * Function used to unregister events from window level
  34220. * @param windowElement defines the Window object to use
  34221. * @param events defines the events to unregister
  34222. */
  34223. static UnregisterTopRootEvents(windowElement: Window, events: {
  34224. name: string;
  34225. handler: Nullable<(e: FocusEvent) => any>;
  34226. }[]): void;
  34227. /**
  34228. * @ignore
  34229. */
  34230. static _ScreenshotCanvas: HTMLCanvasElement;
  34231. /**
  34232. * Dumps the current bound framebuffer
  34233. * @param width defines the rendering width
  34234. * @param height defines the rendering height
  34235. * @param engine defines the hosting engine
  34236. * @param successCallback defines the callback triggered once the data are available
  34237. * @param mimeType defines the mime type of the result
  34238. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  34239. */
  34240. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  34241. /**
  34242. * Converts the canvas data to blob.
  34243. * This acts as a polyfill for browsers not supporting the to blob function.
  34244. * @param canvas Defines the canvas to extract the data from
  34245. * @param successCallback Defines the callback triggered once the data are available
  34246. * @param mimeType Defines the mime type of the result
  34247. */
  34248. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  34249. /**
  34250. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  34251. * @param successCallback defines the callback triggered once the data are available
  34252. * @param mimeType defines the mime type of the result
  34253. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  34254. */
  34255. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  34256. /**
  34257. * Downloads a blob in the browser
  34258. * @param blob defines the blob to download
  34259. * @param fileName defines the name of the downloaded file
  34260. */
  34261. static Download(blob: Blob, fileName: string): void;
  34262. /**
  34263. * Captures a screenshot of the current rendering
  34264. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34265. * @param engine defines the rendering engine
  34266. * @param camera defines the source camera
  34267. * @param size This parameter can be set to a single number or to an object with the
  34268. * following (optional) properties: precision, width, height. If a single number is passed,
  34269. * it will be used for both width and height. If an object is passed, the screenshot size
  34270. * will be derived from the parameters. The precision property is a multiplier allowing
  34271. * rendering at a higher or lower resolution
  34272. * @param successCallback defines the callback receives a single parameter which contains the
  34273. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  34274. * src parameter of an <img> to display it
  34275. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  34276. * Check your browser for supported MIME types
  34277. */
  34278. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  34279. /**
  34280. * Captures a screenshot of the current rendering
  34281. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34282. * @param engine defines the rendering engine
  34283. * @param camera defines the source camera
  34284. * @param size This parameter can be set to a single number or to an object with the
  34285. * following (optional) properties: precision, width, height. If a single number is passed,
  34286. * it will be used for both width and height. If an object is passed, the screenshot size
  34287. * will be derived from the parameters. The precision property is a multiplier allowing
  34288. * rendering at a higher or lower resolution
  34289. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  34290. * Check your browser for supported MIME types
  34291. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  34292. * to the src parameter of an <img> to display it
  34293. */
  34294. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  34295. /**
  34296. * Generates an image screenshot from the specified camera.
  34297. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34298. * @param engine The engine to use for rendering
  34299. * @param camera The camera to use for rendering
  34300. * @param size This parameter can be set to a single number or to an object with the
  34301. * following (optional) properties: precision, width, height. If a single number is passed,
  34302. * it will be used for both width and height. If an object is passed, the screenshot size
  34303. * will be derived from the parameters. The precision property is a multiplier allowing
  34304. * rendering at a higher or lower resolution
  34305. * @param successCallback The callback receives a single parameter which contains the
  34306. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  34307. * src parameter of an <img> to display it
  34308. * @param mimeType The MIME type of the screenshot image (default: image/png).
  34309. * Check your browser for supported MIME types
  34310. * @param samples Texture samples (default: 1)
  34311. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  34312. * @param fileName A name for for the downloaded file.
  34313. */
  34314. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  34315. /**
  34316. * Generates an image screenshot from the specified camera.
  34317. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34318. * @param engine The engine to use for rendering
  34319. * @param camera The camera to use for rendering
  34320. * @param size This parameter can be set to a single number or to an object with the
  34321. * following (optional) properties: precision, width, height. If a single number is passed,
  34322. * it will be used for both width and height. If an object is passed, the screenshot size
  34323. * will be derived from the parameters. The precision property is a multiplier allowing
  34324. * rendering at a higher or lower resolution
  34325. * @param mimeType The MIME type of the screenshot image (default: image/png).
  34326. * Check your browser for supported MIME types
  34327. * @param samples Texture samples (default: 1)
  34328. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  34329. * @param fileName A name for for the downloaded file.
  34330. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  34331. * to the src parameter of an <img> to display it
  34332. */
  34333. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  34334. /**
  34335. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  34336. * Be aware Math.random() could cause collisions, but:
  34337. * "All but 6 of the 128 bits of the ID are randomly generated, which means that for any two ids, there's a 1 in 2^^122 (or 5.3x10^^36) chance they'll collide"
  34338. * @returns a pseudo random id
  34339. */
  34340. static RandomId(): string;
  34341. /**
  34342. * Test if the given uri is a base64 string
  34343. * @param uri The uri to test
  34344. * @return True if the uri is a base64 string or false otherwise
  34345. */
  34346. static IsBase64(uri: string): boolean;
  34347. /**
  34348. * Decode the given base64 uri.
  34349. * @param uri The uri to decode
  34350. * @return The decoded base64 data.
  34351. */
  34352. static DecodeBase64(uri: string): ArrayBuffer;
  34353. /**
  34354. * Gets the absolute url.
  34355. * @param url the input url
  34356. * @return the absolute url
  34357. */
  34358. static GetAbsoluteUrl(url: string): string;
  34359. /**
  34360. * No log
  34361. */
  34362. static readonly NoneLogLevel: number;
  34363. /**
  34364. * Only message logs
  34365. */
  34366. static readonly MessageLogLevel: number;
  34367. /**
  34368. * Only warning logs
  34369. */
  34370. static readonly WarningLogLevel: number;
  34371. /**
  34372. * Only error logs
  34373. */
  34374. static readonly ErrorLogLevel: number;
  34375. /**
  34376. * All logs
  34377. */
  34378. static readonly AllLogLevel: number;
  34379. /**
  34380. * Gets a value indicating the number of loading errors
  34381. * @ignorenaming
  34382. */
  34383. static get errorsCount(): number;
  34384. /**
  34385. * Callback called when a new log is added
  34386. */
  34387. static OnNewCacheEntry: (entry: string) => void;
  34388. /**
  34389. * Log a message to the console
  34390. * @param message defines the message to log
  34391. */
  34392. static Log(message: string): void;
  34393. /**
  34394. * Write a warning message to the console
  34395. * @param message defines the message to log
  34396. */
  34397. static Warn(message: string): void;
  34398. /**
  34399. * Write an error message to the console
  34400. * @param message defines the message to log
  34401. */
  34402. static Error(message: string): void;
  34403. /**
  34404. * Gets current log cache (list of logs)
  34405. */
  34406. static get LogCache(): string;
  34407. /**
  34408. * Clears the log cache
  34409. */
  34410. static ClearLogCache(): void;
  34411. /**
  34412. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  34413. */
  34414. static set LogLevels(level: number);
  34415. /**
  34416. * Checks if the window object exists
  34417. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  34418. */
  34419. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  34420. /**
  34421. * No performance log
  34422. */
  34423. static readonly PerformanceNoneLogLevel: number;
  34424. /**
  34425. * Use user marks to log performance
  34426. */
  34427. static readonly PerformanceUserMarkLogLevel: number;
  34428. /**
  34429. * Log performance to the console
  34430. */
  34431. static readonly PerformanceConsoleLogLevel: number;
  34432. private static _performance;
  34433. /**
  34434. * Sets the current performance log level
  34435. */
  34436. static set PerformanceLogLevel(level: number);
  34437. private static _StartPerformanceCounterDisabled;
  34438. private static _EndPerformanceCounterDisabled;
  34439. private static _StartUserMark;
  34440. private static _EndUserMark;
  34441. private static _StartPerformanceConsole;
  34442. private static _EndPerformanceConsole;
  34443. /**
  34444. * Starts a performance counter
  34445. */
  34446. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  34447. /**
  34448. * Ends a specific performance coutner
  34449. */
  34450. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  34451. /**
  34452. * Gets either window.performance.now() if supported or Date.now() else
  34453. */
  34454. static get Now(): number;
  34455. /**
  34456. * This method will return the name of the class used to create the instance of the given object.
  34457. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  34458. * @param object the object to get the class name from
  34459. * @param isType defines if the object is actually a type
  34460. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  34461. */
  34462. static GetClassName(object: any, isType?: boolean): string;
  34463. /**
  34464. * Gets the first element of an array satisfying a given predicate
  34465. * @param array defines the array to browse
  34466. * @param predicate defines the predicate to use
  34467. * @returns null if not found or the element
  34468. */
  34469. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  34470. /**
  34471. * This method will return the name of the full name of the class, including its owning module (if any).
  34472. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator or implementing a method getClassName():string (in which case the module won't be specified).
  34473. * @param object the object to get the class name from
  34474. * @param isType defines if the object is actually a type
  34475. * @return a string that can have two forms: "moduleName.className" if module was specified when the class' Name was registered or "className" if there was not module specified.
  34476. * @ignorenaming
  34477. */
  34478. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  34479. /**
  34480. * Returns a promise that resolves after the given amount of time.
  34481. * @param delay Number of milliseconds to delay
  34482. * @returns Promise that resolves after the given amount of time
  34483. */
  34484. static DelayAsync(delay: number): Promise<void>;
  34485. /**
  34486. * Utility function to detect if the current user agent is Safari
  34487. * @returns whether or not the current user agent is safari
  34488. */
  34489. static IsSafari(): boolean;
  34490. }
  34491. /**
  34492. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  34493. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  34494. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  34495. * @param name The name of the class, case should be preserved
  34496. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  34497. */
  34498. export function className(name: string, module?: string): (target: Object) => void;
  34499. /**
  34500. * An implementation of a loop for asynchronous functions.
  34501. */
  34502. export class AsyncLoop {
  34503. /**
  34504. * Defines the number of iterations for the loop
  34505. */
  34506. iterations: number;
  34507. /**
  34508. * Defines the current index of the loop.
  34509. */
  34510. index: number;
  34511. private _done;
  34512. private _fn;
  34513. private _successCallback;
  34514. /**
  34515. * Constructor.
  34516. * @param iterations the number of iterations.
  34517. * @param func the function to run each iteration
  34518. * @param successCallback the callback that will be called upon succesful execution
  34519. * @param offset starting offset.
  34520. */
  34521. constructor(
  34522. /**
  34523. * Defines the number of iterations for the loop
  34524. */
  34525. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  34526. /**
  34527. * Execute the next iteration. Must be called after the last iteration was finished.
  34528. */
  34529. executeNext(): void;
  34530. /**
  34531. * Break the loop and run the success callback.
  34532. */
  34533. breakLoop(): void;
  34534. /**
  34535. * Create and run an async loop.
  34536. * @param iterations the number of iterations.
  34537. * @param fn the function to run each iteration
  34538. * @param successCallback the callback that will be called upon succesful execution
  34539. * @param offset starting offset.
  34540. * @returns the created async loop object
  34541. */
  34542. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  34543. /**
  34544. * A for-loop that will run a given number of iterations synchronous and the rest async.
  34545. * @param iterations total number of iterations
  34546. * @param syncedIterations number of synchronous iterations in each async iteration.
  34547. * @param fn the function to call each iteration.
  34548. * @param callback a success call back that will be called when iterating stops.
  34549. * @param breakFunction a break condition (optional)
  34550. * @param timeout timeout settings for the setTimeout function. default - 0.
  34551. * @returns the created async loop object
  34552. */
  34553. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  34554. }
  34555. }
  34556. declare module BABYLON {
  34557. /**
  34558. * This class implement a typical dictionary using a string as key and the generic type T as value.
  34559. * The underlying implementation relies on an associative array to ensure the best performances.
  34560. * The value can be anything including 'null' but except 'undefined'
  34561. */
  34562. export class StringDictionary<T> {
  34563. /**
  34564. * This will clear this dictionary and copy the content from the 'source' one.
  34565. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  34566. * @param source the dictionary to take the content from and copy to this dictionary
  34567. */
  34568. copyFrom(source: StringDictionary<T>): void;
  34569. /**
  34570. * Get a value based from its key
  34571. * @param key the given key to get the matching value from
  34572. * @return the value if found, otherwise undefined is returned
  34573. */
  34574. get(key: string): T | undefined;
  34575. /**
  34576. * Get a value from its key or add it if it doesn't exist.
  34577. * This method will ensure you that a given key/data will be present in the dictionary.
  34578. * @param key the given key to get the matching value from
  34579. * @param factory the factory that will create the value if the key is not present in the dictionary.
  34580. * The factory will only be invoked if there's no data for the given key.
  34581. * @return the value corresponding to the key.
  34582. */
  34583. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  34584. /**
  34585. * Get a value from its key if present in the dictionary otherwise add it
  34586. * @param key the key to get the value from
  34587. * @param val if there's no such key/value pair in the dictionary add it with this value
  34588. * @return the value corresponding to the key
  34589. */
  34590. getOrAdd(key: string, val: T): T;
  34591. /**
  34592. * Check if there's a given key in the dictionary
  34593. * @param key the key to check for
  34594. * @return true if the key is present, false otherwise
  34595. */
  34596. contains(key: string): boolean;
  34597. /**
  34598. * Add a new key and its corresponding value
  34599. * @param key the key to add
  34600. * @param value the value corresponding to the key
  34601. * @return true if the operation completed successfully, false if we couldn't insert the key/value because there was already this key in the dictionary
  34602. */
  34603. add(key: string, value: T): boolean;
  34604. /**
  34605. * Update a specific value associated to a key
  34606. * @param key defines the key to use
  34607. * @param value defines the value to store
  34608. * @returns true if the value was updated (or false if the key was not found)
  34609. */
  34610. set(key: string, value: T): boolean;
  34611. /**
  34612. * Get the element of the given key and remove it from the dictionary
  34613. * @param key defines the key to search
  34614. * @returns the value associated with the key or null if not found
  34615. */
  34616. getAndRemove(key: string): Nullable<T>;
  34617. /**
  34618. * Remove a key/value from the dictionary.
  34619. * @param key the key to remove
  34620. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  34621. */
  34622. remove(key: string): boolean;
  34623. /**
  34624. * Clear the whole content of the dictionary
  34625. */
  34626. clear(): void;
  34627. /**
  34628. * Gets the current count
  34629. */
  34630. get count(): number;
  34631. /**
  34632. * Execute a callback on each key/val of the dictionary.
  34633. * Note that you can remove any element in this dictionary in the callback implementation
  34634. * @param callback the callback to execute on a given key/value pair
  34635. */
  34636. forEach(callback: (key: string, val: T) => void): void;
  34637. /**
  34638. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  34639. * If the callback returns null or undefined the method will iterate to the next key/value pair
  34640. * Note that you can remove any element in this dictionary in the callback implementation
  34641. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  34642. * @returns the first item
  34643. */
  34644. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  34645. private _count;
  34646. private _data;
  34647. }
  34648. }
  34649. declare module BABYLON {
  34650. /** @hidden */
  34651. export interface ICollisionCoordinator {
  34652. createCollider(): Collider;
  34653. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  34654. init(scene: Scene): void;
  34655. }
  34656. /** @hidden */
  34657. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  34658. private _scene;
  34659. private _scaledPosition;
  34660. private _scaledVelocity;
  34661. private _finalPosition;
  34662. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  34663. createCollider(): Collider;
  34664. init(scene: Scene): void;
  34665. private _collideWithWorld;
  34666. }
  34667. }
  34668. declare module BABYLON {
  34669. /**
  34670. * Class used to manage all inputs for the scene.
  34671. */
  34672. export class InputManager {
  34673. /** The distance in pixel that you have to move to prevent some events */
  34674. static DragMovementThreshold: number;
  34675. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  34676. static LongPressDelay: number;
  34677. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  34678. static DoubleClickDelay: number;
  34679. /** If you need to check double click without raising a single click at first click, enable this flag */
  34680. static ExclusiveDoubleClickMode: boolean;
  34681. private _wheelEventName;
  34682. private _onPointerMove;
  34683. private _onPointerDown;
  34684. private _onPointerUp;
  34685. private _initClickEvent;
  34686. private _initActionManager;
  34687. private _delayedSimpleClick;
  34688. private _delayedSimpleClickTimeout;
  34689. private _previousDelayedSimpleClickTimeout;
  34690. private _meshPickProceed;
  34691. private _previousButtonPressed;
  34692. private _currentPickResult;
  34693. private _previousPickResult;
  34694. private _totalPointersPressed;
  34695. private _doubleClickOccured;
  34696. private _pointerOverMesh;
  34697. private _pickedDownMesh;
  34698. private _pickedUpMesh;
  34699. private _pointerX;
  34700. private _pointerY;
  34701. private _unTranslatedPointerX;
  34702. private _unTranslatedPointerY;
  34703. private _startingPointerPosition;
  34704. private _previousStartingPointerPosition;
  34705. private _startingPointerTime;
  34706. private _previousStartingPointerTime;
  34707. private _pointerCaptures;
  34708. private _onKeyDown;
  34709. private _onKeyUp;
  34710. private _onCanvasFocusObserver;
  34711. private _onCanvasBlurObserver;
  34712. private _scene;
  34713. /**
  34714. * Creates a new InputManager
  34715. * @param scene defines the hosting scene
  34716. */
  34717. constructor(scene: Scene);
  34718. /**
  34719. * Gets the mesh that is currently under the pointer
  34720. */
  34721. get meshUnderPointer(): Nullable<AbstractMesh>;
  34722. /**
  34723. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  34724. */
  34725. get unTranslatedPointer(): Vector2;
  34726. /**
  34727. * Gets or sets the current on-screen X position of the pointer
  34728. */
  34729. get pointerX(): number;
  34730. set pointerX(value: number);
  34731. /**
  34732. * Gets or sets the current on-screen Y position of the pointer
  34733. */
  34734. get pointerY(): number;
  34735. set pointerY(value: number);
  34736. private _updatePointerPosition;
  34737. private _processPointerMove;
  34738. private _setRayOnPointerInfo;
  34739. private _checkPrePointerObservable;
  34740. /**
  34741. * Use this method to simulate a pointer move on a mesh
  34742. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34743. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34744. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34745. */
  34746. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  34747. /**
  34748. * Use this method to simulate a pointer down on a mesh
  34749. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34750. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34751. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34752. */
  34753. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  34754. private _processPointerDown;
  34755. /** @hidden */
  34756. _isPointerSwiping(): boolean;
  34757. /**
  34758. * Use this method to simulate a pointer up on a mesh
  34759. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34760. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34761. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34762. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  34763. */
  34764. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  34765. private _processPointerUp;
  34766. /**
  34767. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  34768. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  34769. * @returns true if the pointer was captured
  34770. */
  34771. isPointerCaptured(pointerId?: number): boolean;
  34772. /**
  34773. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  34774. * @param attachUp defines if you want to attach events to pointerup
  34775. * @param attachDown defines if you want to attach events to pointerdown
  34776. * @param attachMove defines if you want to attach events to pointermove
  34777. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  34778. */
  34779. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  34780. /**
  34781. * Detaches all event handlers
  34782. */
  34783. detachControl(): void;
  34784. /**
  34785. * Force the value of meshUnderPointer
  34786. * @param mesh defines the mesh to use
  34787. */
  34788. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  34789. /**
  34790. * Gets the mesh under the pointer
  34791. * @returns a Mesh or null if no mesh is under the pointer
  34792. */
  34793. getPointerOverMesh(): Nullable<AbstractMesh>;
  34794. }
  34795. }
  34796. declare module BABYLON {
  34797. /**
  34798. * Helper class used to generate session unique ID
  34799. */
  34800. export class UniqueIdGenerator {
  34801. private static _UniqueIdCounter;
  34802. /**
  34803. * Gets an unique (relatively to the current scene) Id
  34804. */
  34805. static get UniqueId(): number;
  34806. }
  34807. }
  34808. declare module BABYLON {
  34809. /**
  34810. * This class defines the direct association between an animation and a target
  34811. */
  34812. export class TargetedAnimation {
  34813. /**
  34814. * Animation to perform
  34815. */
  34816. animation: Animation;
  34817. /**
  34818. * Target to animate
  34819. */
  34820. target: any;
  34821. /**
  34822. * Serialize the object
  34823. * @returns the JSON object representing the current entity
  34824. */
  34825. serialize(): any;
  34826. }
  34827. /**
  34828. * Use this class to create coordinated animations on multiple targets
  34829. */
  34830. export class AnimationGroup implements IDisposable {
  34831. /** The name of the animation group */
  34832. name: string;
  34833. private _scene;
  34834. private _targetedAnimations;
  34835. private _animatables;
  34836. private _from;
  34837. private _to;
  34838. private _isStarted;
  34839. private _isPaused;
  34840. private _speedRatio;
  34841. private _loopAnimation;
  34842. /**
  34843. * Gets or sets the unique id of the node
  34844. */
  34845. uniqueId: number;
  34846. /**
  34847. * This observable will notify when one animation have ended
  34848. */
  34849. onAnimationEndObservable: Observable<TargetedAnimation>;
  34850. /**
  34851. * Observer raised when one animation loops
  34852. */
  34853. onAnimationLoopObservable: Observable<TargetedAnimation>;
  34854. /**
  34855. * Observer raised when all animations have looped
  34856. */
  34857. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  34858. /**
  34859. * This observable will notify when all animations have ended.
  34860. */
  34861. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  34862. /**
  34863. * This observable will notify when all animations have paused.
  34864. */
  34865. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  34866. /**
  34867. * This observable will notify when all animations are playing.
  34868. */
  34869. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  34870. /**
  34871. * Gets the first frame
  34872. */
  34873. get from(): number;
  34874. /**
  34875. * Gets the last frame
  34876. */
  34877. get to(): number;
  34878. /**
  34879. * Define if the animations are started
  34880. */
  34881. get isStarted(): boolean;
  34882. /**
  34883. * Gets a value indicating that the current group is playing
  34884. */
  34885. get isPlaying(): boolean;
  34886. /**
  34887. * Gets or sets the speed ratio to use for all animations
  34888. */
  34889. get speedRatio(): number;
  34890. /**
  34891. * Gets or sets the speed ratio to use for all animations
  34892. */
  34893. set speedRatio(value: number);
  34894. /**
  34895. * Gets or sets if all animations should loop or not
  34896. */
  34897. get loopAnimation(): boolean;
  34898. set loopAnimation(value: boolean);
  34899. /**
  34900. * Gets the targeted animations for this animation group
  34901. */
  34902. get targetedAnimations(): Array<TargetedAnimation>;
  34903. /**
  34904. * returning the list of animatables controlled by this animation group.
  34905. */
  34906. get animatables(): Array<Animatable>;
  34907. /**
  34908. * Instantiates a new Animation Group.
  34909. * This helps managing several animations at once.
  34910. * @see http://doc.babylonjs.com/how_to/group
  34911. * @param name Defines the name of the group
  34912. * @param scene Defines the scene the group belongs to
  34913. */
  34914. constructor(
  34915. /** The name of the animation group */
  34916. name: string, scene?: Nullable<Scene>);
  34917. /**
  34918. * Add an animation (with its target) in the group
  34919. * @param animation defines the animation we want to add
  34920. * @param target defines the target of the animation
  34921. * @returns the TargetedAnimation object
  34922. */
  34923. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  34924. /**
  34925. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  34926. * It can add constant keys at begin or end
  34927. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  34928. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  34929. * @returns the animation group
  34930. */
  34931. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  34932. private _animationLoopCount;
  34933. private _animationLoopFlags;
  34934. private _processLoop;
  34935. /**
  34936. * Start all animations on given targets
  34937. * @param loop defines if animations must loop
  34938. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  34939. * @param from defines the from key (optional)
  34940. * @param to defines the to key (optional)
  34941. * @returns the current animation group
  34942. */
  34943. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  34944. /**
  34945. * Pause all animations
  34946. * @returns the animation group
  34947. */
  34948. pause(): AnimationGroup;
  34949. /**
  34950. * Play all animations to initial state
  34951. * This function will start() the animations if they were not started or will restart() them if they were paused
  34952. * @param loop defines if animations must loop
  34953. * @returns the animation group
  34954. */
  34955. play(loop?: boolean): AnimationGroup;
  34956. /**
  34957. * Reset all animations to initial state
  34958. * @returns the animation group
  34959. */
  34960. reset(): AnimationGroup;
  34961. /**
  34962. * Restart animations from key 0
  34963. * @returns the animation group
  34964. */
  34965. restart(): AnimationGroup;
  34966. /**
  34967. * Stop all animations
  34968. * @returns the animation group
  34969. */
  34970. stop(): AnimationGroup;
  34971. /**
  34972. * Set animation weight for all animatables
  34973. * @param weight defines the weight to use
  34974. * @return the animationGroup
  34975. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  34976. */
  34977. setWeightForAllAnimatables(weight: number): AnimationGroup;
  34978. /**
  34979. * Synchronize and normalize all animatables with a source animatable
  34980. * @param root defines the root animatable to synchronize with
  34981. * @return the animationGroup
  34982. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  34983. */
  34984. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  34985. /**
  34986. * Goes to a specific frame in this animation group
  34987. * @param frame the frame number to go to
  34988. * @return the animationGroup
  34989. */
  34990. goToFrame(frame: number): AnimationGroup;
  34991. /**
  34992. * Dispose all associated resources
  34993. */
  34994. dispose(): void;
  34995. private _checkAnimationGroupEnded;
  34996. /**
  34997. * Clone the current animation group and returns a copy
  34998. * @param newName defines the name of the new group
  34999. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  35000. * @returns the new aniamtion group
  35001. */
  35002. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  35003. /**
  35004. * Serializes the animationGroup to an object
  35005. * @returns Serialized object
  35006. */
  35007. serialize(): any;
  35008. /**
  35009. * Returns a new AnimationGroup object parsed from the source provided.
  35010. * @param parsedAnimationGroup defines the source
  35011. * @param scene defines the scene that will receive the animationGroup
  35012. * @returns a new AnimationGroup
  35013. */
  35014. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  35015. /**
  35016. * Returns the string "AnimationGroup"
  35017. * @returns "AnimationGroup"
  35018. */
  35019. getClassName(): string;
  35020. /**
  35021. * Creates a detailled string about the object
  35022. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  35023. * @returns a string representing the object
  35024. */
  35025. toString(fullDetails?: boolean): string;
  35026. }
  35027. }
  35028. declare module BABYLON {
  35029. /**
  35030. * Define an interface for all classes that will hold resources
  35031. */
  35032. export interface IDisposable {
  35033. /**
  35034. * Releases all held resources
  35035. */
  35036. dispose(): void;
  35037. }
  35038. /** Interface defining initialization parameters for Scene class */
  35039. export interface SceneOptions {
  35040. /**
  35041. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  35042. * It will improve performance when the number of geometries becomes important.
  35043. */
  35044. useGeometryUniqueIdsMap?: boolean;
  35045. /**
  35046. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  35047. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  35048. */
  35049. useMaterialMeshMap?: boolean;
  35050. /**
  35051. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  35052. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  35053. */
  35054. useClonedMeshMap?: boolean;
  35055. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  35056. virtual?: boolean;
  35057. }
  35058. /**
  35059. * Represents a scene to be rendered by the engine.
  35060. * @see http://doc.babylonjs.com/features/scene
  35061. */
  35062. export class Scene extends AbstractScene implements IAnimatable {
  35063. /** The fog is deactivated */
  35064. static readonly FOGMODE_NONE: number;
  35065. /** The fog density is following an exponential function */
  35066. static readonly FOGMODE_EXP: number;
  35067. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  35068. static readonly FOGMODE_EXP2: number;
  35069. /** The fog density is following a linear function. */
  35070. static readonly FOGMODE_LINEAR: number;
  35071. /**
  35072. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  35073. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35074. */
  35075. static MinDeltaTime: number;
  35076. /**
  35077. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  35078. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35079. */
  35080. static MaxDeltaTime: number;
  35081. /**
  35082. * Factory used to create the default material.
  35083. * @param name The name of the material to create
  35084. * @param scene The scene to create the material for
  35085. * @returns The default material
  35086. */
  35087. static DefaultMaterialFactory(scene: Scene): Material;
  35088. /**
  35089. * Factory used to create the a collision coordinator.
  35090. * @returns The collision coordinator
  35091. */
  35092. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  35093. /** @hidden */
  35094. _inputManager: InputManager;
  35095. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  35096. cameraToUseForPointers: Nullable<Camera>;
  35097. /** @hidden */
  35098. readonly _isScene: boolean;
  35099. /** @hidden */
  35100. _blockEntityCollection: boolean;
  35101. /**
  35102. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  35103. */
  35104. autoClear: boolean;
  35105. /**
  35106. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  35107. */
  35108. autoClearDepthAndStencil: boolean;
  35109. /**
  35110. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  35111. */
  35112. clearColor: Color4;
  35113. /**
  35114. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  35115. */
  35116. ambientColor: Color3;
  35117. /**
  35118. * This is use to store the default BRDF lookup for PBR materials in your scene.
  35119. * It should only be one of the following (if not the default embedded one):
  35120. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  35121. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  35122. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  35123. * The material properties need to be setup according to the type of texture in use.
  35124. */
  35125. environmentBRDFTexture: BaseTexture;
  35126. /** @hidden */
  35127. protected _environmentTexture: Nullable<BaseTexture>;
  35128. /**
  35129. * Texture used in all pbr material as the reflection texture.
  35130. * As in the majority of the scene they are the same (exception for multi room and so on),
  35131. * this is easier to reference from here than from all the materials.
  35132. */
  35133. get environmentTexture(): Nullable<BaseTexture>;
  35134. /**
  35135. * Texture used in all pbr material as the reflection texture.
  35136. * As in the majority of the scene they are the same (exception for multi room and so on),
  35137. * this is easier to set here than in all the materials.
  35138. */
  35139. set environmentTexture(value: Nullable<BaseTexture>);
  35140. /** @hidden */
  35141. protected _environmentIntensity: number;
  35142. /**
  35143. * Intensity of the environment in all pbr material.
  35144. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  35145. * As in the majority of the scene they are the same (exception for multi room and so on),
  35146. * this is easier to reference from here than from all the materials.
  35147. */
  35148. get environmentIntensity(): number;
  35149. /**
  35150. * Intensity of the environment in all pbr material.
  35151. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  35152. * As in the majority of the scene they are the same (exception for multi room and so on),
  35153. * this is easier to set here than in all the materials.
  35154. */
  35155. set environmentIntensity(value: number);
  35156. /** @hidden */
  35157. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  35158. /**
  35159. * Default image processing configuration used either in the rendering
  35160. * Forward main pass or through the imageProcessingPostProcess if present.
  35161. * As in the majority of the scene they are the same (exception for multi camera),
  35162. * this is easier to reference from here than from all the materials and post process.
  35163. *
  35164. * No setter as we it is a shared configuration, you can set the values instead.
  35165. */
  35166. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  35167. private _forceWireframe;
  35168. /**
  35169. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  35170. */
  35171. set forceWireframe(value: boolean);
  35172. get forceWireframe(): boolean;
  35173. private _skipFrustumClipping;
  35174. /**
  35175. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  35176. */
  35177. set skipFrustumClipping(value: boolean);
  35178. get skipFrustumClipping(): boolean;
  35179. private _forcePointsCloud;
  35180. /**
  35181. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  35182. */
  35183. set forcePointsCloud(value: boolean);
  35184. get forcePointsCloud(): boolean;
  35185. /**
  35186. * Gets or sets the active clipplane 1
  35187. */
  35188. clipPlane: Nullable<Plane>;
  35189. /**
  35190. * Gets or sets the active clipplane 2
  35191. */
  35192. clipPlane2: Nullable<Plane>;
  35193. /**
  35194. * Gets or sets the active clipplane 3
  35195. */
  35196. clipPlane3: Nullable<Plane>;
  35197. /**
  35198. * Gets or sets the active clipplane 4
  35199. */
  35200. clipPlane4: Nullable<Plane>;
  35201. /**
  35202. * Gets or sets the active clipplane 5
  35203. */
  35204. clipPlane5: Nullable<Plane>;
  35205. /**
  35206. * Gets or sets the active clipplane 6
  35207. */
  35208. clipPlane6: Nullable<Plane>;
  35209. /**
  35210. * Gets or sets a boolean indicating if animations are enabled
  35211. */
  35212. animationsEnabled: boolean;
  35213. private _animationPropertiesOverride;
  35214. /**
  35215. * Gets or sets the animation properties override
  35216. */
  35217. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  35218. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  35219. /**
  35220. * Gets or sets a boolean indicating if a constant deltatime has to be used
  35221. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  35222. */
  35223. useConstantAnimationDeltaTime: boolean;
  35224. /**
  35225. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  35226. * Please note that it requires to run a ray cast through the scene on every frame
  35227. */
  35228. constantlyUpdateMeshUnderPointer: boolean;
  35229. /**
  35230. * Defines the HTML cursor to use when hovering over interactive elements
  35231. */
  35232. hoverCursor: string;
  35233. /**
  35234. * Defines the HTML default cursor to use (empty by default)
  35235. */
  35236. defaultCursor: string;
  35237. /**
  35238. * Defines whether cursors are handled by the scene.
  35239. */
  35240. doNotHandleCursors: boolean;
  35241. /**
  35242. * This is used to call preventDefault() on pointer down
  35243. * in order to block unwanted artifacts like system double clicks
  35244. */
  35245. preventDefaultOnPointerDown: boolean;
  35246. /**
  35247. * This is used to call preventDefault() on pointer up
  35248. * in order to block unwanted artifacts like system double clicks
  35249. */
  35250. preventDefaultOnPointerUp: boolean;
  35251. /**
  35252. * Gets or sets user defined metadata
  35253. */
  35254. metadata: any;
  35255. /**
  35256. * For internal use only. Please do not use.
  35257. */
  35258. reservedDataStore: any;
  35259. /**
  35260. * Gets the name of the plugin used to load this scene (null by default)
  35261. */
  35262. loadingPluginName: string;
  35263. /**
  35264. * Use this array to add regular expressions used to disable offline support for specific urls
  35265. */
  35266. disableOfflineSupportExceptionRules: RegExp[];
  35267. /**
  35268. * An event triggered when the scene is disposed.
  35269. */
  35270. onDisposeObservable: Observable<Scene>;
  35271. private _onDisposeObserver;
  35272. /** Sets a function to be executed when this scene is disposed. */
  35273. set onDispose(callback: () => void);
  35274. /**
  35275. * An event triggered before rendering the scene (right after animations and physics)
  35276. */
  35277. onBeforeRenderObservable: Observable<Scene>;
  35278. private _onBeforeRenderObserver;
  35279. /** Sets a function to be executed before rendering this scene */
  35280. set beforeRender(callback: Nullable<() => void>);
  35281. /**
  35282. * An event triggered after rendering the scene
  35283. */
  35284. onAfterRenderObservable: Observable<Scene>;
  35285. /**
  35286. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  35287. */
  35288. onAfterRenderCameraObservable: Observable<Camera>;
  35289. private _onAfterRenderObserver;
  35290. /** Sets a function to be executed after rendering this scene */
  35291. set afterRender(callback: Nullable<() => void>);
  35292. /**
  35293. * An event triggered before animating the scene
  35294. */
  35295. onBeforeAnimationsObservable: Observable<Scene>;
  35296. /**
  35297. * An event triggered after animations processing
  35298. */
  35299. onAfterAnimationsObservable: Observable<Scene>;
  35300. /**
  35301. * An event triggered before draw calls are ready to be sent
  35302. */
  35303. onBeforeDrawPhaseObservable: Observable<Scene>;
  35304. /**
  35305. * An event triggered after draw calls have been sent
  35306. */
  35307. onAfterDrawPhaseObservable: Observable<Scene>;
  35308. /**
  35309. * An event triggered when the scene is ready
  35310. */
  35311. onReadyObservable: Observable<Scene>;
  35312. /**
  35313. * An event triggered before rendering a camera
  35314. */
  35315. onBeforeCameraRenderObservable: Observable<Camera>;
  35316. private _onBeforeCameraRenderObserver;
  35317. /** Sets a function to be executed before rendering a camera*/
  35318. set beforeCameraRender(callback: () => void);
  35319. /**
  35320. * An event triggered after rendering a camera
  35321. */
  35322. onAfterCameraRenderObservable: Observable<Camera>;
  35323. private _onAfterCameraRenderObserver;
  35324. /** Sets a function to be executed after rendering a camera*/
  35325. set afterCameraRender(callback: () => void);
  35326. /**
  35327. * An event triggered when active meshes evaluation is about to start
  35328. */
  35329. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  35330. /**
  35331. * An event triggered when active meshes evaluation is done
  35332. */
  35333. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  35334. /**
  35335. * An event triggered when particles rendering is about to start
  35336. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  35337. */
  35338. onBeforeParticlesRenderingObservable: Observable<Scene>;
  35339. /**
  35340. * An event triggered when particles rendering is done
  35341. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  35342. */
  35343. onAfterParticlesRenderingObservable: Observable<Scene>;
  35344. /**
  35345. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  35346. */
  35347. onDataLoadedObservable: Observable<Scene>;
  35348. /**
  35349. * An event triggered when a camera is created
  35350. */
  35351. onNewCameraAddedObservable: Observable<Camera>;
  35352. /**
  35353. * An event triggered when a camera is removed
  35354. */
  35355. onCameraRemovedObservable: Observable<Camera>;
  35356. /**
  35357. * An event triggered when a light is created
  35358. */
  35359. onNewLightAddedObservable: Observable<Light>;
  35360. /**
  35361. * An event triggered when a light is removed
  35362. */
  35363. onLightRemovedObservable: Observable<Light>;
  35364. /**
  35365. * An event triggered when a geometry is created
  35366. */
  35367. onNewGeometryAddedObservable: Observable<Geometry>;
  35368. /**
  35369. * An event triggered when a geometry is removed
  35370. */
  35371. onGeometryRemovedObservable: Observable<Geometry>;
  35372. /**
  35373. * An event triggered when a transform node is created
  35374. */
  35375. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  35376. /**
  35377. * An event triggered when a transform node is removed
  35378. */
  35379. onTransformNodeRemovedObservable: Observable<TransformNode>;
  35380. /**
  35381. * An event triggered when a mesh is created
  35382. */
  35383. onNewMeshAddedObservable: Observable<AbstractMesh>;
  35384. /**
  35385. * An event triggered when a mesh is removed
  35386. */
  35387. onMeshRemovedObservable: Observable<AbstractMesh>;
  35388. /**
  35389. * An event triggered when a skeleton is created
  35390. */
  35391. onNewSkeletonAddedObservable: Observable<Skeleton>;
  35392. /**
  35393. * An event triggered when a skeleton is removed
  35394. */
  35395. onSkeletonRemovedObservable: Observable<Skeleton>;
  35396. /**
  35397. * An event triggered when a material is created
  35398. */
  35399. onNewMaterialAddedObservable: Observable<Material>;
  35400. /**
  35401. * An event triggered when a material is removed
  35402. */
  35403. onMaterialRemovedObservable: Observable<Material>;
  35404. /**
  35405. * An event triggered when a texture is created
  35406. */
  35407. onNewTextureAddedObservable: Observable<BaseTexture>;
  35408. /**
  35409. * An event triggered when a texture is removed
  35410. */
  35411. onTextureRemovedObservable: Observable<BaseTexture>;
  35412. /**
  35413. * An event triggered when render targets are about to be rendered
  35414. * Can happen multiple times per frame.
  35415. */
  35416. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  35417. /**
  35418. * An event triggered when render targets were rendered.
  35419. * Can happen multiple times per frame.
  35420. */
  35421. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  35422. /**
  35423. * An event triggered before calculating deterministic simulation step
  35424. */
  35425. onBeforeStepObservable: Observable<Scene>;
  35426. /**
  35427. * An event triggered after calculating deterministic simulation step
  35428. */
  35429. onAfterStepObservable: Observable<Scene>;
  35430. /**
  35431. * An event triggered when the activeCamera property is updated
  35432. */
  35433. onActiveCameraChanged: Observable<Scene>;
  35434. /**
  35435. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  35436. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  35437. * 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)
  35438. */
  35439. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  35440. /**
  35441. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  35442. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  35443. * 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)
  35444. */
  35445. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  35446. /**
  35447. * This Observable will when a mesh has been imported into the scene.
  35448. */
  35449. onMeshImportedObservable: Observable<AbstractMesh>;
  35450. /**
  35451. * This Observable will when an animation file has been imported into the scene.
  35452. */
  35453. onAnimationFileImportedObservable: Observable<Scene>;
  35454. /**
  35455. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  35456. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  35457. */
  35458. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  35459. /** @hidden */
  35460. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  35461. /**
  35462. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  35463. */
  35464. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  35465. /**
  35466. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  35467. */
  35468. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  35469. /**
  35470. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  35471. */
  35472. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  35473. /** Callback called when a pointer move is detected */
  35474. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  35475. /** Callback called when a pointer down is detected */
  35476. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  35477. /** Callback called when a pointer up is detected */
  35478. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  35479. /** Callback called when a pointer pick is detected */
  35480. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  35481. /**
  35482. * 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).
  35483. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  35484. */
  35485. onPrePointerObservable: Observable<PointerInfoPre>;
  35486. /**
  35487. * Observable event triggered each time an input event is received from the rendering canvas
  35488. */
  35489. onPointerObservable: Observable<PointerInfo>;
  35490. /**
  35491. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  35492. */
  35493. get unTranslatedPointer(): Vector2;
  35494. /**
  35495. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  35496. */
  35497. static get DragMovementThreshold(): number;
  35498. static set DragMovementThreshold(value: number);
  35499. /**
  35500. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  35501. */
  35502. static get LongPressDelay(): number;
  35503. static set LongPressDelay(value: number);
  35504. /**
  35505. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  35506. */
  35507. static get DoubleClickDelay(): number;
  35508. static set DoubleClickDelay(value: number);
  35509. /** If you need to check double click without raising a single click at first click, enable this flag */
  35510. static get ExclusiveDoubleClickMode(): boolean;
  35511. static set ExclusiveDoubleClickMode(value: boolean);
  35512. /** @hidden */
  35513. _mirroredCameraPosition: Nullable<Vector3>;
  35514. /**
  35515. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  35516. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  35517. */
  35518. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  35519. /**
  35520. * Observable event triggered each time an keyboard event is received from the hosting window
  35521. */
  35522. onKeyboardObservable: Observable<KeyboardInfo>;
  35523. private _useRightHandedSystem;
  35524. /**
  35525. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  35526. */
  35527. set useRightHandedSystem(value: boolean);
  35528. get useRightHandedSystem(): boolean;
  35529. private _timeAccumulator;
  35530. private _currentStepId;
  35531. private _currentInternalStep;
  35532. /**
  35533. * Sets the step Id used by deterministic lock step
  35534. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35535. * @param newStepId defines the step Id
  35536. */
  35537. setStepId(newStepId: number): void;
  35538. /**
  35539. * Gets the step Id used by deterministic lock step
  35540. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35541. * @returns the step Id
  35542. */
  35543. getStepId(): number;
  35544. /**
  35545. * Gets the internal step used by deterministic lock step
  35546. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35547. * @returns the internal step
  35548. */
  35549. getInternalStep(): number;
  35550. private _fogEnabled;
  35551. /**
  35552. * Gets or sets a boolean indicating if fog is enabled on this scene
  35553. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35554. * (Default is true)
  35555. */
  35556. set fogEnabled(value: boolean);
  35557. get fogEnabled(): boolean;
  35558. private _fogMode;
  35559. /**
  35560. * Gets or sets the fog mode to use
  35561. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35562. * | mode | value |
  35563. * | --- | --- |
  35564. * | FOGMODE_NONE | 0 |
  35565. * | FOGMODE_EXP | 1 |
  35566. * | FOGMODE_EXP2 | 2 |
  35567. * | FOGMODE_LINEAR | 3 |
  35568. */
  35569. set fogMode(value: number);
  35570. get fogMode(): number;
  35571. /**
  35572. * Gets or sets the fog color to use
  35573. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35574. * (Default is Color3(0.2, 0.2, 0.3))
  35575. */
  35576. fogColor: Color3;
  35577. /**
  35578. * Gets or sets the fog density to use
  35579. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35580. * (Default is 0.1)
  35581. */
  35582. fogDensity: number;
  35583. /**
  35584. * Gets or sets the fog start distance to use
  35585. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35586. * (Default is 0)
  35587. */
  35588. fogStart: number;
  35589. /**
  35590. * Gets or sets the fog end distance to use
  35591. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35592. * (Default is 1000)
  35593. */
  35594. fogEnd: number;
  35595. private _shadowsEnabled;
  35596. /**
  35597. * Gets or sets a boolean indicating if shadows are enabled on this scene
  35598. */
  35599. set shadowsEnabled(value: boolean);
  35600. get shadowsEnabled(): boolean;
  35601. private _lightsEnabled;
  35602. /**
  35603. * Gets or sets a boolean indicating if lights are enabled on this scene
  35604. */
  35605. set lightsEnabled(value: boolean);
  35606. get lightsEnabled(): boolean;
  35607. /** All of the active cameras added to this scene. */
  35608. activeCameras: Camera[];
  35609. /** @hidden */
  35610. _activeCamera: Nullable<Camera>;
  35611. /** Gets or sets the current active camera */
  35612. get activeCamera(): Nullable<Camera>;
  35613. set activeCamera(value: Nullable<Camera>);
  35614. private _defaultMaterial;
  35615. /** The default material used on meshes when no material is affected */
  35616. get defaultMaterial(): Material;
  35617. /** The default material used on meshes when no material is affected */
  35618. set defaultMaterial(value: Material);
  35619. private _texturesEnabled;
  35620. /**
  35621. * Gets or sets a boolean indicating if textures are enabled on this scene
  35622. */
  35623. set texturesEnabled(value: boolean);
  35624. get texturesEnabled(): boolean;
  35625. /**
  35626. * Gets or sets a boolean indicating if particles are enabled on this scene
  35627. */
  35628. particlesEnabled: boolean;
  35629. /**
  35630. * Gets or sets a boolean indicating if sprites are enabled on this scene
  35631. */
  35632. spritesEnabled: boolean;
  35633. private _skeletonsEnabled;
  35634. /**
  35635. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  35636. */
  35637. set skeletonsEnabled(value: boolean);
  35638. get skeletonsEnabled(): boolean;
  35639. /**
  35640. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  35641. */
  35642. lensFlaresEnabled: boolean;
  35643. /**
  35644. * Gets or sets a boolean indicating if collisions are enabled on this scene
  35645. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  35646. */
  35647. collisionsEnabled: boolean;
  35648. private _collisionCoordinator;
  35649. /** @hidden */
  35650. get collisionCoordinator(): ICollisionCoordinator;
  35651. /**
  35652. * Defines the gravity applied to this scene (used only for collisions)
  35653. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  35654. */
  35655. gravity: Vector3;
  35656. /**
  35657. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  35658. */
  35659. postProcessesEnabled: boolean;
  35660. /**
  35661. * The list of postprocesses added to the scene
  35662. */
  35663. postProcesses: PostProcess[];
  35664. /**
  35665. * Gets the current postprocess manager
  35666. */
  35667. postProcessManager: PostProcessManager;
  35668. /**
  35669. * Gets or sets a boolean indicating if render targets are enabled on this scene
  35670. */
  35671. renderTargetsEnabled: boolean;
  35672. /**
  35673. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  35674. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  35675. */
  35676. dumpNextRenderTargets: boolean;
  35677. /**
  35678. * The list of user defined render targets added to the scene
  35679. */
  35680. customRenderTargets: RenderTargetTexture[];
  35681. /**
  35682. * Defines if texture loading must be delayed
  35683. * If true, textures will only be loaded when they need to be rendered
  35684. */
  35685. useDelayedTextureLoading: boolean;
  35686. /**
  35687. * Gets the list of meshes imported to the scene through SceneLoader
  35688. */
  35689. importedMeshesFiles: String[];
  35690. /**
  35691. * Gets or sets a boolean indicating if probes are enabled on this scene
  35692. */
  35693. probesEnabled: boolean;
  35694. /**
  35695. * Gets or sets the current offline provider to use to store scene data
  35696. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  35697. */
  35698. offlineProvider: IOfflineProvider;
  35699. /**
  35700. * Gets or sets the action manager associated with the scene
  35701. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  35702. */
  35703. actionManager: AbstractActionManager;
  35704. private _meshesForIntersections;
  35705. /**
  35706. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  35707. */
  35708. proceduralTexturesEnabled: boolean;
  35709. private _engine;
  35710. private _totalVertices;
  35711. /** @hidden */
  35712. _activeIndices: PerfCounter;
  35713. /** @hidden */
  35714. _activeParticles: PerfCounter;
  35715. /** @hidden */
  35716. _activeBones: PerfCounter;
  35717. private _animationRatio;
  35718. /** @hidden */
  35719. _animationTimeLast: number;
  35720. /** @hidden */
  35721. _animationTime: number;
  35722. /**
  35723. * Gets or sets a general scale for animation speed
  35724. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  35725. */
  35726. animationTimeScale: number;
  35727. /** @hidden */
  35728. _cachedMaterial: Nullable<Material>;
  35729. /** @hidden */
  35730. _cachedEffect: Nullable<Effect>;
  35731. /** @hidden */
  35732. _cachedVisibility: Nullable<number>;
  35733. private _renderId;
  35734. private _frameId;
  35735. private _executeWhenReadyTimeoutId;
  35736. private _intermediateRendering;
  35737. private _viewUpdateFlag;
  35738. private _projectionUpdateFlag;
  35739. /** @hidden */
  35740. _toBeDisposed: Nullable<IDisposable>[];
  35741. private _activeRequests;
  35742. /** @hidden */
  35743. _pendingData: any[];
  35744. private _isDisposed;
  35745. /**
  35746. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  35747. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  35748. */
  35749. dispatchAllSubMeshesOfActiveMeshes: boolean;
  35750. private _activeMeshes;
  35751. private _processedMaterials;
  35752. private _renderTargets;
  35753. /** @hidden */
  35754. _activeParticleSystems: SmartArray<IParticleSystem>;
  35755. private _activeSkeletons;
  35756. private _softwareSkinnedMeshes;
  35757. private _renderingManager;
  35758. /** @hidden */
  35759. _activeAnimatables: Animatable[];
  35760. private _transformMatrix;
  35761. private _sceneUbo;
  35762. /** @hidden */
  35763. _viewMatrix: Matrix;
  35764. private _projectionMatrix;
  35765. /** @hidden */
  35766. _forcedViewPosition: Nullable<Vector3>;
  35767. /** @hidden */
  35768. _frustumPlanes: Plane[];
  35769. /**
  35770. * Gets the list of frustum planes (built from the active camera)
  35771. */
  35772. get frustumPlanes(): Plane[];
  35773. /**
  35774. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  35775. * This is useful if there are more lights that the maximum simulteanous authorized
  35776. */
  35777. requireLightSorting: boolean;
  35778. /** @hidden */
  35779. readonly useMaterialMeshMap: boolean;
  35780. /** @hidden */
  35781. readonly useClonedMeshMap: boolean;
  35782. private _externalData;
  35783. private _uid;
  35784. /**
  35785. * @hidden
  35786. * Backing store of defined scene components.
  35787. */
  35788. _components: ISceneComponent[];
  35789. /**
  35790. * @hidden
  35791. * Backing store of defined scene components.
  35792. */
  35793. _serializableComponents: ISceneSerializableComponent[];
  35794. /**
  35795. * List of components to register on the next registration step.
  35796. */
  35797. private _transientComponents;
  35798. /**
  35799. * Registers the transient components if needed.
  35800. */
  35801. private _registerTransientComponents;
  35802. /**
  35803. * @hidden
  35804. * Add a component to the scene.
  35805. * Note that the ccomponent could be registered on th next frame if this is called after
  35806. * the register component stage.
  35807. * @param component Defines the component to add to the scene
  35808. */
  35809. _addComponent(component: ISceneComponent): void;
  35810. /**
  35811. * @hidden
  35812. * Gets a component from the scene.
  35813. * @param name defines the name of the component to retrieve
  35814. * @returns the component or null if not present
  35815. */
  35816. _getComponent(name: string): Nullable<ISceneComponent>;
  35817. /**
  35818. * @hidden
  35819. * Defines the actions happening before camera updates.
  35820. */
  35821. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  35822. /**
  35823. * @hidden
  35824. * Defines the actions happening before clear the canvas.
  35825. */
  35826. _beforeClearStage: Stage<SimpleStageAction>;
  35827. /**
  35828. * @hidden
  35829. * Defines the actions when collecting render targets for the frame.
  35830. */
  35831. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  35832. /**
  35833. * @hidden
  35834. * Defines the actions happening for one camera in the frame.
  35835. */
  35836. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  35837. /**
  35838. * @hidden
  35839. * Defines the actions happening during the per mesh ready checks.
  35840. */
  35841. _isReadyForMeshStage: Stage<MeshStageAction>;
  35842. /**
  35843. * @hidden
  35844. * Defines the actions happening before evaluate active mesh checks.
  35845. */
  35846. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  35847. /**
  35848. * @hidden
  35849. * Defines the actions happening during the evaluate sub mesh checks.
  35850. */
  35851. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  35852. /**
  35853. * @hidden
  35854. * Defines the actions happening during the active mesh stage.
  35855. */
  35856. _activeMeshStage: Stage<ActiveMeshStageAction>;
  35857. /**
  35858. * @hidden
  35859. * Defines the actions happening during the per camera render target step.
  35860. */
  35861. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  35862. /**
  35863. * @hidden
  35864. * Defines the actions happening just before the active camera is drawing.
  35865. */
  35866. _beforeCameraDrawStage: Stage<CameraStageAction>;
  35867. /**
  35868. * @hidden
  35869. * Defines the actions happening just before a render target is drawing.
  35870. */
  35871. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  35872. /**
  35873. * @hidden
  35874. * Defines the actions happening just before a rendering group is drawing.
  35875. */
  35876. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  35877. /**
  35878. * @hidden
  35879. * Defines the actions happening just before a mesh is drawing.
  35880. */
  35881. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  35882. /**
  35883. * @hidden
  35884. * Defines the actions happening just after a mesh has been drawn.
  35885. */
  35886. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  35887. /**
  35888. * @hidden
  35889. * Defines the actions happening just after a rendering group has been drawn.
  35890. */
  35891. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  35892. /**
  35893. * @hidden
  35894. * Defines the actions happening just after the active camera has been drawn.
  35895. */
  35896. _afterCameraDrawStage: Stage<CameraStageAction>;
  35897. /**
  35898. * @hidden
  35899. * Defines the actions happening just after a render target has been drawn.
  35900. */
  35901. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  35902. /**
  35903. * @hidden
  35904. * Defines the actions happening just after rendering all cameras and computing intersections.
  35905. */
  35906. _afterRenderStage: Stage<SimpleStageAction>;
  35907. /**
  35908. * @hidden
  35909. * Defines the actions happening when a pointer move event happens.
  35910. */
  35911. _pointerMoveStage: Stage<PointerMoveStageAction>;
  35912. /**
  35913. * @hidden
  35914. * Defines the actions happening when a pointer down event happens.
  35915. */
  35916. _pointerDownStage: Stage<PointerUpDownStageAction>;
  35917. /**
  35918. * @hidden
  35919. * Defines the actions happening when a pointer up event happens.
  35920. */
  35921. _pointerUpStage: Stage<PointerUpDownStageAction>;
  35922. /**
  35923. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  35924. */
  35925. private geometriesByUniqueId;
  35926. /**
  35927. * Creates a new Scene
  35928. * @param engine defines the engine to use to render this scene
  35929. * @param options defines the scene options
  35930. */
  35931. constructor(engine: Engine, options?: SceneOptions);
  35932. /**
  35933. * Gets a string idenfifying the name of the class
  35934. * @returns "Scene" string
  35935. */
  35936. getClassName(): string;
  35937. private _defaultMeshCandidates;
  35938. /**
  35939. * @hidden
  35940. */
  35941. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  35942. private _defaultSubMeshCandidates;
  35943. /**
  35944. * @hidden
  35945. */
  35946. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  35947. /**
  35948. * Sets the default candidate providers for the scene.
  35949. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  35950. * and getCollidingSubMeshCandidates to their default function
  35951. */
  35952. setDefaultCandidateProviders(): void;
  35953. /**
  35954. * Gets the mesh that is currently under the pointer
  35955. */
  35956. get meshUnderPointer(): Nullable<AbstractMesh>;
  35957. /**
  35958. * Gets or sets the current on-screen X position of the pointer
  35959. */
  35960. get pointerX(): number;
  35961. set pointerX(value: number);
  35962. /**
  35963. * Gets or sets the current on-screen Y position of the pointer
  35964. */
  35965. get pointerY(): number;
  35966. set pointerY(value: number);
  35967. /**
  35968. * Gets the cached material (ie. the latest rendered one)
  35969. * @returns the cached material
  35970. */
  35971. getCachedMaterial(): Nullable<Material>;
  35972. /**
  35973. * Gets the cached effect (ie. the latest rendered one)
  35974. * @returns the cached effect
  35975. */
  35976. getCachedEffect(): Nullable<Effect>;
  35977. /**
  35978. * Gets the cached visibility state (ie. the latest rendered one)
  35979. * @returns the cached visibility state
  35980. */
  35981. getCachedVisibility(): Nullable<number>;
  35982. /**
  35983. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  35984. * @param material defines the current material
  35985. * @param effect defines the current effect
  35986. * @param visibility defines the current visibility state
  35987. * @returns true if one parameter is not cached
  35988. */
  35989. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  35990. /**
  35991. * Gets the engine associated with the scene
  35992. * @returns an Engine
  35993. */
  35994. getEngine(): Engine;
  35995. /**
  35996. * Gets the total number of vertices rendered per frame
  35997. * @returns the total number of vertices rendered per frame
  35998. */
  35999. getTotalVertices(): number;
  36000. /**
  36001. * Gets the performance counter for total vertices
  36002. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36003. */
  36004. get totalVerticesPerfCounter(): PerfCounter;
  36005. /**
  36006. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  36007. * @returns the total number of active indices rendered per frame
  36008. */
  36009. getActiveIndices(): number;
  36010. /**
  36011. * Gets the performance counter for active indices
  36012. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36013. */
  36014. get totalActiveIndicesPerfCounter(): PerfCounter;
  36015. /**
  36016. * Gets the total number of active particles rendered per frame
  36017. * @returns the total number of active particles rendered per frame
  36018. */
  36019. getActiveParticles(): number;
  36020. /**
  36021. * Gets the performance counter for active particles
  36022. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36023. */
  36024. get activeParticlesPerfCounter(): PerfCounter;
  36025. /**
  36026. * Gets the total number of active bones rendered per frame
  36027. * @returns the total number of active bones rendered per frame
  36028. */
  36029. getActiveBones(): number;
  36030. /**
  36031. * Gets the performance counter for active bones
  36032. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36033. */
  36034. get activeBonesPerfCounter(): PerfCounter;
  36035. /**
  36036. * Gets the array of active meshes
  36037. * @returns an array of AbstractMesh
  36038. */
  36039. getActiveMeshes(): SmartArray<AbstractMesh>;
  36040. /**
  36041. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  36042. * @returns a number
  36043. */
  36044. getAnimationRatio(): number;
  36045. /**
  36046. * Gets an unique Id for the current render phase
  36047. * @returns a number
  36048. */
  36049. getRenderId(): number;
  36050. /**
  36051. * Gets an unique Id for the current frame
  36052. * @returns a number
  36053. */
  36054. getFrameId(): number;
  36055. /** Call this function if you want to manually increment the render Id*/
  36056. incrementRenderId(): void;
  36057. private _createUbo;
  36058. /**
  36059. * Use this method to simulate a pointer move on a mesh
  36060. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36061. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36062. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36063. * @returns the current scene
  36064. */
  36065. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  36066. /**
  36067. * Use this method to simulate a pointer down on a mesh
  36068. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36069. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36070. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36071. * @returns the current scene
  36072. */
  36073. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  36074. /**
  36075. * Use this method to simulate a pointer up on a mesh
  36076. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36077. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36078. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36079. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  36080. * @returns the current scene
  36081. */
  36082. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  36083. /**
  36084. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  36085. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  36086. * @returns true if the pointer was captured
  36087. */
  36088. isPointerCaptured(pointerId?: number): boolean;
  36089. /**
  36090. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  36091. * @param attachUp defines if you want to attach events to pointerup
  36092. * @param attachDown defines if you want to attach events to pointerdown
  36093. * @param attachMove defines if you want to attach events to pointermove
  36094. */
  36095. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  36096. /** Detaches all event handlers*/
  36097. detachControl(): void;
  36098. /**
  36099. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  36100. * Delay loaded resources are not taking in account
  36101. * @return true if all required resources are ready
  36102. */
  36103. isReady(): boolean;
  36104. /** Resets all cached information relative to material (including effect and visibility) */
  36105. resetCachedMaterial(): void;
  36106. /**
  36107. * Registers a function to be called before every frame render
  36108. * @param func defines the function to register
  36109. */
  36110. registerBeforeRender(func: () => void): void;
  36111. /**
  36112. * Unregisters a function called before every frame render
  36113. * @param func defines the function to unregister
  36114. */
  36115. unregisterBeforeRender(func: () => void): void;
  36116. /**
  36117. * Registers a function to be called after every frame render
  36118. * @param func defines the function to register
  36119. */
  36120. registerAfterRender(func: () => void): void;
  36121. /**
  36122. * Unregisters a function called after every frame render
  36123. * @param func defines the function to unregister
  36124. */
  36125. unregisterAfterRender(func: () => void): void;
  36126. private _executeOnceBeforeRender;
  36127. /**
  36128. * The provided function will run before render once and will be disposed afterwards.
  36129. * A timeout delay can be provided so that the function will be executed in N ms.
  36130. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  36131. * @param func The function to be executed.
  36132. * @param timeout optional delay in ms
  36133. */
  36134. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  36135. /** @hidden */
  36136. _addPendingData(data: any): void;
  36137. /** @hidden */
  36138. _removePendingData(data: any): void;
  36139. /**
  36140. * Returns the number of items waiting to be loaded
  36141. * @returns the number of items waiting to be loaded
  36142. */
  36143. getWaitingItemsCount(): number;
  36144. /**
  36145. * Returns a boolean indicating if the scene is still loading data
  36146. */
  36147. get isLoading(): boolean;
  36148. /**
  36149. * Registers a function to be executed when the scene is ready
  36150. * @param {Function} func - the function to be executed
  36151. */
  36152. executeWhenReady(func: () => void): void;
  36153. /**
  36154. * Returns a promise that resolves when the scene is ready
  36155. * @returns A promise that resolves when the scene is ready
  36156. */
  36157. whenReadyAsync(): Promise<void>;
  36158. /** @hidden */
  36159. _checkIsReady(): void;
  36160. /**
  36161. * Gets all animatable attached to the scene
  36162. */
  36163. get animatables(): Animatable[];
  36164. /**
  36165. * Resets the last animation time frame.
  36166. * Useful to override when animations start running when loading a scene for the first time.
  36167. */
  36168. resetLastAnimationTimeFrame(): void;
  36169. /**
  36170. * Gets the current view matrix
  36171. * @returns a Matrix
  36172. */
  36173. getViewMatrix(): Matrix;
  36174. /**
  36175. * Gets the current projection matrix
  36176. * @returns a Matrix
  36177. */
  36178. getProjectionMatrix(): Matrix;
  36179. /**
  36180. * Gets the current transform matrix
  36181. * @returns a Matrix made of View * Projection
  36182. */
  36183. getTransformMatrix(): Matrix;
  36184. /**
  36185. * Sets the current transform matrix
  36186. * @param viewL defines the View matrix to use
  36187. * @param projectionL defines the Projection matrix to use
  36188. * @param viewR defines the right View matrix to use (if provided)
  36189. * @param projectionR defines the right Projection matrix to use (if provided)
  36190. */
  36191. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  36192. /**
  36193. * Gets the uniform buffer used to store scene data
  36194. * @returns a UniformBuffer
  36195. */
  36196. getSceneUniformBuffer(): UniformBuffer;
  36197. /**
  36198. * Gets an unique (relatively to the current scene) Id
  36199. * @returns an unique number for the scene
  36200. */
  36201. getUniqueId(): number;
  36202. /**
  36203. * Add a mesh to the list of scene's meshes
  36204. * @param newMesh defines the mesh to add
  36205. * @param recursive if all child meshes should also be added to the scene
  36206. */
  36207. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  36208. /**
  36209. * Remove a mesh for the list of scene's meshes
  36210. * @param toRemove defines the mesh to remove
  36211. * @param recursive if all child meshes should also be removed from the scene
  36212. * @returns the index where the mesh was in the mesh list
  36213. */
  36214. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  36215. /**
  36216. * Add a transform node to the list of scene's transform nodes
  36217. * @param newTransformNode defines the transform node to add
  36218. */
  36219. addTransformNode(newTransformNode: TransformNode): void;
  36220. /**
  36221. * Remove a transform node for the list of scene's transform nodes
  36222. * @param toRemove defines the transform node to remove
  36223. * @returns the index where the transform node was in the transform node list
  36224. */
  36225. removeTransformNode(toRemove: TransformNode): number;
  36226. /**
  36227. * Remove a skeleton for the list of scene's skeletons
  36228. * @param toRemove defines the skeleton to remove
  36229. * @returns the index where the skeleton was in the skeleton list
  36230. */
  36231. removeSkeleton(toRemove: Skeleton): number;
  36232. /**
  36233. * Remove a morph target for the list of scene's morph targets
  36234. * @param toRemove defines the morph target to remove
  36235. * @returns the index where the morph target was in the morph target list
  36236. */
  36237. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  36238. /**
  36239. * Remove a light for the list of scene's lights
  36240. * @param toRemove defines the light to remove
  36241. * @returns the index where the light was in the light list
  36242. */
  36243. removeLight(toRemove: Light): number;
  36244. /**
  36245. * Remove a camera for the list of scene's cameras
  36246. * @param toRemove defines the camera to remove
  36247. * @returns the index where the camera was in the camera list
  36248. */
  36249. removeCamera(toRemove: Camera): number;
  36250. /**
  36251. * Remove a particle system for the list of scene's particle systems
  36252. * @param toRemove defines the particle system to remove
  36253. * @returns the index where the particle system was in the particle system list
  36254. */
  36255. removeParticleSystem(toRemove: IParticleSystem): number;
  36256. /**
  36257. * Remove a animation for the list of scene's animations
  36258. * @param toRemove defines the animation to remove
  36259. * @returns the index where the animation was in the animation list
  36260. */
  36261. removeAnimation(toRemove: Animation): number;
  36262. /**
  36263. * Will stop the animation of the given target
  36264. * @param target - the target
  36265. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  36266. * @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)
  36267. */
  36268. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  36269. /**
  36270. * Removes the given animation group from this scene.
  36271. * @param toRemove The animation group to remove
  36272. * @returns The index of the removed animation group
  36273. */
  36274. removeAnimationGroup(toRemove: AnimationGroup): number;
  36275. /**
  36276. * Removes the given multi-material from this scene.
  36277. * @param toRemove The multi-material to remove
  36278. * @returns The index of the removed multi-material
  36279. */
  36280. removeMultiMaterial(toRemove: MultiMaterial): number;
  36281. /**
  36282. * Removes the given material from this scene.
  36283. * @param toRemove The material to remove
  36284. * @returns The index of the removed material
  36285. */
  36286. removeMaterial(toRemove: Material): number;
  36287. /**
  36288. * Removes the given action manager from this scene.
  36289. * @param toRemove The action manager to remove
  36290. * @returns The index of the removed action manager
  36291. */
  36292. removeActionManager(toRemove: AbstractActionManager): number;
  36293. /**
  36294. * Removes the given texture from this scene.
  36295. * @param toRemove The texture to remove
  36296. * @returns The index of the removed texture
  36297. */
  36298. removeTexture(toRemove: BaseTexture): number;
  36299. /**
  36300. * Adds the given light to this scene
  36301. * @param newLight The light to add
  36302. */
  36303. addLight(newLight: Light): void;
  36304. /**
  36305. * Sorts the list list based on light priorities
  36306. */
  36307. sortLightsByPriority(): void;
  36308. /**
  36309. * Adds the given camera to this scene
  36310. * @param newCamera The camera to add
  36311. */
  36312. addCamera(newCamera: Camera): void;
  36313. /**
  36314. * Adds the given skeleton to this scene
  36315. * @param newSkeleton The skeleton to add
  36316. */
  36317. addSkeleton(newSkeleton: Skeleton): void;
  36318. /**
  36319. * Adds the given particle system to this scene
  36320. * @param newParticleSystem The particle system to add
  36321. */
  36322. addParticleSystem(newParticleSystem: IParticleSystem): void;
  36323. /**
  36324. * Adds the given animation to this scene
  36325. * @param newAnimation The animation to add
  36326. */
  36327. addAnimation(newAnimation: Animation): void;
  36328. /**
  36329. * Adds the given animation group to this scene.
  36330. * @param newAnimationGroup The animation group to add
  36331. */
  36332. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  36333. /**
  36334. * Adds the given multi-material to this scene
  36335. * @param newMultiMaterial The multi-material to add
  36336. */
  36337. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  36338. /**
  36339. * Adds the given material to this scene
  36340. * @param newMaterial The material to add
  36341. */
  36342. addMaterial(newMaterial: Material): void;
  36343. /**
  36344. * Adds the given morph target to this scene
  36345. * @param newMorphTargetManager The morph target to add
  36346. */
  36347. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  36348. /**
  36349. * Adds the given geometry to this scene
  36350. * @param newGeometry The geometry to add
  36351. */
  36352. addGeometry(newGeometry: Geometry): void;
  36353. /**
  36354. * Adds the given action manager to this scene
  36355. * @param newActionManager The action manager to add
  36356. */
  36357. addActionManager(newActionManager: AbstractActionManager): void;
  36358. /**
  36359. * Adds the given texture to this scene.
  36360. * @param newTexture The texture to add
  36361. */
  36362. addTexture(newTexture: BaseTexture): void;
  36363. /**
  36364. * Switch active camera
  36365. * @param newCamera defines the new active camera
  36366. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  36367. */
  36368. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  36369. /**
  36370. * sets the active camera of the scene using its ID
  36371. * @param id defines the camera's ID
  36372. * @return the new active camera or null if none found.
  36373. */
  36374. setActiveCameraByID(id: string): Nullable<Camera>;
  36375. /**
  36376. * sets the active camera of the scene using its name
  36377. * @param name defines the camera's name
  36378. * @returns the new active camera or null if none found.
  36379. */
  36380. setActiveCameraByName(name: string): Nullable<Camera>;
  36381. /**
  36382. * get an animation group using its name
  36383. * @param name defines the material's name
  36384. * @return the animation group or null if none found.
  36385. */
  36386. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  36387. /**
  36388. * Get a material using its unique id
  36389. * @param uniqueId defines the material's unique id
  36390. * @return the material or null if none found.
  36391. */
  36392. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  36393. /**
  36394. * get a material using its id
  36395. * @param id defines the material's ID
  36396. * @return the material or null if none found.
  36397. */
  36398. getMaterialByID(id: string): Nullable<Material>;
  36399. /**
  36400. * Gets a the last added material using a given id
  36401. * @param id defines the material's ID
  36402. * @return the last material with the given id or null if none found.
  36403. */
  36404. getLastMaterialByID(id: string): Nullable<Material>;
  36405. /**
  36406. * Gets a material using its name
  36407. * @param name defines the material's name
  36408. * @return the material or null if none found.
  36409. */
  36410. getMaterialByName(name: string): Nullable<Material>;
  36411. /**
  36412. * Get a texture using its unique id
  36413. * @param uniqueId defines the texture's unique id
  36414. * @return the texture or null if none found.
  36415. */
  36416. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  36417. /**
  36418. * Gets a camera using its id
  36419. * @param id defines the id to look for
  36420. * @returns the camera or null if not found
  36421. */
  36422. getCameraByID(id: string): Nullable<Camera>;
  36423. /**
  36424. * Gets a camera using its unique id
  36425. * @param uniqueId defines the unique id to look for
  36426. * @returns the camera or null if not found
  36427. */
  36428. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  36429. /**
  36430. * Gets a camera using its name
  36431. * @param name defines the camera's name
  36432. * @return the camera or null if none found.
  36433. */
  36434. getCameraByName(name: string): Nullable<Camera>;
  36435. /**
  36436. * Gets a bone using its id
  36437. * @param id defines the bone's id
  36438. * @return the bone or null if not found
  36439. */
  36440. getBoneByID(id: string): Nullable<Bone>;
  36441. /**
  36442. * Gets a bone using its id
  36443. * @param name defines the bone's name
  36444. * @return the bone or null if not found
  36445. */
  36446. getBoneByName(name: string): Nullable<Bone>;
  36447. /**
  36448. * Gets a light node using its name
  36449. * @param name defines the the light's name
  36450. * @return the light or null if none found.
  36451. */
  36452. getLightByName(name: string): Nullable<Light>;
  36453. /**
  36454. * Gets a light node using its id
  36455. * @param id defines the light's id
  36456. * @return the light or null if none found.
  36457. */
  36458. getLightByID(id: string): Nullable<Light>;
  36459. /**
  36460. * Gets a light node using its scene-generated unique ID
  36461. * @param uniqueId defines the light's unique id
  36462. * @return the light or null if none found.
  36463. */
  36464. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  36465. /**
  36466. * Gets a particle system by id
  36467. * @param id defines the particle system id
  36468. * @return the corresponding system or null if none found
  36469. */
  36470. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  36471. /**
  36472. * Gets a geometry using its ID
  36473. * @param id defines the geometry's id
  36474. * @return the geometry or null if none found.
  36475. */
  36476. getGeometryByID(id: string): Nullable<Geometry>;
  36477. private _getGeometryByUniqueID;
  36478. /**
  36479. * Add a new geometry to this scene
  36480. * @param geometry defines the geometry to be added to the scene.
  36481. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  36482. * @return a boolean defining if the geometry was added or not
  36483. */
  36484. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  36485. /**
  36486. * Removes an existing geometry
  36487. * @param geometry defines the geometry to be removed from the scene
  36488. * @return a boolean defining if the geometry was removed or not
  36489. */
  36490. removeGeometry(geometry: Geometry): boolean;
  36491. /**
  36492. * Gets the list of geometries attached to the scene
  36493. * @returns an array of Geometry
  36494. */
  36495. getGeometries(): Geometry[];
  36496. /**
  36497. * Gets the first added mesh found of a given ID
  36498. * @param id defines the id to search for
  36499. * @return the mesh found or null if not found at all
  36500. */
  36501. getMeshByID(id: string): Nullable<AbstractMesh>;
  36502. /**
  36503. * Gets a list of meshes using their id
  36504. * @param id defines the id to search for
  36505. * @returns a list of meshes
  36506. */
  36507. getMeshesByID(id: string): Array<AbstractMesh>;
  36508. /**
  36509. * Gets the first added transform node found of a given ID
  36510. * @param id defines the id to search for
  36511. * @return the found transform node or null if not found at all.
  36512. */
  36513. getTransformNodeByID(id: string): Nullable<TransformNode>;
  36514. /**
  36515. * Gets a transform node with its auto-generated unique id
  36516. * @param uniqueId efines the unique id to search for
  36517. * @return the found transform node or null if not found at all.
  36518. */
  36519. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  36520. /**
  36521. * Gets a list of transform nodes using their id
  36522. * @param id defines the id to search for
  36523. * @returns a list of transform nodes
  36524. */
  36525. getTransformNodesByID(id: string): Array<TransformNode>;
  36526. /**
  36527. * Gets a mesh with its auto-generated unique id
  36528. * @param uniqueId defines the unique id to search for
  36529. * @return the found mesh or null if not found at all.
  36530. */
  36531. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  36532. /**
  36533. * Gets a the last added mesh using a given id
  36534. * @param id defines the id to search for
  36535. * @return the found mesh or null if not found at all.
  36536. */
  36537. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  36538. /**
  36539. * Gets a the last added node (Mesh, Camera, Light) using a given id
  36540. * @param id defines the id to search for
  36541. * @return the found node or null if not found at all
  36542. */
  36543. getLastEntryByID(id: string): Nullable<Node>;
  36544. /**
  36545. * Gets a node (Mesh, Camera, Light) using a given id
  36546. * @param id defines the id to search for
  36547. * @return the found node or null if not found at all
  36548. */
  36549. getNodeByID(id: string): Nullable<Node>;
  36550. /**
  36551. * Gets a node (Mesh, Camera, Light) using a given name
  36552. * @param name defines the name to search for
  36553. * @return the found node or null if not found at all.
  36554. */
  36555. getNodeByName(name: string): Nullable<Node>;
  36556. /**
  36557. * Gets a mesh using a given name
  36558. * @param name defines the name to search for
  36559. * @return the found mesh or null if not found at all.
  36560. */
  36561. getMeshByName(name: string): Nullable<AbstractMesh>;
  36562. /**
  36563. * Gets a transform node using a given name
  36564. * @param name defines the name to search for
  36565. * @return the found transform node or null if not found at all.
  36566. */
  36567. getTransformNodeByName(name: string): Nullable<TransformNode>;
  36568. /**
  36569. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  36570. * @param id defines the id to search for
  36571. * @return the found skeleton or null if not found at all.
  36572. */
  36573. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  36574. /**
  36575. * Gets a skeleton using a given auto generated unique id
  36576. * @param uniqueId defines the unique id to search for
  36577. * @return the found skeleton or null if not found at all.
  36578. */
  36579. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  36580. /**
  36581. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  36582. * @param id defines the id to search for
  36583. * @return the found skeleton or null if not found at all.
  36584. */
  36585. getSkeletonById(id: string): Nullable<Skeleton>;
  36586. /**
  36587. * Gets a skeleton using a given name
  36588. * @param name defines the name to search for
  36589. * @return the found skeleton or null if not found at all.
  36590. */
  36591. getSkeletonByName(name: string): Nullable<Skeleton>;
  36592. /**
  36593. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  36594. * @param id defines the id to search for
  36595. * @return the found morph target manager or null if not found at all.
  36596. */
  36597. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  36598. /**
  36599. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  36600. * @param id defines the id to search for
  36601. * @return the found morph target or null if not found at all.
  36602. */
  36603. getMorphTargetById(id: string): Nullable<MorphTarget>;
  36604. /**
  36605. * Gets a boolean indicating if the given mesh is active
  36606. * @param mesh defines the mesh to look for
  36607. * @returns true if the mesh is in the active list
  36608. */
  36609. isActiveMesh(mesh: AbstractMesh): boolean;
  36610. /**
  36611. * Return a unique id as a string which can serve as an identifier for the scene
  36612. */
  36613. get uid(): string;
  36614. /**
  36615. * Add an externaly attached data from its key.
  36616. * This method call will fail and return false, if such key already exists.
  36617. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  36618. * @param key the unique key that identifies the data
  36619. * @param data the data object to associate to the key for this Engine instance
  36620. * @return true if no such key were already present and the data was added successfully, false otherwise
  36621. */
  36622. addExternalData<T>(key: string, data: T): boolean;
  36623. /**
  36624. * Get an externaly attached data from its key
  36625. * @param key the unique key that identifies the data
  36626. * @return the associated data, if present (can be null), or undefined if not present
  36627. */
  36628. getExternalData<T>(key: string): Nullable<T>;
  36629. /**
  36630. * Get an externaly attached data from its key, create it using a factory if it's not already present
  36631. * @param key the unique key that identifies the data
  36632. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  36633. * @return the associated data, can be null if the factory returned null.
  36634. */
  36635. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  36636. /**
  36637. * Remove an externaly attached data from the Engine instance
  36638. * @param key the unique key that identifies the data
  36639. * @return true if the data was successfully removed, false if it doesn't exist
  36640. */
  36641. removeExternalData(key: string): boolean;
  36642. private _evaluateSubMesh;
  36643. /**
  36644. * Clear the processed materials smart array preventing retention point in material dispose.
  36645. */
  36646. freeProcessedMaterials(): void;
  36647. private _preventFreeActiveMeshesAndRenderingGroups;
  36648. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  36649. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  36650. * when disposing several meshes in a row or a hierarchy of meshes.
  36651. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  36652. */
  36653. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  36654. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  36655. /**
  36656. * Clear the active meshes smart array preventing retention point in mesh dispose.
  36657. */
  36658. freeActiveMeshes(): void;
  36659. /**
  36660. * Clear the info related to rendering groups preventing retention points during dispose.
  36661. */
  36662. freeRenderingGroups(): void;
  36663. /** @hidden */
  36664. _isInIntermediateRendering(): boolean;
  36665. /**
  36666. * Lambda returning the list of potentially active meshes.
  36667. */
  36668. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  36669. /**
  36670. * Lambda returning the list of potentially active sub meshes.
  36671. */
  36672. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  36673. /**
  36674. * Lambda returning the list of potentially intersecting sub meshes.
  36675. */
  36676. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  36677. /**
  36678. * Lambda returning the list of potentially colliding sub meshes.
  36679. */
  36680. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  36681. private _activeMeshesFrozen;
  36682. private _skipEvaluateActiveMeshesCompletely;
  36683. /**
  36684. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  36685. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  36686. * @returns the current scene
  36687. */
  36688. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  36689. /**
  36690. * Use this function to restart evaluating active meshes on every frame
  36691. * @returns the current scene
  36692. */
  36693. unfreezeActiveMeshes(): Scene;
  36694. private _evaluateActiveMeshes;
  36695. private _activeMesh;
  36696. /**
  36697. * Update the transform matrix to update from the current active camera
  36698. * @param force defines a boolean used to force the update even if cache is up to date
  36699. */
  36700. updateTransformMatrix(force?: boolean): void;
  36701. private _bindFrameBuffer;
  36702. /** @hidden */
  36703. _allowPostProcessClearColor: boolean;
  36704. /** @hidden */
  36705. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  36706. private _processSubCameras;
  36707. private _checkIntersections;
  36708. /** @hidden */
  36709. _advancePhysicsEngineStep(step: number): void;
  36710. /**
  36711. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  36712. */
  36713. getDeterministicFrameTime: () => number;
  36714. /** @hidden */
  36715. _animate(): void;
  36716. /** Execute all animations (for a frame) */
  36717. animate(): void;
  36718. /**
  36719. * Render the scene
  36720. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  36721. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  36722. */
  36723. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  36724. /**
  36725. * Freeze all materials
  36726. * A frozen material will not be updatable but should be faster to render
  36727. */
  36728. freezeMaterials(): void;
  36729. /**
  36730. * Unfreeze all materials
  36731. * A frozen material will not be updatable but should be faster to render
  36732. */
  36733. unfreezeMaterials(): void;
  36734. /**
  36735. * Releases all held ressources
  36736. */
  36737. dispose(): void;
  36738. /**
  36739. * Gets if the scene is already disposed
  36740. */
  36741. get isDisposed(): boolean;
  36742. /**
  36743. * Call this function to reduce memory footprint of the scene.
  36744. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  36745. */
  36746. clearCachedVertexData(): void;
  36747. /**
  36748. * This function will remove the local cached buffer data from texture.
  36749. * It will save memory but will prevent the texture from being rebuilt
  36750. */
  36751. cleanCachedTextureBuffer(): void;
  36752. /**
  36753. * Get the world extend vectors with an optional filter
  36754. *
  36755. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  36756. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  36757. */
  36758. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  36759. min: Vector3;
  36760. max: Vector3;
  36761. };
  36762. /**
  36763. * Creates a ray that can be used to pick in the scene
  36764. * @param x defines the x coordinate of the origin (on-screen)
  36765. * @param y defines the y coordinate of the origin (on-screen)
  36766. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  36767. * @param camera defines the camera to use for the picking
  36768. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  36769. * @returns a Ray
  36770. */
  36771. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  36772. /**
  36773. * Creates a ray that can be used to pick in the scene
  36774. * @param x defines the x coordinate of the origin (on-screen)
  36775. * @param y defines the y coordinate of the origin (on-screen)
  36776. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  36777. * @param result defines the ray where to store the picking ray
  36778. * @param camera defines the camera to use for the picking
  36779. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  36780. * @returns the current scene
  36781. */
  36782. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  36783. /**
  36784. * Creates a ray that can be used to pick in the scene
  36785. * @param x defines the x coordinate of the origin (on-screen)
  36786. * @param y defines the y coordinate of the origin (on-screen)
  36787. * @param camera defines the camera to use for the picking
  36788. * @returns a Ray
  36789. */
  36790. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  36791. /**
  36792. * Creates a ray that can be used to pick in the scene
  36793. * @param x defines the x coordinate of the origin (on-screen)
  36794. * @param y defines the y coordinate of the origin (on-screen)
  36795. * @param result defines the ray where to store the picking ray
  36796. * @param camera defines the camera to use for the picking
  36797. * @returns the current scene
  36798. */
  36799. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  36800. /** Launch a ray to try to pick a mesh in the scene
  36801. * @param x position on screen
  36802. * @param y position on screen
  36803. * @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
  36804. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  36805. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  36806. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  36807. * @returns a PickingInfo
  36808. */
  36809. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  36810. /** Use the given ray to pick a mesh in the scene
  36811. * @param ray The ray to use to pick meshes
  36812. * @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
  36813. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  36814. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  36815. * @returns a PickingInfo
  36816. */
  36817. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  36818. /**
  36819. * Launch a ray to try to pick a mesh in the scene
  36820. * @param x X position on screen
  36821. * @param y Y position on screen
  36822. * @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
  36823. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  36824. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  36825. * @returns an array of PickingInfo
  36826. */
  36827. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  36828. /**
  36829. * Launch a ray to try to pick a mesh in the scene
  36830. * @param ray Ray to use
  36831. * @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
  36832. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  36833. * @returns an array of PickingInfo
  36834. */
  36835. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  36836. /**
  36837. * Force the value of meshUnderPointer
  36838. * @param mesh defines the mesh to use
  36839. */
  36840. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  36841. /**
  36842. * Gets the mesh under the pointer
  36843. * @returns a Mesh or null if no mesh is under the pointer
  36844. */
  36845. getPointerOverMesh(): Nullable<AbstractMesh>;
  36846. /** @hidden */
  36847. _rebuildGeometries(): void;
  36848. /** @hidden */
  36849. _rebuildTextures(): void;
  36850. private _getByTags;
  36851. /**
  36852. * Get a list of meshes by tags
  36853. * @param tagsQuery defines the tags query to use
  36854. * @param forEach defines a predicate used to filter results
  36855. * @returns an array of Mesh
  36856. */
  36857. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  36858. /**
  36859. * Get a list of cameras by tags
  36860. * @param tagsQuery defines the tags query to use
  36861. * @param forEach defines a predicate used to filter results
  36862. * @returns an array of Camera
  36863. */
  36864. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  36865. /**
  36866. * Get a list of lights by tags
  36867. * @param tagsQuery defines the tags query to use
  36868. * @param forEach defines a predicate used to filter results
  36869. * @returns an array of Light
  36870. */
  36871. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  36872. /**
  36873. * Get a list of materials by tags
  36874. * @param tagsQuery defines the tags query to use
  36875. * @param forEach defines a predicate used to filter results
  36876. * @returns an array of Material
  36877. */
  36878. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  36879. /**
  36880. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  36881. * This allowed control for front to back rendering or reversly depending of the special needs.
  36882. *
  36883. * @param renderingGroupId The rendering group id corresponding to its index
  36884. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  36885. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  36886. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  36887. */
  36888. 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;
  36889. /**
  36890. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  36891. *
  36892. * @param renderingGroupId The rendering group id corresponding to its index
  36893. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  36894. * @param depth Automatically clears depth between groups if true and autoClear is true.
  36895. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  36896. */
  36897. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  36898. /**
  36899. * Gets the current auto clear configuration for one rendering group of the rendering
  36900. * manager.
  36901. * @param index the rendering group index to get the information for
  36902. * @returns The auto clear setup for the requested rendering group
  36903. */
  36904. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  36905. private _blockMaterialDirtyMechanism;
  36906. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  36907. get blockMaterialDirtyMechanism(): boolean;
  36908. set blockMaterialDirtyMechanism(value: boolean);
  36909. /**
  36910. * Will flag all materials as dirty to trigger new shader compilation
  36911. * @param flag defines the flag used to specify which material part must be marked as dirty
  36912. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  36913. */
  36914. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  36915. /** @hidden */
  36916. _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;
  36917. /** @hidden */
  36918. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  36919. /** @hidden */
  36920. _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;
  36921. /** @hidden */
  36922. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  36923. /** @hidden */
  36924. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  36925. /** @hidden */
  36926. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  36927. }
  36928. }
  36929. declare module BABYLON {
  36930. /**
  36931. * Set of assets to keep when moving a scene into an asset container.
  36932. */
  36933. export class KeepAssets extends AbstractScene {
  36934. }
  36935. /**
  36936. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  36937. */
  36938. export class InstantiatedEntries {
  36939. /**
  36940. * List of new root nodes (eg. nodes with no parent)
  36941. */
  36942. rootNodes: TransformNode[];
  36943. /**
  36944. * List of new skeletons
  36945. */
  36946. skeletons: Skeleton[];
  36947. /**
  36948. * List of new animation groups
  36949. */
  36950. animationGroups: AnimationGroup[];
  36951. }
  36952. /**
  36953. * Container with a set of assets that can be added or removed from a scene.
  36954. */
  36955. export class AssetContainer extends AbstractScene {
  36956. /**
  36957. * The scene the AssetContainer belongs to.
  36958. */
  36959. scene: Scene;
  36960. /**
  36961. * Instantiates an AssetContainer.
  36962. * @param scene The scene the AssetContainer belongs to.
  36963. */
  36964. constructor(scene: Scene);
  36965. /**
  36966. * Instantiate or clone all meshes and add the new ones to the scene.
  36967. * Skeletons and animation groups will all be cloned
  36968. * @param nameFunction defines an optional function used to get new names for clones
  36969. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  36970. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  36971. */
  36972. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  36973. /**
  36974. * Adds all the assets from the container to the scene.
  36975. */
  36976. addAllToScene(): void;
  36977. /**
  36978. * Removes all the assets in the container from the scene
  36979. */
  36980. removeAllFromScene(): void;
  36981. /**
  36982. * Disposes all the assets in the container
  36983. */
  36984. dispose(): void;
  36985. private _moveAssets;
  36986. /**
  36987. * Removes all the assets contained in the scene and adds them to the container.
  36988. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  36989. */
  36990. moveAllFromScene(keepAssets?: KeepAssets): void;
  36991. /**
  36992. * 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.
  36993. * @returns the root mesh
  36994. */
  36995. createRootMesh(): Mesh;
  36996. /**
  36997. * Merge animations from this asset container into a scene
  36998. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  36999. * @param animatables set of animatables to retarget to a node from the scene
  37000. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  37001. */
  37002. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): void;
  37003. }
  37004. }
  37005. declare module BABYLON {
  37006. /**
  37007. * Defines how the parser contract is defined.
  37008. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  37009. */
  37010. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  37011. /**
  37012. * Defines how the individual parser contract is defined.
  37013. * These parser can parse an individual asset
  37014. */
  37015. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  37016. /**
  37017. * Base class of the scene acting as a container for the different elements composing a scene.
  37018. * This class is dynamically extended by the different components of the scene increasing
  37019. * flexibility and reducing coupling
  37020. */
  37021. export abstract class AbstractScene {
  37022. /**
  37023. * Stores the list of available parsers in the application.
  37024. */
  37025. private static _BabylonFileParsers;
  37026. /**
  37027. * Stores the list of available individual parsers in the application.
  37028. */
  37029. private static _IndividualBabylonFileParsers;
  37030. /**
  37031. * Adds a 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 AddParser(name: string, parser: BabylonFileParser): void;
  37036. /**
  37037. * Gets a general 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 GetParser(name: string): Nullable<BabylonFileParser>;
  37042. /**
  37043. * Adds n individual parser in the list of available ones
  37044. * @param name Defines the name of the parser
  37045. * @param parser Defines the parser to add
  37046. */
  37047. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  37048. /**
  37049. * Gets an individual parser from the list of avaialble ones
  37050. * @param name Defines the name of the parser
  37051. * @returns the requested parser or null
  37052. */
  37053. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  37054. /**
  37055. * Parser json data and populate both a scene and its associated container object
  37056. * @param jsonData Defines the data to parse
  37057. * @param scene Defines the scene to parse the data for
  37058. * @param container Defines the container attached to the parsing sequence
  37059. * @param rootUrl Defines the root url of the data
  37060. */
  37061. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  37062. /**
  37063. * Gets the list of root nodes (ie. nodes with no parent)
  37064. */
  37065. rootNodes: Node[];
  37066. /** All of the cameras added to this scene
  37067. * @see http://doc.babylonjs.com/babylon101/cameras
  37068. */
  37069. cameras: Camera[];
  37070. /**
  37071. * All of the lights added to this scene
  37072. * @see http://doc.babylonjs.com/babylon101/lights
  37073. */
  37074. lights: Light[];
  37075. /**
  37076. * All of the (abstract) meshes added to this scene
  37077. */
  37078. meshes: AbstractMesh[];
  37079. /**
  37080. * The list of skeletons added to the scene
  37081. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  37082. */
  37083. skeletons: Skeleton[];
  37084. /**
  37085. * All of the particle systems added to this scene
  37086. * @see http://doc.babylonjs.com/babylon101/particles
  37087. */
  37088. particleSystems: IParticleSystem[];
  37089. /**
  37090. * Gets a list of Animations associated with the scene
  37091. */
  37092. animations: Animation[];
  37093. /**
  37094. * All of the animation groups added to this scene
  37095. * @see http://doc.babylonjs.com/how_to/group
  37096. */
  37097. animationGroups: AnimationGroup[];
  37098. /**
  37099. * All of the multi-materials added to this scene
  37100. * @see http://doc.babylonjs.com/how_to/multi_materials
  37101. */
  37102. multiMaterials: MultiMaterial[];
  37103. /**
  37104. * All of the materials added to this scene
  37105. * In the context of a Scene, it is not supposed to be modified manually.
  37106. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  37107. * Note also that the order of the Material within the array is not significant and might change.
  37108. * @see http://doc.babylonjs.com/babylon101/materials
  37109. */
  37110. materials: Material[];
  37111. /**
  37112. * The list of morph target managers added to the scene
  37113. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  37114. */
  37115. morphTargetManagers: MorphTargetManager[];
  37116. /**
  37117. * The list of geometries used in the scene.
  37118. */
  37119. geometries: Geometry[];
  37120. /**
  37121. * All of the tranform nodes added to this scene
  37122. * In the context of a Scene, it is not supposed to be modified manually.
  37123. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  37124. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  37125. * @see http://doc.babylonjs.com/how_to/transformnode
  37126. */
  37127. transformNodes: TransformNode[];
  37128. /**
  37129. * ActionManagers available on the scene.
  37130. */
  37131. actionManagers: AbstractActionManager[];
  37132. /**
  37133. * Textures to keep.
  37134. */
  37135. textures: BaseTexture[];
  37136. /**
  37137. * Environment texture for the scene
  37138. */
  37139. environmentTexture: Nullable<BaseTexture>;
  37140. /**
  37141. * @returns all meshes, lights, cameras, transformNodes and bones
  37142. */
  37143. getNodes(): Array<Node>;
  37144. }
  37145. }
  37146. declare module BABYLON {
  37147. /**
  37148. * Interface used to define options for Sound class
  37149. */
  37150. export interface ISoundOptions {
  37151. /**
  37152. * Does the sound autoplay once loaded.
  37153. */
  37154. autoplay?: boolean;
  37155. /**
  37156. * Does the sound loop after it finishes playing once.
  37157. */
  37158. loop?: boolean;
  37159. /**
  37160. * Sound's volume
  37161. */
  37162. volume?: number;
  37163. /**
  37164. * Is it a spatial sound?
  37165. */
  37166. spatialSound?: boolean;
  37167. /**
  37168. * Maximum distance to hear that sound
  37169. */
  37170. maxDistance?: number;
  37171. /**
  37172. * Uses user defined attenuation function
  37173. */
  37174. useCustomAttenuation?: boolean;
  37175. /**
  37176. * Define the roll off factor of spatial sounds.
  37177. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37178. */
  37179. rolloffFactor?: number;
  37180. /**
  37181. * Define the reference distance the sound should be heard perfectly.
  37182. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37183. */
  37184. refDistance?: number;
  37185. /**
  37186. * Define the distance attenuation model the sound will follow.
  37187. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37188. */
  37189. distanceModel?: string;
  37190. /**
  37191. * Defines the playback speed (1 by default)
  37192. */
  37193. playbackRate?: number;
  37194. /**
  37195. * Defines if the sound is from a streaming source
  37196. */
  37197. streaming?: boolean;
  37198. /**
  37199. * Defines an optional length (in seconds) inside the sound file
  37200. */
  37201. length?: number;
  37202. /**
  37203. * Defines an optional offset (in seconds) inside the sound file
  37204. */
  37205. offset?: number;
  37206. /**
  37207. * If true, URLs will not be required to state the audio file codec to use.
  37208. */
  37209. skipCodecCheck?: boolean;
  37210. }
  37211. /**
  37212. * Defines a sound that can be played in the application.
  37213. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  37214. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37215. */
  37216. export class Sound {
  37217. /**
  37218. * The name of the sound in the scene.
  37219. */
  37220. name: string;
  37221. /**
  37222. * Does the sound autoplay once loaded.
  37223. */
  37224. autoplay: boolean;
  37225. /**
  37226. * Does the sound loop after it finishes playing once.
  37227. */
  37228. loop: boolean;
  37229. /**
  37230. * Does the sound use a custom attenuation curve to simulate the falloff
  37231. * happening when the source gets further away from the camera.
  37232. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  37233. */
  37234. useCustomAttenuation: boolean;
  37235. /**
  37236. * The sound track id this sound belongs to.
  37237. */
  37238. soundTrackId: number;
  37239. /**
  37240. * Is this sound currently played.
  37241. */
  37242. isPlaying: boolean;
  37243. /**
  37244. * Is this sound currently paused.
  37245. */
  37246. isPaused: boolean;
  37247. /**
  37248. * Does this sound enables spatial sound.
  37249. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37250. */
  37251. spatialSound: boolean;
  37252. /**
  37253. * Define the reference distance the sound should be heard perfectly.
  37254. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37255. */
  37256. refDistance: number;
  37257. /**
  37258. * Define the roll off factor of spatial sounds.
  37259. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37260. */
  37261. rolloffFactor: number;
  37262. /**
  37263. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  37264. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37265. */
  37266. maxDistance: number;
  37267. /**
  37268. * Define the distance attenuation model the sound will follow.
  37269. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37270. */
  37271. distanceModel: string;
  37272. /**
  37273. * @hidden
  37274. * Back Compat
  37275. **/
  37276. onended: () => any;
  37277. /**
  37278. * Observable event when the current playing sound finishes.
  37279. */
  37280. onEndedObservable: Observable<Sound>;
  37281. private _panningModel;
  37282. private _playbackRate;
  37283. private _streaming;
  37284. private _startTime;
  37285. private _startOffset;
  37286. private _position;
  37287. /** @hidden */
  37288. _positionInEmitterSpace: boolean;
  37289. private _localDirection;
  37290. private _volume;
  37291. private _isReadyToPlay;
  37292. private _isDirectional;
  37293. private _readyToPlayCallback;
  37294. private _audioBuffer;
  37295. private _soundSource;
  37296. private _streamingSource;
  37297. private _soundPanner;
  37298. private _soundGain;
  37299. private _inputAudioNode;
  37300. private _outputAudioNode;
  37301. private _coneInnerAngle;
  37302. private _coneOuterAngle;
  37303. private _coneOuterGain;
  37304. private _scene;
  37305. private _connectedTransformNode;
  37306. private _customAttenuationFunction;
  37307. private _registerFunc;
  37308. private _isOutputConnected;
  37309. private _htmlAudioElement;
  37310. private _urlType;
  37311. private _length?;
  37312. private _offset?;
  37313. /** @hidden */
  37314. static _SceneComponentInitialization: (scene: Scene) => void;
  37315. /**
  37316. * Create a sound and attach it to a scene
  37317. * @param name Name of your sound
  37318. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  37319. * @param scene defines the scene the sound belongs to
  37320. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  37321. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  37322. */
  37323. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  37324. /**
  37325. * Release the sound and its associated resources
  37326. */
  37327. dispose(): void;
  37328. /**
  37329. * Gets if the sounds is ready to be played or not.
  37330. * @returns true if ready, otherwise false
  37331. */
  37332. isReady(): boolean;
  37333. private _soundLoaded;
  37334. /**
  37335. * Sets the data of the sound from an audiobuffer
  37336. * @param audioBuffer The audioBuffer containing the data
  37337. */
  37338. setAudioBuffer(audioBuffer: AudioBuffer): void;
  37339. /**
  37340. * Updates the current sounds options such as maxdistance, loop...
  37341. * @param options A JSON object containing values named as the object properties
  37342. */
  37343. updateOptions(options: ISoundOptions): void;
  37344. private _createSpatialParameters;
  37345. private _updateSpatialParameters;
  37346. /**
  37347. * Switch the panning model to HRTF:
  37348. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  37349. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37350. */
  37351. switchPanningModelToHRTF(): void;
  37352. /**
  37353. * Switch the panning model to Equal Power:
  37354. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  37355. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37356. */
  37357. switchPanningModelToEqualPower(): void;
  37358. private _switchPanningModel;
  37359. /**
  37360. * Connect this sound to a sound track audio node like gain...
  37361. * @param soundTrackAudioNode the sound track audio node to connect to
  37362. */
  37363. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  37364. /**
  37365. * Transform this sound into a directional source
  37366. * @param coneInnerAngle Size of the inner cone in degree
  37367. * @param coneOuterAngle Size of the outer cone in degree
  37368. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  37369. */
  37370. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  37371. /**
  37372. * Gets or sets the inner angle for the directional cone.
  37373. */
  37374. get directionalConeInnerAngle(): number;
  37375. /**
  37376. * Gets or sets the inner angle for the directional cone.
  37377. */
  37378. set directionalConeInnerAngle(value: number);
  37379. /**
  37380. * Gets or sets the outer angle for the directional cone.
  37381. */
  37382. get directionalConeOuterAngle(): number;
  37383. /**
  37384. * Gets or sets the outer angle for the directional cone.
  37385. */
  37386. set directionalConeOuterAngle(value: number);
  37387. /**
  37388. * Sets the position of the emitter if spatial sound is enabled
  37389. * @param newPosition Defines the new posisiton
  37390. */
  37391. setPosition(newPosition: Vector3): void;
  37392. /**
  37393. * Sets the local direction of the emitter if spatial sound is enabled
  37394. * @param newLocalDirection Defines the new local direction
  37395. */
  37396. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  37397. private _updateDirection;
  37398. /** @hidden */
  37399. updateDistanceFromListener(): void;
  37400. /**
  37401. * Sets a new custom attenuation function for the sound.
  37402. * @param callback Defines the function used for the attenuation
  37403. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  37404. */
  37405. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  37406. /**
  37407. * Play the sound
  37408. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  37409. * @param offset (optional) Start the sound at a specific time in seconds
  37410. * @param length (optional) Sound duration (in seconds)
  37411. */
  37412. play(time?: number, offset?: number, length?: number): void;
  37413. private _onended;
  37414. /**
  37415. * Stop the sound
  37416. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  37417. */
  37418. stop(time?: number): void;
  37419. /**
  37420. * Put the sound in pause
  37421. */
  37422. pause(): void;
  37423. /**
  37424. * Sets a dedicated volume for this sounds
  37425. * @param newVolume Define the new volume of the sound
  37426. * @param time Define time for gradual change to new volume
  37427. */
  37428. setVolume(newVolume: number, time?: number): void;
  37429. /**
  37430. * Set the sound play back rate
  37431. * @param newPlaybackRate Define the playback rate the sound should be played at
  37432. */
  37433. setPlaybackRate(newPlaybackRate: number): void;
  37434. /**
  37435. * Gets the volume of the sound.
  37436. * @returns the volume of the sound
  37437. */
  37438. getVolume(): number;
  37439. /**
  37440. * Attach the sound to a dedicated mesh
  37441. * @param transformNode The transform node to connect the sound with
  37442. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  37443. */
  37444. attachToMesh(transformNode: TransformNode): void;
  37445. /**
  37446. * Detach the sound from the previously attached mesh
  37447. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  37448. */
  37449. detachFromMesh(): void;
  37450. private _onRegisterAfterWorldMatrixUpdate;
  37451. /**
  37452. * Clone the current sound in the scene.
  37453. * @returns the new sound clone
  37454. */
  37455. clone(): Nullable<Sound>;
  37456. /**
  37457. * Gets the current underlying audio buffer containing the data
  37458. * @returns the audio buffer
  37459. */
  37460. getAudioBuffer(): Nullable<AudioBuffer>;
  37461. /**
  37462. * Serializes the Sound in a JSON representation
  37463. * @returns the JSON representation of the sound
  37464. */
  37465. serialize(): any;
  37466. /**
  37467. * Parse a JSON representation of a sound to innstantiate in a given scene
  37468. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  37469. * @param scene Define the scene the new parsed sound should be created in
  37470. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  37471. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  37472. * @returns the newly parsed sound
  37473. */
  37474. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  37475. }
  37476. }
  37477. declare module BABYLON {
  37478. /**
  37479. * This defines an action helpful to play a defined sound on a triggered action.
  37480. */
  37481. export class PlaySoundAction extends Action {
  37482. private _sound;
  37483. /**
  37484. * Instantiate the action
  37485. * @param triggerOptions defines the trigger options
  37486. * @param sound defines the sound to play
  37487. * @param condition defines the trigger related conditions
  37488. */
  37489. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  37490. /** @hidden */
  37491. _prepare(): void;
  37492. /**
  37493. * Execute the action and play the sound.
  37494. */
  37495. execute(): void;
  37496. /**
  37497. * Serializes the actions and its related information.
  37498. * @param parent defines the object to serialize in
  37499. * @returns the serialized object
  37500. */
  37501. serialize(parent: any): any;
  37502. }
  37503. /**
  37504. * This defines an action helpful to stop a defined sound on a triggered action.
  37505. */
  37506. export class StopSoundAction extends Action {
  37507. private _sound;
  37508. /**
  37509. * Instantiate the action
  37510. * @param triggerOptions defines the trigger options
  37511. * @param sound defines the sound to stop
  37512. * @param condition defines the trigger related conditions
  37513. */
  37514. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  37515. /** @hidden */
  37516. _prepare(): void;
  37517. /**
  37518. * Execute the action and stop the sound.
  37519. */
  37520. execute(): void;
  37521. /**
  37522. * Serializes the actions and its related information.
  37523. * @param parent defines the object to serialize in
  37524. * @returns the serialized object
  37525. */
  37526. serialize(parent: any): any;
  37527. }
  37528. }
  37529. declare module BABYLON {
  37530. /**
  37531. * This defines an action responsible to change the value of a property
  37532. * by interpolating between its current value and the newly set one once triggered.
  37533. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  37534. */
  37535. export class InterpolateValueAction extends Action {
  37536. /**
  37537. * Defines the path of the property where the value should be interpolated
  37538. */
  37539. propertyPath: string;
  37540. /**
  37541. * Defines the target value at the end of the interpolation.
  37542. */
  37543. value: any;
  37544. /**
  37545. * Defines the time it will take for the property to interpolate to the value.
  37546. */
  37547. duration: number;
  37548. /**
  37549. * Defines if the other scene animations should be stopped when the action has been triggered
  37550. */
  37551. stopOtherAnimations?: boolean;
  37552. /**
  37553. * Defines a callback raised once the interpolation animation has been done.
  37554. */
  37555. onInterpolationDone?: () => void;
  37556. /**
  37557. * Observable triggered once the interpolation animation has been done.
  37558. */
  37559. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  37560. private _target;
  37561. private _effectiveTarget;
  37562. private _property;
  37563. /**
  37564. * Instantiate the action
  37565. * @param triggerOptions defines the trigger options
  37566. * @param target defines the object containing the value to interpolate
  37567. * @param propertyPath defines the path to the property in the target object
  37568. * @param value defines the target value at the end of the interpolation
  37569. * @param duration deines the time it will take for the property to interpolate to the value.
  37570. * @param condition defines the trigger related conditions
  37571. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  37572. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  37573. */
  37574. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  37575. /** @hidden */
  37576. _prepare(): void;
  37577. /**
  37578. * Execute the action starts the value interpolation.
  37579. */
  37580. execute(): void;
  37581. /**
  37582. * Serializes the actions and its related information.
  37583. * @param parent defines the object to serialize in
  37584. * @returns the serialized object
  37585. */
  37586. serialize(parent: any): any;
  37587. }
  37588. }
  37589. declare module BABYLON {
  37590. /**
  37591. * Options allowed during the creation of a sound track.
  37592. */
  37593. export interface ISoundTrackOptions {
  37594. /**
  37595. * The volume the sound track should take during creation
  37596. */
  37597. volume?: number;
  37598. /**
  37599. * Define if the sound track is the main sound track of the scene
  37600. */
  37601. mainTrack?: boolean;
  37602. }
  37603. /**
  37604. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  37605. * It will be also used in a future release to apply effects on a specific track.
  37606. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  37607. */
  37608. export class SoundTrack {
  37609. /**
  37610. * The unique identifier of the sound track in the scene.
  37611. */
  37612. id: number;
  37613. /**
  37614. * The list of sounds included in the sound track.
  37615. */
  37616. soundCollection: Array<Sound>;
  37617. private _outputAudioNode;
  37618. private _scene;
  37619. private _connectedAnalyser;
  37620. private _options;
  37621. private _isInitialized;
  37622. /**
  37623. * Creates a new sound track.
  37624. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  37625. * @param scene Define the scene the sound track belongs to
  37626. * @param options
  37627. */
  37628. constructor(scene: Scene, options?: ISoundTrackOptions);
  37629. private _initializeSoundTrackAudioGraph;
  37630. /**
  37631. * Release the sound track and its associated resources
  37632. */
  37633. dispose(): void;
  37634. /**
  37635. * Adds a sound to this sound track
  37636. * @param sound define the cound to add
  37637. * @ignoreNaming
  37638. */
  37639. AddSound(sound: Sound): void;
  37640. /**
  37641. * Removes a sound to this sound track
  37642. * @param sound define the cound to remove
  37643. * @ignoreNaming
  37644. */
  37645. RemoveSound(sound: Sound): void;
  37646. /**
  37647. * Set a global volume for the full sound track.
  37648. * @param newVolume Define the new volume of the sound track
  37649. */
  37650. setVolume(newVolume: number): void;
  37651. /**
  37652. * Switch the panning model to HRTF:
  37653. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  37654. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37655. */
  37656. switchPanningModelToHRTF(): void;
  37657. /**
  37658. * Switch the panning model to Equal Power:
  37659. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  37660. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37661. */
  37662. switchPanningModelToEqualPower(): void;
  37663. /**
  37664. * Connect the sound track to an audio analyser allowing some amazing
  37665. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  37666. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  37667. * @param analyser The analyser to connect to the engine
  37668. */
  37669. connectToAnalyser(analyser: Analyser): void;
  37670. }
  37671. }
  37672. declare module BABYLON {
  37673. interface AbstractScene {
  37674. /**
  37675. * The list of sounds used in the scene.
  37676. */
  37677. sounds: Nullable<Array<Sound>>;
  37678. }
  37679. interface Scene {
  37680. /**
  37681. * @hidden
  37682. * Backing field
  37683. */
  37684. _mainSoundTrack: SoundTrack;
  37685. /**
  37686. * The main sound track played by the scene.
  37687. * It cotains your primary collection of sounds.
  37688. */
  37689. mainSoundTrack: SoundTrack;
  37690. /**
  37691. * The list of sound tracks added to the scene
  37692. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37693. */
  37694. soundTracks: Nullable<Array<SoundTrack>>;
  37695. /**
  37696. * Gets a sound using a given name
  37697. * @param name defines the name to search for
  37698. * @return the found sound or null if not found at all.
  37699. */
  37700. getSoundByName(name: string): Nullable<Sound>;
  37701. /**
  37702. * Gets or sets if audio support is enabled
  37703. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37704. */
  37705. audioEnabled: boolean;
  37706. /**
  37707. * Gets or sets if audio will be output to headphones
  37708. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37709. */
  37710. headphone: boolean;
  37711. /**
  37712. * Gets or sets custom audio listener position provider
  37713. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37714. */
  37715. audioListenerPositionProvider: Nullable<() => Vector3>;
  37716. /**
  37717. * Gets or sets a refresh rate when using 3D audio positioning
  37718. */
  37719. audioPositioningRefreshRate: number;
  37720. }
  37721. /**
  37722. * Defines the sound scene component responsible to manage any sounds
  37723. * in a given scene.
  37724. */
  37725. export class AudioSceneComponent implements ISceneSerializableComponent {
  37726. /**
  37727. * The component name helpfull to identify the component in the list of scene components.
  37728. */
  37729. readonly name: string;
  37730. /**
  37731. * The scene the component belongs to.
  37732. */
  37733. scene: Scene;
  37734. private _audioEnabled;
  37735. /**
  37736. * Gets whether audio is enabled or not.
  37737. * Please use related enable/disable method to switch state.
  37738. */
  37739. get audioEnabled(): boolean;
  37740. private _headphone;
  37741. /**
  37742. * Gets whether audio is outputing to headphone or not.
  37743. * Please use the according Switch methods to change output.
  37744. */
  37745. get headphone(): boolean;
  37746. /**
  37747. * Gets or sets a refresh rate when using 3D audio positioning
  37748. */
  37749. audioPositioningRefreshRate: number;
  37750. private _audioListenerPositionProvider;
  37751. /**
  37752. * Gets the current audio listener position provider
  37753. */
  37754. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  37755. /**
  37756. * Sets a custom listener position for all sounds in the scene
  37757. * By default, this is the position of the first active camera
  37758. */
  37759. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  37760. /**
  37761. * Creates a new instance of the component for the given scene
  37762. * @param scene Defines the scene to register the component in
  37763. */
  37764. constructor(scene: Scene);
  37765. /**
  37766. * Registers the component in a given scene
  37767. */
  37768. register(): void;
  37769. /**
  37770. * Rebuilds the elements related to this component in case of
  37771. * context lost for instance.
  37772. */
  37773. rebuild(): void;
  37774. /**
  37775. * Serializes the component data to the specified json object
  37776. * @param serializationObject The object to serialize to
  37777. */
  37778. serialize(serializationObject: any): void;
  37779. /**
  37780. * Adds all the elements from the container to the scene
  37781. * @param container the container holding the elements
  37782. */
  37783. addFromContainer(container: AbstractScene): void;
  37784. /**
  37785. * Removes all the elements in the container from the scene
  37786. * @param container contains the elements to remove
  37787. * @param dispose if the removed element should be disposed (default: false)
  37788. */
  37789. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  37790. /**
  37791. * Disposes the component and the associated ressources.
  37792. */
  37793. dispose(): void;
  37794. /**
  37795. * Disables audio in the associated scene.
  37796. */
  37797. disableAudio(): void;
  37798. /**
  37799. * Enables audio in the associated scene.
  37800. */
  37801. enableAudio(): void;
  37802. /**
  37803. * Switch audio to headphone output.
  37804. */
  37805. switchAudioModeForHeadphones(): void;
  37806. /**
  37807. * Switch audio to normal speakers.
  37808. */
  37809. switchAudioModeForNormalSpeakers(): void;
  37810. private _cachedCameraDirection;
  37811. private _cachedCameraPosition;
  37812. private _lastCheck;
  37813. private _afterRender;
  37814. }
  37815. }
  37816. declare module BABYLON {
  37817. /**
  37818. * Wraps one or more Sound objects and selects one with random weight for playback.
  37819. */
  37820. export class WeightedSound {
  37821. /** When true a Sound will be selected and played when the current playing Sound completes. */
  37822. loop: boolean;
  37823. private _coneInnerAngle;
  37824. private _coneOuterAngle;
  37825. private _volume;
  37826. /** A Sound is currently playing. */
  37827. isPlaying: boolean;
  37828. /** A Sound is currently paused. */
  37829. isPaused: boolean;
  37830. private _sounds;
  37831. private _weights;
  37832. private _currentIndex?;
  37833. /**
  37834. * Creates a new WeightedSound from the list of sounds given.
  37835. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  37836. * @param sounds Array of Sounds that will be selected from.
  37837. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  37838. */
  37839. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  37840. /**
  37841. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  37842. */
  37843. get directionalConeInnerAngle(): number;
  37844. /**
  37845. * The size of cone in degress for a directional sound in which there will be no attenuation.
  37846. */
  37847. set directionalConeInnerAngle(value: number);
  37848. /**
  37849. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  37850. * Listener angles between innerAngle and outerAngle will falloff linearly.
  37851. */
  37852. get directionalConeOuterAngle(): number;
  37853. /**
  37854. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  37855. * Listener angles between innerAngle and outerAngle will falloff linearly.
  37856. */
  37857. set directionalConeOuterAngle(value: number);
  37858. /**
  37859. * Playback volume.
  37860. */
  37861. get volume(): number;
  37862. /**
  37863. * Playback volume.
  37864. */
  37865. set volume(value: number);
  37866. private _onended;
  37867. /**
  37868. * Suspend playback
  37869. */
  37870. pause(): void;
  37871. /**
  37872. * Stop playback
  37873. */
  37874. stop(): void;
  37875. /**
  37876. * Start playback.
  37877. * @param startOffset Position the clip head at a specific time in seconds.
  37878. */
  37879. play(startOffset?: number): void;
  37880. }
  37881. }
  37882. declare module BABYLON {
  37883. /**
  37884. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  37885. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  37886. */
  37887. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  37888. /**
  37889. * Gets the name of the behavior.
  37890. */
  37891. get name(): string;
  37892. /**
  37893. * The easing function used by animations
  37894. */
  37895. static EasingFunction: BackEase;
  37896. /**
  37897. * The easing mode used by animations
  37898. */
  37899. static EasingMode: number;
  37900. /**
  37901. * The duration of the animation, in milliseconds
  37902. */
  37903. transitionDuration: number;
  37904. /**
  37905. * Length of the distance animated by the transition when lower radius is reached
  37906. */
  37907. lowerRadiusTransitionRange: number;
  37908. /**
  37909. * Length of the distance animated by the transition when upper radius is reached
  37910. */
  37911. upperRadiusTransitionRange: number;
  37912. private _autoTransitionRange;
  37913. /**
  37914. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  37915. */
  37916. get autoTransitionRange(): boolean;
  37917. /**
  37918. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  37919. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  37920. */
  37921. set autoTransitionRange(value: boolean);
  37922. private _attachedCamera;
  37923. private _onAfterCheckInputsObserver;
  37924. private _onMeshTargetChangedObserver;
  37925. /**
  37926. * Initializes the behavior.
  37927. */
  37928. init(): void;
  37929. /**
  37930. * Attaches the behavior to its arc rotate camera.
  37931. * @param camera Defines the camera to attach the behavior to
  37932. */
  37933. attach(camera: ArcRotateCamera): void;
  37934. /**
  37935. * Detaches the behavior from its current arc rotate camera.
  37936. */
  37937. detach(): void;
  37938. private _radiusIsAnimating;
  37939. private _radiusBounceTransition;
  37940. private _animatables;
  37941. private _cachedWheelPrecision;
  37942. /**
  37943. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  37944. * @param radiusLimit The limit to check against.
  37945. * @return Bool to indicate if at limit.
  37946. */
  37947. private _isRadiusAtLimit;
  37948. /**
  37949. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  37950. * @param radiusDelta The delta by which to animate to. Can be negative.
  37951. */
  37952. private _applyBoundRadiusAnimation;
  37953. /**
  37954. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  37955. */
  37956. protected _clearAnimationLocks(): void;
  37957. /**
  37958. * Stops and removes all animations that have been applied to the camera
  37959. */
  37960. stopAllAnimations(): void;
  37961. }
  37962. }
  37963. declare module BABYLON {
  37964. /**
  37965. * 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.
  37966. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  37967. */
  37968. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  37969. /**
  37970. * Gets the name of the behavior.
  37971. */
  37972. get name(): string;
  37973. private _mode;
  37974. private _radiusScale;
  37975. private _positionScale;
  37976. private _defaultElevation;
  37977. private _elevationReturnTime;
  37978. private _elevationReturnWaitTime;
  37979. private _zoomStopsAnimation;
  37980. private _framingTime;
  37981. /**
  37982. * The easing function used by animations
  37983. */
  37984. static EasingFunction: ExponentialEase;
  37985. /**
  37986. * The easing mode used by animations
  37987. */
  37988. static EasingMode: number;
  37989. /**
  37990. * Sets the current mode used by the behavior
  37991. */
  37992. set mode(mode: number);
  37993. /**
  37994. * Gets current mode used by the behavior.
  37995. */
  37996. get mode(): number;
  37997. /**
  37998. * Sets the scale applied to the radius (1 by default)
  37999. */
  38000. set radiusScale(radius: number);
  38001. /**
  38002. * Gets the scale applied to the radius
  38003. */
  38004. get radiusScale(): number;
  38005. /**
  38006. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  38007. */
  38008. set positionScale(scale: number);
  38009. /**
  38010. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  38011. */
  38012. get positionScale(): number;
  38013. /**
  38014. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  38015. * behaviour is triggered, in radians.
  38016. */
  38017. set defaultElevation(elevation: number);
  38018. /**
  38019. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  38020. * behaviour is triggered, in radians.
  38021. */
  38022. get defaultElevation(): number;
  38023. /**
  38024. * Sets the time (in milliseconds) taken to return to the default beta position.
  38025. * Negative value indicates camera should not return to default.
  38026. */
  38027. set elevationReturnTime(speed: number);
  38028. /**
  38029. * Gets the time (in milliseconds) taken to return to the default beta position.
  38030. * Negative value indicates camera should not return to default.
  38031. */
  38032. get elevationReturnTime(): number;
  38033. /**
  38034. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  38035. */
  38036. set elevationReturnWaitTime(time: number);
  38037. /**
  38038. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  38039. */
  38040. get elevationReturnWaitTime(): number;
  38041. /**
  38042. * Sets the flag that indicates if user zooming should stop animation.
  38043. */
  38044. set zoomStopsAnimation(flag: boolean);
  38045. /**
  38046. * Gets the flag that indicates if user zooming should stop animation.
  38047. */
  38048. get zoomStopsAnimation(): boolean;
  38049. /**
  38050. * Sets the transition time when framing the mesh, in milliseconds
  38051. */
  38052. set framingTime(time: number);
  38053. /**
  38054. * Gets the transition time when framing the mesh, in milliseconds
  38055. */
  38056. get framingTime(): number;
  38057. /**
  38058. * Define if the behavior should automatically change the configured
  38059. * camera limits and sensibilities.
  38060. */
  38061. autoCorrectCameraLimitsAndSensibility: boolean;
  38062. private _onPrePointerObservableObserver;
  38063. private _onAfterCheckInputsObserver;
  38064. private _onMeshTargetChangedObserver;
  38065. private _attachedCamera;
  38066. private _isPointerDown;
  38067. private _lastInteractionTime;
  38068. /**
  38069. * Initializes the behavior.
  38070. */
  38071. init(): void;
  38072. /**
  38073. * Attaches the behavior to its arc rotate camera.
  38074. * @param camera Defines the camera to attach the behavior to
  38075. */
  38076. attach(camera: ArcRotateCamera): void;
  38077. /**
  38078. * Detaches the behavior from its current arc rotate camera.
  38079. */
  38080. detach(): void;
  38081. private _animatables;
  38082. private _betaIsAnimating;
  38083. private _betaTransition;
  38084. private _radiusTransition;
  38085. private _vectorTransition;
  38086. /**
  38087. * Targets the given mesh and updates zoom level accordingly.
  38088. * @param mesh The mesh to target.
  38089. * @param radius Optional. If a cached radius position already exists, overrides default.
  38090. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  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. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38095. /**
  38096. * Targets the given mesh with its children and updates zoom level accordingly.
  38097. * @param mesh The mesh to target.
  38098. * @param radius Optional. If a cached radius position already exists, overrides default.
  38099. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  38100. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38101. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38102. */
  38103. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38104. /**
  38105. * Targets the given meshes with their children and updates zoom level accordingly.
  38106. * @param meshes The mesh to target.
  38107. * @param radius Optional. If a cached radius position already exists, overrides default.
  38108. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  38109. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38110. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38111. */
  38112. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38113. /**
  38114. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  38115. * @param minimumWorld Determines the smaller position of the bounding box extend
  38116. * @param maximumWorld Determines the bigger position of the bounding box extend
  38117. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38118. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38119. */
  38120. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38121. /**
  38122. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  38123. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  38124. * frustum width.
  38125. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  38126. * to fully enclose the mesh in the viewing frustum.
  38127. */
  38128. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  38129. /**
  38130. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  38131. * is automatically returned to its default position (expected to be above ground plane).
  38132. */
  38133. private _maintainCameraAboveGround;
  38134. /**
  38135. * Returns the frustum slope based on the canvas ratio and camera FOV
  38136. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  38137. */
  38138. private _getFrustumSlope;
  38139. /**
  38140. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  38141. */
  38142. private _clearAnimationLocks;
  38143. /**
  38144. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  38145. */
  38146. private _applyUserInteraction;
  38147. /**
  38148. * Stops and removes all animations that have been applied to the camera
  38149. */
  38150. stopAllAnimations(): void;
  38151. /**
  38152. * Gets a value indicating if the user is moving the camera
  38153. */
  38154. get isUserIsMoving(): boolean;
  38155. /**
  38156. * The camera can move all the way towards the mesh.
  38157. */
  38158. static IgnoreBoundsSizeMode: number;
  38159. /**
  38160. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  38161. */
  38162. static FitFrustumSidesMode: number;
  38163. }
  38164. }
  38165. declare module BABYLON {
  38166. /**
  38167. * Base class for Camera Pointer Inputs.
  38168. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  38169. * for example usage.
  38170. */
  38171. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  38172. /**
  38173. * Defines the camera the input is attached to.
  38174. */
  38175. abstract camera: Camera;
  38176. /**
  38177. * Whether keyboard modifier keys are pressed at time of last mouse event.
  38178. */
  38179. protected _altKey: boolean;
  38180. protected _ctrlKey: boolean;
  38181. protected _metaKey: boolean;
  38182. protected _shiftKey: boolean;
  38183. /**
  38184. * Which mouse buttons were pressed at time of last mouse event.
  38185. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  38186. */
  38187. protected _buttonsPressed: number;
  38188. /**
  38189. * Defines the buttons associated with the input to handle camera move.
  38190. */
  38191. buttons: number[];
  38192. /**
  38193. * Attach the input controls to a specific dom element to get the input from.
  38194. * @param element Defines the element the controls should be listened from
  38195. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38196. */
  38197. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38198. /**
  38199. * Detach the current controls from the specified dom element.
  38200. * @param element Defines the element to stop listening the inputs from
  38201. */
  38202. detachControl(element: Nullable<HTMLElement>): void;
  38203. /**
  38204. * Gets the class name of the current input.
  38205. * @returns the class name
  38206. */
  38207. getClassName(): string;
  38208. /**
  38209. * Get the friendly name associated with the input class.
  38210. * @returns the input friendly name
  38211. */
  38212. getSimpleName(): string;
  38213. /**
  38214. * Called on pointer POINTERDOUBLETAP event.
  38215. * Override this method to provide functionality on POINTERDOUBLETAP event.
  38216. */
  38217. protected onDoubleTap(type: string): void;
  38218. /**
  38219. * Called on pointer POINTERMOVE event if only a single touch is active.
  38220. * Override this method to provide functionality.
  38221. */
  38222. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  38223. /**
  38224. * Called on pointer POINTERMOVE event if multiple touches are active.
  38225. * Override this method to provide functionality.
  38226. */
  38227. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  38228. /**
  38229. * Called on JS contextmenu event.
  38230. * Override this method to provide functionality.
  38231. */
  38232. protected onContextMenu(evt: PointerEvent): void;
  38233. /**
  38234. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  38235. * press.
  38236. * Override this method to provide functionality.
  38237. */
  38238. protected onButtonDown(evt: PointerEvent): void;
  38239. /**
  38240. * Called each time a new POINTERUP event occurs. Ie, for each button
  38241. * release.
  38242. * Override this method to provide functionality.
  38243. */
  38244. protected onButtonUp(evt: PointerEvent): void;
  38245. /**
  38246. * Called when window becomes inactive.
  38247. * Override this method to provide functionality.
  38248. */
  38249. protected onLostFocus(): void;
  38250. private _pointerInput;
  38251. private _observer;
  38252. private _onLostFocus;
  38253. private pointA;
  38254. private pointB;
  38255. }
  38256. }
  38257. declare module BABYLON {
  38258. /**
  38259. * Manage the pointers inputs to control an arc rotate camera.
  38260. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38261. */
  38262. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  38263. /**
  38264. * Defines the camera the input is attached to.
  38265. */
  38266. camera: ArcRotateCamera;
  38267. /**
  38268. * Gets the class name of the current input.
  38269. * @returns the class name
  38270. */
  38271. getClassName(): string;
  38272. /**
  38273. * Defines the buttons associated with the input to handle camera move.
  38274. */
  38275. buttons: number[];
  38276. /**
  38277. * Defines the pointer angular sensibility along the X axis or how fast is
  38278. * the camera rotating.
  38279. */
  38280. angularSensibilityX: number;
  38281. /**
  38282. * Defines the pointer angular sensibility along the Y axis or how fast is
  38283. * the camera rotating.
  38284. */
  38285. angularSensibilityY: number;
  38286. /**
  38287. * Defines the pointer pinch precision or how fast is the camera zooming.
  38288. */
  38289. pinchPrecision: number;
  38290. /**
  38291. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  38292. * from 0.
  38293. * It defines the percentage of current camera.radius to use as delta when
  38294. * pinch zoom is used.
  38295. */
  38296. pinchDeltaPercentage: number;
  38297. /**
  38298. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  38299. * that any object in the plane at the camera's target point will scale
  38300. * perfectly with finger motion.
  38301. * Overrides pinchDeltaPercentage and pinchPrecision.
  38302. */
  38303. useNaturalPinchZoom: boolean;
  38304. /**
  38305. * Defines the pointer panning sensibility or how fast is the camera moving.
  38306. */
  38307. panningSensibility: number;
  38308. /**
  38309. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  38310. */
  38311. multiTouchPanning: boolean;
  38312. /**
  38313. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  38314. * zoom (pinch) through multitouch.
  38315. */
  38316. multiTouchPanAndZoom: boolean;
  38317. /**
  38318. * Revers pinch action direction.
  38319. */
  38320. pinchInwards: boolean;
  38321. private _isPanClick;
  38322. private _twoFingerActivityCount;
  38323. private _isPinching;
  38324. /**
  38325. * Called on pointer POINTERMOVE event if only a single touch is active.
  38326. */
  38327. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  38328. /**
  38329. * Called on pointer POINTERDOUBLETAP event.
  38330. */
  38331. protected onDoubleTap(type: string): void;
  38332. /**
  38333. * Called on pointer POINTERMOVE event if multiple touches are active.
  38334. */
  38335. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  38336. /**
  38337. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  38338. * press.
  38339. */
  38340. protected onButtonDown(evt: PointerEvent): void;
  38341. /**
  38342. * Called each time a new POINTERUP event occurs. Ie, for each button
  38343. * release.
  38344. */
  38345. protected onButtonUp(evt: PointerEvent): void;
  38346. /**
  38347. * Called when window becomes inactive.
  38348. */
  38349. protected onLostFocus(): void;
  38350. }
  38351. }
  38352. declare module BABYLON {
  38353. /**
  38354. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  38355. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38356. */
  38357. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  38358. /**
  38359. * Defines the camera the input is attached to.
  38360. */
  38361. camera: ArcRotateCamera;
  38362. /**
  38363. * Defines the list of key codes associated with the up action (increase alpha)
  38364. */
  38365. keysUp: number[];
  38366. /**
  38367. * Defines the list of key codes associated with the down action (decrease alpha)
  38368. */
  38369. keysDown: number[];
  38370. /**
  38371. * Defines the list of key codes associated with the left action (increase beta)
  38372. */
  38373. keysLeft: number[];
  38374. /**
  38375. * Defines the list of key codes associated with the right action (decrease beta)
  38376. */
  38377. keysRight: number[];
  38378. /**
  38379. * Defines the list of key codes associated with the reset action.
  38380. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  38381. */
  38382. keysReset: number[];
  38383. /**
  38384. * Defines the panning sensibility of the inputs.
  38385. * (How fast is the camera panning)
  38386. */
  38387. panningSensibility: number;
  38388. /**
  38389. * Defines the zooming sensibility of the inputs.
  38390. * (How fast is the camera zooming)
  38391. */
  38392. zoomingSensibility: number;
  38393. /**
  38394. * Defines whether maintaining the alt key down switch the movement mode from
  38395. * orientation to zoom.
  38396. */
  38397. useAltToZoom: boolean;
  38398. /**
  38399. * Rotation speed of the camera
  38400. */
  38401. angularSpeed: number;
  38402. private _keys;
  38403. private _ctrlPressed;
  38404. private _altPressed;
  38405. private _onCanvasBlurObserver;
  38406. private _onKeyboardObserver;
  38407. private _engine;
  38408. private _scene;
  38409. /**
  38410. * Attach the input controls to a specific dom element to get the input from.
  38411. * @param element Defines the element the controls should be listened from
  38412. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38413. */
  38414. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38415. /**
  38416. * Detach the current controls from the specified dom element.
  38417. * @param element Defines the element to stop listening the inputs from
  38418. */
  38419. detachControl(element: Nullable<HTMLElement>): void;
  38420. /**
  38421. * Update the current camera state depending on the inputs that have been used this frame.
  38422. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38423. */
  38424. checkInputs(): void;
  38425. /**
  38426. * Gets the class name of the current intput.
  38427. * @returns the class name
  38428. */
  38429. getClassName(): string;
  38430. /**
  38431. * Get the friendly name associated with the input class.
  38432. * @returns the input friendly name
  38433. */
  38434. getSimpleName(): string;
  38435. }
  38436. }
  38437. declare module BABYLON {
  38438. /**
  38439. * Manage the mouse wheel inputs to control an arc rotate camera.
  38440. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38441. */
  38442. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  38443. /**
  38444. * Defines the camera the input is attached to.
  38445. */
  38446. camera: ArcRotateCamera;
  38447. /**
  38448. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  38449. */
  38450. wheelPrecision: number;
  38451. /**
  38452. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  38453. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  38454. */
  38455. wheelDeltaPercentage: number;
  38456. private _wheel;
  38457. private _observer;
  38458. private computeDeltaFromMouseWheelLegacyEvent;
  38459. /**
  38460. * Attach the input controls to a specific dom element to get the input from.
  38461. * @param element Defines the element the controls should be listened from
  38462. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38463. */
  38464. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38465. /**
  38466. * Detach the current controls from the specified dom element.
  38467. * @param element Defines the element to stop listening the inputs from
  38468. */
  38469. detachControl(element: Nullable<HTMLElement>): void;
  38470. /**
  38471. * Gets the class name of the current intput.
  38472. * @returns the class name
  38473. */
  38474. getClassName(): string;
  38475. /**
  38476. * Get the friendly name associated with the input class.
  38477. * @returns the input friendly name
  38478. */
  38479. getSimpleName(): string;
  38480. }
  38481. }
  38482. declare module BABYLON {
  38483. /**
  38484. * Default Inputs manager for the ArcRotateCamera.
  38485. * It groups all the default supported inputs for ease of use.
  38486. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38487. */
  38488. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  38489. /**
  38490. * Instantiates a new ArcRotateCameraInputsManager.
  38491. * @param camera Defines the camera the inputs belong to
  38492. */
  38493. constructor(camera: ArcRotateCamera);
  38494. /**
  38495. * Add mouse wheel input support to the input manager.
  38496. * @returns the current input manager
  38497. */
  38498. addMouseWheel(): ArcRotateCameraInputsManager;
  38499. /**
  38500. * Add pointers input support to the input manager.
  38501. * @returns the current input manager
  38502. */
  38503. addPointers(): ArcRotateCameraInputsManager;
  38504. /**
  38505. * Add keyboard input support to the input manager.
  38506. * @returns the current input manager
  38507. */
  38508. addKeyboard(): ArcRotateCameraInputsManager;
  38509. }
  38510. }
  38511. declare module BABYLON {
  38512. /**
  38513. * This represents an orbital type of camera.
  38514. *
  38515. * 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.
  38516. * 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.
  38517. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  38518. */
  38519. export class ArcRotateCamera extends TargetCamera {
  38520. /**
  38521. * Defines the rotation angle of the camera along the longitudinal axis.
  38522. */
  38523. alpha: number;
  38524. /**
  38525. * Defines the rotation angle of the camera along the latitudinal axis.
  38526. */
  38527. beta: number;
  38528. /**
  38529. * Defines the radius of the camera from it s target point.
  38530. */
  38531. radius: number;
  38532. protected _target: Vector3;
  38533. protected _targetHost: Nullable<AbstractMesh>;
  38534. /**
  38535. * Defines the target point of the camera.
  38536. * The camera looks towards it form the radius distance.
  38537. */
  38538. get target(): Vector3;
  38539. set target(value: Vector3);
  38540. /**
  38541. * Define the current local position of the camera in the scene
  38542. */
  38543. get position(): Vector3;
  38544. set position(newPosition: Vector3);
  38545. protected _upVector: Vector3;
  38546. protected _upToYMatrix: Matrix;
  38547. protected _YToUpMatrix: Matrix;
  38548. /**
  38549. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  38550. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  38551. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  38552. */
  38553. set upVector(vec: Vector3);
  38554. get upVector(): Vector3;
  38555. /**
  38556. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  38557. */
  38558. setMatUp(): void;
  38559. /**
  38560. * Current inertia value on the longitudinal axis.
  38561. * The bigger this number the longer it will take for the camera to stop.
  38562. */
  38563. inertialAlphaOffset: number;
  38564. /**
  38565. * Current inertia value on the latitudinal axis.
  38566. * The bigger this number the longer it will take for the camera to stop.
  38567. */
  38568. inertialBetaOffset: number;
  38569. /**
  38570. * Current inertia value on the radius axis.
  38571. * The bigger this number the longer it will take for the camera to stop.
  38572. */
  38573. inertialRadiusOffset: number;
  38574. /**
  38575. * Minimum allowed angle on the longitudinal axis.
  38576. * This can help limiting how the Camera is able to move in the scene.
  38577. */
  38578. lowerAlphaLimit: Nullable<number>;
  38579. /**
  38580. * Maximum allowed angle on the longitudinal axis.
  38581. * This can help limiting how the Camera is able to move in the scene.
  38582. */
  38583. upperAlphaLimit: Nullable<number>;
  38584. /**
  38585. * Minimum allowed angle on the latitudinal axis.
  38586. * This can help limiting how the Camera is able to move in the scene.
  38587. */
  38588. lowerBetaLimit: number;
  38589. /**
  38590. * Maximum allowed angle on the latitudinal axis.
  38591. * This can help limiting how the Camera is able to move in the scene.
  38592. */
  38593. upperBetaLimit: number;
  38594. /**
  38595. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  38596. * This can help limiting how the Camera is able to move in the scene.
  38597. */
  38598. lowerRadiusLimit: Nullable<number>;
  38599. /**
  38600. * Maximum allowed distance of the camera to the target (The camera can not get further).
  38601. * This can help limiting how the Camera is able to move in the scene.
  38602. */
  38603. upperRadiusLimit: Nullable<number>;
  38604. /**
  38605. * Defines the current inertia value used during panning of the camera along the X axis.
  38606. */
  38607. inertialPanningX: number;
  38608. /**
  38609. * Defines the current inertia value used during panning of the camera along the Y axis.
  38610. */
  38611. inertialPanningY: number;
  38612. /**
  38613. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  38614. * Basically if your fingers moves away from more than this distance you will be considered
  38615. * in pinch mode.
  38616. */
  38617. pinchToPanMaxDistance: number;
  38618. /**
  38619. * Defines the maximum distance the camera can pan.
  38620. * This could help keeping the cammera always in your scene.
  38621. */
  38622. panningDistanceLimit: Nullable<number>;
  38623. /**
  38624. * Defines the target of the camera before paning.
  38625. */
  38626. panningOriginTarget: Vector3;
  38627. /**
  38628. * Defines the value of the inertia used during panning.
  38629. * 0 would mean stop inertia and one would mean no decelleration at all.
  38630. */
  38631. panningInertia: number;
  38632. /**
  38633. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  38634. */
  38635. get angularSensibilityX(): number;
  38636. set angularSensibilityX(value: number);
  38637. /**
  38638. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  38639. */
  38640. get angularSensibilityY(): number;
  38641. set angularSensibilityY(value: number);
  38642. /**
  38643. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  38644. */
  38645. get pinchPrecision(): number;
  38646. set pinchPrecision(value: number);
  38647. /**
  38648. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  38649. * It will be used instead of pinchDeltaPrecision if different from 0.
  38650. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  38651. */
  38652. get pinchDeltaPercentage(): number;
  38653. set pinchDeltaPercentage(value: number);
  38654. /**
  38655. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  38656. * and pinch delta percentage.
  38657. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  38658. * that any object in the plane at the camera's target point will scale
  38659. * perfectly with finger motion.
  38660. */
  38661. get useNaturalPinchZoom(): boolean;
  38662. set useNaturalPinchZoom(value: boolean);
  38663. /**
  38664. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  38665. */
  38666. get panningSensibility(): number;
  38667. set panningSensibility(value: number);
  38668. /**
  38669. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  38670. */
  38671. get keysUp(): number[];
  38672. set keysUp(value: number[]);
  38673. /**
  38674. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  38675. */
  38676. get keysDown(): number[];
  38677. set keysDown(value: number[]);
  38678. /**
  38679. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  38680. */
  38681. get keysLeft(): number[];
  38682. set keysLeft(value: number[]);
  38683. /**
  38684. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  38685. */
  38686. get keysRight(): number[];
  38687. set keysRight(value: number[]);
  38688. /**
  38689. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  38690. */
  38691. get wheelPrecision(): number;
  38692. set wheelPrecision(value: number);
  38693. /**
  38694. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  38695. * It will be used instead of pinchDeltaPrecision if different from 0.
  38696. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  38697. */
  38698. get wheelDeltaPercentage(): number;
  38699. set wheelDeltaPercentage(value: number);
  38700. /**
  38701. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  38702. */
  38703. zoomOnFactor: number;
  38704. /**
  38705. * Defines a screen offset for the camera position.
  38706. */
  38707. targetScreenOffset: Vector2;
  38708. /**
  38709. * Allows the camera to be completely reversed.
  38710. * If false the camera can not arrive upside down.
  38711. */
  38712. allowUpsideDown: boolean;
  38713. /**
  38714. * Define if double tap/click is used to restore the previously saved state of the camera.
  38715. */
  38716. useInputToRestoreState: boolean;
  38717. /** @hidden */
  38718. _viewMatrix: Matrix;
  38719. /** @hidden */
  38720. _useCtrlForPanning: boolean;
  38721. /** @hidden */
  38722. _panningMouseButton: number;
  38723. /**
  38724. * Defines the input associated to the camera.
  38725. */
  38726. inputs: ArcRotateCameraInputsManager;
  38727. /** @hidden */
  38728. _reset: () => void;
  38729. /**
  38730. * Defines the allowed panning axis.
  38731. */
  38732. panningAxis: Vector3;
  38733. protected _localDirection: Vector3;
  38734. protected _transformedDirection: Vector3;
  38735. private _bouncingBehavior;
  38736. /**
  38737. * Gets the bouncing behavior of the camera if it has been enabled.
  38738. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  38739. */
  38740. get bouncingBehavior(): Nullable<BouncingBehavior>;
  38741. /**
  38742. * Defines if the bouncing behavior of the camera is enabled on the camera.
  38743. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  38744. */
  38745. get useBouncingBehavior(): boolean;
  38746. set useBouncingBehavior(value: boolean);
  38747. private _framingBehavior;
  38748. /**
  38749. * Gets the framing behavior of the camera if it has been enabled.
  38750. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  38751. */
  38752. get framingBehavior(): Nullable<FramingBehavior>;
  38753. /**
  38754. * Defines if the framing behavior of the camera is enabled on the camera.
  38755. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  38756. */
  38757. get useFramingBehavior(): boolean;
  38758. set useFramingBehavior(value: boolean);
  38759. private _autoRotationBehavior;
  38760. /**
  38761. * Gets the auto rotation behavior of the camera if it has been enabled.
  38762. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  38763. */
  38764. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  38765. /**
  38766. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  38767. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  38768. */
  38769. get useAutoRotationBehavior(): boolean;
  38770. set useAutoRotationBehavior(value: boolean);
  38771. /**
  38772. * Observable triggered when the mesh target has been changed on the camera.
  38773. */
  38774. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  38775. /**
  38776. * Event raised when the camera is colliding with a mesh.
  38777. */
  38778. onCollide: (collidedMesh: AbstractMesh) => void;
  38779. /**
  38780. * Defines whether the camera should check collision with the objects oh the scene.
  38781. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  38782. */
  38783. checkCollisions: boolean;
  38784. /**
  38785. * Defines the collision radius of the camera.
  38786. * This simulates a sphere around the camera.
  38787. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  38788. */
  38789. collisionRadius: Vector3;
  38790. protected _collider: Collider;
  38791. protected _previousPosition: Vector3;
  38792. protected _collisionVelocity: Vector3;
  38793. protected _newPosition: Vector3;
  38794. protected _previousAlpha: number;
  38795. protected _previousBeta: number;
  38796. protected _previousRadius: number;
  38797. protected _collisionTriggered: boolean;
  38798. protected _targetBoundingCenter: Nullable<Vector3>;
  38799. private _computationVector;
  38800. /**
  38801. * Instantiates a new ArcRotateCamera in a given scene
  38802. * @param name Defines the name of the camera
  38803. * @param alpha Defines the camera rotation along the logitudinal axis
  38804. * @param beta Defines the camera rotation along the latitudinal axis
  38805. * @param radius Defines the camera distance from its target
  38806. * @param target Defines the camera target
  38807. * @param scene Defines the scene the camera belongs to
  38808. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  38809. */
  38810. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  38811. /** @hidden */
  38812. _initCache(): void;
  38813. /** @hidden */
  38814. _updateCache(ignoreParentClass?: boolean): void;
  38815. protected _getTargetPosition(): Vector3;
  38816. private _storedAlpha;
  38817. private _storedBeta;
  38818. private _storedRadius;
  38819. private _storedTarget;
  38820. private _storedTargetScreenOffset;
  38821. /**
  38822. * Stores the current state of the camera (alpha, beta, radius and target)
  38823. * @returns the camera itself
  38824. */
  38825. storeState(): Camera;
  38826. /**
  38827. * @hidden
  38828. * Restored camera state. You must call storeState() first
  38829. */
  38830. _restoreStateValues(): boolean;
  38831. /** @hidden */
  38832. _isSynchronizedViewMatrix(): boolean;
  38833. /**
  38834. * Attached controls to the current camera.
  38835. * @param element Defines the element the controls should be listened from
  38836. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38837. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  38838. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  38839. */
  38840. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  38841. /**
  38842. * Detach the current controls from the camera.
  38843. * The camera will stop reacting to inputs.
  38844. * @param element Defines the element to stop listening the inputs from
  38845. */
  38846. detachControl(element: HTMLElement): void;
  38847. /** @hidden */
  38848. _checkInputs(): void;
  38849. protected _checkLimits(): void;
  38850. /**
  38851. * Rebuilds angles (alpha, beta) and radius from the give position and target
  38852. */
  38853. rebuildAnglesAndRadius(): void;
  38854. /**
  38855. * Use a position to define the current camera related information like alpha, beta and radius
  38856. * @param position Defines the position to set the camera at
  38857. */
  38858. setPosition(position: Vector3): void;
  38859. /**
  38860. * Defines the target the camera should look at.
  38861. * This will automatically adapt alpha beta and radius to fit within the new target.
  38862. * @param target Defines the new target as a Vector or a mesh
  38863. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  38864. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  38865. */
  38866. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  38867. /** @hidden */
  38868. _getViewMatrix(): Matrix;
  38869. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  38870. /**
  38871. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  38872. * @param meshes Defines the mesh to zoom on
  38873. * @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)
  38874. */
  38875. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  38876. /**
  38877. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  38878. * The target will be changed but the radius
  38879. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  38880. * @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)
  38881. */
  38882. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  38883. min: Vector3;
  38884. max: Vector3;
  38885. distance: number;
  38886. }, doNotUpdateMaxZ?: boolean): void;
  38887. /**
  38888. * @override
  38889. * Override Camera.createRigCamera
  38890. */
  38891. createRigCamera(name: string, cameraIndex: number): Camera;
  38892. /**
  38893. * @hidden
  38894. * @override
  38895. * Override Camera._updateRigCameras
  38896. */
  38897. _updateRigCameras(): void;
  38898. /**
  38899. * Destroy the camera and release the current resources hold by it.
  38900. */
  38901. dispose(): void;
  38902. /**
  38903. * Gets the current object class name.
  38904. * @return the class name
  38905. */
  38906. getClassName(): string;
  38907. }
  38908. }
  38909. declare module BABYLON {
  38910. /**
  38911. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  38912. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  38913. */
  38914. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  38915. /**
  38916. * Gets the name of the behavior.
  38917. */
  38918. get name(): string;
  38919. private _zoomStopsAnimation;
  38920. private _idleRotationSpeed;
  38921. private _idleRotationWaitTime;
  38922. private _idleRotationSpinupTime;
  38923. /**
  38924. * Sets the flag that indicates if user zooming should stop animation.
  38925. */
  38926. set zoomStopsAnimation(flag: boolean);
  38927. /**
  38928. * Gets the flag that indicates if user zooming should stop animation.
  38929. */
  38930. get zoomStopsAnimation(): boolean;
  38931. /**
  38932. * Sets the default speed at which the camera rotates around the model.
  38933. */
  38934. set idleRotationSpeed(speed: number);
  38935. /**
  38936. * Gets the default speed at which the camera rotates around the model.
  38937. */
  38938. get idleRotationSpeed(): number;
  38939. /**
  38940. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  38941. */
  38942. set idleRotationWaitTime(time: number);
  38943. /**
  38944. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  38945. */
  38946. get idleRotationWaitTime(): number;
  38947. /**
  38948. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  38949. */
  38950. set idleRotationSpinupTime(time: number);
  38951. /**
  38952. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  38953. */
  38954. get idleRotationSpinupTime(): number;
  38955. /**
  38956. * Gets a value indicating if the camera is currently rotating because of this behavior
  38957. */
  38958. get rotationInProgress(): boolean;
  38959. private _onPrePointerObservableObserver;
  38960. private _onAfterCheckInputsObserver;
  38961. private _attachedCamera;
  38962. private _isPointerDown;
  38963. private _lastFrameTime;
  38964. private _lastInteractionTime;
  38965. private _cameraRotationSpeed;
  38966. /**
  38967. * Initializes the behavior.
  38968. */
  38969. init(): void;
  38970. /**
  38971. * Attaches the behavior to its arc rotate camera.
  38972. * @param camera Defines the camera to attach the behavior to
  38973. */
  38974. attach(camera: ArcRotateCamera): void;
  38975. /**
  38976. * Detaches the behavior from its current arc rotate camera.
  38977. */
  38978. detach(): void;
  38979. /**
  38980. * Returns true if user is scrolling.
  38981. * @return true if user is scrolling.
  38982. */
  38983. private _userIsZooming;
  38984. private _lastFrameRadius;
  38985. private _shouldAnimationStopForInteraction;
  38986. /**
  38987. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  38988. */
  38989. private _applyUserInteraction;
  38990. private _userIsMoving;
  38991. }
  38992. }
  38993. declare module BABYLON {
  38994. /**
  38995. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  38996. */
  38997. export class AttachToBoxBehavior implements Behavior<Mesh> {
  38998. private ui;
  38999. /**
  39000. * The name of the behavior
  39001. */
  39002. name: string;
  39003. /**
  39004. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  39005. */
  39006. distanceAwayFromFace: number;
  39007. /**
  39008. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  39009. */
  39010. distanceAwayFromBottomOfFace: number;
  39011. private _faceVectors;
  39012. private _target;
  39013. private _scene;
  39014. private _onRenderObserver;
  39015. private _tmpMatrix;
  39016. private _tmpVector;
  39017. /**
  39018. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  39019. * @param ui The transform node that should be attched to the mesh
  39020. */
  39021. constructor(ui: TransformNode);
  39022. /**
  39023. * Initializes the behavior
  39024. */
  39025. init(): void;
  39026. private _closestFace;
  39027. private _zeroVector;
  39028. private _lookAtTmpMatrix;
  39029. private _lookAtToRef;
  39030. /**
  39031. * Attaches the AttachToBoxBehavior to the passed in mesh
  39032. * @param target The mesh that the specified node will be attached to
  39033. */
  39034. attach(target: Mesh): void;
  39035. /**
  39036. * Detaches the behavior from the mesh
  39037. */
  39038. detach(): void;
  39039. }
  39040. }
  39041. declare module BABYLON {
  39042. /**
  39043. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  39044. */
  39045. export class FadeInOutBehavior implements Behavior<Mesh> {
  39046. /**
  39047. * Time in milliseconds to delay before fading in (Default: 0)
  39048. */
  39049. delay: number;
  39050. /**
  39051. * Time in milliseconds for the mesh to fade in (Default: 300)
  39052. */
  39053. fadeInTime: number;
  39054. private _millisecondsPerFrame;
  39055. private _hovered;
  39056. private _hoverValue;
  39057. private _ownerNode;
  39058. /**
  39059. * Instatiates the FadeInOutBehavior
  39060. */
  39061. constructor();
  39062. /**
  39063. * The name of the behavior
  39064. */
  39065. get name(): string;
  39066. /**
  39067. * Initializes the behavior
  39068. */
  39069. init(): void;
  39070. /**
  39071. * Attaches the fade behavior on the passed in mesh
  39072. * @param ownerNode The mesh that will be faded in/out once attached
  39073. */
  39074. attach(ownerNode: Mesh): void;
  39075. /**
  39076. * Detaches the behavior from the mesh
  39077. */
  39078. detach(): void;
  39079. /**
  39080. * Triggers the mesh to begin fading in or out
  39081. * @param value if the object should fade in or out (true to fade in)
  39082. */
  39083. fadeIn(value: boolean): void;
  39084. private _update;
  39085. private _setAllVisibility;
  39086. }
  39087. }
  39088. declare module BABYLON {
  39089. /**
  39090. * Class containing a set of static utilities functions for managing Pivots
  39091. * @hidden
  39092. */
  39093. export class PivotTools {
  39094. private static _PivotCached;
  39095. private static _OldPivotPoint;
  39096. private static _PivotTranslation;
  39097. private static _PivotTmpVector;
  39098. /** @hidden */
  39099. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  39100. /** @hidden */
  39101. static _RestorePivotPoint(mesh: AbstractMesh): void;
  39102. }
  39103. }
  39104. declare module BABYLON {
  39105. /**
  39106. * Class containing static functions to help procedurally build meshes
  39107. */
  39108. export class PlaneBuilder {
  39109. /**
  39110. * Creates a plane mesh
  39111. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  39112. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  39113. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  39114. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  39115. * * 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
  39116. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  39117. * @param name defines the name of the mesh
  39118. * @param options defines the options used to create the mesh
  39119. * @param scene defines the hosting scene
  39120. * @returns the plane mesh
  39121. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  39122. */
  39123. static CreatePlane(name: string, options: {
  39124. size?: number;
  39125. width?: number;
  39126. height?: number;
  39127. sideOrientation?: number;
  39128. frontUVs?: Vector4;
  39129. backUVs?: Vector4;
  39130. updatable?: boolean;
  39131. sourcePlane?: Plane;
  39132. }, scene?: Nullable<Scene>): Mesh;
  39133. }
  39134. }
  39135. declare module BABYLON {
  39136. /**
  39137. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  39138. */
  39139. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  39140. private static _AnyMouseID;
  39141. /**
  39142. * Abstract mesh the behavior is set on
  39143. */
  39144. attachedNode: AbstractMesh;
  39145. private _dragPlane;
  39146. private _scene;
  39147. private _pointerObserver;
  39148. private _beforeRenderObserver;
  39149. private static _planeScene;
  39150. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  39151. /**
  39152. * 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)
  39153. */
  39154. maxDragAngle: number;
  39155. /**
  39156. * @hidden
  39157. */
  39158. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  39159. /**
  39160. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  39161. */
  39162. currentDraggingPointerID: number;
  39163. /**
  39164. * The last position where the pointer hit the drag plane in world space
  39165. */
  39166. lastDragPosition: Vector3;
  39167. /**
  39168. * If the behavior is currently in a dragging state
  39169. */
  39170. dragging: boolean;
  39171. /**
  39172. * 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)
  39173. */
  39174. dragDeltaRatio: number;
  39175. /**
  39176. * If the drag plane orientation should be updated during the dragging (Default: true)
  39177. */
  39178. updateDragPlane: boolean;
  39179. private _debugMode;
  39180. private _moving;
  39181. /**
  39182. * Fires each time the attached mesh is dragged with the pointer
  39183. * * delta between last drag position and current drag position in world space
  39184. * * dragDistance along the drag axis
  39185. * * dragPlaneNormal normal of the current drag plane used during the drag
  39186. * * dragPlanePoint in world space where the drag intersects the drag plane
  39187. */
  39188. onDragObservable: Observable<{
  39189. delta: Vector3;
  39190. dragPlanePoint: Vector3;
  39191. dragPlaneNormal: Vector3;
  39192. dragDistance: number;
  39193. pointerId: number;
  39194. }>;
  39195. /**
  39196. * Fires each time a drag begins (eg. mouse down on mesh)
  39197. */
  39198. onDragStartObservable: Observable<{
  39199. dragPlanePoint: Vector3;
  39200. pointerId: number;
  39201. }>;
  39202. /**
  39203. * Fires each time a drag ends (eg. mouse release after drag)
  39204. */
  39205. onDragEndObservable: Observable<{
  39206. dragPlanePoint: Vector3;
  39207. pointerId: number;
  39208. }>;
  39209. /**
  39210. * If the attached mesh should be moved when dragged
  39211. */
  39212. moveAttached: boolean;
  39213. /**
  39214. * If the drag behavior will react to drag events (Default: true)
  39215. */
  39216. enabled: boolean;
  39217. /**
  39218. * If pointer events should start and release the drag (Default: true)
  39219. */
  39220. startAndReleaseDragOnPointerEvents: boolean;
  39221. /**
  39222. * If camera controls should be detached during the drag
  39223. */
  39224. detachCameraControls: boolean;
  39225. /**
  39226. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  39227. */
  39228. useObjectOrientationForDragging: boolean;
  39229. private _options;
  39230. /**
  39231. * Gets the options used by the behavior
  39232. */
  39233. get options(): {
  39234. dragAxis?: Vector3;
  39235. dragPlaneNormal?: Vector3;
  39236. };
  39237. /**
  39238. * Sets the options used by the behavior
  39239. */
  39240. set options(options: {
  39241. dragAxis?: Vector3;
  39242. dragPlaneNormal?: Vector3;
  39243. });
  39244. /**
  39245. * Creates a pointer drag behavior that can be attached to a mesh
  39246. * @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)
  39247. */
  39248. constructor(options?: {
  39249. dragAxis?: Vector3;
  39250. dragPlaneNormal?: Vector3;
  39251. });
  39252. /**
  39253. * Predicate to determine if it is valid to move the object to a new position when it is moved
  39254. */
  39255. validateDrag: (targetPosition: Vector3) => boolean;
  39256. /**
  39257. * The name of the behavior
  39258. */
  39259. get name(): string;
  39260. /**
  39261. * Initializes the behavior
  39262. */
  39263. init(): void;
  39264. private _tmpVector;
  39265. private _alternatePickedPoint;
  39266. private _worldDragAxis;
  39267. private _targetPosition;
  39268. private _attachedElement;
  39269. /**
  39270. * Attaches the drag behavior the passed in mesh
  39271. * @param ownerNode The mesh that will be dragged around once attached
  39272. * @param predicate Predicate to use for pick filtering
  39273. */
  39274. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  39275. /**
  39276. * Force relase the drag action by code.
  39277. */
  39278. releaseDrag(): void;
  39279. private _startDragRay;
  39280. private _lastPointerRay;
  39281. /**
  39282. * Simulates the start of a pointer drag event on the behavior
  39283. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  39284. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  39285. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  39286. */
  39287. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  39288. private _startDrag;
  39289. private _dragDelta;
  39290. private _moveDrag;
  39291. private _pickWithRayOnDragPlane;
  39292. private _pointA;
  39293. private _pointB;
  39294. private _pointC;
  39295. private _lineA;
  39296. private _lineB;
  39297. private _localAxis;
  39298. private _lookAt;
  39299. private _updateDragPlanePosition;
  39300. /**
  39301. * Detaches the behavior from the mesh
  39302. */
  39303. detach(): void;
  39304. }
  39305. }
  39306. declare module BABYLON {
  39307. /**
  39308. * A behavior that when attached to a mesh will allow the mesh to be scaled
  39309. */
  39310. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  39311. private _dragBehaviorA;
  39312. private _dragBehaviorB;
  39313. private _startDistance;
  39314. private _initialScale;
  39315. private _targetScale;
  39316. private _ownerNode;
  39317. private _sceneRenderObserver;
  39318. /**
  39319. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  39320. */
  39321. constructor();
  39322. /**
  39323. * The name of the behavior
  39324. */
  39325. get name(): string;
  39326. /**
  39327. * Initializes the behavior
  39328. */
  39329. init(): void;
  39330. private _getCurrentDistance;
  39331. /**
  39332. * Attaches the scale behavior the passed in mesh
  39333. * @param ownerNode The mesh that will be scaled around once attached
  39334. */
  39335. attach(ownerNode: Mesh): void;
  39336. /**
  39337. * Detaches the behavior from the mesh
  39338. */
  39339. detach(): void;
  39340. }
  39341. }
  39342. declare module BABYLON {
  39343. /**
  39344. * 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
  39345. */
  39346. export class SixDofDragBehavior implements Behavior<Mesh> {
  39347. private static _virtualScene;
  39348. private _ownerNode;
  39349. private _sceneRenderObserver;
  39350. private _scene;
  39351. private _targetPosition;
  39352. private _virtualOriginMesh;
  39353. private _virtualDragMesh;
  39354. private _pointerObserver;
  39355. private _moving;
  39356. private _startingOrientation;
  39357. /**
  39358. * 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)
  39359. */
  39360. private zDragFactor;
  39361. /**
  39362. * If the object should rotate to face the drag origin
  39363. */
  39364. rotateDraggedObject: boolean;
  39365. /**
  39366. * If the behavior is currently in a dragging state
  39367. */
  39368. dragging: boolean;
  39369. /**
  39370. * 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)
  39371. */
  39372. dragDeltaRatio: number;
  39373. /**
  39374. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  39375. */
  39376. currentDraggingPointerID: number;
  39377. /**
  39378. * If camera controls should be detached during the drag
  39379. */
  39380. detachCameraControls: boolean;
  39381. /**
  39382. * Fires each time a drag starts
  39383. */
  39384. onDragStartObservable: Observable<{}>;
  39385. /**
  39386. * Fires each time a drag ends (eg. mouse release after drag)
  39387. */
  39388. onDragEndObservable: Observable<{}>;
  39389. /**
  39390. * 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
  39391. */
  39392. constructor();
  39393. /**
  39394. * The name of the behavior
  39395. */
  39396. get name(): string;
  39397. /**
  39398. * Initializes the behavior
  39399. */
  39400. init(): void;
  39401. /**
  39402. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  39403. */
  39404. private get _pointerCamera();
  39405. /**
  39406. * Attaches the scale behavior the passed in mesh
  39407. * @param ownerNode The mesh that will be scaled around once attached
  39408. */
  39409. attach(ownerNode: Mesh): void;
  39410. /**
  39411. * Detaches the behavior from the mesh
  39412. */
  39413. detach(): void;
  39414. }
  39415. }
  39416. declare module BABYLON {
  39417. /**
  39418. * Class used to apply inverse kinematics to bones
  39419. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  39420. */
  39421. export class BoneIKController {
  39422. private static _tmpVecs;
  39423. private static _tmpQuat;
  39424. private static _tmpMats;
  39425. /**
  39426. * Gets or sets the target mesh
  39427. */
  39428. targetMesh: AbstractMesh;
  39429. /** Gets or sets the mesh used as pole */
  39430. poleTargetMesh: AbstractMesh;
  39431. /**
  39432. * Gets or sets the bone used as pole
  39433. */
  39434. poleTargetBone: Nullable<Bone>;
  39435. /**
  39436. * Gets or sets the target position
  39437. */
  39438. targetPosition: Vector3;
  39439. /**
  39440. * Gets or sets the pole target position
  39441. */
  39442. poleTargetPosition: Vector3;
  39443. /**
  39444. * Gets or sets the pole target local offset
  39445. */
  39446. poleTargetLocalOffset: Vector3;
  39447. /**
  39448. * Gets or sets the pole angle
  39449. */
  39450. poleAngle: number;
  39451. /**
  39452. * Gets or sets the mesh associated with the controller
  39453. */
  39454. mesh: AbstractMesh;
  39455. /**
  39456. * 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)
  39457. */
  39458. slerpAmount: number;
  39459. private _bone1Quat;
  39460. private _bone1Mat;
  39461. private _bone2Ang;
  39462. private _bone1;
  39463. private _bone2;
  39464. private _bone1Length;
  39465. private _bone2Length;
  39466. private _maxAngle;
  39467. private _maxReach;
  39468. private _rightHandedSystem;
  39469. private _bendAxis;
  39470. private _slerping;
  39471. private _adjustRoll;
  39472. /**
  39473. * Gets or sets maximum allowed angle
  39474. */
  39475. get maxAngle(): number;
  39476. set maxAngle(value: number);
  39477. /**
  39478. * Creates a new BoneIKController
  39479. * @param mesh defines the mesh to control
  39480. * @param bone defines the bone to control
  39481. * @param options defines options to set up the controller
  39482. */
  39483. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  39484. targetMesh?: AbstractMesh;
  39485. poleTargetMesh?: AbstractMesh;
  39486. poleTargetBone?: Bone;
  39487. poleTargetLocalOffset?: Vector3;
  39488. poleAngle?: number;
  39489. bendAxis?: Vector3;
  39490. maxAngle?: number;
  39491. slerpAmount?: number;
  39492. });
  39493. private _setMaxAngle;
  39494. /**
  39495. * Force the controller to update the bones
  39496. */
  39497. update(): void;
  39498. }
  39499. }
  39500. declare module BABYLON {
  39501. /**
  39502. * Class used to make a bone look toward a point in space
  39503. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  39504. */
  39505. export class BoneLookController {
  39506. private static _tmpVecs;
  39507. private static _tmpQuat;
  39508. private static _tmpMats;
  39509. /**
  39510. * The target Vector3 that the bone will look at
  39511. */
  39512. target: Vector3;
  39513. /**
  39514. * The mesh that the bone is attached to
  39515. */
  39516. mesh: AbstractMesh;
  39517. /**
  39518. * The bone that will be looking to the target
  39519. */
  39520. bone: Bone;
  39521. /**
  39522. * The up axis of the coordinate system that is used when the bone is rotated
  39523. */
  39524. upAxis: Vector3;
  39525. /**
  39526. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  39527. */
  39528. upAxisSpace: Space;
  39529. /**
  39530. * Used to make an adjustment to the yaw of the bone
  39531. */
  39532. adjustYaw: number;
  39533. /**
  39534. * Used to make an adjustment to the pitch of the bone
  39535. */
  39536. adjustPitch: number;
  39537. /**
  39538. * Used to make an adjustment to the roll of the bone
  39539. */
  39540. adjustRoll: number;
  39541. /**
  39542. * 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)
  39543. */
  39544. slerpAmount: number;
  39545. private _minYaw;
  39546. private _maxYaw;
  39547. private _minPitch;
  39548. private _maxPitch;
  39549. private _minYawSin;
  39550. private _minYawCos;
  39551. private _maxYawSin;
  39552. private _maxYawCos;
  39553. private _midYawConstraint;
  39554. private _minPitchTan;
  39555. private _maxPitchTan;
  39556. private _boneQuat;
  39557. private _slerping;
  39558. private _transformYawPitch;
  39559. private _transformYawPitchInv;
  39560. private _firstFrameSkipped;
  39561. private _yawRange;
  39562. private _fowardAxis;
  39563. /**
  39564. * Gets or sets the minimum yaw angle that the bone can look to
  39565. */
  39566. get minYaw(): number;
  39567. set minYaw(value: number);
  39568. /**
  39569. * Gets or sets the maximum yaw angle that the bone can look to
  39570. */
  39571. get maxYaw(): number;
  39572. set maxYaw(value: number);
  39573. /**
  39574. * Gets or sets the minimum pitch angle that the bone can look to
  39575. */
  39576. get minPitch(): number;
  39577. set minPitch(value: number);
  39578. /**
  39579. * Gets or sets the maximum pitch angle that the bone can look to
  39580. */
  39581. get maxPitch(): number;
  39582. set maxPitch(value: number);
  39583. /**
  39584. * Create a BoneLookController
  39585. * @param mesh the mesh that the bone belongs to
  39586. * @param bone the bone that will be looking to the target
  39587. * @param target the target Vector3 to look at
  39588. * @param options optional settings:
  39589. * * maxYaw: the maximum angle the bone will yaw to
  39590. * * minYaw: the minimum angle the bone will yaw to
  39591. * * maxPitch: the maximum angle the bone will pitch to
  39592. * * minPitch: the minimum angle the bone will yaw to
  39593. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  39594. * * upAxis: the up axis of the coordinate system
  39595. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  39596. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  39597. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  39598. * * adjustYaw: used to make an adjustment to the yaw of the bone
  39599. * * adjustPitch: used to make an adjustment to the pitch of the bone
  39600. * * adjustRoll: used to make an adjustment to the roll of the bone
  39601. **/
  39602. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  39603. maxYaw?: number;
  39604. minYaw?: number;
  39605. maxPitch?: number;
  39606. minPitch?: number;
  39607. slerpAmount?: number;
  39608. upAxis?: Vector3;
  39609. upAxisSpace?: Space;
  39610. yawAxis?: Vector3;
  39611. pitchAxis?: Vector3;
  39612. adjustYaw?: number;
  39613. adjustPitch?: number;
  39614. adjustRoll?: number;
  39615. });
  39616. /**
  39617. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  39618. */
  39619. update(): void;
  39620. private _getAngleDiff;
  39621. private _getAngleBetween;
  39622. private _isAngleBetween;
  39623. }
  39624. }
  39625. declare module BABYLON {
  39626. /**
  39627. * Manage the gamepad inputs to control an arc rotate camera.
  39628. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39629. */
  39630. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  39631. /**
  39632. * Defines the camera the input is attached to.
  39633. */
  39634. camera: ArcRotateCamera;
  39635. /**
  39636. * Defines the gamepad the input is gathering event from.
  39637. */
  39638. gamepad: Nullable<Gamepad>;
  39639. /**
  39640. * Defines the gamepad rotation sensiblity.
  39641. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  39642. */
  39643. gamepadRotationSensibility: number;
  39644. /**
  39645. * Defines the gamepad move sensiblity.
  39646. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  39647. */
  39648. gamepadMoveSensibility: number;
  39649. private _yAxisScale;
  39650. /**
  39651. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  39652. */
  39653. get invertYAxis(): boolean;
  39654. set invertYAxis(value: boolean);
  39655. private _onGamepadConnectedObserver;
  39656. private _onGamepadDisconnectedObserver;
  39657. /**
  39658. * Attach the input controls to a specific dom element to get the input from.
  39659. * @param element Defines the element the controls should be listened from
  39660. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39661. */
  39662. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39663. /**
  39664. * Detach the current controls from the specified dom element.
  39665. * @param element Defines the element to stop listening the inputs from
  39666. */
  39667. detachControl(element: Nullable<HTMLElement>): void;
  39668. /**
  39669. * Update the current camera state depending on the inputs that have been used this frame.
  39670. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39671. */
  39672. checkInputs(): void;
  39673. /**
  39674. * Gets the class name of the current intput.
  39675. * @returns the class name
  39676. */
  39677. getClassName(): string;
  39678. /**
  39679. * Get the friendly name associated with the input class.
  39680. * @returns the input friendly name
  39681. */
  39682. getSimpleName(): string;
  39683. }
  39684. }
  39685. declare module BABYLON {
  39686. interface ArcRotateCameraInputsManager {
  39687. /**
  39688. * Add orientation input support to the input manager.
  39689. * @returns the current input manager
  39690. */
  39691. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  39692. }
  39693. /**
  39694. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  39695. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39696. */
  39697. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  39698. /**
  39699. * Defines the camera the input is attached to.
  39700. */
  39701. camera: ArcRotateCamera;
  39702. /**
  39703. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  39704. */
  39705. alphaCorrection: number;
  39706. /**
  39707. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  39708. */
  39709. gammaCorrection: number;
  39710. private _alpha;
  39711. private _gamma;
  39712. private _dirty;
  39713. private _deviceOrientationHandler;
  39714. /**
  39715. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  39716. */
  39717. constructor();
  39718. /**
  39719. * Attach the input controls to a specific dom element to get the input from.
  39720. * @param element Defines the element the controls should be listened from
  39721. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39722. */
  39723. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39724. /** @hidden */
  39725. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  39726. /**
  39727. * Update the current camera state depending on the inputs that have been used this frame.
  39728. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39729. */
  39730. checkInputs(): void;
  39731. /**
  39732. * Detach the current controls from the specified dom element.
  39733. * @param element Defines the element to stop listening the inputs from
  39734. */
  39735. detachControl(element: Nullable<HTMLElement>): void;
  39736. /**
  39737. * Gets the class name of the current intput.
  39738. * @returns the class name
  39739. */
  39740. getClassName(): string;
  39741. /**
  39742. * Get the friendly name associated with the input class.
  39743. * @returns the input friendly name
  39744. */
  39745. getSimpleName(): string;
  39746. }
  39747. }
  39748. declare module BABYLON {
  39749. /**
  39750. * Listen to mouse events to control the camera.
  39751. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39752. */
  39753. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  39754. /**
  39755. * Defines the camera the input is attached to.
  39756. */
  39757. camera: FlyCamera;
  39758. /**
  39759. * Defines if touch is enabled. (Default is true.)
  39760. */
  39761. touchEnabled: boolean;
  39762. /**
  39763. * Defines the buttons associated with the input to handle camera rotation.
  39764. */
  39765. buttons: number[];
  39766. /**
  39767. * Assign buttons for Yaw control.
  39768. */
  39769. buttonsYaw: number[];
  39770. /**
  39771. * Assign buttons for Pitch control.
  39772. */
  39773. buttonsPitch: number[];
  39774. /**
  39775. * Assign buttons for Roll control.
  39776. */
  39777. buttonsRoll: number[];
  39778. /**
  39779. * Detect if any button is being pressed while mouse is moved.
  39780. * -1 = Mouse locked.
  39781. * 0 = Left button.
  39782. * 1 = Middle Button.
  39783. * 2 = Right Button.
  39784. */
  39785. activeButton: number;
  39786. /**
  39787. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  39788. * Higher values reduce its sensitivity.
  39789. */
  39790. angularSensibility: number;
  39791. private _mousemoveCallback;
  39792. private _observer;
  39793. private _rollObserver;
  39794. private previousPosition;
  39795. private noPreventDefault;
  39796. private element;
  39797. /**
  39798. * Listen to mouse events to control the camera.
  39799. * @param touchEnabled Define if touch is enabled. (Default is true.)
  39800. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39801. */
  39802. constructor(touchEnabled?: boolean);
  39803. /**
  39804. * Attach the mouse control to the HTML DOM element.
  39805. * @param element Defines the element that listens to the input events.
  39806. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  39807. */
  39808. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39809. /**
  39810. * Detach the current controls from the specified dom element.
  39811. * @param element Defines the element to stop listening the inputs from
  39812. */
  39813. detachControl(element: Nullable<HTMLElement>): void;
  39814. /**
  39815. * Gets the class name of the current input.
  39816. * @returns the class name.
  39817. */
  39818. getClassName(): string;
  39819. /**
  39820. * Get the friendly name associated with the input class.
  39821. * @returns the input's friendly name.
  39822. */
  39823. getSimpleName(): string;
  39824. private _pointerInput;
  39825. private _onMouseMove;
  39826. /**
  39827. * Rotate camera by mouse offset.
  39828. */
  39829. private rotateCamera;
  39830. }
  39831. }
  39832. declare module BABYLON {
  39833. /**
  39834. * Default Inputs manager for the FlyCamera.
  39835. * It groups all the default supported inputs for ease of use.
  39836. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39837. */
  39838. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  39839. /**
  39840. * Instantiates a new FlyCameraInputsManager.
  39841. * @param camera Defines the camera the inputs belong to.
  39842. */
  39843. constructor(camera: FlyCamera);
  39844. /**
  39845. * Add keyboard input support to the input manager.
  39846. * @returns the new FlyCameraKeyboardMoveInput().
  39847. */
  39848. addKeyboard(): FlyCameraInputsManager;
  39849. /**
  39850. * Add mouse input support to the input manager.
  39851. * @param touchEnabled Enable touch screen support.
  39852. * @returns the new FlyCameraMouseInput().
  39853. */
  39854. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  39855. }
  39856. }
  39857. declare module BABYLON {
  39858. /**
  39859. * This is a flying camera, designed for 3D movement and rotation in all directions,
  39860. * such as in a 3D Space Shooter or a Flight Simulator.
  39861. */
  39862. export class FlyCamera extends TargetCamera {
  39863. /**
  39864. * Define the collision ellipsoid of the camera.
  39865. * This is helpful for simulating a camera body, like a player's body.
  39866. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  39867. */
  39868. ellipsoid: Vector3;
  39869. /**
  39870. * Define an offset for the position of the ellipsoid around the camera.
  39871. * This can be helpful if the camera is attached away from the player's body center,
  39872. * such as at its head.
  39873. */
  39874. ellipsoidOffset: Vector3;
  39875. /**
  39876. * Enable or disable collisions of the camera with the rest of the scene objects.
  39877. */
  39878. checkCollisions: boolean;
  39879. /**
  39880. * Enable or disable gravity on the camera.
  39881. */
  39882. applyGravity: boolean;
  39883. /**
  39884. * Define the current direction the camera is moving to.
  39885. */
  39886. cameraDirection: Vector3;
  39887. /**
  39888. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  39889. * This overrides and empties cameraRotation.
  39890. */
  39891. rotationQuaternion: Quaternion;
  39892. /**
  39893. * Track Roll to maintain the wanted Rolling when looking around.
  39894. */
  39895. _trackRoll: number;
  39896. /**
  39897. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  39898. */
  39899. rollCorrect: number;
  39900. /**
  39901. * Mimic a banked turn, Rolling the camera when Yawing.
  39902. * It's recommended to use rollCorrect = 10 for faster banking correction.
  39903. */
  39904. bankedTurn: boolean;
  39905. /**
  39906. * Limit in radians for how much Roll banking will add. (Default: 90°)
  39907. */
  39908. bankedTurnLimit: number;
  39909. /**
  39910. * Value of 0 disables the banked Roll.
  39911. * Value of 1 is equal to the Yaw angle in radians.
  39912. */
  39913. bankedTurnMultiplier: number;
  39914. /**
  39915. * The inputs manager loads all the input sources, such as keyboard and mouse.
  39916. */
  39917. inputs: FlyCameraInputsManager;
  39918. /**
  39919. * Gets the input sensibility for mouse input.
  39920. * Higher values reduce sensitivity.
  39921. */
  39922. get angularSensibility(): number;
  39923. /**
  39924. * Sets the input sensibility for a mouse input.
  39925. * Higher values reduce sensitivity.
  39926. */
  39927. set angularSensibility(value: number);
  39928. /**
  39929. * Get the keys for camera movement forward.
  39930. */
  39931. get keysForward(): number[];
  39932. /**
  39933. * Set the keys for camera movement forward.
  39934. */
  39935. set keysForward(value: number[]);
  39936. /**
  39937. * Get the keys for camera movement backward.
  39938. */
  39939. get keysBackward(): number[];
  39940. set keysBackward(value: number[]);
  39941. /**
  39942. * Get the keys for camera movement up.
  39943. */
  39944. get keysUp(): number[];
  39945. /**
  39946. * Set the keys for camera movement up.
  39947. */
  39948. set keysUp(value: number[]);
  39949. /**
  39950. * Get the keys for camera movement down.
  39951. */
  39952. get keysDown(): number[];
  39953. /**
  39954. * Set the keys for camera movement down.
  39955. */
  39956. set keysDown(value: number[]);
  39957. /**
  39958. * Get the keys for camera movement left.
  39959. */
  39960. get keysLeft(): number[];
  39961. /**
  39962. * Set the keys for camera movement left.
  39963. */
  39964. set keysLeft(value: number[]);
  39965. /**
  39966. * Set the keys for camera movement right.
  39967. */
  39968. get keysRight(): number[];
  39969. /**
  39970. * Set the keys for camera movement right.
  39971. */
  39972. set keysRight(value: number[]);
  39973. /**
  39974. * Event raised when the camera collides with a mesh in the scene.
  39975. */
  39976. onCollide: (collidedMesh: AbstractMesh) => void;
  39977. private _collider;
  39978. private _needMoveForGravity;
  39979. private _oldPosition;
  39980. private _diffPosition;
  39981. private _newPosition;
  39982. /** @hidden */
  39983. _localDirection: Vector3;
  39984. /** @hidden */
  39985. _transformedDirection: Vector3;
  39986. /**
  39987. * Instantiates a FlyCamera.
  39988. * This is a flying camera, designed for 3D movement and rotation in all directions,
  39989. * such as in a 3D Space Shooter or a Flight Simulator.
  39990. * @param name Define the name of the camera in the scene.
  39991. * @param position Define the starting position of the camera in the scene.
  39992. * @param scene Define the scene the camera belongs to.
  39993. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  39994. */
  39995. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  39996. /**
  39997. * Attach a control to the HTML DOM element.
  39998. * @param element Defines the element that listens to the input events.
  39999. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  40000. */
  40001. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40002. /**
  40003. * Detach a control from the HTML DOM element.
  40004. * The camera will stop reacting to that input.
  40005. * @param element Defines the element that listens to the input events.
  40006. */
  40007. detachControl(element: HTMLElement): void;
  40008. private _collisionMask;
  40009. /**
  40010. * Get the mask that the camera ignores in collision events.
  40011. */
  40012. get collisionMask(): number;
  40013. /**
  40014. * Set the mask that the camera ignores in collision events.
  40015. */
  40016. set collisionMask(mask: number);
  40017. /** @hidden */
  40018. _collideWithWorld(displacement: Vector3): void;
  40019. /** @hidden */
  40020. private _onCollisionPositionChange;
  40021. /** @hidden */
  40022. _checkInputs(): void;
  40023. /** @hidden */
  40024. _decideIfNeedsToMove(): boolean;
  40025. /** @hidden */
  40026. _updatePosition(): void;
  40027. /**
  40028. * Restore the Roll to its target value at the rate specified.
  40029. * @param rate - Higher means slower restoring.
  40030. * @hidden
  40031. */
  40032. restoreRoll(rate: number): void;
  40033. /**
  40034. * Destroy the camera and release the current resources held by it.
  40035. */
  40036. dispose(): void;
  40037. /**
  40038. * Get the current object class name.
  40039. * @returns the class name.
  40040. */
  40041. getClassName(): string;
  40042. }
  40043. }
  40044. declare module BABYLON {
  40045. /**
  40046. * Listen to keyboard events to control the camera.
  40047. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40048. */
  40049. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  40050. /**
  40051. * Defines the camera the input is attached to.
  40052. */
  40053. camera: FlyCamera;
  40054. /**
  40055. * The list of keyboard keys used to control the forward move of the camera.
  40056. */
  40057. keysForward: number[];
  40058. /**
  40059. * The list of keyboard keys used to control the backward move of the camera.
  40060. */
  40061. keysBackward: number[];
  40062. /**
  40063. * The list of keyboard keys used to control the forward move of the camera.
  40064. */
  40065. keysUp: number[];
  40066. /**
  40067. * The list of keyboard keys used to control the backward move of the camera.
  40068. */
  40069. keysDown: number[];
  40070. /**
  40071. * The list of keyboard keys used to control the right strafe move of the camera.
  40072. */
  40073. keysRight: number[];
  40074. /**
  40075. * The list of keyboard keys used to control the left strafe move of the camera.
  40076. */
  40077. keysLeft: number[];
  40078. private _keys;
  40079. private _onCanvasBlurObserver;
  40080. private _onKeyboardObserver;
  40081. private _engine;
  40082. private _scene;
  40083. /**
  40084. * Attach the input controls to a specific dom element to get the input from.
  40085. * @param element Defines the element the controls should be listened from
  40086. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40087. */
  40088. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40089. /**
  40090. * Detach the current controls from the specified dom element.
  40091. * @param element Defines the element to stop listening the inputs from
  40092. */
  40093. detachControl(element: Nullable<HTMLElement>): void;
  40094. /**
  40095. * Gets the class name of the current intput.
  40096. * @returns the class name
  40097. */
  40098. getClassName(): string;
  40099. /** @hidden */
  40100. _onLostFocus(e: FocusEvent): void;
  40101. /**
  40102. * Get the friendly name associated with the input class.
  40103. * @returns the input friendly name
  40104. */
  40105. getSimpleName(): string;
  40106. /**
  40107. * Update the current camera state depending on the inputs that have been used this frame.
  40108. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40109. */
  40110. checkInputs(): void;
  40111. }
  40112. }
  40113. declare module BABYLON {
  40114. /**
  40115. * Manage the mouse wheel inputs to control a follow camera.
  40116. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40117. */
  40118. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  40119. /**
  40120. * Defines the camera the input is attached to.
  40121. */
  40122. camera: FollowCamera;
  40123. /**
  40124. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  40125. */
  40126. axisControlRadius: boolean;
  40127. /**
  40128. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  40129. */
  40130. axisControlHeight: boolean;
  40131. /**
  40132. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  40133. */
  40134. axisControlRotation: boolean;
  40135. /**
  40136. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  40137. * relation to mouseWheel events.
  40138. */
  40139. wheelPrecision: number;
  40140. /**
  40141. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  40142. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  40143. */
  40144. wheelDeltaPercentage: number;
  40145. private _wheel;
  40146. private _observer;
  40147. /**
  40148. * Attach the input controls to a specific dom element to get the input from.
  40149. * @param element Defines the element the controls should be listened from
  40150. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40151. */
  40152. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40153. /**
  40154. * Detach the current controls from the specified dom element.
  40155. * @param element Defines the element to stop listening the inputs from
  40156. */
  40157. detachControl(element: Nullable<HTMLElement>): void;
  40158. /**
  40159. * Gets the class name of the current intput.
  40160. * @returns the class name
  40161. */
  40162. getClassName(): string;
  40163. /**
  40164. * Get the friendly name associated with the input class.
  40165. * @returns the input friendly name
  40166. */
  40167. getSimpleName(): string;
  40168. }
  40169. }
  40170. declare module BABYLON {
  40171. /**
  40172. * Manage the pointers inputs to control an follow camera.
  40173. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40174. */
  40175. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  40176. /**
  40177. * Defines the camera the input is attached to.
  40178. */
  40179. camera: FollowCamera;
  40180. /**
  40181. * Gets the class name of the current input.
  40182. * @returns the class name
  40183. */
  40184. getClassName(): string;
  40185. /**
  40186. * Defines the pointer angular sensibility along the X axis or how fast is
  40187. * the camera rotating.
  40188. * A negative number will reverse the axis direction.
  40189. */
  40190. angularSensibilityX: number;
  40191. /**
  40192. * Defines the pointer angular sensibility along the Y axis or how fast is
  40193. * the camera rotating.
  40194. * A negative number will reverse the axis direction.
  40195. */
  40196. angularSensibilityY: number;
  40197. /**
  40198. * Defines the pointer pinch precision or how fast is the camera zooming.
  40199. * A negative number will reverse the axis direction.
  40200. */
  40201. pinchPrecision: number;
  40202. /**
  40203. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  40204. * from 0.
  40205. * It defines the percentage of current camera.radius to use as delta when
  40206. * pinch zoom is used.
  40207. */
  40208. pinchDeltaPercentage: number;
  40209. /**
  40210. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  40211. */
  40212. axisXControlRadius: boolean;
  40213. /**
  40214. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  40215. */
  40216. axisXControlHeight: boolean;
  40217. /**
  40218. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  40219. */
  40220. axisXControlRotation: boolean;
  40221. /**
  40222. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  40223. */
  40224. axisYControlRadius: boolean;
  40225. /**
  40226. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  40227. */
  40228. axisYControlHeight: boolean;
  40229. /**
  40230. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  40231. */
  40232. axisYControlRotation: boolean;
  40233. /**
  40234. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  40235. */
  40236. axisPinchControlRadius: boolean;
  40237. /**
  40238. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  40239. */
  40240. axisPinchControlHeight: boolean;
  40241. /**
  40242. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  40243. */
  40244. axisPinchControlRotation: boolean;
  40245. /**
  40246. * Log error messages if basic misconfiguration has occurred.
  40247. */
  40248. warningEnable: boolean;
  40249. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  40250. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  40251. private _warningCounter;
  40252. private _warning;
  40253. }
  40254. }
  40255. declare module BABYLON {
  40256. /**
  40257. * Default Inputs manager for the FollowCamera.
  40258. * It groups all the default supported inputs for ease of use.
  40259. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40260. */
  40261. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  40262. /**
  40263. * Instantiates a new FollowCameraInputsManager.
  40264. * @param camera Defines the camera the inputs belong to
  40265. */
  40266. constructor(camera: FollowCamera);
  40267. /**
  40268. * Add keyboard input support to the input manager.
  40269. * @returns the current input manager
  40270. */
  40271. addKeyboard(): FollowCameraInputsManager;
  40272. /**
  40273. * Add mouse wheel input support to the input manager.
  40274. * @returns the current input manager
  40275. */
  40276. addMouseWheel(): FollowCameraInputsManager;
  40277. /**
  40278. * Add pointers input support to the input manager.
  40279. * @returns the current input manager
  40280. */
  40281. addPointers(): FollowCameraInputsManager;
  40282. /**
  40283. * Add orientation input support to the input manager.
  40284. * @returns the current input manager
  40285. */
  40286. addVRDeviceOrientation(): FollowCameraInputsManager;
  40287. }
  40288. }
  40289. declare module BABYLON {
  40290. /**
  40291. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  40292. * an arc rotate version arcFollowCamera are available.
  40293. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40294. */
  40295. export class FollowCamera extends TargetCamera {
  40296. /**
  40297. * Distance the follow camera should follow an object at
  40298. */
  40299. radius: number;
  40300. /**
  40301. * Minimum allowed distance of the camera to the axis of rotation
  40302. * (The camera can not get closer).
  40303. * This can help limiting how the Camera is able to move in the scene.
  40304. */
  40305. lowerRadiusLimit: Nullable<number>;
  40306. /**
  40307. * Maximum allowed distance of the camera to the axis of rotation
  40308. * (The camera can not get further).
  40309. * This can help limiting how the Camera is able to move in the scene.
  40310. */
  40311. upperRadiusLimit: Nullable<number>;
  40312. /**
  40313. * Define a rotation offset between the camera and the object it follows
  40314. */
  40315. rotationOffset: number;
  40316. /**
  40317. * Minimum allowed angle to camera position relative to target object.
  40318. * This can help limiting how the Camera is able to move in the scene.
  40319. */
  40320. lowerRotationOffsetLimit: Nullable<number>;
  40321. /**
  40322. * Maximum allowed angle to camera position relative to target object.
  40323. * This can help limiting how the Camera is able to move in the scene.
  40324. */
  40325. upperRotationOffsetLimit: Nullable<number>;
  40326. /**
  40327. * Define a height offset between the camera and the object it follows.
  40328. * It can help following an object from the top (like a car chaing a plane)
  40329. */
  40330. heightOffset: number;
  40331. /**
  40332. * Minimum allowed height of camera position relative to target object.
  40333. * This can help limiting how the Camera is able to move in the scene.
  40334. */
  40335. lowerHeightOffsetLimit: Nullable<number>;
  40336. /**
  40337. * Maximum allowed height of camera position relative to target object.
  40338. * This can help limiting how the Camera is able to move in the scene.
  40339. */
  40340. upperHeightOffsetLimit: Nullable<number>;
  40341. /**
  40342. * Define how fast the camera can accelerate to follow it s target.
  40343. */
  40344. cameraAcceleration: number;
  40345. /**
  40346. * Define the speed limit of the camera following an object.
  40347. */
  40348. maxCameraSpeed: number;
  40349. /**
  40350. * Define the target of the camera.
  40351. */
  40352. lockedTarget: Nullable<AbstractMesh>;
  40353. /**
  40354. * Defines the input associated with the camera.
  40355. */
  40356. inputs: FollowCameraInputsManager;
  40357. /**
  40358. * Instantiates the follow camera.
  40359. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40360. * @param name Define the name of the camera in the scene
  40361. * @param position Define the position of the camera
  40362. * @param scene Define the scene the camera belong to
  40363. * @param lockedTarget Define the target of the camera
  40364. */
  40365. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  40366. private _follow;
  40367. /**
  40368. * Attached controls to the current camera.
  40369. * @param element Defines the element the controls should be listened from
  40370. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40371. */
  40372. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40373. /**
  40374. * Detach the current controls from the camera.
  40375. * The camera will stop reacting to inputs.
  40376. * @param element Defines the element to stop listening the inputs from
  40377. */
  40378. detachControl(element: HTMLElement): void;
  40379. /** @hidden */
  40380. _checkInputs(): void;
  40381. private _checkLimits;
  40382. /**
  40383. * Gets the camera class name.
  40384. * @returns the class name
  40385. */
  40386. getClassName(): string;
  40387. }
  40388. /**
  40389. * Arc Rotate version of the follow camera.
  40390. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  40391. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40392. */
  40393. export class ArcFollowCamera extends TargetCamera {
  40394. /** The longitudinal angle of the camera */
  40395. alpha: number;
  40396. /** The latitudinal angle of the camera */
  40397. beta: number;
  40398. /** The radius of the camera from its target */
  40399. radius: number;
  40400. /** Define the camera target (the messh it should follow) */
  40401. target: Nullable<AbstractMesh>;
  40402. private _cartesianCoordinates;
  40403. /**
  40404. * Instantiates a new ArcFollowCamera
  40405. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40406. * @param name Define the name of the camera
  40407. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  40408. * @param beta Define the rotation angle of the camera around the elevation axis
  40409. * @param radius Define the radius of the camera from its target point
  40410. * @param target Define the target of the camera
  40411. * @param scene Define the scene the camera belongs to
  40412. */
  40413. constructor(name: string,
  40414. /** The longitudinal angle of the camera */
  40415. alpha: number,
  40416. /** The latitudinal angle of the camera */
  40417. beta: number,
  40418. /** The radius of the camera from its target */
  40419. radius: number,
  40420. /** Define the camera target (the messh it should follow) */
  40421. target: Nullable<AbstractMesh>, scene: Scene);
  40422. private _follow;
  40423. /** @hidden */
  40424. _checkInputs(): void;
  40425. /**
  40426. * Returns the class name of the object.
  40427. * It is mostly used internally for serialization purposes.
  40428. */
  40429. getClassName(): string;
  40430. }
  40431. }
  40432. declare module BABYLON {
  40433. /**
  40434. * Manage the keyboard inputs to control the movement of a follow camera.
  40435. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40436. */
  40437. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  40438. /**
  40439. * Defines the camera the input is attached to.
  40440. */
  40441. camera: FollowCamera;
  40442. /**
  40443. * Defines the list of key codes associated with the up action (increase heightOffset)
  40444. */
  40445. keysHeightOffsetIncr: number[];
  40446. /**
  40447. * Defines the list of key codes associated with the down action (decrease heightOffset)
  40448. */
  40449. keysHeightOffsetDecr: number[];
  40450. /**
  40451. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  40452. */
  40453. keysHeightOffsetModifierAlt: boolean;
  40454. /**
  40455. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  40456. */
  40457. keysHeightOffsetModifierCtrl: boolean;
  40458. /**
  40459. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  40460. */
  40461. keysHeightOffsetModifierShift: boolean;
  40462. /**
  40463. * Defines the list of key codes associated with the left action (increase rotationOffset)
  40464. */
  40465. keysRotationOffsetIncr: number[];
  40466. /**
  40467. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  40468. */
  40469. keysRotationOffsetDecr: number[];
  40470. /**
  40471. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  40472. */
  40473. keysRotationOffsetModifierAlt: boolean;
  40474. /**
  40475. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  40476. */
  40477. keysRotationOffsetModifierCtrl: boolean;
  40478. /**
  40479. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  40480. */
  40481. keysRotationOffsetModifierShift: boolean;
  40482. /**
  40483. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  40484. */
  40485. keysRadiusIncr: number[];
  40486. /**
  40487. * Defines the list of key codes associated with the zoom-out action (increase radius)
  40488. */
  40489. keysRadiusDecr: number[];
  40490. /**
  40491. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  40492. */
  40493. keysRadiusModifierAlt: boolean;
  40494. /**
  40495. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  40496. */
  40497. keysRadiusModifierCtrl: boolean;
  40498. /**
  40499. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  40500. */
  40501. keysRadiusModifierShift: boolean;
  40502. /**
  40503. * Defines the rate of change of heightOffset.
  40504. */
  40505. heightSensibility: number;
  40506. /**
  40507. * Defines the rate of change of rotationOffset.
  40508. */
  40509. rotationSensibility: number;
  40510. /**
  40511. * Defines the rate of change of radius.
  40512. */
  40513. radiusSensibility: number;
  40514. private _keys;
  40515. private _ctrlPressed;
  40516. private _altPressed;
  40517. private _shiftPressed;
  40518. private _onCanvasBlurObserver;
  40519. private _onKeyboardObserver;
  40520. private _engine;
  40521. private _scene;
  40522. /**
  40523. * Attach the input controls to a specific dom element to get the input from.
  40524. * @param element Defines the element the controls should be listened from
  40525. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40526. */
  40527. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40528. /**
  40529. * Detach the current controls from the specified dom element.
  40530. * @param element Defines the element to stop listening the inputs from
  40531. */
  40532. detachControl(element: Nullable<HTMLElement>): void;
  40533. /**
  40534. * Update the current camera state depending on the inputs that have been used this frame.
  40535. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40536. */
  40537. checkInputs(): void;
  40538. /**
  40539. * Gets the class name of the current input.
  40540. * @returns the class name
  40541. */
  40542. getClassName(): string;
  40543. /**
  40544. * Get the friendly name associated with the input class.
  40545. * @returns the input friendly name
  40546. */
  40547. getSimpleName(): string;
  40548. /**
  40549. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  40550. * allow modification of the heightOffset value.
  40551. */
  40552. private _modifierHeightOffset;
  40553. /**
  40554. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  40555. * allow modification of the rotationOffset value.
  40556. */
  40557. private _modifierRotationOffset;
  40558. /**
  40559. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  40560. * allow modification of the radius value.
  40561. */
  40562. private _modifierRadius;
  40563. }
  40564. }
  40565. declare module BABYLON {
  40566. interface FreeCameraInputsManager {
  40567. /**
  40568. * @hidden
  40569. */
  40570. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  40571. /**
  40572. * Add orientation input support to the input manager.
  40573. * @returns the current input manager
  40574. */
  40575. addDeviceOrientation(): FreeCameraInputsManager;
  40576. }
  40577. /**
  40578. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  40579. * Screen rotation is taken into account.
  40580. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40581. */
  40582. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  40583. private _camera;
  40584. private _screenOrientationAngle;
  40585. private _constantTranform;
  40586. private _screenQuaternion;
  40587. private _alpha;
  40588. private _beta;
  40589. private _gamma;
  40590. /**
  40591. * Can be used to detect if a device orientation sensor is available on a device
  40592. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  40593. * @returns a promise that will resolve on orientation change
  40594. */
  40595. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  40596. /**
  40597. * @hidden
  40598. */
  40599. _onDeviceOrientationChangedObservable: Observable<void>;
  40600. /**
  40601. * Instantiates a new input
  40602. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40603. */
  40604. constructor();
  40605. /**
  40606. * Define the camera controlled by the input.
  40607. */
  40608. get camera(): FreeCamera;
  40609. set camera(camera: FreeCamera);
  40610. /**
  40611. * Attach the input controls to a specific dom element to get the input from.
  40612. * @param element Defines the element the controls should be listened from
  40613. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40614. */
  40615. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40616. private _orientationChanged;
  40617. private _deviceOrientation;
  40618. /**
  40619. * Detach the current controls from the specified dom element.
  40620. * @param element Defines the element to stop listening the inputs from
  40621. */
  40622. detachControl(element: Nullable<HTMLElement>): void;
  40623. /**
  40624. * Update the current camera state depending on the inputs that have been used this frame.
  40625. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40626. */
  40627. checkInputs(): void;
  40628. /**
  40629. * Gets the class name of the current intput.
  40630. * @returns the class name
  40631. */
  40632. getClassName(): string;
  40633. /**
  40634. * Get the friendly name associated with the input class.
  40635. * @returns the input friendly name
  40636. */
  40637. getSimpleName(): string;
  40638. }
  40639. }
  40640. declare module BABYLON {
  40641. /**
  40642. * Manage the gamepad inputs to control a free camera.
  40643. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40644. */
  40645. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  40646. /**
  40647. * Define the camera the input is attached to.
  40648. */
  40649. camera: FreeCamera;
  40650. /**
  40651. * Define the Gamepad controlling the input
  40652. */
  40653. gamepad: Nullable<Gamepad>;
  40654. /**
  40655. * Defines the gamepad rotation sensiblity.
  40656. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  40657. */
  40658. gamepadAngularSensibility: number;
  40659. /**
  40660. * Defines the gamepad move sensiblity.
  40661. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  40662. */
  40663. gamepadMoveSensibility: number;
  40664. private _yAxisScale;
  40665. /**
  40666. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  40667. */
  40668. get invertYAxis(): boolean;
  40669. set invertYAxis(value: boolean);
  40670. private _onGamepadConnectedObserver;
  40671. private _onGamepadDisconnectedObserver;
  40672. private _cameraTransform;
  40673. private _deltaTransform;
  40674. private _vector3;
  40675. private _vector2;
  40676. /**
  40677. * Attach the input controls to a specific dom element to get the input from.
  40678. * @param element Defines the element the controls should be listened from
  40679. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40680. */
  40681. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40682. /**
  40683. * Detach the current controls from the specified dom element.
  40684. * @param element Defines the element to stop listening the inputs from
  40685. */
  40686. detachControl(element: Nullable<HTMLElement>): void;
  40687. /**
  40688. * Update the current camera state depending on the inputs that have been used this frame.
  40689. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40690. */
  40691. checkInputs(): void;
  40692. /**
  40693. * Gets the class name of the current intput.
  40694. * @returns the class name
  40695. */
  40696. getClassName(): string;
  40697. /**
  40698. * Get the friendly name associated with the input class.
  40699. * @returns the input friendly name
  40700. */
  40701. getSimpleName(): string;
  40702. }
  40703. }
  40704. declare module BABYLON {
  40705. /**
  40706. * Defines the potential axis of a Joystick
  40707. */
  40708. export enum JoystickAxis {
  40709. /** X axis */
  40710. X = 0,
  40711. /** Y axis */
  40712. Y = 1,
  40713. /** Z axis */
  40714. Z = 2
  40715. }
  40716. /**
  40717. * Class used to define virtual joystick (used in touch mode)
  40718. */
  40719. export class VirtualJoystick {
  40720. /**
  40721. * Gets or sets a boolean indicating that left and right values must be inverted
  40722. */
  40723. reverseLeftRight: boolean;
  40724. /**
  40725. * Gets or sets a boolean indicating that up and down values must be inverted
  40726. */
  40727. reverseUpDown: boolean;
  40728. /**
  40729. * Gets the offset value for the position (ie. the change of the position value)
  40730. */
  40731. deltaPosition: Vector3;
  40732. /**
  40733. * Gets a boolean indicating if the virtual joystick was pressed
  40734. */
  40735. pressed: boolean;
  40736. /**
  40737. * Canvas the virtual joystick will render onto, default z-index of this is 5
  40738. */
  40739. static Canvas: Nullable<HTMLCanvasElement>;
  40740. private static _globalJoystickIndex;
  40741. private static vjCanvasContext;
  40742. private static vjCanvasWidth;
  40743. private static vjCanvasHeight;
  40744. private static halfWidth;
  40745. private _action;
  40746. private _axisTargetedByLeftAndRight;
  40747. private _axisTargetedByUpAndDown;
  40748. private _joystickSensibility;
  40749. private _inversedSensibility;
  40750. private _joystickPointerID;
  40751. private _joystickColor;
  40752. private _joystickPointerPos;
  40753. private _joystickPreviousPointerPos;
  40754. private _joystickPointerStartPos;
  40755. private _deltaJoystickVector;
  40756. private _leftJoystick;
  40757. private _touches;
  40758. private _onPointerDownHandlerRef;
  40759. private _onPointerMoveHandlerRef;
  40760. private _onPointerUpHandlerRef;
  40761. private _onResize;
  40762. /**
  40763. * Creates a new virtual joystick
  40764. * @param leftJoystick defines that the joystick is for left hand (false by default)
  40765. */
  40766. constructor(leftJoystick?: boolean);
  40767. /**
  40768. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  40769. * @param newJoystickSensibility defines the new sensibility
  40770. */
  40771. setJoystickSensibility(newJoystickSensibility: number): void;
  40772. private _onPointerDown;
  40773. private _onPointerMove;
  40774. private _onPointerUp;
  40775. /**
  40776. * Change the color of the virtual joystick
  40777. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  40778. */
  40779. setJoystickColor(newColor: string): void;
  40780. /**
  40781. * Defines a callback to call when the joystick is touched
  40782. * @param action defines the callback
  40783. */
  40784. setActionOnTouch(action: () => any): void;
  40785. /**
  40786. * Defines which axis you'd like to control for left & right
  40787. * @param axis defines the axis to use
  40788. */
  40789. setAxisForLeftRight(axis: JoystickAxis): void;
  40790. /**
  40791. * Defines which axis you'd like to control for up & down
  40792. * @param axis defines the axis to use
  40793. */
  40794. setAxisForUpDown(axis: JoystickAxis): void;
  40795. private _drawVirtualJoystick;
  40796. /**
  40797. * Release internal HTML canvas
  40798. */
  40799. releaseCanvas(): void;
  40800. }
  40801. }
  40802. declare module BABYLON {
  40803. interface FreeCameraInputsManager {
  40804. /**
  40805. * Add virtual joystick input support to the input manager.
  40806. * @returns the current input manager
  40807. */
  40808. addVirtualJoystick(): FreeCameraInputsManager;
  40809. }
  40810. /**
  40811. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  40812. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40813. */
  40814. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  40815. /**
  40816. * Defines the camera the input is attached to.
  40817. */
  40818. camera: FreeCamera;
  40819. private _leftjoystick;
  40820. private _rightjoystick;
  40821. /**
  40822. * Gets the left stick of the virtual joystick.
  40823. * @returns The virtual Joystick
  40824. */
  40825. getLeftJoystick(): VirtualJoystick;
  40826. /**
  40827. * Gets the right stick of the virtual joystick.
  40828. * @returns The virtual Joystick
  40829. */
  40830. getRightJoystick(): VirtualJoystick;
  40831. /**
  40832. * Update the current camera state depending on the inputs that have been used this frame.
  40833. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40834. */
  40835. checkInputs(): void;
  40836. /**
  40837. * Attach the input controls to a specific dom element to get the input from.
  40838. * @param element Defines the element the controls should be listened from
  40839. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40840. */
  40841. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40842. /**
  40843. * Detach the current controls from the specified dom element.
  40844. * @param element Defines the element to stop listening the inputs from
  40845. */
  40846. detachControl(element: Nullable<HTMLElement>): void;
  40847. /**
  40848. * Gets the class name of the current intput.
  40849. * @returns the class name
  40850. */
  40851. getClassName(): string;
  40852. /**
  40853. * Get the friendly name associated with the input class.
  40854. * @returns the input friendly name
  40855. */
  40856. getSimpleName(): string;
  40857. }
  40858. }
  40859. declare module BABYLON {
  40860. /**
  40861. * This represents a FPS type of camera controlled by touch.
  40862. * This is like a universal camera minus the Gamepad controls.
  40863. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40864. */
  40865. export class TouchCamera extends FreeCamera {
  40866. /**
  40867. * Defines the touch sensibility for rotation.
  40868. * The higher the faster.
  40869. */
  40870. get touchAngularSensibility(): number;
  40871. set touchAngularSensibility(value: number);
  40872. /**
  40873. * Defines the touch sensibility for move.
  40874. * The higher the faster.
  40875. */
  40876. get touchMoveSensibility(): number;
  40877. set touchMoveSensibility(value: number);
  40878. /**
  40879. * Instantiates a new touch camera.
  40880. * This represents a FPS type of camera controlled by touch.
  40881. * This is like a universal camera minus the Gamepad controls.
  40882. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40883. * @param name Define the name of the camera in the scene
  40884. * @param position Define the start position of the camera in the scene
  40885. * @param scene Define the scene the camera belongs to
  40886. */
  40887. constructor(name: string, position: Vector3, scene: Scene);
  40888. /**
  40889. * Gets the current object class name.
  40890. * @return the class name
  40891. */
  40892. getClassName(): string;
  40893. /** @hidden */
  40894. _setupInputs(): void;
  40895. }
  40896. }
  40897. declare module BABYLON {
  40898. /**
  40899. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  40900. * being tilted forward or back and left or right.
  40901. */
  40902. export class DeviceOrientationCamera extends FreeCamera {
  40903. private _initialQuaternion;
  40904. private _quaternionCache;
  40905. private _tmpDragQuaternion;
  40906. private _disablePointerInputWhenUsingDeviceOrientation;
  40907. /**
  40908. * Creates a new device orientation camera
  40909. * @param name The name of the camera
  40910. * @param position The start position camera
  40911. * @param scene The scene the camera belongs to
  40912. */
  40913. constructor(name: string, position: Vector3, scene: Scene);
  40914. /**
  40915. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  40916. */
  40917. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  40918. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  40919. private _dragFactor;
  40920. /**
  40921. * Enabled turning on the y axis when the orientation sensor is active
  40922. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  40923. */
  40924. enableHorizontalDragging(dragFactor?: number): void;
  40925. /**
  40926. * Gets the current instance class name ("DeviceOrientationCamera").
  40927. * This helps avoiding instanceof at run time.
  40928. * @returns the class name
  40929. */
  40930. getClassName(): string;
  40931. /**
  40932. * @hidden
  40933. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  40934. */
  40935. _checkInputs(): void;
  40936. /**
  40937. * Reset the camera to its default orientation on the specified axis only.
  40938. * @param axis The axis to reset
  40939. */
  40940. resetToCurrentRotation(axis?: Axis): void;
  40941. }
  40942. }
  40943. declare module BABYLON {
  40944. /**
  40945. * Defines supported buttons for XBox360 compatible gamepads
  40946. */
  40947. export enum Xbox360Button {
  40948. /** A */
  40949. A = 0,
  40950. /** B */
  40951. B = 1,
  40952. /** X */
  40953. X = 2,
  40954. /** Y */
  40955. Y = 3,
  40956. /** Start */
  40957. Start = 4,
  40958. /** Back */
  40959. Back = 5,
  40960. /** Left button */
  40961. LB = 6,
  40962. /** Right button */
  40963. RB = 7,
  40964. /** Left stick */
  40965. LeftStick = 8,
  40966. /** Right stick */
  40967. RightStick = 9
  40968. }
  40969. /** Defines values for XBox360 DPad */
  40970. export enum Xbox360Dpad {
  40971. /** Up */
  40972. Up = 0,
  40973. /** Down */
  40974. Down = 1,
  40975. /** Left */
  40976. Left = 2,
  40977. /** Right */
  40978. Right = 3
  40979. }
  40980. /**
  40981. * Defines a XBox360 gamepad
  40982. */
  40983. export class Xbox360Pad extends Gamepad {
  40984. private _leftTrigger;
  40985. private _rightTrigger;
  40986. private _onlefttriggerchanged;
  40987. private _onrighttriggerchanged;
  40988. private _onbuttondown;
  40989. private _onbuttonup;
  40990. private _ondpaddown;
  40991. private _ondpadup;
  40992. /** Observable raised when a button is pressed */
  40993. onButtonDownObservable: Observable<Xbox360Button>;
  40994. /** Observable raised when a button is released */
  40995. onButtonUpObservable: Observable<Xbox360Button>;
  40996. /** Observable raised when a pad is pressed */
  40997. onPadDownObservable: Observable<Xbox360Dpad>;
  40998. /** Observable raised when a pad is released */
  40999. onPadUpObservable: Observable<Xbox360Dpad>;
  41000. private _buttonA;
  41001. private _buttonB;
  41002. private _buttonX;
  41003. private _buttonY;
  41004. private _buttonBack;
  41005. private _buttonStart;
  41006. private _buttonLB;
  41007. private _buttonRB;
  41008. private _buttonLeftStick;
  41009. private _buttonRightStick;
  41010. private _dPadUp;
  41011. private _dPadDown;
  41012. private _dPadLeft;
  41013. private _dPadRight;
  41014. private _isXboxOnePad;
  41015. /**
  41016. * Creates a new XBox360 gamepad object
  41017. * @param id defines the id of this gamepad
  41018. * @param index defines its index
  41019. * @param gamepad defines the internal HTML gamepad object
  41020. * @param xboxOne defines if it is a XBox One gamepad
  41021. */
  41022. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  41023. /**
  41024. * Defines the callback to call when left trigger is pressed
  41025. * @param callback defines the callback to use
  41026. */
  41027. onlefttriggerchanged(callback: (value: number) => void): void;
  41028. /**
  41029. * Defines the callback to call when right trigger is pressed
  41030. * @param callback defines the callback to use
  41031. */
  41032. onrighttriggerchanged(callback: (value: number) => void): void;
  41033. /**
  41034. * Gets the left trigger value
  41035. */
  41036. get leftTrigger(): number;
  41037. /**
  41038. * Sets the left trigger value
  41039. */
  41040. set leftTrigger(newValue: number);
  41041. /**
  41042. * Gets the right trigger value
  41043. */
  41044. get rightTrigger(): number;
  41045. /**
  41046. * Sets the right trigger value
  41047. */
  41048. set rightTrigger(newValue: number);
  41049. /**
  41050. * Defines the callback to call when a button is pressed
  41051. * @param callback defines the callback to use
  41052. */
  41053. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  41054. /**
  41055. * Defines the callback to call when a button is released
  41056. * @param callback defines the callback to use
  41057. */
  41058. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  41059. /**
  41060. * Defines the callback to call when a pad is pressed
  41061. * @param callback defines the callback to use
  41062. */
  41063. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  41064. /**
  41065. * Defines the callback to call when a pad is released
  41066. * @param callback defines the callback to use
  41067. */
  41068. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  41069. private _setButtonValue;
  41070. private _setDPadValue;
  41071. /**
  41072. * Gets the value of the `A` button
  41073. */
  41074. get buttonA(): number;
  41075. /**
  41076. * Sets the value of the `A` button
  41077. */
  41078. set buttonA(value: number);
  41079. /**
  41080. * Gets the value of the `B` button
  41081. */
  41082. get buttonB(): number;
  41083. /**
  41084. * Sets the value of the `B` button
  41085. */
  41086. set buttonB(value: number);
  41087. /**
  41088. * Gets the value of the `X` button
  41089. */
  41090. get buttonX(): number;
  41091. /**
  41092. * Sets the value of the `X` button
  41093. */
  41094. set buttonX(value: number);
  41095. /**
  41096. * Gets the value of the `Y` button
  41097. */
  41098. get buttonY(): number;
  41099. /**
  41100. * Sets the value of the `Y` button
  41101. */
  41102. set buttonY(value: number);
  41103. /**
  41104. * Gets the value of the `Start` button
  41105. */
  41106. get buttonStart(): number;
  41107. /**
  41108. * Sets the value of the `Start` button
  41109. */
  41110. set buttonStart(value: number);
  41111. /**
  41112. * Gets the value of the `Back` button
  41113. */
  41114. get buttonBack(): number;
  41115. /**
  41116. * Sets the value of the `Back` button
  41117. */
  41118. set buttonBack(value: number);
  41119. /**
  41120. * Gets the value of the `Left` button
  41121. */
  41122. get buttonLB(): number;
  41123. /**
  41124. * Sets the value of the `Left` button
  41125. */
  41126. set buttonLB(value: number);
  41127. /**
  41128. * Gets the value of the `Right` button
  41129. */
  41130. get buttonRB(): number;
  41131. /**
  41132. * Sets the value of the `Right` button
  41133. */
  41134. set buttonRB(value: number);
  41135. /**
  41136. * Gets the value of the Left joystick
  41137. */
  41138. get buttonLeftStick(): number;
  41139. /**
  41140. * Sets the value of the Left joystick
  41141. */
  41142. set buttonLeftStick(value: number);
  41143. /**
  41144. * Gets the value of the Right joystick
  41145. */
  41146. get buttonRightStick(): number;
  41147. /**
  41148. * Sets the value of the Right joystick
  41149. */
  41150. set buttonRightStick(value: number);
  41151. /**
  41152. * Gets the value of D-pad up
  41153. */
  41154. get dPadUp(): number;
  41155. /**
  41156. * Sets the value of D-pad up
  41157. */
  41158. set dPadUp(value: number);
  41159. /**
  41160. * Gets the value of D-pad down
  41161. */
  41162. get dPadDown(): number;
  41163. /**
  41164. * Sets the value of D-pad down
  41165. */
  41166. set dPadDown(value: number);
  41167. /**
  41168. * Gets the value of D-pad left
  41169. */
  41170. get dPadLeft(): number;
  41171. /**
  41172. * Sets the value of D-pad left
  41173. */
  41174. set dPadLeft(value: number);
  41175. /**
  41176. * Gets the value of D-pad right
  41177. */
  41178. get dPadRight(): number;
  41179. /**
  41180. * Sets the value of D-pad right
  41181. */
  41182. set dPadRight(value: number);
  41183. /**
  41184. * Force the gamepad to synchronize with device values
  41185. */
  41186. update(): void;
  41187. /**
  41188. * Disposes the gamepad
  41189. */
  41190. dispose(): void;
  41191. }
  41192. }
  41193. declare module BABYLON {
  41194. /**
  41195. * Defines supported buttons for DualShock compatible gamepads
  41196. */
  41197. export enum DualShockButton {
  41198. /** Cross */
  41199. Cross = 0,
  41200. /** Circle */
  41201. Circle = 1,
  41202. /** Square */
  41203. Square = 2,
  41204. /** Triangle */
  41205. Triangle = 3,
  41206. /** Options */
  41207. Options = 4,
  41208. /** Share */
  41209. Share = 5,
  41210. /** L1 */
  41211. L1 = 6,
  41212. /** R1 */
  41213. R1 = 7,
  41214. /** Left stick */
  41215. LeftStick = 8,
  41216. /** Right stick */
  41217. RightStick = 9
  41218. }
  41219. /** Defines values for DualShock DPad */
  41220. export enum DualShockDpad {
  41221. /** Up */
  41222. Up = 0,
  41223. /** Down */
  41224. Down = 1,
  41225. /** Left */
  41226. Left = 2,
  41227. /** Right */
  41228. Right = 3
  41229. }
  41230. /**
  41231. * Defines a DualShock gamepad
  41232. */
  41233. export class DualShockPad extends Gamepad {
  41234. private _leftTrigger;
  41235. private _rightTrigger;
  41236. private _onlefttriggerchanged;
  41237. private _onrighttriggerchanged;
  41238. private _onbuttondown;
  41239. private _onbuttonup;
  41240. private _ondpaddown;
  41241. private _ondpadup;
  41242. /** Observable raised when a button is pressed */
  41243. onButtonDownObservable: Observable<DualShockButton>;
  41244. /** Observable raised when a button is released */
  41245. onButtonUpObservable: Observable<DualShockButton>;
  41246. /** Observable raised when a pad is pressed */
  41247. onPadDownObservable: Observable<DualShockDpad>;
  41248. /** Observable raised when a pad is released */
  41249. onPadUpObservable: Observable<DualShockDpad>;
  41250. private _buttonCross;
  41251. private _buttonCircle;
  41252. private _buttonSquare;
  41253. private _buttonTriangle;
  41254. private _buttonShare;
  41255. private _buttonOptions;
  41256. private _buttonL1;
  41257. private _buttonR1;
  41258. private _buttonLeftStick;
  41259. private _buttonRightStick;
  41260. private _dPadUp;
  41261. private _dPadDown;
  41262. private _dPadLeft;
  41263. private _dPadRight;
  41264. /**
  41265. * Creates a new DualShock gamepad object
  41266. * @param id defines the id of this gamepad
  41267. * @param index defines its index
  41268. * @param gamepad defines the internal HTML gamepad object
  41269. */
  41270. constructor(id: string, index: number, gamepad: any);
  41271. /**
  41272. * Defines the callback to call when left trigger is pressed
  41273. * @param callback defines the callback to use
  41274. */
  41275. onlefttriggerchanged(callback: (value: number) => void): void;
  41276. /**
  41277. * Defines the callback to call when right trigger is pressed
  41278. * @param callback defines the callback to use
  41279. */
  41280. onrighttriggerchanged(callback: (value: number) => void): void;
  41281. /**
  41282. * Gets the left trigger value
  41283. */
  41284. get leftTrigger(): number;
  41285. /**
  41286. * Sets the left trigger value
  41287. */
  41288. set leftTrigger(newValue: number);
  41289. /**
  41290. * Gets the right trigger value
  41291. */
  41292. get rightTrigger(): number;
  41293. /**
  41294. * Sets the right trigger value
  41295. */
  41296. set rightTrigger(newValue: number);
  41297. /**
  41298. * Defines the callback to call when a button is pressed
  41299. * @param callback defines the callback to use
  41300. */
  41301. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  41302. /**
  41303. * Defines the callback to call when a button is released
  41304. * @param callback defines the callback to use
  41305. */
  41306. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  41307. /**
  41308. * Defines the callback to call when a pad is pressed
  41309. * @param callback defines the callback to use
  41310. */
  41311. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  41312. /**
  41313. * Defines the callback to call when a pad is released
  41314. * @param callback defines the callback to use
  41315. */
  41316. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  41317. private _setButtonValue;
  41318. private _setDPadValue;
  41319. /**
  41320. * Gets the value of the `Cross` button
  41321. */
  41322. get buttonCross(): number;
  41323. /**
  41324. * Sets the value of the `Cross` button
  41325. */
  41326. set buttonCross(value: number);
  41327. /**
  41328. * Gets the value of the `Circle` button
  41329. */
  41330. get buttonCircle(): number;
  41331. /**
  41332. * Sets the value of the `Circle` button
  41333. */
  41334. set buttonCircle(value: number);
  41335. /**
  41336. * Gets the value of the `Square` button
  41337. */
  41338. get buttonSquare(): number;
  41339. /**
  41340. * Sets the value of the `Square` button
  41341. */
  41342. set buttonSquare(value: number);
  41343. /**
  41344. * Gets the value of the `Triangle` button
  41345. */
  41346. get buttonTriangle(): number;
  41347. /**
  41348. * Sets the value of the `Triangle` button
  41349. */
  41350. set buttonTriangle(value: number);
  41351. /**
  41352. * Gets the value of the `Options` button
  41353. */
  41354. get buttonOptions(): number;
  41355. /**
  41356. * Sets the value of the `Options` button
  41357. */
  41358. set buttonOptions(value: number);
  41359. /**
  41360. * Gets the value of the `Share` button
  41361. */
  41362. get buttonShare(): number;
  41363. /**
  41364. * Sets the value of the `Share` button
  41365. */
  41366. set buttonShare(value: number);
  41367. /**
  41368. * Gets the value of the `L1` button
  41369. */
  41370. get buttonL1(): number;
  41371. /**
  41372. * Sets the value of the `L1` button
  41373. */
  41374. set buttonL1(value: number);
  41375. /**
  41376. * Gets the value of the `R1` button
  41377. */
  41378. get buttonR1(): number;
  41379. /**
  41380. * Sets the value of the `R1` button
  41381. */
  41382. set buttonR1(value: number);
  41383. /**
  41384. * Gets the value of the Left joystick
  41385. */
  41386. get buttonLeftStick(): number;
  41387. /**
  41388. * Sets the value of the Left joystick
  41389. */
  41390. set buttonLeftStick(value: number);
  41391. /**
  41392. * Gets the value of the Right joystick
  41393. */
  41394. get buttonRightStick(): number;
  41395. /**
  41396. * Sets the value of the Right joystick
  41397. */
  41398. set buttonRightStick(value: number);
  41399. /**
  41400. * Gets the value of D-pad up
  41401. */
  41402. get dPadUp(): number;
  41403. /**
  41404. * Sets the value of D-pad up
  41405. */
  41406. set dPadUp(value: number);
  41407. /**
  41408. * Gets the value of D-pad down
  41409. */
  41410. get dPadDown(): number;
  41411. /**
  41412. * Sets the value of D-pad down
  41413. */
  41414. set dPadDown(value: number);
  41415. /**
  41416. * Gets the value of D-pad left
  41417. */
  41418. get dPadLeft(): number;
  41419. /**
  41420. * Sets the value of D-pad left
  41421. */
  41422. set dPadLeft(value: number);
  41423. /**
  41424. * Gets the value of D-pad right
  41425. */
  41426. get dPadRight(): number;
  41427. /**
  41428. * Sets the value of D-pad right
  41429. */
  41430. set dPadRight(value: number);
  41431. /**
  41432. * Force the gamepad to synchronize with device values
  41433. */
  41434. update(): void;
  41435. /**
  41436. * Disposes the gamepad
  41437. */
  41438. dispose(): void;
  41439. }
  41440. }
  41441. declare module BABYLON {
  41442. /**
  41443. * Manager for handling gamepads
  41444. */
  41445. export class GamepadManager {
  41446. private _scene?;
  41447. private _babylonGamepads;
  41448. private _oneGamepadConnected;
  41449. /** @hidden */
  41450. _isMonitoring: boolean;
  41451. private _gamepadEventSupported;
  41452. private _gamepadSupport?;
  41453. /**
  41454. * observable to be triggered when the gamepad controller has been connected
  41455. */
  41456. onGamepadConnectedObservable: Observable<Gamepad>;
  41457. /**
  41458. * observable to be triggered when the gamepad controller has been disconnected
  41459. */
  41460. onGamepadDisconnectedObservable: Observable<Gamepad>;
  41461. private _onGamepadConnectedEvent;
  41462. private _onGamepadDisconnectedEvent;
  41463. /**
  41464. * Initializes the gamepad manager
  41465. * @param _scene BabylonJS scene
  41466. */
  41467. constructor(_scene?: Scene | undefined);
  41468. /**
  41469. * The gamepads in the game pad manager
  41470. */
  41471. get gamepads(): Gamepad[];
  41472. /**
  41473. * Get the gamepad controllers based on type
  41474. * @param type The type of gamepad controller
  41475. * @returns Nullable gamepad
  41476. */
  41477. getGamepadByType(type?: number): Nullable<Gamepad>;
  41478. /**
  41479. * Disposes the gamepad manager
  41480. */
  41481. dispose(): void;
  41482. private _addNewGamepad;
  41483. private _startMonitoringGamepads;
  41484. private _stopMonitoringGamepads;
  41485. /** @hidden */
  41486. _checkGamepadsStatus(): void;
  41487. private _updateGamepadObjects;
  41488. }
  41489. }
  41490. declare module BABYLON {
  41491. interface Scene {
  41492. /** @hidden */
  41493. _gamepadManager: Nullable<GamepadManager>;
  41494. /**
  41495. * Gets the gamepad manager associated with the scene
  41496. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  41497. */
  41498. gamepadManager: GamepadManager;
  41499. }
  41500. /**
  41501. * Interface representing a free camera inputs manager
  41502. */
  41503. interface FreeCameraInputsManager {
  41504. /**
  41505. * Adds gamepad input support to the FreeCameraInputsManager.
  41506. * @returns the FreeCameraInputsManager
  41507. */
  41508. addGamepad(): FreeCameraInputsManager;
  41509. }
  41510. /**
  41511. * Interface representing an arc rotate camera inputs manager
  41512. */
  41513. interface ArcRotateCameraInputsManager {
  41514. /**
  41515. * Adds gamepad input support to the ArcRotateCamera InputManager.
  41516. * @returns the camera inputs manager
  41517. */
  41518. addGamepad(): ArcRotateCameraInputsManager;
  41519. }
  41520. /**
  41521. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  41522. */
  41523. export class GamepadSystemSceneComponent implements ISceneComponent {
  41524. /**
  41525. * The component name helpfull to identify the component in the list of scene components.
  41526. */
  41527. readonly name: string;
  41528. /**
  41529. * The scene the component belongs to.
  41530. */
  41531. scene: Scene;
  41532. /**
  41533. * Creates a new instance of the component for the given scene
  41534. * @param scene Defines the scene to register the component in
  41535. */
  41536. constructor(scene: Scene);
  41537. /**
  41538. * Registers the component in a given scene
  41539. */
  41540. register(): void;
  41541. /**
  41542. * Rebuilds the elements related to this component in case of
  41543. * context lost for instance.
  41544. */
  41545. rebuild(): void;
  41546. /**
  41547. * Disposes the component and the associated ressources
  41548. */
  41549. dispose(): void;
  41550. private _beforeCameraUpdate;
  41551. }
  41552. }
  41553. declare module BABYLON {
  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. */
  41559. export class UniversalCamera extends TouchCamera {
  41560. /**
  41561. * Defines the gamepad rotation sensiblity.
  41562. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  41563. */
  41564. get gamepadAngularSensibility(): number;
  41565. set gamepadAngularSensibility(value: number);
  41566. /**
  41567. * Defines the gamepad move sensiblity.
  41568. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  41569. */
  41570. get gamepadMoveSensibility(): number;
  41571. set gamepadMoveSensibility(value: number);
  41572. /**
  41573. * 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,
  41574. * which still works and will still be found in many Playgrounds.
  41575. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41576. * @param name Define the name of the camera in the scene
  41577. * @param position Define the start position of the camera in the scene
  41578. * @param scene Define the scene the camera belongs to
  41579. */
  41580. constructor(name: string, position: Vector3, scene: Scene);
  41581. /**
  41582. * Gets the current object class name.
  41583. * @return the class name
  41584. */
  41585. getClassName(): string;
  41586. }
  41587. }
  41588. declare module BABYLON {
  41589. /**
  41590. * This represents a FPS type of camera. This is only here for back compat purpose.
  41591. * Please use the UniversalCamera instead as both are identical.
  41592. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41593. */
  41594. export class GamepadCamera extends UniversalCamera {
  41595. /**
  41596. * Instantiates a new Gamepad Camera
  41597. * This represents a FPS type of camera. This is only here for back compat purpose.
  41598. * Please use the UniversalCamera instead as both are identical.
  41599. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41600. * @param name Define the name of the camera in the scene
  41601. * @param position Define the start position of the camera in the scene
  41602. * @param scene Define the scene the camera belongs to
  41603. */
  41604. constructor(name: string, position: Vector3, scene: Scene);
  41605. /**
  41606. * Gets the current object class name.
  41607. * @return the class name
  41608. */
  41609. getClassName(): string;
  41610. }
  41611. }
  41612. declare module BABYLON {
  41613. /** @hidden */
  41614. export var passPixelShader: {
  41615. name: string;
  41616. shader: string;
  41617. };
  41618. }
  41619. declare module BABYLON {
  41620. /** @hidden */
  41621. export var passCubePixelShader: {
  41622. name: string;
  41623. shader: string;
  41624. };
  41625. }
  41626. declare module BABYLON {
  41627. /**
  41628. * PassPostProcess which produces an output the same as it's input
  41629. */
  41630. export class PassPostProcess extends PostProcess {
  41631. /**
  41632. * Creates the PassPostProcess
  41633. * @param name The name of the effect.
  41634. * @param options The required width/height ratio to downsize to before computing the render pass.
  41635. * @param camera The camera to apply the render pass to.
  41636. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  41637. * @param engine The engine which the post process will be applied. (default: current engine)
  41638. * @param reusable If the post process can be reused on the same frame. (default: false)
  41639. * @param textureType The type of texture to be used when performing the post processing.
  41640. * @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)
  41641. */
  41642. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  41643. }
  41644. /**
  41645. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  41646. */
  41647. export class PassCubePostProcess extends PostProcess {
  41648. private _face;
  41649. /**
  41650. * Gets or sets the cube face to display.
  41651. * * 0 is +X
  41652. * * 1 is -X
  41653. * * 2 is +Y
  41654. * * 3 is -Y
  41655. * * 4 is +Z
  41656. * * 5 is -Z
  41657. */
  41658. get face(): number;
  41659. set face(value: number);
  41660. /**
  41661. * Creates the PassCubePostProcess
  41662. * @param name The name of the effect.
  41663. * @param options The required width/height ratio to downsize to before computing the render pass.
  41664. * @param camera The camera to apply the render pass to.
  41665. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  41666. * @param engine The engine which the post process will be applied. (default: current engine)
  41667. * @param reusable If the post process can be reused on the same frame. (default: false)
  41668. * @param textureType The type of texture to be used when performing the post processing.
  41669. * @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)
  41670. */
  41671. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  41672. }
  41673. }
  41674. declare module BABYLON {
  41675. /** @hidden */
  41676. export var anaglyphPixelShader: {
  41677. name: string;
  41678. shader: string;
  41679. };
  41680. }
  41681. declare module BABYLON {
  41682. /**
  41683. * Postprocess used to generate anaglyphic rendering
  41684. */
  41685. export class AnaglyphPostProcess extends PostProcess {
  41686. private _passedProcess;
  41687. /**
  41688. * Creates a new AnaglyphPostProcess
  41689. * @param name defines postprocess name
  41690. * @param options defines creation options or target ratio scale
  41691. * @param rigCameras defines cameras using this postprocess
  41692. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  41693. * @param engine defines hosting engine
  41694. * @param reusable defines if the postprocess will be reused multiple times per frame
  41695. */
  41696. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  41697. }
  41698. }
  41699. declare module BABYLON {
  41700. /**
  41701. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  41702. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41703. */
  41704. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  41705. /**
  41706. * Creates a new AnaglyphArcRotateCamera
  41707. * @param name defines camera name
  41708. * @param alpha defines alpha angle (in radians)
  41709. * @param beta defines beta angle (in radians)
  41710. * @param radius defines radius
  41711. * @param target defines camera target
  41712. * @param interaxialDistance defines distance between each color axis
  41713. * @param scene defines the hosting scene
  41714. */
  41715. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  41716. /**
  41717. * Gets camera class name
  41718. * @returns AnaglyphArcRotateCamera
  41719. */
  41720. getClassName(): string;
  41721. }
  41722. }
  41723. declare module BABYLON {
  41724. /**
  41725. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  41726. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41727. */
  41728. export class AnaglyphFreeCamera extends FreeCamera {
  41729. /**
  41730. * Creates a new AnaglyphFreeCamera
  41731. * @param name defines camera name
  41732. * @param position defines initial position
  41733. * @param interaxialDistance defines distance between each color axis
  41734. * @param scene defines the hosting scene
  41735. */
  41736. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  41737. /**
  41738. * Gets camera class name
  41739. * @returns AnaglyphFreeCamera
  41740. */
  41741. getClassName(): string;
  41742. }
  41743. }
  41744. declare module BABYLON {
  41745. /**
  41746. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  41747. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41748. */
  41749. export class AnaglyphGamepadCamera extends GamepadCamera {
  41750. /**
  41751. * Creates a new AnaglyphGamepadCamera
  41752. * @param name defines camera name
  41753. * @param position defines initial position
  41754. * @param interaxialDistance defines distance between each color axis
  41755. * @param scene defines the hosting scene
  41756. */
  41757. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  41758. /**
  41759. * Gets camera class name
  41760. * @returns AnaglyphGamepadCamera
  41761. */
  41762. getClassName(): string;
  41763. }
  41764. }
  41765. declare module BABYLON {
  41766. /**
  41767. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  41768. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41769. */
  41770. export class AnaglyphUniversalCamera extends UniversalCamera {
  41771. /**
  41772. * Creates a new AnaglyphUniversalCamera
  41773. * @param name defines camera name
  41774. * @param position defines initial position
  41775. * @param interaxialDistance defines distance between each color axis
  41776. * @param scene defines the hosting scene
  41777. */
  41778. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  41779. /**
  41780. * Gets camera class name
  41781. * @returns AnaglyphUniversalCamera
  41782. */
  41783. getClassName(): string;
  41784. }
  41785. }
  41786. declare module BABYLON {
  41787. /** @hidden */
  41788. export var stereoscopicInterlacePixelShader: {
  41789. name: string;
  41790. shader: string;
  41791. };
  41792. }
  41793. declare module BABYLON {
  41794. /**
  41795. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  41796. */
  41797. export class StereoscopicInterlacePostProcessI extends PostProcess {
  41798. private _stepSize;
  41799. private _passedProcess;
  41800. /**
  41801. * Initializes a StereoscopicInterlacePostProcessI
  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 vertical
  41805. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  41806. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  41807. * @param engine The engine which the post process will be applied. (default: current engine)
  41808. * @param reusable If the post process can be reused on the same frame. (default: false)
  41809. */
  41810. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  41811. }
  41812. /**
  41813. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  41814. */
  41815. export class StereoscopicInterlacePostProcess extends PostProcess {
  41816. private _stepSize;
  41817. private _passedProcess;
  41818. /**
  41819. * Initializes a StereoscopicInterlacePostProcess
  41820. * @param name The name of the effect.
  41821. * @param rigCameras The rig cameras to be appled to the post process
  41822. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  41823. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  41824. * @param engine The engine which the post process will be applied. (default: current engine)
  41825. * @param reusable If the post process can be reused on the same frame. (default: false)
  41826. */
  41827. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  41828. }
  41829. }
  41830. declare module BABYLON {
  41831. /**
  41832. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  41833. * @see http://doc.babylonjs.com/features/cameras
  41834. */
  41835. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  41836. /**
  41837. * Creates a new StereoscopicArcRotateCamera
  41838. * @param name defines camera name
  41839. * @param alpha defines alpha angle (in radians)
  41840. * @param beta defines beta angle (in radians)
  41841. * @param radius defines radius
  41842. * @param target defines camera target
  41843. * @param interaxialDistance defines distance between each color axis
  41844. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41845. * @param scene defines the hosting scene
  41846. */
  41847. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41848. /**
  41849. * Gets camera class name
  41850. * @returns StereoscopicArcRotateCamera
  41851. */
  41852. getClassName(): string;
  41853. }
  41854. }
  41855. declare module BABYLON {
  41856. /**
  41857. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  41858. * @see http://doc.babylonjs.com/features/cameras
  41859. */
  41860. export class StereoscopicFreeCamera extends FreeCamera {
  41861. /**
  41862. * Creates a new StereoscopicFreeCamera
  41863. * @param name defines camera name
  41864. * @param position defines initial position
  41865. * @param interaxialDistance defines distance between each color axis
  41866. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41867. * @param scene defines the hosting scene
  41868. */
  41869. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41870. /**
  41871. * Gets camera class name
  41872. * @returns StereoscopicFreeCamera
  41873. */
  41874. getClassName(): string;
  41875. }
  41876. }
  41877. declare module BABYLON {
  41878. /**
  41879. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  41880. * @see http://doc.babylonjs.com/features/cameras
  41881. */
  41882. export class StereoscopicGamepadCamera extends GamepadCamera {
  41883. /**
  41884. * Creates a new StereoscopicGamepadCamera
  41885. * @param name defines camera name
  41886. * @param position defines initial position
  41887. * @param interaxialDistance defines distance between each color axis
  41888. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41889. * @param scene defines the hosting scene
  41890. */
  41891. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41892. /**
  41893. * Gets camera class name
  41894. * @returns StereoscopicGamepadCamera
  41895. */
  41896. getClassName(): string;
  41897. }
  41898. }
  41899. declare module BABYLON {
  41900. /**
  41901. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  41902. * @see http://doc.babylonjs.com/features/cameras
  41903. */
  41904. export class StereoscopicUniversalCamera extends UniversalCamera {
  41905. /**
  41906. * Creates a new StereoscopicUniversalCamera
  41907. * @param name defines camera name
  41908. * @param position defines initial position
  41909. * @param interaxialDistance defines distance between each color axis
  41910. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41911. * @param scene defines the hosting scene
  41912. */
  41913. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41914. /**
  41915. * Gets camera class name
  41916. * @returns StereoscopicUniversalCamera
  41917. */
  41918. getClassName(): string;
  41919. }
  41920. }
  41921. declare module BABYLON {
  41922. /**
  41923. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  41924. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  41925. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  41926. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  41927. */
  41928. export class VirtualJoysticksCamera extends FreeCamera {
  41929. /**
  41930. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  41931. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  41932. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  41933. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  41934. * @param name Define the name of the camera in the scene
  41935. * @param position Define the start position of the camera in the scene
  41936. * @param scene Define the scene the camera belongs to
  41937. */
  41938. constructor(name: string, position: Vector3, scene: Scene);
  41939. /**
  41940. * Gets the current object class name.
  41941. * @return the class name
  41942. */
  41943. getClassName(): string;
  41944. }
  41945. }
  41946. declare module BABYLON {
  41947. /**
  41948. * This represents all the required metrics to create a VR camera.
  41949. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  41950. */
  41951. export class VRCameraMetrics {
  41952. /**
  41953. * Define the horizontal resolution off the screen.
  41954. */
  41955. hResolution: number;
  41956. /**
  41957. * Define the vertical resolution off the screen.
  41958. */
  41959. vResolution: number;
  41960. /**
  41961. * Define the horizontal screen size.
  41962. */
  41963. hScreenSize: number;
  41964. /**
  41965. * Define the vertical screen size.
  41966. */
  41967. vScreenSize: number;
  41968. /**
  41969. * Define the vertical screen center position.
  41970. */
  41971. vScreenCenter: number;
  41972. /**
  41973. * Define the distance of the eyes to the screen.
  41974. */
  41975. eyeToScreenDistance: number;
  41976. /**
  41977. * Define the distance between both lenses
  41978. */
  41979. lensSeparationDistance: number;
  41980. /**
  41981. * Define the distance between both viewer's eyes.
  41982. */
  41983. interpupillaryDistance: number;
  41984. /**
  41985. * Define the distortion factor of the VR postprocess.
  41986. * Please, touch with care.
  41987. */
  41988. distortionK: number[];
  41989. /**
  41990. * Define the chromatic aberration correction factors for the VR post process.
  41991. */
  41992. chromaAbCorrection: number[];
  41993. /**
  41994. * Define the scale factor of the post process.
  41995. * The smaller the better but the slower.
  41996. */
  41997. postProcessScaleFactor: number;
  41998. /**
  41999. * Define an offset for the lens center.
  42000. */
  42001. lensCenterOffset: number;
  42002. /**
  42003. * Define if the current vr camera should compensate the distortion of the lense or not.
  42004. */
  42005. compensateDistortion: boolean;
  42006. /**
  42007. * Defines if multiview should be enabled when rendering (Default: false)
  42008. */
  42009. multiviewEnabled: boolean;
  42010. /**
  42011. * Gets the rendering aspect ratio based on the provided resolutions.
  42012. */
  42013. get aspectRatio(): number;
  42014. /**
  42015. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  42016. */
  42017. get aspectRatioFov(): number;
  42018. /**
  42019. * @hidden
  42020. */
  42021. get leftHMatrix(): Matrix;
  42022. /**
  42023. * @hidden
  42024. */
  42025. get rightHMatrix(): Matrix;
  42026. /**
  42027. * @hidden
  42028. */
  42029. get leftPreViewMatrix(): Matrix;
  42030. /**
  42031. * @hidden
  42032. */
  42033. get rightPreViewMatrix(): Matrix;
  42034. /**
  42035. * Get the default VRMetrics based on the most generic setup.
  42036. * @returns the default vr metrics
  42037. */
  42038. static GetDefault(): VRCameraMetrics;
  42039. }
  42040. }
  42041. declare module BABYLON {
  42042. /** @hidden */
  42043. export var vrDistortionCorrectionPixelShader: {
  42044. name: string;
  42045. shader: string;
  42046. };
  42047. }
  42048. declare module BABYLON {
  42049. /**
  42050. * VRDistortionCorrectionPostProcess used for mobile VR
  42051. */
  42052. export class VRDistortionCorrectionPostProcess extends PostProcess {
  42053. private _isRightEye;
  42054. private _distortionFactors;
  42055. private _postProcessScaleFactor;
  42056. private _lensCenterOffset;
  42057. private _scaleIn;
  42058. private _scaleFactor;
  42059. private _lensCenter;
  42060. /**
  42061. * Initializes the VRDistortionCorrectionPostProcess
  42062. * @param name The name of the effect.
  42063. * @param camera The camera to apply the render pass to.
  42064. * @param isRightEye If this is for the right eye distortion
  42065. * @param vrMetrics All the required metrics for the VR camera
  42066. */
  42067. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  42068. }
  42069. }
  42070. declare module BABYLON {
  42071. /**
  42072. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  42073. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  42074. */
  42075. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  42076. /**
  42077. * Creates a new VRDeviceOrientationArcRotateCamera
  42078. * @param name defines camera name
  42079. * @param alpha defines the camera rotation along the logitudinal axis
  42080. * @param beta defines the camera rotation along the latitudinal axis
  42081. * @param radius defines the camera distance from its target
  42082. * @param target defines the camera target
  42083. * @param scene defines the scene the camera belongs to
  42084. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  42085. * @param vrCameraMetrics defines the vr metrics associated to the camera
  42086. */
  42087. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  42088. /**
  42089. * Gets camera class name
  42090. * @returns VRDeviceOrientationArcRotateCamera
  42091. */
  42092. getClassName(): string;
  42093. }
  42094. }
  42095. declare module BABYLON {
  42096. /**
  42097. * Camera used to simulate VR rendering (based on FreeCamera)
  42098. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  42099. */
  42100. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  42101. /**
  42102. * Creates a new VRDeviceOrientationFreeCamera
  42103. * @param name defines camera name
  42104. * @param position defines the start position of the camera
  42105. * @param scene defines the scene the camera belongs to
  42106. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  42107. * @param vrCameraMetrics defines the vr metrics associated to the camera
  42108. */
  42109. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  42110. /**
  42111. * Gets camera class name
  42112. * @returns VRDeviceOrientationFreeCamera
  42113. */
  42114. getClassName(): string;
  42115. }
  42116. }
  42117. declare module BABYLON {
  42118. /**
  42119. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  42120. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  42121. */
  42122. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  42123. /**
  42124. * Creates a new VRDeviceOrientationGamepadCamera
  42125. * @param name defines camera name
  42126. * @param position defines the start position of the camera
  42127. * @param scene defines the scene the camera belongs to
  42128. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  42129. * @param vrCameraMetrics defines the vr metrics associated to the camera
  42130. */
  42131. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  42132. /**
  42133. * Gets camera class name
  42134. * @returns VRDeviceOrientationGamepadCamera
  42135. */
  42136. getClassName(): string;
  42137. }
  42138. }
  42139. declare module BABYLON {
  42140. /** @hidden */
  42141. export var imageProcessingPixelShader: {
  42142. name: string;
  42143. shader: string;
  42144. };
  42145. }
  42146. declare module BABYLON {
  42147. /**
  42148. * ImageProcessingPostProcess
  42149. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  42150. */
  42151. export class ImageProcessingPostProcess extends PostProcess {
  42152. /**
  42153. * Default configuration related to image processing available in the PBR Material.
  42154. */
  42155. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  42156. /**
  42157. * Gets the image processing configuration used either in this material.
  42158. */
  42159. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  42160. /**
  42161. * Sets the Default image processing configuration used either in the this material.
  42162. *
  42163. * If sets to null, the scene one is in use.
  42164. */
  42165. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  42166. /**
  42167. * Keep track of the image processing observer to allow dispose and replace.
  42168. */
  42169. private _imageProcessingObserver;
  42170. /**
  42171. * Attaches a new image processing configuration to the PBR Material.
  42172. * @param configuration
  42173. */
  42174. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  42175. /**
  42176. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  42177. */
  42178. get colorCurves(): Nullable<ColorCurves>;
  42179. /**
  42180. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  42181. */
  42182. set colorCurves(value: Nullable<ColorCurves>);
  42183. /**
  42184. * Gets wether the color curves effect is enabled.
  42185. */
  42186. get colorCurvesEnabled(): boolean;
  42187. /**
  42188. * Sets wether the color curves effect is enabled.
  42189. */
  42190. set colorCurvesEnabled(value: boolean);
  42191. /**
  42192. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  42193. */
  42194. get colorGradingTexture(): Nullable<BaseTexture>;
  42195. /**
  42196. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  42197. */
  42198. set colorGradingTexture(value: Nullable<BaseTexture>);
  42199. /**
  42200. * Gets wether the color grading effect is enabled.
  42201. */
  42202. get colorGradingEnabled(): boolean;
  42203. /**
  42204. * Gets wether the color grading effect is enabled.
  42205. */
  42206. set colorGradingEnabled(value: boolean);
  42207. /**
  42208. * Gets exposure used in the effect.
  42209. */
  42210. get exposure(): number;
  42211. /**
  42212. * Sets exposure used in the effect.
  42213. */
  42214. set exposure(value: number);
  42215. /**
  42216. * Gets wether tonemapping is enabled or not.
  42217. */
  42218. get toneMappingEnabled(): boolean;
  42219. /**
  42220. * Sets wether tonemapping is enabled or not
  42221. */
  42222. set toneMappingEnabled(value: boolean);
  42223. /**
  42224. * Gets the type of tone mapping effect.
  42225. */
  42226. get toneMappingType(): number;
  42227. /**
  42228. * Sets the type of tone mapping effect.
  42229. */
  42230. set toneMappingType(value: number);
  42231. /**
  42232. * Gets contrast used in the effect.
  42233. */
  42234. get contrast(): number;
  42235. /**
  42236. * Sets contrast used in the effect.
  42237. */
  42238. set contrast(value: number);
  42239. /**
  42240. * Gets Vignette stretch size.
  42241. */
  42242. get vignetteStretch(): number;
  42243. /**
  42244. * Sets Vignette stretch size.
  42245. */
  42246. set vignetteStretch(value: number);
  42247. /**
  42248. * Gets Vignette centre X Offset.
  42249. */
  42250. get vignetteCentreX(): number;
  42251. /**
  42252. * Sets Vignette centre X Offset.
  42253. */
  42254. set vignetteCentreX(value: number);
  42255. /**
  42256. * Gets Vignette centre Y Offset.
  42257. */
  42258. get vignetteCentreY(): number;
  42259. /**
  42260. * Sets Vignette centre Y Offset.
  42261. */
  42262. set vignetteCentreY(value: number);
  42263. /**
  42264. * Gets Vignette weight or intensity of the vignette effect.
  42265. */
  42266. get vignetteWeight(): number;
  42267. /**
  42268. * Sets Vignette weight or intensity of the vignette effect.
  42269. */
  42270. set vignetteWeight(value: number);
  42271. /**
  42272. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  42273. * if vignetteEnabled is set to true.
  42274. */
  42275. get vignetteColor(): Color4;
  42276. /**
  42277. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  42278. * if vignetteEnabled is set to true.
  42279. */
  42280. set vignetteColor(value: Color4);
  42281. /**
  42282. * Gets Camera field of view used by the Vignette effect.
  42283. */
  42284. get vignetteCameraFov(): number;
  42285. /**
  42286. * Sets Camera field of view used by the Vignette effect.
  42287. */
  42288. set vignetteCameraFov(value: number);
  42289. /**
  42290. * Gets the vignette blend mode allowing different kind of effect.
  42291. */
  42292. get vignetteBlendMode(): number;
  42293. /**
  42294. * Sets the vignette blend mode allowing different kind of effect.
  42295. */
  42296. set vignetteBlendMode(value: number);
  42297. /**
  42298. * Gets wether the vignette effect is enabled.
  42299. */
  42300. get vignetteEnabled(): boolean;
  42301. /**
  42302. * Sets wether the vignette effect is enabled.
  42303. */
  42304. set vignetteEnabled(value: boolean);
  42305. private _fromLinearSpace;
  42306. /**
  42307. * Gets wether the input of the processing is in Gamma or Linear Space.
  42308. */
  42309. get fromLinearSpace(): boolean;
  42310. /**
  42311. * Sets wether the input of the processing is in Gamma or Linear Space.
  42312. */
  42313. set fromLinearSpace(value: boolean);
  42314. /**
  42315. * Defines cache preventing GC.
  42316. */
  42317. private _defines;
  42318. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  42319. /**
  42320. * "ImageProcessingPostProcess"
  42321. * @returns "ImageProcessingPostProcess"
  42322. */
  42323. getClassName(): string;
  42324. protected _updateParameters(): void;
  42325. dispose(camera?: Camera): void;
  42326. }
  42327. }
  42328. declare module BABYLON {
  42329. /**
  42330. * Class containing static functions to help procedurally build meshes
  42331. */
  42332. export class GroundBuilder {
  42333. /**
  42334. * Creates a ground mesh
  42335. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  42336. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  42337. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42338. * @param name defines the name of the mesh
  42339. * @param options defines the options used to create the mesh
  42340. * @param scene defines the hosting scene
  42341. * @returns the ground mesh
  42342. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  42343. */
  42344. static CreateGround(name: string, options: {
  42345. width?: number;
  42346. height?: number;
  42347. subdivisions?: number;
  42348. subdivisionsX?: number;
  42349. subdivisionsY?: number;
  42350. updatable?: boolean;
  42351. }, scene: any): Mesh;
  42352. /**
  42353. * Creates a tiled ground mesh
  42354. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  42355. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  42356. * * 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
  42357. * * 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
  42358. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42359. * @param name defines the name of the mesh
  42360. * @param options defines the options used to create the mesh
  42361. * @param scene defines the hosting scene
  42362. * @returns the tiled ground mesh
  42363. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  42364. */
  42365. static CreateTiledGround(name: string, options: {
  42366. xmin: number;
  42367. zmin: number;
  42368. xmax: number;
  42369. zmax: number;
  42370. subdivisions?: {
  42371. w: number;
  42372. h: number;
  42373. };
  42374. precision?: {
  42375. w: number;
  42376. h: number;
  42377. };
  42378. updatable?: boolean;
  42379. }, scene?: Nullable<Scene>): Mesh;
  42380. /**
  42381. * Creates a ground mesh from a height map
  42382. * * The parameter `url` sets the URL of the height map image resource.
  42383. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  42384. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  42385. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  42386. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  42387. * * 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.
  42388. * * 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).
  42389. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  42390. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42391. * @param name defines the name of the mesh
  42392. * @param url defines the url to the height map
  42393. * @param options defines the options used to create the mesh
  42394. * @param scene defines the hosting scene
  42395. * @returns the ground mesh
  42396. * @see https://doc.babylonjs.com/babylon101/height_map
  42397. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  42398. */
  42399. static CreateGroundFromHeightMap(name: string, url: string, options: {
  42400. width?: number;
  42401. height?: number;
  42402. subdivisions?: number;
  42403. minHeight?: number;
  42404. maxHeight?: number;
  42405. colorFilter?: Color3;
  42406. alphaFilter?: number;
  42407. updatable?: boolean;
  42408. onReady?: (mesh: GroundMesh) => void;
  42409. }, scene?: Nullable<Scene>): GroundMesh;
  42410. }
  42411. }
  42412. declare module BABYLON {
  42413. /**
  42414. * Class containing static functions to help procedurally build meshes
  42415. */
  42416. export class TorusBuilder {
  42417. /**
  42418. * Creates a torus mesh
  42419. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  42420. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  42421. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  42422. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42423. * * 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
  42424. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42425. * @param name defines the name of the mesh
  42426. * @param options defines the options used to create the mesh
  42427. * @param scene defines the hosting scene
  42428. * @returns the torus mesh
  42429. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  42430. */
  42431. static CreateTorus(name: string, options: {
  42432. diameter?: number;
  42433. thickness?: number;
  42434. tessellation?: number;
  42435. updatable?: boolean;
  42436. sideOrientation?: number;
  42437. frontUVs?: Vector4;
  42438. backUVs?: Vector4;
  42439. }, scene: any): Mesh;
  42440. }
  42441. }
  42442. declare module BABYLON {
  42443. /**
  42444. * Class containing static functions to help procedurally build meshes
  42445. */
  42446. export class CylinderBuilder {
  42447. /**
  42448. * Creates a cylinder or a cone mesh
  42449. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  42450. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  42451. * * 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.
  42452. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  42453. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  42454. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  42455. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  42456. * * 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).
  42457. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  42458. * * 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).
  42459. * * 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
  42460. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  42461. * * 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
  42462. * * 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.
  42463. * * If `enclose` is false, a ring surface is one element.
  42464. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  42465. * * 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
  42466. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42467. * * 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
  42468. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42469. * @param name defines the name of the mesh
  42470. * @param options defines the options used to create the mesh
  42471. * @param scene defines the hosting scene
  42472. * @returns the cylinder mesh
  42473. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  42474. */
  42475. static CreateCylinder(name: string, options: {
  42476. height?: number;
  42477. diameterTop?: number;
  42478. diameterBottom?: number;
  42479. diameter?: number;
  42480. tessellation?: number;
  42481. subdivisions?: number;
  42482. arc?: number;
  42483. faceColors?: Color4[];
  42484. faceUV?: Vector4[];
  42485. updatable?: boolean;
  42486. hasRings?: boolean;
  42487. enclose?: boolean;
  42488. cap?: number;
  42489. sideOrientation?: number;
  42490. frontUVs?: Vector4;
  42491. backUVs?: Vector4;
  42492. }, scene: any): Mesh;
  42493. }
  42494. }
  42495. declare module BABYLON {
  42496. /**
  42497. * States of the webXR experience
  42498. */
  42499. export enum WebXRState {
  42500. /**
  42501. * Transitioning to being in XR mode
  42502. */
  42503. ENTERING_XR = 0,
  42504. /**
  42505. * Transitioning to non XR mode
  42506. */
  42507. EXITING_XR = 1,
  42508. /**
  42509. * In XR mode and presenting
  42510. */
  42511. IN_XR = 2,
  42512. /**
  42513. * Not entered XR mode
  42514. */
  42515. NOT_IN_XR = 3
  42516. }
  42517. /**
  42518. * Abstraction of the XR render target
  42519. */
  42520. export interface WebXRRenderTarget extends IDisposable {
  42521. /**
  42522. * xrpresent context of the canvas which can be used to display/mirror xr content
  42523. */
  42524. canvasContext: WebGLRenderingContext;
  42525. /**
  42526. * xr layer for the canvas
  42527. */
  42528. xrLayer: Nullable<XRWebGLLayer>;
  42529. /**
  42530. * Initializes the xr layer for the session
  42531. * @param xrSession xr session
  42532. * @returns a promise that will resolve once the XR Layer has been created
  42533. */
  42534. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  42535. }
  42536. }
  42537. declare module BABYLON {
  42538. /**
  42539. * COnfiguration object for WebXR output canvas
  42540. */
  42541. export class WebXRManagedOutputCanvasOptions {
  42542. /**
  42543. * Options for this XR Layer output
  42544. */
  42545. canvasOptions?: XRWebGLLayerOptions;
  42546. /**
  42547. * CSS styling for a newly created canvas (if not provided)
  42548. */
  42549. newCanvasCssStyle?: string;
  42550. /**
  42551. * An optional canvas in case you wish to create it yourself and provide it here.
  42552. * If not provided, a new canvas will be created
  42553. */
  42554. canvasElement?: HTMLCanvasElement;
  42555. /**
  42556. * Get the default values of the configuration object
  42557. * @returns default values of this configuration object
  42558. */
  42559. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  42560. }
  42561. /**
  42562. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  42563. */
  42564. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  42565. private _options;
  42566. private _engine;
  42567. private _canvas;
  42568. /**
  42569. * Rendering context of the canvas which can be used to display/mirror xr content
  42570. */
  42571. canvasContext: WebGLRenderingContext;
  42572. /**
  42573. * xr layer for the canvas
  42574. */
  42575. xrLayer: Nullable<XRWebGLLayer>;
  42576. /**
  42577. * Initializes the xr layer for the session
  42578. * @param xrSession xr session
  42579. * @returns a promise that will resolve once the XR Layer has been created
  42580. */
  42581. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  42582. /**
  42583. * Initializes the canvas to be added/removed upon entering/exiting xr
  42584. * @param _xrSessionManager The XR Session manager
  42585. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  42586. */
  42587. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  42588. /**
  42589. * Disposes of the object
  42590. */
  42591. dispose(): void;
  42592. private _setManagedOutputCanvas;
  42593. private _addCanvas;
  42594. private _removeCanvas;
  42595. }
  42596. }
  42597. declare module BABYLON {
  42598. /**
  42599. * Manages an XRSession to work with Babylon's engine
  42600. * @see https://doc.babylonjs.com/how_to/webxr
  42601. */
  42602. export class WebXRSessionManager implements IDisposable {
  42603. /** The scene which the session should be created for */
  42604. scene: Scene;
  42605. /**
  42606. * Fires every time a new xrFrame arrives which can be used to update the camera
  42607. */
  42608. onXRFrameObservable: Observable<XRFrame>;
  42609. /**
  42610. * Fires when the xr session is ended either by the device or manually done
  42611. */
  42612. onXRSessionEnded: Observable<any>;
  42613. /**
  42614. * Fires when the xr session is ended either by the device or manually done
  42615. */
  42616. onXRSessionInit: Observable<XRSession>;
  42617. /**
  42618. * Fires when the reference space changed
  42619. */
  42620. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  42621. /**
  42622. * Underlying xr session
  42623. */
  42624. session: XRSession;
  42625. /**
  42626. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  42627. * or get the offset the player is currently at.
  42628. */
  42629. viewerReferenceSpace: XRReferenceSpace;
  42630. private _referenceSpace;
  42631. /**
  42632. * The current reference space used in this session. This reference space can constantly change!
  42633. * It is mainly used to offset the camera's position.
  42634. */
  42635. get referenceSpace(): XRReferenceSpace;
  42636. /**
  42637. * Set a new reference space and triggers the observable
  42638. */
  42639. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  42640. /**
  42641. * The base reference space from which the session started. good if you want to reset your
  42642. * reference space
  42643. */
  42644. baseReferenceSpace: XRReferenceSpace;
  42645. /**
  42646. * Used just in case of a failure to initialize an immersive session.
  42647. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  42648. */
  42649. defaultHeightCompensation: number;
  42650. /**
  42651. * Current XR frame
  42652. */
  42653. currentFrame: Nullable<XRFrame>;
  42654. /** WebXR timestamp updated every frame */
  42655. currentTimestamp: number;
  42656. private _xrNavigator;
  42657. private baseLayer;
  42658. private _rttProvider;
  42659. private _sessionEnded;
  42660. /**
  42661. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  42662. * @param scene The scene which the session should be created for
  42663. */
  42664. constructor(
  42665. /** The scene which the session should be created for */
  42666. scene: Scene);
  42667. /**
  42668. * Initializes the manager
  42669. * After initialization enterXR can be called to start an XR session
  42670. * @returns Promise which resolves after it is initialized
  42671. */
  42672. initializeAsync(): Promise<void>;
  42673. /**
  42674. * Initializes an xr session
  42675. * @param xrSessionMode mode to initialize
  42676. * @param xrSessionInit defines optional and required values to pass to the session builder
  42677. * @returns a promise which will resolve once the session has been initialized
  42678. */
  42679. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  42680. /**
  42681. * Sets the reference space on the xr session
  42682. * @param referenceSpaceType space to set
  42683. * @returns a promise that will resolve once the reference space has been set
  42684. */
  42685. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  42686. /**
  42687. * Resets the reference space to the one started the session
  42688. */
  42689. resetReferenceSpace(): void;
  42690. /**
  42691. * Updates the render state of the session
  42692. * @param state state to set
  42693. * @returns a promise that resolves once the render state has been updated
  42694. */
  42695. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  42696. /**
  42697. * Starts rendering to the xr layer
  42698. */
  42699. runXRRenderLoop(): void;
  42700. /**
  42701. * Gets the correct render target texture to be rendered this frame for this eye
  42702. * @param eye the eye for which to get the render target
  42703. * @returns the render target for the specified eye
  42704. */
  42705. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  42706. /**
  42707. * Stops the xrSession and restores the renderloop
  42708. * @returns Promise which resolves after it exits XR
  42709. */
  42710. exitXRAsync(): Promise<void>;
  42711. /**
  42712. * Checks if a session would be supported for the creation options specified
  42713. * @param sessionMode session mode to check if supported eg. immersive-vr
  42714. * @returns A Promise that resolves to true if supported and false if not
  42715. */
  42716. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  42717. /**
  42718. * Creates a WebXRRenderTarget object for the XR session
  42719. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  42720. * @param options optional options to provide when creating a new render target
  42721. * @returns a WebXR render target to which the session can render
  42722. */
  42723. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  42724. /**
  42725. * @hidden
  42726. * Converts the render layer of xrSession to a render target
  42727. * @param session session to create render target for
  42728. * @param scene scene the new render target should be created for
  42729. * @param baseLayer the webgl layer to create the render target for
  42730. */
  42731. static _CreateRenderTargetTextureFromSession(_session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  42732. /**
  42733. * Disposes of the session manager
  42734. */
  42735. dispose(): void;
  42736. /**
  42737. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  42738. * @param sessionMode defines the session to test
  42739. * @returns a promise with boolean as final value
  42740. */
  42741. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  42742. }
  42743. }
  42744. declare module BABYLON {
  42745. /**
  42746. * WebXR Camera which holds the views for the xrSession
  42747. * @see https://doc.babylonjs.com/how_to/webxr_camera
  42748. */
  42749. export class WebXRCamera extends FreeCamera {
  42750. private _xrSessionManager;
  42751. private _firstFrame;
  42752. private _referenceQuaternion;
  42753. private _referencedPosition;
  42754. private _xrInvPositionCache;
  42755. private _xrInvQuaternionCache;
  42756. /**
  42757. * Should position compensation execute on first frame.
  42758. * This is used when copying the position from a native (non XR) camera
  42759. */
  42760. compensateOnFirstFrame: boolean;
  42761. /**
  42762. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  42763. * @param name the name of the camera
  42764. * @param scene the scene to add the camera to
  42765. * @param _xrSessionManager a constructed xr session manager
  42766. */
  42767. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  42768. /**
  42769. * Return the user's height, unrelated to the current ground.
  42770. * This will be the y position of this camera, when ground level is 0.
  42771. */
  42772. get realWorldHeight(): number;
  42773. /** @hidden */
  42774. _updateForDualEyeDebugging(): void;
  42775. /**
  42776. * Sets this camera's transformation based on a non-vr camera
  42777. * @param otherCamera the non-vr camera to copy the transformation from
  42778. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  42779. */
  42780. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  42781. private _updateFromXRSession;
  42782. private _updateNumberOfRigCameras;
  42783. private _updateReferenceSpace;
  42784. private _updateReferenceSpaceOffset;
  42785. }
  42786. }
  42787. declare module BABYLON {
  42788. /**
  42789. * Defining the interface required for a (webxr) feature
  42790. */
  42791. export interface IWebXRFeature extends IDisposable {
  42792. /**
  42793. * Is this feature attached
  42794. */
  42795. attached: boolean;
  42796. /**
  42797. * Should auto-attach be disabled?
  42798. */
  42799. disableAutoAttach: boolean;
  42800. /**
  42801. * Attach the feature to the session
  42802. * Will usually be called by the features manager
  42803. *
  42804. * @param force should attachment be forced (even when already attached)
  42805. * @returns true if successful.
  42806. */
  42807. attach(force?: boolean): boolean;
  42808. /**
  42809. * Detach the feature from the session
  42810. * Will usually be called by the features manager
  42811. *
  42812. * @returns true if successful.
  42813. */
  42814. detach(): boolean;
  42815. }
  42816. /**
  42817. * A list of the currently available features without referencing them
  42818. */
  42819. export class WebXRFeatureName {
  42820. /**
  42821. * The name of the hit test feature
  42822. */
  42823. static HIT_TEST: string;
  42824. /**
  42825. * The name of the anchor system feature
  42826. */
  42827. static ANCHOR_SYSTEM: string;
  42828. /**
  42829. * The name of the background remover feature
  42830. */
  42831. static BACKGROUND_REMOVER: string;
  42832. /**
  42833. * The name of the pointer selection feature
  42834. */
  42835. static POINTER_SELECTION: string;
  42836. /**
  42837. * The name of the teleportation feature
  42838. */
  42839. static TELEPORTATION: string;
  42840. /**
  42841. * The name of the plane detection feature
  42842. */
  42843. static PLANE_DETECTION: string;
  42844. /**
  42845. * physics impostors for xr controllers feature
  42846. */
  42847. static PHYSICS_CONTROLLERS: string;
  42848. }
  42849. /**
  42850. * Defining the constructor of a feature. Used to register the modules.
  42851. */
  42852. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  42853. /**
  42854. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  42855. * It is mainly used in AR sessions.
  42856. *
  42857. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  42858. */
  42859. export class WebXRFeaturesManager implements IDisposable {
  42860. private _xrSessionManager;
  42861. private static readonly _AvailableFeatures;
  42862. /**
  42863. * Used to register a module. After calling this function a developer can use this feature in the scene.
  42864. * Mainly used internally.
  42865. *
  42866. * @param featureName the name of the feature to register
  42867. * @param constructorFunction the function used to construct the module
  42868. * @param version the (babylon) version of the module
  42869. * @param stable is that a stable version of this module
  42870. */
  42871. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  42872. /**
  42873. * Returns a constructor of a specific feature.
  42874. *
  42875. * @param featureName the name of the feature to construct
  42876. * @param version the version of the feature to load
  42877. * @param xrSessionManager the xrSessionManager. Used to construct the module
  42878. * @param options optional options provided to the module.
  42879. * @returns a function that, when called, will return a new instance of this feature
  42880. */
  42881. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  42882. /**
  42883. * Return the latest unstable 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 GetLatestVersionOfFeature(featureName: string): number;
  42888. /**
  42889. * Return the latest stable version of this feature
  42890. * @param featureName the name of the feature to search
  42891. * @returns the version number. if not found will return -1
  42892. */
  42893. static GetStableVersionOfFeature(featureName: string): number;
  42894. /**
  42895. * Can be used to return the list of features currently registered
  42896. *
  42897. * @returns an Array of available features
  42898. */
  42899. static GetAvailableFeatures(): string[];
  42900. /**
  42901. * Gets the versions available for a specific feature
  42902. * @param featureName the name of the feature
  42903. * @returns an array with the available versions
  42904. */
  42905. static GetAvailableVersions(featureName: string): string[];
  42906. private _features;
  42907. /**
  42908. * constructs a new features manages.
  42909. *
  42910. * @param _xrSessionManager an instance of WebXRSessionManager
  42911. */
  42912. constructor(_xrSessionManager: WebXRSessionManager);
  42913. /**
  42914. * 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.
  42915. * 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.
  42916. *
  42917. * @param featureName the name of the feature to load or the class of the feature
  42918. * @param version optional version to load. if not provided the latest version will be enabled
  42919. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  42920. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  42921. * @returns a new constructed feature or throws an error if feature not found.
  42922. */
  42923. enableFeature(featureName: string | {
  42924. Name: string;
  42925. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  42926. /**
  42927. * Used to disable an already-enabled feature
  42928. * The feature will be disposed and will be recreated once enabled.
  42929. * @param featureName the feature to disable
  42930. * @returns true if disable was successful
  42931. */
  42932. disableFeature(featureName: string | {
  42933. Name: string;
  42934. }): boolean;
  42935. /**
  42936. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  42937. * Can be used during a session to start a feature
  42938. * @param featureName the name of feature to attach
  42939. */
  42940. attachFeature(featureName: string): void;
  42941. /**
  42942. * Can be used inside a session or when the session ends to detach a specific feature
  42943. * @param featureName the name of the feature to detach
  42944. */
  42945. detachFeature(featureName: string): void;
  42946. /**
  42947. * Get the list of enabled features
  42948. * @returns an array of enabled features
  42949. */
  42950. getEnabledFeatures(): string[];
  42951. /**
  42952. * get the implementation of an enabled feature.
  42953. * @param featureName the name of the feature to load
  42954. * @returns the feature class, if found
  42955. */
  42956. getEnabledFeature(featureName: string): IWebXRFeature;
  42957. /**
  42958. * dispose this features manager
  42959. */
  42960. dispose(): void;
  42961. }
  42962. }
  42963. declare module BABYLON {
  42964. /**
  42965. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  42966. * @see https://doc.babylonjs.com/how_to/webxr
  42967. */
  42968. export class WebXRExperienceHelper implements IDisposable {
  42969. private scene;
  42970. /**
  42971. * Camera used to render xr content
  42972. */
  42973. camera: WebXRCamera;
  42974. /**
  42975. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  42976. */
  42977. state: WebXRState;
  42978. private _setState;
  42979. /**
  42980. * Fires when the state of the experience helper has changed
  42981. */
  42982. onStateChangedObservable: Observable<WebXRState>;
  42983. /**
  42984. * Observers registered here will be triggered after the camera's initial transformation is set
  42985. * This can be used to set a different ground level or an extra rotation.
  42986. *
  42987. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  42988. * to the position set after this observable is done executing.
  42989. */
  42990. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  42991. /** Session manager used to keep track of xr session */
  42992. sessionManager: WebXRSessionManager;
  42993. /** A features manager for this xr session */
  42994. featuresManager: WebXRFeaturesManager;
  42995. private _nonVRCamera;
  42996. private _originalSceneAutoClear;
  42997. private _supported;
  42998. /**
  42999. * Creates the experience helper
  43000. * @param scene the scene to attach the experience helper to
  43001. * @returns a promise for the experience helper
  43002. */
  43003. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  43004. /**
  43005. * Creates a WebXRExperienceHelper
  43006. * @param scene The scene the helper should be created in
  43007. */
  43008. private constructor();
  43009. /**
  43010. * Exits XR mode and returns the scene to its original state
  43011. * @returns promise that resolves after xr mode has exited
  43012. */
  43013. exitXRAsync(): Promise<void>;
  43014. /**
  43015. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  43016. * @param sessionMode options for the XR session
  43017. * @param referenceSpaceType frame of reference of the XR session
  43018. * @param renderTarget the output canvas that will be used to enter XR mode
  43019. * @returns promise that resolves after xr mode has entered
  43020. */
  43021. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget): Promise<WebXRSessionManager>;
  43022. /**
  43023. * Disposes of the experience helper
  43024. */
  43025. dispose(): void;
  43026. private _nonXRToXRCamera;
  43027. }
  43028. }
  43029. declare module BABYLON {
  43030. /**
  43031. * X-Y values for axes in WebXR
  43032. */
  43033. export interface IWebXRMotionControllerAxesValue {
  43034. /**
  43035. * The value of the x axis
  43036. */
  43037. x: number;
  43038. /**
  43039. * The value of the y-axis
  43040. */
  43041. y: number;
  43042. }
  43043. /**
  43044. * changed / previous values for the values of this component
  43045. */
  43046. export interface IWebXRMotionControllerComponentChangesValues<T> {
  43047. /**
  43048. * current (this frame) value
  43049. */
  43050. current: T;
  43051. /**
  43052. * previous (last change) value
  43053. */
  43054. previous: T;
  43055. }
  43056. /**
  43057. * Represents changes in the component between current frame and last values recorded
  43058. */
  43059. export interface IWebXRMotionControllerComponentChanges {
  43060. /**
  43061. * will be populated with previous and current values if touched changed
  43062. */
  43063. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  43064. /**
  43065. * will be populated with previous and current values if pressed changed
  43066. */
  43067. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  43068. /**
  43069. * will be populated with previous and current values if value changed
  43070. */
  43071. value?: IWebXRMotionControllerComponentChangesValues<number>;
  43072. /**
  43073. * will be populated with previous and current values if axes changed
  43074. */
  43075. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  43076. }
  43077. /**
  43078. * This class represents a single component (for example button or thumbstick) of a motion controller
  43079. */
  43080. export class WebXRControllerComponent implements IDisposable {
  43081. /**
  43082. * the id of this component
  43083. */
  43084. id: string;
  43085. /**
  43086. * the type of the component
  43087. */
  43088. type: MotionControllerComponentType;
  43089. private _buttonIndex;
  43090. private _axesIndices;
  43091. /**
  43092. * Thumbstick component type
  43093. */
  43094. static THUMBSTICK: MotionControllerComponentType;
  43095. /**
  43096. * Touchpad component type
  43097. */
  43098. static TOUCHPAD: MotionControllerComponentType;
  43099. /**
  43100. * trigger component type
  43101. */
  43102. static TRIGGER: MotionControllerComponentType;
  43103. /**
  43104. * squeeze component type
  43105. */
  43106. static SQUEEZE: MotionControllerComponentType;
  43107. /**
  43108. * button component type
  43109. */
  43110. static BUTTON: MotionControllerComponentType;
  43111. /**
  43112. * Observers registered here will be triggered when the state of a button changes
  43113. * State change is either pressed / touched / value
  43114. */
  43115. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  43116. /**
  43117. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  43118. * the axes data changes
  43119. */
  43120. onAxisValueChangedObservable: Observable<{
  43121. x: number;
  43122. y: number;
  43123. }>;
  43124. private _currentValue;
  43125. private _touched;
  43126. private _pressed;
  43127. private _axes;
  43128. private _changes;
  43129. private _hasChanges;
  43130. /**
  43131. * Return whether or not the component changed the last frame
  43132. */
  43133. get hasChanges(): boolean;
  43134. /**
  43135. * Creates a new component for a motion controller.
  43136. * It is created by the motion controller itself
  43137. *
  43138. * @param id the id of this component
  43139. * @param type the type of the component
  43140. * @param _buttonIndex index in the buttons array of the gamepad
  43141. * @param _axesIndices indices of the values in the axes array of the gamepad
  43142. */
  43143. constructor(
  43144. /**
  43145. * the id of this component
  43146. */
  43147. id: string,
  43148. /**
  43149. * the type of the component
  43150. */
  43151. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  43152. /**
  43153. * Get the current value of this component
  43154. */
  43155. get value(): number;
  43156. /**
  43157. * is the button currently pressed
  43158. */
  43159. get pressed(): boolean;
  43160. /**
  43161. * is the button currently touched
  43162. */
  43163. get touched(): boolean;
  43164. /**
  43165. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  43166. */
  43167. get axes(): IWebXRMotionControllerAxesValue;
  43168. /**
  43169. * Get the changes. Elements will be populated only if they changed with their previous and current value
  43170. */
  43171. get changes(): IWebXRMotionControllerComponentChanges;
  43172. /**
  43173. * Is this component a button (hence - pressable)
  43174. * @returns true if can be pressed
  43175. */
  43176. isButton(): boolean;
  43177. /**
  43178. * Are there axes correlating to this component
  43179. * @return true is axes data is available
  43180. */
  43181. isAxes(): boolean;
  43182. /**
  43183. * update this component using the gamepad object it is in. Called on every frame
  43184. * @param nativeController the native gamepad controller object
  43185. */
  43186. update(nativeController: IMinimalMotionControllerObject): void;
  43187. /**
  43188. * Dispose this component
  43189. */
  43190. dispose(): void;
  43191. }
  43192. }
  43193. declare module BABYLON {
  43194. /**
  43195. * Class used to represent data loading progression
  43196. */
  43197. export class SceneLoaderProgressEvent {
  43198. /** defines if data length to load can be evaluated */
  43199. readonly lengthComputable: boolean;
  43200. /** defines the loaded data length */
  43201. readonly loaded: number;
  43202. /** defines the data length to load */
  43203. readonly total: number;
  43204. /**
  43205. * Create a new progress event
  43206. * @param lengthComputable defines if data length to load can be evaluated
  43207. * @param loaded defines the loaded data length
  43208. * @param total defines the data length to load
  43209. */
  43210. constructor(
  43211. /** defines if data length to load can be evaluated */
  43212. lengthComputable: boolean,
  43213. /** defines the loaded data length */
  43214. loaded: number,
  43215. /** defines the data length to load */
  43216. total: number);
  43217. /**
  43218. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  43219. * @param event defines the source event
  43220. * @returns a new SceneLoaderProgressEvent
  43221. */
  43222. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  43223. }
  43224. /**
  43225. * Interface used by SceneLoader plugins to define supported file extensions
  43226. */
  43227. export interface ISceneLoaderPluginExtensions {
  43228. /**
  43229. * Defines the list of supported extensions
  43230. */
  43231. [extension: string]: {
  43232. isBinary: boolean;
  43233. };
  43234. }
  43235. /**
  43236. * Interface used by SceneLoader plugin factory
  43237. */
  43238. export interface ISceneLoaderPluginFactory {
  43239. /**
  43240. * Defines the name of the factory
  43241. */
  43242. name: string;
  43243. /**
  43244. * Function called to create a new plugin
  43245. * @return the new plugin
  43246. */
  43247. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  43248. /**
  43249. * The callback that returns true if the data can be directly loaded.
  43250. * @param data string containing the file data
  43251. * @returns if the data can be loaded directly
  43252. */
  43253. canDirectLoad?(data: string): boolean;
  43254. }
  43255. /**
  43256. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  43257. */
  43258. export interface ISceneLoaderPluginBase {
  43259. /**
  43260. * The friendly name of this plugin.
  43261. */
  43262. name: string;
  43263. /**
  43264. * The file extensions supported by this plugin.
  43265. */
  43266. extensions: string | ISceneLoaderPluginExtensions;
  43267. /**
  43268. * The callback called when loading from a url.
  43269. * @param scene scene loading this url
  43270. * @param url url to load
  43271. * @param onSuccess callback called when the file successfully loads
  43272. * @param onProgress callback called while file is loading (if the server supports this mode)
  43273. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  43274. * @param onError callback called when the file fails to load
  43275. * @returns a file request object
  43276. */
  43277. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  43278. /**
  43279. * The callback called when loading from a file object.
  43280. * @param scene scene loading this file
  43281. * @param file defines the file to load
  43282. * @param onSuccess defines the callback to call when data is loaded
  43283. * @param onProgress defines the callback to call during loading process
  43284. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  43285. * @param onError defines the callback to call when an error occurs
  43286. * @returns a file request object
  43287. */
  43288. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  43289. /**
  43290. * The callback that returns true if the data can be directly loaded.
  43291. * @param data string containing the file data
  43292. * @returns if the data can be loaded directly
  43293. */
  43294. canDirectLoad?(data: string): boolean;
  43295. /**
  43296. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  43297. * @param scene scene loading this data
  43298. * @param data string containing the data
  43299. * @returns data to pass to the plugin
  43300. */
  43301. directLoad?(scene: Scene, data: string): any;
  43302. /**
  43303. * The callback that allows custom handling of the root url based on the response url.
  43304. * @param rootUrl the original root url
  43305. * @param responseURL the response url if available
  43306. * @returns the new root url
  43307. */
  43308. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  43309. }
  43310. /**
  43311. * Interface used to define a SceneLoader plugin
  43312. */
  43313. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  43314. /**
  43315. * Import meshes into a scene.
  43316. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43317. * @param scene The scene to import into
  43318. * @param data The data to import
  43319. * @param rootUrl The root url for scene and resources
  43320. * @param meshes The meshes array to import into
  43321. * @param particleSystems The particle systems array to import into
  43322. * @param skeletons The skeletons array to import into
  43323. * @param onError The callback when import fails
  43324. * @returns True if successful or false otherwise
  43325. */
  43326. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  43327. /**
  43328. * Load into a scene.
  43329. * @param scene The scene to load into
  43330. * @param data The data to import
  43331. * @param rootUrl The root url for scene and resources
  43332. * @param onError The callback when import fails
  43333. * @returns True if successful or false otherwise
  43334. */
  43335. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  43336. /**
  43337. * Load into an asset container.
  43338. * @param scene The scene to load into
  43339. * @param data The data to import
  43340. * @param rootUrl The root url for scene and resources
  43341. * @param onError The callback when import fails
  43342. * @returns The loaded asset container
  43343. */
  43344. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  43345. }
  43346. /**
  43347. * Interface used to define an async SceneLoader plugin
  43348. */
  43349. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  43350. /**
  43351. * Import meshes into a scene.
  43352. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43353. * @param scene The scene to import 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 meshes, particle systems, skeletons, and animation groups
  43359. */
  43360. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  43361. meshes: AbstractMesh[];
  43362. particleSystems: IParticleSystem[];
  43363. skeletons: Skeleton[];
  43364. animationGroups: AnimationGroup[];
  43365. }>;
  43366. /**
  43367. * Load into a scene.
  43368. * @param scene The scene to load into
  43369. * @param data The data to import
  43370. * @param rootUrl The root url for scene and resources
  43371. * @param onProgress The callback when the load progresses
  43372. * @param fileName Defines the name of the file to load
  43373. * @returns Nothing
  43374. */
  43375. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  43376. /**
  43377. * Load into an asset container.
  43378. * @param scene The scene to load into
  43379. * @param data The data to import
  43380. * @param rootUrl The root url for scene and resources
  43381. * @param onProgress The callback when the load progresses
  43382. * @param fileName Defines the name of the file to load
  43383. * @returns The loaded asset container
  43384. */
  43385. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  43386. }
  43387. /**
  43388. * Mode that determines how to handle old animation groups before loading new ones.
  43389. */
  43390. export enum SceneLoaderAnimationGroupLoadingMode {
  43391. /**
  43392. * Reset all old animations to initial state then dispose them.
  43393. */
  43394. Clean = 0,
  43395. /**
  43396. * Stop all old animations.
  43397. */
  43398. Stop = 1,
  43399. /**
  43400. * Restart old animations from first frame.
  43401. */
  43402. Sync = 2,
  43403. /**
  43404. * Old animations remains untouched.
  43405. */
  43406. NoSync = 3
  43407. }
  43408. /**
  43409. * Class used to load scene from various file formats using registered plugins
  43410. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  43411. */
  43412. export class SceneLoader {
  43413. /**
  43414. * No logging while loading
  43415. */
  43416. static readonly NO_LOGGING: number;
  43417. /**
  43418. * Minimal logging while loading
  43419. */
  43420. static readonly MINIMAL_LOGGING: number;
  43421. /**
  43422. * Summary logging while loading
  43423. */
  43424. static readonly SUMMARY_LOGGING: number;
  43425. /**
  43426. * Detailled logging while loading
  43427. */
  43428. static readonly DETAILED_LOGGING: number;
  43429. /**
  43430. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  43431. */
  43432. static get ForceFullSceneLoadingForIncremental(): boolean;
  43433. static set ForceFullSceneLoadingForIncremental(value: boolean);
  43434. /**
  43435. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  43436. */
  43437. static get ShowLoadingScreen(): boolean;
  43438. static set ShowLoadingScreen(value: boolean);
  43439. /**
  43440. * Defines the current logging level (while loading the scene)
  43441. * @ignorenaming
  43442. */
  43443. static get loggingLevel(): number;
  43444. static set loggingLevel(value: number);
  43445. /**
  43446. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  43447. */
  43448. static get CleanBoneMatrixWeights(): boolean;
  43449. static set CleanBoneMatrixWeights(value: boolean);
  43450. /**
  43451. * Event raised when a plugin is used to load a scene
  43452. */
  43453. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  43454. private static _registeredPlugins;
  43455. private static _getDefaultPlugin;
  43456. private static _getPluginForExtension;
  43457. private static _getPluginForDirectLoad;
  43458. private static _getPluginForFilename;
  43459. private static _getDirectLoad;
  43460. private static _loadData;
  43461. private static _getFileInfo;
  43462. /**
  43463. * Gets a plugin that can load the given extension
  43464. * @param extension defines the extension to load
  43465. * @returns a plugin or null if none works
  43466. */
  43467. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  43468. /**
  43469. * Gets a boolean indicating that the given extension can be loaded
  43470. * @param extension defines the extension to load
  43471. * @returns true if the extension is supported
  43472. */
  43473. static IsPluginForExtensionAvailable(extension: string): boolean;
  43474. /**
  43475. * Adds a new plugin to the list of registered plugins
  43476. * @param plugin defines the plugin to add
  43477. */
  43478. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  43479. /**
  43480. * Import meshes into a scene
  43481. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43482. * @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)
  43483. * @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)
  43484. * @param scene the instance of BABYLON.Scene to append to
  43485. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  43486. * @param onProgress a callback with a progress event for each file being loaded
  43487. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43488. * @param pluginExtension the extension used to determine the plugin
  43489. * @returns The loaded plugin
  43490. */
  43491. 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>;
  43492. /**
  43493. * Import meshes into a scene
  43494. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43495. * @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)
  43496. * @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)
  43497. * @param scene the instance of BABYLON.Scene to append to
  43498. * @param onProgress a callback with a progress event for each file being loaded
  43499. * @param pluginExtension the extension used to determine the plugin
  43500. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  43501. */
  43502. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  43503. meshes: AbstractMesh[];
  43504. particleSystems: IParticleSystem[];
  43505. skeletons: Skeleton[];
  43506. animationGroups: AnimationGroup[];
  43507. }>;
  43508. /**
  43509. * Load a scene
  43510. * @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)
  43511. * @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)
  43512. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43513. * @param onSuccess a callback with the scene when import succeeds
  43514. * @param onProgress a callback with a progress event for each file being loaded
  43515. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43516. * @param pluginExtension the extension used to determine the plugin
  43517. * @returns The loaded plugin
  43518. */
  43519. 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>;
  43520. /**
  43521. * Load a scene
  43522. * @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)
  43523. * @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)
  43524. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43525. * @param onProgress a callback with a progress event for each file being loaded
  43526. * @param pluginExtension the extension used to determine the plugin
  43527. * @returns The loaded scene
  43528. */
  43529. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43530. /**
  43531. * Append a scene
  43532. * @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)
  43533. * @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)
  43534. * @param scene is the instance of BABYLON.Scene to append to
  43535. * @param onSuccess a callback with the scene when import succeeds
  43536. * @param onProgress a callback with a progress event for each file being loaded
  43537. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43538. * @param pluginExtension the extension used to determine the plugin
  43539. * @returns The loaded plugin
  43540. */
  43541. 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>;
  43542. /**
  43543. * Append a scene
  43544. * @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)
  43545. * @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)
  43546. * @param scene is the instance of BABYLON.Scene to append to
  43547. * @param onProgress a callback with a progress event for each file being loaded
  43548. * @param pluginExtension the extension used to determine the plugin
  43549. * @returns The given scene
  43550. */
  43551. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43552. /**
  43553. * Load a scene into an asset container
  43554. * @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)
  43555. * @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)
  43556. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  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. * @param pluginExtension the extension used to determine the plugin
  43561. * @returns The loaded plugin
  43562. */
  43563. 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>;
  43564. /**
  43565. * Load a scene into an asset container
  43566. * @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)
  43567. * @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)
  43568. * @param scene is the instance of Scene to append to
  43569. * @param onProgress a callback with a progress event for each file being loaded
  43570. * @param pluginExtension the extension used to determine the plugin
  43571. * @returns The loaded asset container
  43572. */
  43573. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  43574. /**
  43575. * Import animations from a file into a scene
  43576. * @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)
  43577. * @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)
  43578. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  43579. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  43580. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  43581. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  43582. * @param onSuccess a callback with the scene when import succeeds
  43583. * @param onProgress a callback with a progress event for each file being loaded
  43584. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43585. */
  43586. 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;
  43587. /**
  43588. * Import animations from a file into a scene
  43589. * @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)
  43590. * @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)
  43591. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  43592. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  43593. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  43594. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  43595. * @param onSuccess a callback with the scene when import succeeds
  43596. * @param onProgress a callback with a progress event for each file being loaded
  43597. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43598. * @returns the updated scene with imported animations
  43599. */
  43600. 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>;
  43601. }
  43602. }
  43603. declare module BABYLON {
  43604. /**
  43605. * Handness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  43606. */
  43607. export type MotionControllerHandness = "none" | "left" | "right";
  43608. /**
  43609. * The type of components available in motion controllers.
  43610. * This is not the name of the component.
  43611. */
  43612. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  43613. /**
  43614. * The state of a controller component
  43615. */
  43616. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  43617. /**
  43618. * The schema of motion controller layout.
  43619. * No object will be initialized using this interface
  43620. * This is used just to define the profile.
  43621. */
  43622. export interface IMotionControllerLayout {
  43623. /**
  43624. * Defines the main button component id
  43625. */
  43626. selectComponentId: string;
  43627. /**
  43628. * Available components (unsorted)
  43629. */
  43630. components: {
  43631. /**
  43632. * A map of component Ids
  43633. */
  43634. [componentId: string]: {
  43635. /**
  43636. * The type of input the component outputs
  43637. */
  43638. type: MotionControllerComponentType;
  43639. /**
  43640. * The indices of this component in the gamepad object
  43641. */
  43642. gamepadIndices: {
  43643. /**
  43644. * Index of button
  43645. */
  43646. button?: number;
  43647. /**
  43648. * If available, index of x-axis
  43649. */
  43650. xAxis?: number;
  43651. /**
  43652. * If available, index of y-axis
  43653. */
  43654. yAxis?: number;
  43655. };
  43656. /**
  43657. * The mesh's root node name
  43658. */
  43659. rootNodeName: string;
  43660. /**
  43661. * Animation definitions for this model
  43662. */
  43663. visualResponses: {
  43664. [stateKey: string]: {
  43665. /**
  43666. * What property will be animated
  43667. */
  43668. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  43669. /**
  43670. * What states influence this visual reponse
  43671. */
  43672. states: MotionControllerComponentStateType[];
  43673. /**
  43674. * Type of animation - movement or visibility
  43675. */
  43676. valueNodeProperty: "transform" | "visibility";
  43677. /**
  43678. * Base node name to move. Its position will be calculated according to the min and max nodes
  43679. */
  43680. valueNodeName?: string;
  43681. /**
  43682. * Minimum movement node
  43683. */
  43684. minNodeName?: string;
  43685. /**
  43686. * Max movement node
  43687. */
  43688. maxNodeName?: string;
  43689. };
  43690. };
  43691. /**
  43692. * If touch enabled, what is the name of node to display user feedback
  43693. */
  43694. touchPointNodeName?: string;
  43695. };
  43696. };
  43697. /**
  43698. * Is it xr standard mapping or not
  43699. */
  43700. gamepadMapping: "" | "xr-standard";
  43701. /**
  43702. * Base root node of this entire model
  43703. */
  43704. rootNodeName: string;
  43705. /**
  43706. * Path to load the assets. Usually relative to the base path
  43707. */
  43708. assetPath: string;
  43709. }
  43710. /**
  43711. * A definition for the layout map in the input profile
  43712. */
  43713. export interface IMotionControllerLayoutMap {
  43714. /**
  43715. * Layouts with handness type as a key
  43716. */
  43717. [handness: string]: IMotionControllerLayout;
  43718. }
  43719. /**
  43720. * The XR Input profile schema
  43721. * Profiles can be found here:
  43722. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  43723. */
  43724. export interface IMotionControllerProfile {
  43725. /**
  43726. * The id of this profile
  43727. * correlates to the profile(s) in the xrInput.profiles array
  43728. */
  43729. profileId: string;
  43730. /**
  43731. * fallback profiles for this profileId
  43732. */
  43733. fallbackProfileIds: string[];
  43734. /**
  43735. * The layout map, with handness as key
  43736. */
  43737. layouts: IMotionControllerLayoutMap;
  43738. }
  43739. /**
  43740. * A helper-interface for the 3 meshes needed for controller button animation
  43741. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  43742. */
  43743. export interface IMotionControllerButtonMeshMap {
  43744. /**
  43745. * The mesh that will be changed when value changes
  43746. */
  43747. valueMesh: AbstractMesh;
  43748. /**
  43749. * the mesh that defines the pressed value mesh position.
  43750. * This is used to find the max-position of this button
  43751. */
  43752. pressedMesh: AbstractMesh;
  43753. /**
  43754. * the mesh that defines the unpressed value mesh position.
  43755. * This is used to find the min (or initial) position of this button
  43756. */
  43757. unpressedMesh: AbstractMesh;
  43758. }
  43759. /**
  43760. * A helper-interface for the 3 meshes needed for controller axis animation.
  43761. * This will be expanded when touchpad animations are fully supported
  43762. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  43763. */
  43764. export interface IMotionControllerMeshMap {
  43765. /**
  43766. * The mesh that will be changed when axis value changes
  43767. */
  43768. valueMesh: AbstractMesh;
  43769. /**
  43770. * the mesh that defines the minimum value mesh position.
  43771. */
  43772. minMesh?: AbstractMesh;
  43773. /**
  43774. * the mesh that defines the maximum value mesh position.
  43775. */
  43776. maxMesh?: AbstractMesh;
  43777. }
  43778. /**
  43779. * The elements needed for change-detection of the gamepad objects in motion controllers
  43780. */
  43781. export interface IMinimalMotionControllerObject {
  43782. /**
  43783. * An array of available buttons
  43784. */
  43785. buttons: Array<{
  43786. /**
  43787. * Value of the button/trigger
  43788. */
  43789. value: number;
  43790. /**
  43791. * If the button/trigger is currently touched
  43792. */
  43793. touched: boolean;
  43794. /**
  43795. * If the button/trigger is currently pressed
  43796. */
  43797. pressed: boolean;
  43798. }>;
  43799. /**
  43800. * Available axes of this controller
  43801. */
  43802. axes: number[];
  43803. }
  43804. /**
  43805. * An Abstract Motion controller
  43806. * This class receives an xrInput and a profile layout and uses those to initialize the components
  43807. * Each component has an observable to check for changes in value and state
  43808. */
  43809. export abstract class WebXRAbstractMotionController implements IDisposable {
  43810. protected scene: Scene;
  43811. protected layout: IMotionControllerLayout;
  43812. /**
  43813. * The gamepad object correlating to this controller
  43814. */
  43815. gamepadObject: IMinimalMotionControllerObject;
  43816. /**
  43817. * handness (left/right/none) of this controller
  43818. */
  43819. handness: MotionControllerHandness;
  43820. /**
  43821. * The profile id of this motion controller
  43822. */
  43823. abstract profileId: string;
  43824. /**
  43825. * A map of components (WebXRControllerComponent) in this motion controller
  43826. * Components have a ComponentType and can also have both button and axis definitions
  43827. */
  43828. readonly components: {
  43829. [id: string]: WebXRControllerComponent;
  43830. };
  43831. /**
  43832. * Observers registered here will be triggered when the model of this controller is done loading
  43833. */
  43834. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  43835. /**
  43836. * The root mesh of the model. It is null if the model was not yet initialized
  43837. */
  43838. rootMesh: Nullable<AbstractMesh>;
  43839. /**
  43840. * Disable the model's animation. Can be set at any time.
  43841. */
  43842. disableAnimation: boolean;
  43843. private _modelReady;
  43844. /**
  43845. * constructs a new abstract motion controller
  43846. * @param scene the scene to which the model of the controller will be added
  43847. * @param layout The profile layout to load
  43848. * @param gamepadObject The gamepad object correlating to this controller
  43849. * @param handness handness (left/right/none) of this controller
  43850. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  43851. */
  43852. constructor(scene: Scene, layout: IMotionControllerLayout,
  43853. /**
  43854. * The gamepad object correlating to this controller
  43855. */
  43856. gamepadObject: IMinimalMotionControllerObject,
  43857. /**
  43858. * handness (left/right/none) of this controller
  43859. */
  43860. handness: MotionControllerHandness, _doNotLoadControllerMesh?: boolean);
  43861. private _initComponent;
  43862. /**
  43863. * Update this model using the current XRFrame
  43864. * @param xrFrame the current xr frame to use and update the model
  43865. */
  43866. updateFromXRFrame(xrFrame: XRFrame): void;
  43867. /**
  43868. * Get the list of components available in this motion controller
  43869. * @returns an array of strings correlating to available components
  43870. */
  43871. getComponentIds(): string[];
  43872. /**
  43873. * Get the main (Select) component of this controller as defined in the layout
  43874. * @returns the main component of this controller
  43875. */
  43876. getMainComponent(): WebXRControllerComponent;
  43877. /**
  43878. * get a component based an its component id as defined in layout.components
  43879. * @param id the id of the component
  43880. * @returns the component correlates to the id or undefined if not found
  43881. */
  43882. getComponent(id: string): WebXRControllerComponent;
  43883. /**
  43884. * Get the first component of specific type
  43885. * @param type type of component to find
  43886. * @return a controller component or null if not found
  43887. */
  43888. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  43889. /**
  43890. * Returns all components of specific type
  43891. * @param type the type to search for
  43892. * @return an array of components with this type
  43893. */
  43894. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  43895. /**
  43896. * Loads the model correlating to this controller
  43897. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  43898. * @returns A promise fulfilled with the result of the model loading
  43899. */
  43900. loadModel(): Promise<boolean>;
  43901. /**
  43902. * Update the model itself with the current frame data
  43903. * @param xrFrame the frame to use for updating the model mesh
  43904. */
  43905. protected updateModel(xrFrame: XRFrame): void;
  43906. /**
  43907. * Moves the axis on the controller mesh based on its current state
  43908. * @param axis the index of the axis
  43909. * @param axisValue the value of the axis which determines the meshes new position
  43910. * @hidden
  43911. */
  43912. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  43913. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh;
  43914. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh;
  43915. private _getGenericFilenameAndPath;
  43916. private _getGenericParentMesh;
  43917. /**
  43918. * Get the filename and path for this controller's model
  43919. * @returns a map of filename and path
  43920. */
  43921. protected abstract _getFilenameAndPath(): {
  43922. filename: string;
  43923. path: string;
  43924. };
  43925. /**
  43926. * This function will be called after the model was successfully loaded and can be used
  43927. * for mesh transformations before it is available for the user
  43928. * @param meshes the loaded meshes
  43929. */
  43930. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  43931. /**
  43932. * Set the root mesh for this controller. Important for the WebXR controller class
  43933. * @param meshes the loaded meshes
  43934. */
  43935. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  43936. /**
  43937. * A function executed each frame that updates the mesh (if needed)
  43938. * @param xrFrame the current xrFrame
  43939. */
  43940. protected abstract _updateModel(xrFrame: XRFrame): void;
  43941. /**
  43942. * This function is called before the mesh is loaded. It checks for loading constraints.
  43943. * For example, this function can check if the GLB loader is available
  43944. * If this function returns false, the generic controller will be loaded instead
  43945. * @returns Is the client ready to load the mesh
  43946. */
  43947. protected abstract _getModelLoadingConstraints(): boolean;
  43948. /**
  43949. * Dispose this controller, the model mesh and all its components
  43950. */
  43951. dispose(): void;
  43952. }
  43953. }
  43954. declare module BABYLON {
  43955. /**
  43956. * A generic trigger-only motion controller for WebXR
  43957. */
  43958. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  43959. /**
  43960. * Static version of the profile id of this controller
  43961. */
  43962. static ProfileId: string;
  43963. profileId: string;
  43964. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  43965. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  43966. protected _updateModel(): void;
  43967. protected _getFilenameAndPath(): {
  43968. filename: string;
  43969. path: string;
  43970. };
  43971. protected _setRootMesh(meshes: AbstractMesh[]): void;
  43972. protected _getModelLoadingConstraints(): boolean;
  43973. }
  43974. }
  43975. declare module BABYLON {
  43976. /**
  43977. * Class containing static functions to help procedurally build meshes
  43978. */
  43979. export class SphereBuilder {
  43980. /**
  43981. * Creates a sphere mesh
  43982. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  43983. * * 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`)
  43984. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  43985. * * 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
  43986. * * 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)
  43987. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43988. * * 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
  43989. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43990. * @param name defines the name of the mesh
  43991. * @param options defines the options used to create the mesh
  43992. * @param scene defines the hosting scene
  43993. * @returns the sphere mesh
  43994. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  43995. */
  43996. static CreateSphere(name: string, options: {
  43997. segments?: number;
  43998. diameter?: number;
  43999. diameterX?: number;
  44000. diameterY?: number;
  44001. diameterZ?: number;
  44002. arc?: number;
  44003. slice?: number;
  44004. sideOrientation?: number;
  44005. frontUVs?: Vector4;
  44006. backUVs?: Vector4;
  44007. updatable?: boolean;
  44008. }, scene?: Nullable<Scene>): Mesh;
  44009. }
  44010. }
  44011. declare module BABYLON {
  44012. /**
  44013. * A profiled motion controller has its profile loaded from an online repository.
  44014. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  44015. */
  44016. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  44017. private _repositoryUrl;
  44018. /**
  44019. * The profile ID of this controller. Will be populated when the controller initializes.
  44020. */
  44021. profileId: string;
  44022. private _buttonMeshMapping;
  44023. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  44024. protected _getFilenameAndPath(): {
  44025. filename: string;
  44026. path: string;
  44027. };
  44028. private _touchDots;
  44029. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  44030. protected _setRootMesh(meshes: AbstractMesh[]): void;
  44031. protected _updateModel(_xrFrame: XRFrame): void;
  44032. protected _getModelLoadingConstraints(): boolean;
  44033. dispose(): void;
  44034. }
  44035. }
  44036. declare module BABYLON {
  44037. /**
  44038. * A construction function type to create a new controller based on an xrInput object
  44039. */
  44040. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  44041. /**
  44042. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  44043. *
  44044. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  44045. * it should be replaced with auto-loaded controllers.
  44046. *
  44047. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  44048. */
  44049. export class WebXRMotionControllerManager {
  44050. /**
  44051. * The base URL of the online controller repository. Can be changed at any time.
  44052. */
  44053. static BaseRepositoryUrl: string;
  44054. /**
  44055. * Use the online repository, or use only locally-defined controllers
  44056. */
  44057. static UseOnlineRepository: boolean;
  44058. /**
  44059. * Which repository gets priority - local or online
  44060. */
  44061. static PrioritizeOnlineRepository: boolean;
  44062. private static _AvailableControllers;
  44063. private static _Fallbacks;
  44064. /**
  44065. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  44066. *
  44067. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  44068. *
  44069. * @param type the profile type to register
  44070. * @param constructFunction the function to be called when loading this profile
  44071. */
  44072. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  44073. /**
  44074. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  44075. * The order of search:
  44076. *
  44077. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  44078. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  44079. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  44080. * 4) return the generic trigger controller if none were found
  44081. *
  44082. * @param xrInput the xrInput to which a new controller is initialized
  44083. * @param scene the scene to which the model will be added
  44084. * @param forceProfile force a certain profile for this controller
  44085. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  44086. */
  44087. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  44088. private static _LoadProfilesFromAvailableControllers;
  44089. private static _ProfilesList;
  44090. private static _ProfileLoadingPromises;
  44091. private static _LoadProfileFromRepository;
  44092. /**
  44093. * Clear the cache used for profile loading and reload when requested again
  44094. */
  44095. static ClearProfilesCache(): void;
  44096. /**
  44097. * Will update the list of profiles available in the repository
  44098. * @return a promise that resolves to a map of profiles available online
  44099. */
  44100. static UpdateProfilesList(): Promise<{
  44101. [profile: string]: string;
  44102. }>;
  44103. /**
  44104. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  44105. * @param profileId the profile to which a fallback needs to be found
  44106. * @return an array with corresponding fallback profiles
  44107. */
  44108. static FindFallbackWithProfileId(profileId: string): string[];
  44109. /**
  44110. * Register a fallback to a specific profile.
  44111. * @param profileId the profileId that will receive the fallbacks
  44112. * @param fallbacks A list of fallback profiles
  44113. */
  44114. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  44115. /**
  44116. * Register the default fallbacks.
  44117. * This function is called automatically when this file is imported.
  44118. */
  44119. static DefaultFallbacks(): void;
  44120. }
  44121. }
  44122. declare module BABYLON {
  44123. /**
  44124. * Configuration options for the WebXR controller creation
  44125. */
  44126. export interface IWebXRControllerOptions {
  44127. /**
  44128. * Force a specific controller type for this controller.
  44129. * This can be used when creating your own profile or when testing different controllers
  44130. */
  44131. forceControllerProfile?: string;
  44132. /**
  44133. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  44134. */
  44135. doNotLoadControllerMesh?: boolean;
  44136. /**
  44137. * Should the controller mesh be animated when a user interacts with it
  44138. * The pressed buttons / thumbstick and touchpad animations will be disabled
  44139. */
  44140. disableMotionControllerAnimation?: boolean;
  44141. }
  44142. /**
  44143. * Represents an XR controller
  44144. */
  44145. export class WebXRInputSource {
  44146. private _scene;
  44147. /** The underlying input source for the controller */
  44148. inputSource: XRInputSource;
  44149. private _options;
  44150. /**
  44151. * 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
  44152. */
  44153. grip?: AbstractMesh;
  44154. /**
  44155. * Pointer which can be used to select objects or attach a visible laser to
  44156. */
  44157. pointer: AbstractMesh;
  44158. /**
  44159. * If available, this is the gamepad object related to this controller.
  44160. * Using this object it is possible to get click events and trackpad changes of the
  44161. * webxr controller that is currently being used.
  44162. */
  44163. motionController?: WebXRAbstractMotionController;
  44164. /**
  44165. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  44166. */
  44167. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  44168. /**
  44169. * Will be triggered when the mesh associated with the motion controller is done loading.
  44170. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  44171. * A shortened version of controller -> motion controller -> on mesh loaded.
  44172. */
  44173. onMeshLoadedObservable: Observable<AbstractMesh>;
  44174. /**
  44175. * Event that fires when the controller is removed/disposed.
  44176. * The object provided as event data is this controller, after associated assets were disposed.
  44177. * uniqueId is still available.
  44178. */
  44179. onDisposeObservable: Observable<WebXRInputSource>;
  44180. private _tmpQuaternion;
  44181. private _tmpVector;
  44182. private _uniqueId;
  44183. /**
  44184. * Creates the controller
  44185. * @see https://doc.babylonjs.com/how_to/webxr
  44186. * @param _scene the scene which the controller should be associated to
  44187. * @param inputSource the underlying input source for the controller
  44188. * @param _options options for this controller creation
  44189. */
  44190. constructor(_scene: Scene,
  44191. /** The underlying input source for the controller */
  44192. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  44193. /**
  44194. * Get this controllers unique id
  44195. */
  44196. get uniqueId(): string;
  44197. /**
  44198. * Updates the controller pose based on the given XRFrame
  44199. * @param xrFrame xr frame to update the pose with
  44200. * @param referenceSpace reference space to use
  44201. */
  44202. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  44203. /**
  44204. * Gets a world space ray coming from the pointer or grip
  44205. * @param result the resulting ray
  44206. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  44207. */
  44208. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  44209. /**
  44210. * Disposes of the object
  44211. */
  44212. dispose(): void;
  44213. }
  44214. }
  44215. declare module BABYLON {
  44216. /**
  44217. * The schema for initialization options of the XR Input class
  44218. */
  44219. export interface IWebXRInputOptions {
  44220. /**
  44221. * If set to true no model will be automatically loaded
  44222. */
  44223. doNotLoadControllerMeshes?: boolean;
  44224. /**
  44225. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  44226. * If not found, the xr input profile data will be used.
  44227. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  44228. */
  44229. forceInputProfile?: string;
  44230. /**
  44231. * Do not send a request to the controlle repository to load the profile.
  44232. *
  44233. * Instead, use the controllers available in babylon itself.
  44234. */
  44235. disableOnlineControllerRepository?: boolean;
  44236. /**
  44237. * A custom URL for the controllers repository
  44238. */
  44239. customControllersRepositoryURL?: string;
  44240. /**
  44241. * Should the controller model's components not move according to the user input
  44242. */
  44243. disableControllerAnimation?: boolean;
  44244. }
  44245. /**
  44246. * XR input used to track XR inputs such as controllers/rays
  44247. */
  44248. export class WebXRInput implements IDisposable {
  44249. /**
  44250. * the xr session manager for this session
  44251. */
  44252. xrSessionManager: WebXRSessionManager;
  44253. /**
  44254. * the WebXR camera for this session. Mainly used for teleportation
  44255. */
  44256. xrCamera: WebXRCamera;
  44257. private readonly options;
  44258. /**
  44259. * XR controllers being tracked
  44260. */
  44261. controllers: Array<WebXRInputSource>;
  44262. private _frameObserver;
  44263. private _sessionEndedObserver;
  44264. private _sessionInitObserver;
  44265. /**
  44266. * Event when a controller has been connected/added
  44267. */
  44268. onControllerAddedObservable: Observable<WebXRInputSource>;
  44269. /**
  44270. * Event when a controller has been removed/disconnected
  44271. */
  44272. onControllerRemovedObservable: Observable<WebXRInputSource>;
  44273. /**
  44274. * Initializes the WebXRInput
  44275. * @param xrSessionManager the xr session manager for this session
  44276. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  44277. * @param options = initialization options for this xr input
  44278. */
  44279. constructor(
  44280. /**
  44281. * the xr session manager for this session
  44282. */
  44283. xrSessionManager: WebXRSessionManager,
  44284. /**
  44285. * the WebXR camera for this session. Mainly used for teleportation
  44286. */
  44287. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  44288. private _onInputSourcesChange;
  44289. private _addAndRemoveControllers;
  44290. /**
  44291. * Disposes of the object
  44292. */
  44293. dispose(): void;
  44294. }
  44295. }
  44296. declare module BABYLON {
  44297. /**
  44298. * This is the base class for all WebXR features.
  44299. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  44300. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  44301. */
  44302. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  44303. protected _xrSessionManager: WebXRSessionManager;
  44304. /**
  44305. * Construct a new (abstract) webxr feature
  44306. * @param _xrSessionManager the xr session manager for this feature
  44307. */
  44308. constructor(_xrSessionManager: WebXRSessionManager);
  44309. private _attached;
  44310. private _removeOnDetach;
  44311. /**
  44312. * Is this feature attached
  44313. */
  44314. get attached(): boolean;
  44315. /**
  44316. * Should auto-attach be disabled?
  44317. */
  44318. disableAutoAttach: boolean;
  44319. /**
  44320. * attach this feature
  44321. *
  44322. * @param force should attachment be forced (even when already attached)
  44323. * @returns true if successful, false is failed or already attached
  44324. */
  44325. attach(force?: boolean): boolean;
  44326. /**
  44327. * detach this feature.
  44328. *
  44329. * @returns true if successful, false if failed or already detached
  44330. */
  44331. detach(): boolean;
  44332. /**
  44333. * Dispose this feature and all of the resources attached
  44334. */
  44335. dispose(): void;
  44336. /**
  44337. * Code in this function will be executed on each xrFrame received from the browser.
  44338. * This function will not execute after the feature is detached.
  44339. * @param _xrFrame the current frame
  44340. */
  44341. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  44342. /**
  44343. * This is used to register callbacks that will automatically be removed when detach is called.
  44344. * @param observable the observable to which the observer will be attached
  44345. * @param callback the callback to register
  44346. */
  44347. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  44348. }
  44349. }
  44350. declare module BABYLON {
  44351. /**
  44352. * Renders a layer on top of an existing scene
  44353. */
  44354. export class UtilityLayerRenderer implements IDisposable {
  44355. /** the original scene that will be rendered on top of */
  44356. originalScene: Scene;
  44357. private _pointerCaptures;
  44358. private _lastPointerEvents;
  44359. private static _DefaultUtilityLayer;
  44360. private static _DefaultKeepDepthUtilityLayer;
  44361. private _sharedGizmoLight;
  44362. private _renderCamera;
  44363. /**
  44364. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  44365. * @returns the camera that is used when rendering the utility layer
  44366. */
  44367. getRenderCamera(): Camera;
  44368. /**
  44369. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  44370. * @param cam the camera that should be used when rendering the utility layer
  44371. */
  44372. setRenderCamera(cam: Nullable<Camera>): void;
  44373. /**
  44374. * @hidden
  44375. * Light which used by gizmos to get light shading
  44376. */
  44377. _getSharedGizmoLight(): HemisphericLight;
  44378. /**
  44379. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  44380. */
  44381. pickUtilitySceneFirst: boolean;
  44382. /**
  44383. * 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)
  44384. */
  44385. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  44386. /**
  44387. * 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)
  44388. */
  44389. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  44390. /**
  44391. * The scene that is rendered on top of the original scene
  44392. */
  44393. utilityLayerScene: Scene;
  44394. /**
  44395. * If the utility layer should automatically be rendered on top of existing scene
  44396. */
  44397. shouldRender: boolean;
  44398. /**
  44399. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  44400. */
  44401. onlyCheckPointerDownEvents: boolean;
  44402. /**
  44403. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  44404. */
  44405. processAllEvents: boolean;
  44406. /**
  44407. * Observable raised when the pointer move from the utility layer scene to the main scene
  44408. */
  44409. onPointerOutObservable: Observable<number>;
  44410. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  44411. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  44412. private _afterRenderObserver;
  44413. private _sceneDisposeObserver;
  44414. private _originalPointerObserver;
  44415. /**
  44416. * Instantiates a UtilityLayerRenderer
  44417. * @param originalScene the original scene that will be rendered on top of
  44418. * @param handleEvents boolean indicating if the utility layer should handle events
  44419. */
  44420. constructor(
  44421. /** the original scene that will be rendered on top of */
  44422. originalScene: Scene, handleEvents?: boolean);
  44423. private _notifyObservers;
  44424. /**
  44425. * Renders the utility layers scene on top of the original scene
  44426. */
  44427. render(): void;
  44428. /**
  44429. * Disposes of the renderer
  44430. */
  44431. dispose(): void;
  44432. private _updateCamera;
  44433. }
  44434. }
  44435. declare module BABYLON {
  44436. /**
  44437. * Options interface for the pointer selection module
  44438. */
  44439. export interface IWebXRControllerPointerSelectionOptions {
  44440. /**
  44441. * the xr input to use with this pointer selection
  44442. */
  44443. xrInput: WebXRInput;
  44444. /**
  44445. * Different button type to use instead of the main component
  44446. */
  44447. overrideButtonId?: string;
  44448. /**
  44449. * The amount of time in miliseconds it takes between pick found something to a pointer down event.
  44450. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  44451. * 3000 means 3 seconds between pointing at something and selecting it
  44452. */
  44453. timeToSelect?: number;
  44454. /**
  44455. * 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)
  44456. * If not disabled, the last picked point will be used to execute a pointer up event
  44457. * If disabled, pointer up event will be triggered right after the pointer down event.
  44458. * Used in screen and gaze target ray mode only
  44459. */
  44460. disablePointerUpOnTouchOut: boolean;
  44461. /**
  44462. * For gaze mode (time to select instead of press)
  44463. */
  44464. forceGazeMode: boolean;
  44465. /**
  44466. * 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
  44467. * to start a new countdown to the pointer down event.
  44468. * Defaults to 1.
  44469. */
  44470. gazeModePointerMovedFactor?: number;
  44471. /**
  44472. * Should meshes created here be added to a utility layer or the main scene
  44473. */
  44474. useUtilityLayer?: boolean;
  44475. /**
  44476. * if provided, this scene will be used to render meshes.
  44477. */
  44478. customUtilityLayerScene?: Scene;
  44479. }
  44480. /**
  44481. * A module that will enable pointer selection for motion controllers of XR Input Sources
  44482. */
  44483. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  44484. private readonly _options;
  44485. /**
  44486. * The module's name
  44487. */
  44488. static readonly Name: string;
  44489. /**
  44490. * The (Babylon) version of this module.
  44491. * This is an integer representing the implementation version.
  44492. * This number does not correspond to the webxr specs version
  44493. */
  44494. static readonly Version: number;
  44495. /**
  44496. * This color will be set to the laser pointer when selection is triggered
  44497. */
  44498. laserPointerPickedColor: Color3;
  44499. /**
  44500. * This color will be applied to the selection ring when selection is triggered
  44501. */
  44502. selectionMeshPickedColor: Color3;
  44503. /**
  44504. * default color of the selection ring
  44505. */
  44506. selectionMeshDefaultColor: Color3;
  44507. /**
  44508. * Default color of the laser pointer
  44509. */
  44510. lasterPointerDefaultColor: Color3;
  44511. /**
  44512. * Should the laser pointer be displayed
  44513. */
  44514. displayLaserPointer: boolean;
  44515. /**
  44516. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  44517. */
  44518. displaySelectionMesh: boolean;
  44519. /**
  44520. * Disable lighting on the laser pointer (so it will always be visible)
  44521. */
  44522. disablePointerLighting: boolean;
  44523. /**
  44524. * Disable lighting on the selection mesh (so it will always be visible)
  44525. */
  44526. disableSelectionMeshLighting: boolean;
  44527. private static _idCounter;
  44528. private _tmpRay;
  44529. private _controllers;
  44530. private _scene;
  44531. /**
  44532. * constructs a new background remover module
  44533. * @param _xrSessionManager the session manager for this module
  44534. * @param _options read-only options to be used in this module
  44535. */
  44536. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  44537. /**
  44538. * attach this feature
  44539. * Will usually be called by the features manager
  44540. *
  44541. * @returns true if successful.
  44542. */
  44543. attach(): boolean;
  44544. /**
  44545. * detach this feature.
  44546. * Will usually be called by the features manager
  44547. *
  44548. * @returns true if successful.
  44549. */
  44550. detach(): boolean;
  44551. /**
  44552. * Get the xr controller that correlates to the pointer id in the pointer event
  44553. *
  44554. * @param id the pointer id to search for
  44555. * @returns the controller that correlates to this id or null if not found
  44556. */
  44557. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  44558. protected _onXRFrame(_xrFrame: XRFrame): void;
  44559. private _attachController;
  44560. private _attachScreenRayMode;
  44561. private _attachGazeMode;
  44562. private _tmpVectorForPickCompare;
  44563. private _pickingMoved;
  44564. private _attachTrackedPointerRayMode;
  44565. private _detachController;
  44566. private _generateNewMeshPair;
  44567. private _convertNormalToDirectionOfRay;
  44568. private _updatePointerDistance;
  44569. }
  44570. }
  44571. declare module BABYLON {
  44572. /**
  44573. * Button which can be used to enter a different mode of XR
  44574. */
  44575. export class WebXREnterExitUIButton {
  44576. /** button element */
  44577. element: HTMLElement;
  44578. /** XR initialization options for the button */
  44579. sessionMode: XRSessionMode;
  44580. /** Reference space type */
  44581. referenceSpaceType: XRReferenceSpaceType;
  44582. /**
  44583. * Creates a WebXREnterExitUIButton
  44584. * @param element button element
  44585. * @param sessionMode XR initialization session mode
  44586. * @param referenceSpaceType the type of reference space to be used
  44587. */
  44588. constructor(
  44589. /** button element */
  44590. element: HTMLElement,
  44591. /** XR initialization options for the button */
  44592. sessionMode: XRSessionMode,
  44593. /** Reference space type */
  44594. referenceSpaceType: XRReferenceSpaceType);
  44595. /**
  44596. * Overwritable function which can be used to update the button's visuals when the state changes
  44597. * @param activeButton the current active button in the UI
  44598. */
  44599. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  44600. }
  44601. /**
  44602. * Options to create the webXR UI
  44603. */
  44604. export class WebXREnterExitUIOptions {
  44605. /**
  44606. * Context to enter xr with
  44607. */
  44608. renderTarget?: Nullable<WebXRRenderTarget>;
  44609. /**
  44610. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  44611. */
  44612. customButtons?: Array<WebXREnterExitUIButton>;
  44613. /**
  44614. * A session mode to use when creating the default button.
  44615. * Default is immersive-vr
  44616. */
  44617. sessionMode?: XRSessionMode;
  44618. /**
  44619. * A reference space type to use when creating the default button.
  44620. * Default is local-floor
  44621. */
  44622. referenceSpaceType?: XRReferenceSpaceType;
  44623. }
  44624. /**
  44625. * UI to allow the user to enter/exit XR mode
  44626. */
  44627. export class WebXREnterExitUI implements IDisposable {
  44628. private scene;
  44629. /** version of the options passed to this UI */
  44630. options: WebXREnterExitUIOptions;
  44631. private _overlay;
  44632. private _buttons;
  44633. private _activeButton;
  44634. /**
  44635. * Fired every time the active button is changed.
  44636. *
  44637. * When xr is entered via a button that launches xr that button will be the callback parameter
  44638. *
  44639. * When exiting xr the callback parameter will be null)
  44640. */
  44641. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  44642. /**
  44643. * Creates UI to allow the user to enter/exit XR mode
  44644. * @param scene the scene to add the ui to
  44645. * @param helper the xr experience helper to enter/exit xr with
  44646. * @param options options to configure the UI
  44647. * @returns the created ui
  44648. */
  44649. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  44650. /**
  44651. *
  44652. * @param scene babylon scene object to use
  44653. * @param options (read-only) version of the options passed to this UI
  44654. */
  44655. private constructor();
  44656. private _updateButtons;
  44657. /**
  44658. * Disposes of the object
  44659. */
  44660. dispose(): void;
  44661. }
  44662. }
  44663. declare module BABYLON {
  44664. /**
  44665. * Class containing static functions to help procedurally build meshes
  44666. */
  44667. export class LinesBuilder {
  44668. /**
  44669. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  44670. * * 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
  44671. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  44672. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  44673. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  44674. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  44675. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  44676. * * 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
  44677. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  44678. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44679. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  44680. * @param name defines the name of the new line system
  44681. * @param options defines the options used to create the line system
  44682. * @param scene defines the hosting scene
  44683. * @returns a new line system mesh
  44684. */
  44685. static CreateLineSystem(name: string, options: {
  44686. lines: Vector3[][];
  44687. updatable?: boolean;
  44688. instance?: Nullable<LinesMesh>;
  44689. colors?: Nullable<Color4[][]>;
  44690. useVertexAlpha?: boolean;
  44691. }, scene: Nullable<Scene>): LinesMesh;
  44692. /**
  44693. * Creates a line mesh
  44694. * 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
  44695. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  44696. * * The parameter `points` is an array successive Vector3
  44697. * * 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
  44698. * * The optional parameter `colors` is an array of successive Color4, one per line point
  44699. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  44700. * * When updating an instance, remember that only point positions can change, not the number of points
  44701. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44702. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  44703. * @param name defines the name of the new line system
  44704. * @param options defines the options used to create the line system
  44705. * @param scene defines the hosting scene
  44706. * @returns a new line mesh
  44707. */
  44708. static CreateLines(name: string, options: {
  44709. points: Vector3[];
  44710. updatable?: boolean;
  44711. instance?: Nullable<LinesMesh>;
  44712. colors?: Color4[];
  44713. useVertexAlpha?: boolean;
  44714. }, scene?: Nullable<Scene>): LinesMesh;
  44715. /**
  44716. * Creates a dashed line mesh
  44717. * * 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
  44718. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  44719. * * The parameter `points` is an array successive Vector3
  44720. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  44721. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  44722. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  44723. * * 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
  44724. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  44725. * * When updating an instance, remember that only point positions can change, not the number of points
  44726. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44727. * @param name defines the name of the mesh
  44728. * @param options defines the options used to create the mesh
  44729. * @param scene defines the hosting scene
  44730. * @returns the dashed line mesh
  44731. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  44732. */
  44733. static CreateDashedLines(name: string, options: {
  44734. points: Vector3[];
  44735. dashSize?: number;
  44736. gapSize?: number;
  44737. dashNb?: number;
  44738. updatable?: boolean;
  44739. instance?: LinesMesh;
  44740. useVertexAlpha?: boolean;
  44741. }, scene?: Nullable<Scene>): LinesMesh;
  44742. }
  44743. }
  44744. declare module BABYLON {
  44745. /**
  44746. * The options container for the teleportation module
  44747. */
  44748. export interface IWebXRTeleportationOptions {
  44749. /**
  44750. * Babylon XR Input class for controller
  44751. */
  44752. xrInput: WebXRInput;
  44753. /**
  44754. * A list of meshes to use as floor meshes.
  44755. * Meshes can be added and removed after initializing the feature using the
  44756. * addFloorMesh and removeFloorMesh functions
  44757. * If empty, rotation will still work
  44758. */
  44759. floorMeshes?: AbstractMesh[];
  44760. /**
  44761. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  44762. * If you want to support rotation, make sure your mesh has a direction indicator.
  44763. *
  44764. * When left untouched, the default mesh will be initialized.
  44765. */
  44766. teleportationTargetMesh?: AbstractMesh;
  44767. /**
  44768. * Values to configure the default target mesh
  44769. */
  44770. defaultTargetMeshOptions?: {
  44771. /**
  44772. * Fill color of the teleportation area
  44773. */
  44774. teleportationFillColor?: string;
  44775. /**
  44776. * Border color for the teleportation area
  44777. */
  44778. teleportationBorderColor?: string;
  44779. /**
  44780. * Disable the mesh's animation sequence
  44781. */
  44782. disableAnimation?: boolean;
  44783. /**
  44784. * Disable lighting on the material or the ring and arrow
  44785. */
  44786. disableLighting?: boolean;
  44787. /**
  44788. * Override the default material of the torus and arrow
  44789. */
  44790. torusArrowMaterial?: Material;
  44791. };
  44792. /**
  44793. * Disable using the thumbstick and use the main component (usuallly trigger) on long press.
  44794. * This will be automatically true if the controller doesnt have a thumbstick or touchpad.
  44795. */
  44796. useMainComponentOnly?: boolean;
  44797. /**
  44798. * If main component is used (no thumbstick), how long should the "long press" take before teleporting
  44799. */
  44800. timeToTeleport?: number;
  44801. /**
  44802. * Should meshes created here be added to a utility layer or the main scene
  44803. */
  44804. useUtilityLayer?: boolean;
  44805. /**
  44806. * if provided, this scene will be used to render meshes.
  44807. */
  44808. customUtilityLayerScene?: Scene;
  44809. }
  44810. /**
  44811. * This is a teleportation feature to be used with webxr-enabled motion controllers.
  44812. * When enabled and attached, the feature will allow a user to move aroundand rotate in the scene using
  44813. * the input of the attached controllers.
  44814. */
  44815. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  44816. private _options;
  44817. /**
  44818. * The module's name
  44819. */
  44820. static readonly Name: string;
  44821. /**
  44822. * The (Babylon) version of this module.
  44823. * This is an integer representing the implementation version.
  44824. * This number does not correspond to the webxr specs version
  44825. */
  44826. static readonly Version: number;
  44827. /**
  44828. * Is rotation enabled when moving forward?
  44829. * Disabling this feature will prevent the user from deciding the direction when teleporting
  44830. */
  44831. rotationEnabled: boolean;
  44832. /**
  44833. * Should the module support parabolic ray on top of direct ray
  44834. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  44835. * Very helpful when moving between floors / different heights
  44836. */
  44837. parabolicRayEnabled: boolean;
  44838. /**
  44839. * The distance from the user to the inspection point in the direction of the controller
  44840. * A higher number will allow the user to move further
  44841. * defaults to 5 (meters, in xr units)
  44842. */
  44843. parabolicCheckRadius: number;
  44844. /**
  44845. * How much rotation should be applied when rotating right and left
  44846. */
  44847. rotationAngle: number;
  44848. /**
  44849. * Is movement backwards enabled
  44850. */
  44851. backwardsMovementEnabled: boolean;
  44852. /**
  44853. * Distance to travel when moving backwards
  44854. */
  44855. backwardsTeleportationDistance: number;
  44856. /**
  44857. * Add a new mesh to the floor meshes array
  44858. * @param mesh the mesh to use as floor mesh
  44859. */
  44860. addFloorMesh(mesh: AbstractMesh): void;
  44861. /**
  44862. * Remove a mesh from the floor meshes array
  44863. * @param mesh the mesh to remove
  44864. */
  44865. removeFloorMesh(mesh: AbstractMesh): void;
  44866. /**
  44867. * Remove a mesh from the floor meshes array using its name
  44868. * @param name the mesh name to remove
  44869. */
  44870. removeFloorMeshByName(name: string): void;
  44871. private _tmpRay;
  44872. private _tmpVector;
  44873. private _floorMeshes;
  44874. private _controllers;
  44875. /**
  44876. * constructs a new anchor system
  44877. * @param _xrSessionManager an instance of WebXRSessionManager
  44878. * @param _options configuration object for this feature
  44879. */
  44880. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  44881. private _selectionFeature;
  44882. /**
  44883. * This function sets a selection feature that will be disabled when
  44884. * the forward ray is shown and will be reattached when hidden.
  44885. * This is used to remove the selection rays when moving.
  44886. * @param selectionFeature the feature to disable when forward movement is enabled
  44887. */
  44888. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  44889. attach(): boolean;
  44890. detach(): boolean;
  44891. dispose(): void;
  44892. protected _onXRFrame(_xrFrame: XRFrame): void;
  44893. private _currentTeleportationControllerId;
  44894. private _attachController;
  44895. private _teleportForward;
  44896. private _detachController;
  44897. private createDefaultTargetMesh;
  44898. private setTargetMeshVisibility;
  44899. private setTargetMeshPosition;
  44900. private _quadraticBezierCurve;
  44901. private _showParabolicPath;
  44902. }
  44903. }
  44904. declare module BABYLON {
  44905. /**
  44906. * Options for the default xr helper
  44907. */
  44908. export class WebXRDefaultExperienceOptions {
  44909. /**
  44910. * Floor meshes that will be used for teleporting
  44911. */
  44912. floorMeshes?: Array<AbstractMesh>;
  44913. /**
  44914. * Enable or disable default UI to enter XR
  44915. */
  44916. disableDefaultUI?: boolean;
  44917. /**
  44918. * optional configuration for the output canvas
  44919. */
  44920. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  44921. /**
  44922. * optional UI options. This can be used among other to change session mode and reference space type
  44923. */
  44924. uiOptions?: WebXREnterExitUIOptions;
  44925. /**
  44926. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  44927. */
  44928. inputOptions?: IWebXRInputOptions;
  44929. /**
  44930. * Should teleportation not initialize. defaults to false.
  44931. */
  44932. disableTeleportation?: boolean;
  44933. /**
  44934. * If set to true, the first frame will not be used to reset position
  44935. * The first frame is mainly used when copying transformation from the old camera
  44936. * Mainly used in AR
  44937. */
  44938. ignoreNativeCameraTransformation?: boolean;
  44939. /**
  44940. * When loading teleportation and pointer select, use stable versions instead of latest.
  44941. */
  44942. useStablePlugins?: boolean;
  44943. }
  44944. /**
  44945. * Default experience which provides a similar setup to the previous webVRExperience
  44946. */
  44947. export class WebXRDefaultExperience {
  44948. /**
  44949. * Base experience
  44950. */
  44951. baseExperience: WebXRExperienceHelper;
  44952. /**
  44953. * Input experience extension
  44954. */
  44955. input: WebXRInput;
  44956. /**
  44957. * Enables laser pointer and selection
  44958. */
  44959. pointerSelection: WebXRControllerPointerSelection;
  44960. /**
  44961. * Enables teleportation
  44962. */
  44963. teleportation: WebXRMotionControllerTeleportation;
  44964. /**
  44965. * Enables ui for entering/exiting xr
  44966. */
  44967. enterExitUI: WebXREnterExitUI;
  44968. /**
  44969. * Default target xr should render to
  44970. */
  44971. renderTarget: WebXRRenderTarget;
  44972. /**
  44973. * Creates the default xr experience
  44974. * @param scene scene
  44975. * @param options options for basic configuration
  44976. * @returns resulting WebXRDefaultExperience
  44977. */
  44978. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  44979. private constructor();
  44980. /**
  44981. * DIsposes of the experience helper
  44982. */
  44983. dispose(): void;
  44984. }
  44985. }
  44986. declare module BABYLON {
  44987. /**
  44988. * Options to modify the vr teleportation behavior.
  44989. */
  44990. export interface VRTeleportationOptions {
  44991. /**
  44992. * The name of the mesh which should be used as the teleportation floor. (default: null)
  44993. */
  44994. floorMeshName?: string;
  44995. /**
  44996. * A list of meshes to be used as the teleportation floor. (default: empty)
  44997. */
  44998. floorMeshes?: Mesh[];
  44999. /**
  45000. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  45001. */
  45002. teleportationMode?: number;
  45003. /**
  45004. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  45005. */
  45006. teleportationTime?: number;
  45007. /**
  45008. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  45009. */
  45010. teleportationSpeed?: number;
  45011. /**
  45012. * The easing function used in the animation or null for Linear. (default CircleEase)
  45013. */
  45014. easingFunction?: EasingFunction;
  45015. }
  45016. /**
  45017. * Options to modify the vr experience helper's behavior.
  45018. */
  45019. export interface VRExperienceHelperOptions extends WebVROptions {
  45020. /**
  45021. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  45022. */
  45023. createDeviceOrientationCamera?: boolean;
  45024. /**
  45025. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  45026. */
  45027. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  45028. /**
  45029. * Uses the main button on the controller to toggle the laser casted. (default: true)
  45030. */
  45031. laserToggle?: boolean;
  45032. /**
  45033. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  45034. */
  45035. floorMeshes?: Mesh[];
  45036. /**
  45037. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  45038. */
  45039. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  45040. /**
  45041. * Defines if WebXR should be used instead of WebVR (if available)
  45042. */
  45043. useXR?: boolean;
  45044. }
  45045. /**
  45046. * Event containing information after VR has been entered
  45047. */
  45048. export class OnAfterEnteringVRObservableEvent {
  45049. /**
  45050. * If entering vr was successful
  45051. */
  45052. success: boolean;
  45053. }
  45054. /**
  45055. * Helps to quickly add VR support to an existing scene.
  45056. * See http://doc.babylonjs.com/how_to/webvr_helper
  45057. */
  45058. export class VRExperienceHelper {
  45059. /** Options to modify the vr experience helper's behavior. */
  45060. webVROptions: VRExperienceHelperOptions;
  45061. private _scene;
  45062. private _position;
  45063. private _btnVR;
  45064. private _btnVRDisplayed;
  45065. private _webVRsupported;
  45066. private _webVRready;
  45067. private _webVRrequesting;
  45068. private _webVRpresenting;
  45069. private _hasEnteredVR;
  45070. private _fullscreenVRpresenting;
  45071. private _inputElement;
  45072. private _webVRCamera;
  45073. private _vrDeviceOrientationCamera;
  45074. private _deviceOrientationCamera;
  45075. private _existingCamera;
  45076. private _onKeyDown;
  45077. private _onVrDisplayPresentChange;
  45078. private _onVRDisplayChanged;
  45079. private _onVRRequestPresentStart;
  45080. private _onVRRequestPresentComplete;
  45081. /**
  45082. * 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)
  45083. */
  45084. enableGazeEvenWhenNoPointerLock: boolean;
  45085. /**
  45086. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  45087. */
  45088. exitVROnDoubleTap: boolean;
  45089. /**
  45090. * Observable raised right before entering VR.
  45091. */
  45092. onEnteringVRObservable: Observable<VRExperienceHelper>;
  45093. /**
  45094. * Observable raised when entering VR has completed.
  45095. */
  45096. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  45097. /**
  45098. * Observable raised when exiting VR.
  45099. */
  45100. onExitingVRObservable: Observable<VRExperienceHelper>;
  45101. /**
  45102. * Observable raised when controller mesh is loaded.
  45103. */
  45104. onControllerMeshLoadedObservable: Observable<WebVRController>;
  45105. /** Return this.onEnteringVRObservable
  45106. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  45107. */
  45108. get onEnteringVR(): Observable<VRExperienceHelper>;
  45109. /** Return this.onExitingVRObservable
  45110. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  45111. */
  45112. get onExitingVR(): Observable<VRExperienceHelper>;
  45113. /** Return this.onControllerMeshLoadedObservable
  45114. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  45115. */
  45116. get onControllerMeshLoaded(): Observable<WebVRController>;
  45117. private _rayLength;
  45118. private _useCustomVRButton;
  45119. private _teleportationRequested;
  45120. private _teleportActive;
  45121. private _floorMeshName;
  45122. private _floorMeshesCollection;
  45123. private _teleportationMode;
  45124. private _teleportationTime;
  45125. private _teleportationSpeed;
  45126. private _teleportationEasing;
  45127. private _rotationAllowed;
  45128. private _teleportBackwardsVector;
  45129. private _teleportationTarget;
  45130. private _isDefaultTeleportationTarget;
  45131. private _postProcessMove;
  45132. private _teleportationFillColor;
  45133. private _teleportationBorderColor;
  45134. private _rotationAngle;
  45135. private _haloCenter;
  45136. private _cameraGazer;
  45137. private _padSensibilityUp;
  45138. private _padSensibilityDown;
  45139. private _leftController;
  45140. private _rightController;
  45141. private _gazeColor;
  45142. private _laserColor;
  45143. private _pickedLaserColor;
  45144. private _pickedGazeColor;
  45145. /**
  45146. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  45147. */
  45148. onNewMeshSelected: Observable<AbstractMesh>;
  45149. /**
  45150. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  45151. * This observable will provide the mesh and the controller used to select the mesh
  45152. */
  45153. onMeshSelectedWithController: Observable<{
  45154. mesh: AbstractMesh;
  45155. controller: WebVRController;
  45156. }>;
  45157. /**
  45158. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  45159. */
  45160. onNewMeshPicked: Observable<PickingInfo>;
  45161. private _circleEase;
  45162. /**
  45163. * Observable raised before camera teleportation
  45164. */
  45165. onBeforeCameraTeleport: Observable<Vector3>;
  45166. /**
  45167. * Observable raised after camera teleportation
  45168. */
  45169. onAfterCameraTeleport: Observable<Vector3>;
  45170. /**
  45171. * Observable raised when current selected mesh gets unselected
  45172. */
  45173. onSelectedMeshUnselected: Observable<AbstractMesh>;
  45174. private _raySelectionPredicate;
  45175. /**
  45176. * To be optionaly changed by user to define custom ray selection
  45177. */
  45178. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  45179. /**
  45180. * To be optionaly changed by user to define custom selection logic (after ray selection)
  45181. */
  45182. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  45183. /**
  45184. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  45185. */
  45186. teleportationEnabled: boolean;
  45187. private _defaultHeight;
  45188. private _teleportationInitialized;
  45189. private _interactionsEnabled;
  45190. private _interactionsRequested;
  45191. private _displayGaze;
  45192. private _displayLaserPointer;
  45193. /**
  45194. * The mesh used to display where the user is going to teleport.
  45195. */
  45196. get teleportationTarget(): Mesh;
  45197. /**
  45198. * Sets the mesh to be used to display where the user is going to teleport.
  45199. */
  45200. set teleportationTarget(value: Mesh);
  45201. /**
  45202. * 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
  45203. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  45204. * See http://doc.babylonjs.com/resources/baking_transformations
  45205. */
  45206. get gazeTrackerMesh(): Mesh;
  45207. set gazeTrackerMesh(value: Mesh);
  45208. /**
  45209. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  45210. */
  45211. updateGazeTrackerScale: boolean;
  45212. /**
  45213. * If the gaze trackers color should be updated when selecting meshes
  45214. */
  45215. updateGazeTrackerColor: boolean;
  45216. /**
  45217. * If the controller laser color should be updated when selecting meshes
  45218. */
  45219. updateControllerLaserColor: boolean;
  45220. /**
  45221. * The gaze tracking mesh corresponding to the left controller
  45222. */
  45223. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  45224. /**
  45225. * The gaze tracking mesh corresponding to the right controller
  45226. */
  45227. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  45228. /**
  45229. * If the ray of the gaze should be displayed.
  45230. */
  45231. get displayGaze(): boolean;
  45232. /**
  45233. * Sets if the ray of the gaze should be displayed.
  45234. */
  45235. set displayGaze(value: boolean);
  45236. /**
  45237. * If the ray of the LaserPointer should be displayed.
  45238. */
  45239. get displayLaserPointer(): boolean;
  45240. /**
  45241. * Sets if the ray of the LaserPointer should be displayed.
  45242. */
  45243. set displayLaserPointer(value: boolean);
  45244. /**
  45245. * The deviceOrientationCamera used as the camera when not in VR.
  45246. */
  45247. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  45248. /**
  45249. * Based on the current WebVR support, returns the current VR camera used.
  45250. */
  45251. get currentVRCamera(): Nullable<Camera>;
  45252. /**
  45253. * The webVRCamera which is used when in VR.
  45254. */
  45255. get webVRCamera(): WebVRFreeCamera;
  45256. /**
  45257. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  45258. */
  45259. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  45260. /**
  45261. * The html button that is used to trigger entering into VR.
  45262. */
  45263. get vrButton(): Nullable<HTMLButtonElement>;
  45264. private get _teleportationRequestInitiated();
  45265. /**
  45266. * Defines whether or not Pointer lock should be requested when switching to
  45267. * full screen.
  45268. */
  45269. requestPointerLockOnFullScreen: boolean;
  45270. /**
  45271. * If asking to force XR, this will be populated with the default xr experience
  45272. */
  45273. xr: WebXRDefaultExperience;
  45274. /**
  45275. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  45276. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  45277. */
  45278. xrTestDone: boolean;
  45279. /**
  45280. * Instantiates a VRExperienceHelper.
  45281. * Helps to quickly add VR support to an existing scene.
  45282. * @param scene The scene the VRExperienceHelper belongs to.
  45283. * @param webVROptions Options to modify the vr experience helper's behavior.
  45284. */
  45285. constructor(scene: Scene,
  45286. /** Options to modify the vr experience helper's behavior. */
  45287. webVROptions?: VRExperienceHelperOptions);
  45288. private completeVRInit;
  45289. private _onDefaultMeshLoaded;
  45290. private _onResize;
  45291. private _onFullscreenChange;
  45292. /**
  45293. * Gets a value indicating if we are currently in VR mode.
  45294. */
  45295. get isInVRMode(): boolean;
  45296. private onVrDisplayPresentChange;
  45297. private onVRDisplayChanged;
  45298. private moveButtonToBottomRight;
  45299. private displayVRButton;
  45300. private updateButtonVisibility;
  45301. private _cachedAngularSensibility;
  45302. /**
  45303. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  45304. * Otherwise, will use the fullscreen API.
  45305. */
  45306. enterVR(): void;
  45307. /**
  45308. * Attempt to exit VR, or fullscreen.
  45309. */
  45310. exitVR(): void;
  45311. /**
  45312. * The position of the vr experience helper.
  45313. */
  45314. get position(): Vector3;
  45315. /**
  45316. * Sets the position of the vr experience helper.
  45317. */
  45318. set position(value: Vector3);
  45319. /**
  45320. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  45321. */
  45322. enableInteractions(): void;
  45323. private get _noControllerIsActive();
  45324. private beforeRender;
  45325. private _isTeleportationFloor;
  45326. /**
  45327. * Adds a floor mesh to be used for teleportation.
  45328. * @param floorMesh the mesh to be used for teleportation.
  45329. */
  45330. addFloorMesh(floorMesh: Mesh): void;
  45331. /**
  45332. * Removes a floor mesh from being used for teleportation.
  45333. * @param floorMesh the mesh to be removed.
  45334. */
  45335. removeFloorMesh(floorMesh: Mesh): void;
  45336. /**
  45337. * Enables interactions and teleportation using the VR controllers and gaze.
  45338. * @param vrTeleportationOptions options to modify teleportation behavior.
  45339. */
  45340. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  45341. private _onNewGamepadConnected;
  45342. private _tryEnableInteractionOnController;
  45343. private _onNewGamepadDisconnected;
  45344. private _enableInteractionOnController;
  45345. private _checkTeleportWithRay;
  45346. private _checkRotate;
  45347. private _checkTeleportBackwards;
  45348. private _enableTeleportationOnController;
  45349. private _createTeleportationCircles;
  45350. private _displayTeleportationTarget;
  45351. private _hideTeleportationTarget;
  45352. private _rotateCamera;
  45353. private _moveTeleportationSelectorTo;
  45354. private _workingVector;
  45355. private _workingQuaternion;
  45356. private _workingMatrix;
  45357. /**
  45358. * Time Constant Teleportation Mode
  45359. */
  45360. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  45361. /**
  45362. * Speed Constant Teleportation Mode
  45363. */
  45364. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  45365. /**
  45366. * Teleports the users feet to the desired location
  45367. * @param location The location where the user's feet should be placed
  45368. */
  45369. teleportCamera(location: Vector3): void;
  45370. private _convertNormalToDirectionOfRay;
  45371. private _castRayAndSelectObject;
  45372. private _notifySelectedMeshUnselected;
  45373. /**
  45374. * Permanently set new colors for the laser pointer
  45375. * @param color the new laser color
  45376. * @param pickedColor the new laser color when picked mesh detected
  45377. */
  45378. setLaserColor(color: Color3, pickedColor?: Color3): void;
  45379. /**
  45380. * Set lighting enabled / disabled on the laser pointer of both controllers
  45381. * @param enabled should the lighting be enabled on the laser pointer
  45382. */
  45383. setLaserLightingState(enabled?: boolean): void;
  45384. /**
  45385. * Permanently set new colors for the gaze pointer
  45386. * @param color the new gaze color
  45387. * @param pickedColor the new gaze color when picked mesh detected
  45388. */
  45389. setGazeColor(color: Color3, pickedColor?: Color3): void;
  45390. /**
  45391. * Sets the color of the laser ray from the vr controllers.
  45392. * @param color new color for the ray.
  45393. */
  45394. changeLaserColor(color: Color3): void;
  45395. /**
  45396. * Sets the color of the ray from the vr headsets gaze.
  45397. * @param color new color for the ray.
  45398. */
  45399. changeGazeColor(color: Color3): void;
  45400. /**
  45401. * Exits VR and disposes of the vr experience helper
  45402. */
  45403. dispose(): void;
  45404. /**
  45405. * Gets the name of the VRExperienceHelper class
  45406. * @returns "VRExperienceHelper"
  45407. */
  45408. getClassName(): string;
  45409. }
  45410. }
  45411. declare module BABYLON {
  45412. /**
  45413. * Contains an array of blocks representing the octree
  45414. */
  45415. export interface IOctreeContainer<T> {
  45416. /**
  45417. * Blocks within the octree
  45418. */
  45419. blocks: Array<OctreeBlock<T>>;
  45420. }
  45421. /**
  45422. * Class used to store a cell in an octree
  45423. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45424. */
  45425. export class OctreeBlock<T> {
  45426. /**
  45427. * Gets the content of the current block
  45428. */
  45429. entries: T[];
  45430. /**
  45431. * Gets the list of block children
  45432. */
  45433. blocks: Array<OctreeBlock<T>>;
  45434. private _depth;
  45435. private _maxDepth;
  45436. private _capacity;
  45437. private _minPoint;
  45438. private _maxPoint;
  45439. private _boundingVectors;
  45440. private _creationFunc;
  45441. /**
  45442. * Creates a new block
  45443. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  45444. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  45445. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  45446. * @param depth defines the current depth of this block in the octree
  45447. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  45448. * @param creationFunc defines a callback to call when an element is added to the block
  45449. */
  45450. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  45451. /**
  45452. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  45453. */
  45454. get capacity(): number;
  45455. /**
  45456. * Gets the minimum vector (in world space) of the block's bounding box
  45457. */
  45458. get minPoint(): Vector3;
  45459. /**
  45460. * Gets the maximum vector (in world space) of the block's bounding box
  45461. */
  45462. get maxPoint(): Vector3;
  45463. /**
  45464. * Add a new element to this block
  45465. * @param entry defines the element to add
  45466. */
  45467. addEntry(entry: T): void;
  45468. /**
  45469. * Remove an element from this block
  45470. * @param entry defines the element to remove
  45471. */
  45472. removeEntry(entry: T): void;
  45473. /**
  45474. * Add an array of elements to this block
  45475. * @param entries defines the array of elements to add
  45476. */
  45477. addEntries(entries: T[]): void;
  45478. /**
  45479. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  45480. * @param frustumPlanes defines the frustum planes to test
  45481. * @param selection defines the array to store current content if selection is positive
  45482. * @param allowDuplicate defines if the selection array can contains duplicated entries
  45483. */
  45484. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  45485. /**
  45486. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  45487. * @param sphereCenter defines the bounding sphere center
  45488. * @param sphereRadius defines the bounding sphere radius
  45489. * @param selection defines the array to store current content if selection is positive
  45490. * @param allowDuplicate defines if the selection array can contains duplicated entries
  45491. */
  45492. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  45493. /**
  45494. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  45495. * @param ray defines the ray to test with
  45496. * @param selection defines the array to store current content if selection is positive
  45497. */
  45498. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  45499. /**
  45500. * Subdivide the content into child blocks (this block will then be empty)
  45501. */
  45502. createInnerBlocks(): void;
  45503. /**
  45504. * @hidden
  45505. */
  45506. 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;
  45507. }
  45508. }
  45509. declare module BABYLON {
  45510. /**
  45511. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  45512. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45513. */
  45514. export class Octree<T> {
  45515. /** 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.) */
  45516. maxDepth: number;
  45517. /**
  45518. * Blocks within the octree containing objects
  45519. */
  45520. blocks: Array<OctreeBlock<T>>;
  45521. /**
  45522. * Content stored in the octree
  45523. */
  45524. dynamicContent: T[];
  45525. private _maxBlockCapacity;
  45526. private _selectionContent;
  45527. private _creationFunc;
  45528. /**
  45529. * Creates a octree
  45530. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45531. * @param creationFunc function to be used to instatiate the octree
  45532. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  45533. * @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.)
  45534. */
  45535. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  45536. /** 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.) */
  45537. maxDepth?: number);
  45538. /**
  45539. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  45540. * @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);
  45541. * @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);
  45542. * @param entries meshes to be added to the octree blocks
  45543. */
  45544. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  45545. /**
  45546. * Adds a mesh to the octree
  45547. * @param entry Mesh to add to the octree
  45548. */
  45549. addMesh(entry: T): void;
  45550. /**
  45551. * Remove an element from the octree
  45552. * @param entry defines the element to remove
  45553. */
  45554. removeMesh(entry: T): void;
  45555. /**
  45556. * Selects an array of meshes within the frustum
  45557. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  45558. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  45559. * @returns array of meshes within the frustum
  45560. */
  45561. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  45562. /**
  45563. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  45564. * @param sphereCenter defines the bounding sphere center
  45565. * @param sphereRadius defines the bounding sphere radius
  45566. * @param allowDuplicate defines if the selection array can contains duplicated entries
  45567. * @returns an array of objects that intersect the sphere
  45568. */
  45569. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  45570. /**
  45571. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  45572. * @param ray defines the ray to test with
  45573. * @returns array of intersected objects
  45574. */
  45575. intersectsRay(ray: Ray): SmartArray<T>;
  45576. /**
  45577. * Adds a mesh into the octree block if it intersects the block
  45578. */
  45579. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  45580. /**
  45581. * Adds a submesh into the octree block if it intersects the block
  45582. */
  45583. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  45584. }
  45585. }
  45586. declare module BABYLON {
  45587. interface Scene {
  45588. /**
  45589. * @hidden
  45590. * Backing Filed
  45591. */
  45592. _selectionOctree: Octree<AbstractMesh>;
  45593. /**
  45594. * Gets the octree used to boost mesh selection (picking)
  45595. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45596. */
  45597. selectionOctree: Octree<AbstractMesh>;
  45598. /**
  45599. * Creates or updates the octree used to boost selection (picking)
  45600. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45601. * @param maxCapacity defines the maximum capacity per leaf
  45602. * @param maxDepth defines the maximum depth of the octree
  45603. * @returns an octree of AbstractMesh
  45604. */
  45605. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  45606. }
  45607. interface AbstractMesh {
  45608. /**
  45609. * @hidden
  45610. * Backing Field
  45611. */
  45612. _submeshesOctree: Octree<SubMesh>;
  45613. /**
  45614. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  45615. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  45616. * @param maxCapacity defines the maximum size of each block (64 by default)
  45617. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  45618. * @returns the new octree
  45619. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  45620. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45621. */
  45622. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  45623. }
  45624. /**
  45625. * Defines the octree scene component responsible to manage any octrees
  45626. * in a given scene.
  45627. */
  45628. export class OctreeSceneComponent {
  45629. /**
  45630. * The component name help to identify the component in the list of scene components.
  45631. */
  45632. readonly name: string;
  45633. /**
  45634. * The scene the component belongs to.
  45635. */
  45636. scene: Scene;
  45637. /**
  45638. * Indicates if the meshes have been checked to make sure they are isEnabled()
  45639. */
  45640. readonly checksIsEnabled: boolean;
  45641. /**
  45642. * Creates a new instance of the component for the given scene
  45643. * @param scene Defines the scene to register the component in
  45644. */
  45645. constructor(scene: Scene);
  45646. /**
  45647. * Registers the component in a given scene
  45648. */
  45649. register(): void;
  45650. /**
  45651. * Return the list of active meshes
  45652. * @returns the list of active meshes
  45653. */
  45654. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  45655. /**
  45656. * Return the list of active sub meshes
  45657. * @param mesh The mesh to get the candidates sub meshes from
  45658. * @returns the list of active sub meshes
  45659. */
  45660. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  45661. private _tempRay;
  45662. /**
  45663. * Return the list of sub meshes intersecting with a given local ray
  45664. * @param mesh defines the mesh to find the submesh for
  45665. * @param localRay defines the ray in local space
  45666. * @returns the list of intersecting sub meshes
  45667. */
  45668. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  45669. /**
  45670. * Return the list of sub meshes colliding with a collider
  45671. * @param mesh defines the mesh to find the submesh for
  45672. * @param collider defines the collider to evaluate the collision against
  45673. * @returns the list of colliding sub meshes
  45674. */
  45675. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  45676. /**
  45677. * Rebuilds the elements related to this component in case of
  45678. * context lost for instance.
  45679. */
  45680. rebuild(): void;
  45681. /**
  45682. * Disposes the component and the associated ressources.
  45683. */
  45684. dispose(): void;
  45685. }
  45686. }
  45687. declare module BABYLON {
  45688. /**
  45689. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  45690. */
  45691. export class Gizmo implements IDisposable {
  45692. /** The utility layer the gizmo will be added to */
  45693. gizmoLayer: UtilityLayerRenderer;
  45694. /**
  45695. * The root mesh of the gizmo
  45696. */
  45697. _rootMesh: Mesh;
  45698. private _attachedMesh;
  45699. /**
  45700. * Ratio for the scale of the gizmo (Default: 1)
  45701. */
  45702. scaleRatio: number;
  45703. /**
  45704. * If a custom mesh has been set (Default: false)
  45705. */
  45706. protected _customMeshSet: boolean;
  45707. /**
  45708. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  45709. * * When set, interactions will be enabled
  45710. */
  45711. get attachedMesh(): Nullable<AbstractMesh>;
  45712. set attachedMesh(value: Nullable<AbstractMesh>);
  45713. /**
  45714. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  45715. * @param mesh The mesh to replace the default mesh of the gizmo
  45716. */
  45717. setCustomMesh(mesh: Mesh): void;
  45718. /**
  45719. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  45720. */
  45721. updateGizmoRotationToMatchAttachedMesh: boolean;
  45722. /**
  45723. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  45724. */
  45725. updateGizmoPositionToMatchAttachedMesh: boolean;
  45726. /**
  45727. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  45728. */
  45729. updateScale: boolean;
  45730. protected _interactionsEnabled: boolean;
  45731. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45732. private _beforeRenderObserver;
  45733. private _tempVector;
  45734. /**
  45735. * Creates a gizmo
  45736. * @param gizmoLayer The utility layer the gizmo will be added to
  45737. */
  45738. constructor(
  45739. /** The utility layer the gizmo will be added to */
  45740. gizmoLayer?: UtilityLayerRenderer);
  45741. /**
  45742. * Updates the gizmo to match the attached mesh's position/rotation
  45743. */
  45744. protected _update(): void;
  45745. /**
  45746. * Disposes of the gizmo
  45747. */
  45748. dispose(): void;
  45749. }
  45750. }
  45751. declare module BABYLON {
  45752. /**
  45753. * Single plane drag gizmo
  45754. */
  45755. export class PlaneDragGizmo extends Gizmo {
  45756. /**
  45757. * Drag behavior responsible for the gizmos dragging interactions
  45758. */
  45759. dragBehavior: PointerDragBehavior;
  45760. private _pointerObserver;
  45761. /**
  45762. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45763. */
  45764. snapDistance: number;
  45765. /**
  45766. * Event that fires each time the gizmo snaps to a new location.
  45767. * * snapDistance is the the change in distance
  45768. */
  45769. onSnapObservable: Observable<{
  45770. snapDistance: number;
  45771. }>;
  45772. private _plane;
  45773. private _coloredMaterial;
  45774. private _hoverMaterial;
  45775. private _isEnabled;
  45776. private _parent;
  45777. /** @hidden */
  45778. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  45779. /** @hidden */
  45780. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  45781. /**
  45782. * Creates a PlaneDragGizmo
  45783. * @param gizmoLayer The utility layer the gizmo will be added to
  45784. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  45785. * @param color The color of the gizmo
  45786. */
  45787. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  45788. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45789. /**
  45790. * If the gizmo is enabled
  45791. */
  45792. set isEnabled(value: boolean);
  45793. get isEnabled(): boolean;
  45794. /**
  45795. * Disposes of the gizmo
  45796. */
  45797. dispose(): void;
  45798. }
  45799. }
  45800. declare module BABYLON {
  45801. /**
  45802. * Gizmo that enables dragging a mesh along 3 axis
  45803. */
  45804. export class PositionGizmo extends Gizmo {
  45805. /**
  45806. * Internal gizmo used for interactions on the x axis
  45807. */
  45808. xGizmo: AxisDragGizmo;
  45809. /**
  45810. * Internal gizmo used for interactions on the y axis
  45811. */
  45812. yGizmo: AxisDragGizmo;
  45813. /**
  45814. * Internal gizmo used for interactions on the z axis
  45815. */
  45816. zGizmo: AxisDragGizmo;
  45817. /**
  45818. * Internal gizmo used for interactions on the yz plane
  45819. */
  45820. xPlaneGizmo: PlaneDragGizmo;
  45821. /**
  45822. * Internal gizmo used for interactions on the xz plane
  45823. */
  45824. yPlaneGizmo: PlaneDragGizmo;
  45825. /**
  45826. * Internal gizmo used for interactions on the xy plane
  45827. */
  45828. zPlaneGizmo: PlaneDragGizmo;
  45829. /**
  45830. * private variables
  45831. */
  45832. private _meshAttached;
  45833. private _updateGizmoRotationToMatchAttachedMesh;
  45834. private _snapDistance;
  45835. private _scaleRatio;
  45836. /** Fires an event when any of it's sub gizmos are dragged */
  45837. onDragStartObservable: Observable<unknown>;
  45838. /** Fires an event when any of it's sub gizmos are released from dragging */
  45839. onDragEndObservable: Observable<unknown>;
  45840. /**
  45841. * If set to true, planar drag is enabled
  45842. */
  45843. private _planarGizmoEnabled;
  45844. get attachedMesh(): Nullable<AbstractMesh>;
  45845. set attachedMesh(mesh: Nullable<AbstractMesh>);
  45846. /**
  45847. * Creates a PositionGizmo
  45848. * @param gizmoLayer The utility layer the gizmo will be added to
  45849. */
  45850. constructor(gizmoLayer?: UtilityLayerRenderer);
  45851. /**
  45852. * If the planar drag gizmo is enabled
  45853. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  45854. */
  45855. set planarGizmoEnabled(value: boolean);
  45856. get planarGizmoEnabled(): boolean;
  45857. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  45858. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  45859. /**
  45860. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45861. */
  45862. set snapDistance(value: number);
  45863. get snapDistance(): number;
  45864. /**
  45865. * Ratio for the scale of the gizmo (Default: 1)
  45866. */
  45867. set scaleRatio(value: number);
  45868. get scaleRatio(): number;
  45869. /**
  45870. * Disposes of the gizmo
  45871. */
  45872. dispose(): void;
  45873. /**
  45874. * CustomMeshes are not supported by this gizmo
  45875. * @param mesh The mesh to replace the default mesh of the gizmo
  45876. */
  45877. setCustomMesh(mesh: Mesh): void;
  45878. }
  45879. }
  45880. declare module BABYLON {
  45881. /**
  45882. * Single axis drag gizmo
  45883. */
  45884. export class AxisDragGizmo extends Gizmo {
  45885. /**
  45886. * Drag behavior responsible for the gizmos dragging interactions
  45887. */
  45888. dragBehavior: PointerDragBehavior;
  45889. private _pointerObserver;
  45890. /**
  45891. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45892. */
  45893. snapDistance: number;
  45894. /**
  45895. * Event that fires each time the gizmo snaps to a new location.
  45896. * * snapDistance is the the change in distance
  45897. */
  45898. onSnapObservable: Observable<{
  45899. snapDistance: number;
  45900. }>;
  45901. private _isEnabled;
  45902. private _parent;
  45903. private _arrow;
  45904. private _coloredMaterial;
  45905. private _hoverMaterial;
  45906. /** @hidden */
  45907. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  45908. /** @hidden */
  45909. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  45910. /**
  45911. * Creates an AxisDragGizmo
  45912. * @param gizmoLayer The utility layer the gizmo will be added to
  45913. * @param dragAxis The axis which the gizmo will be able to drag on
  45914. * @param color The color of the gizmo
  45915. */
  45916. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  45917. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45918. /**
  45919. * If the gizmo is enabled
  45920. */
  45921. set isEnabled(value: boolean);
  45922. get isEnabled(): boolean;
  45923. /**
  45924. * Disposes of the gizmo
  45925. */
  45926. dispose(): void;
  45927. }
  45928. }
  45929. declare module BABYLON.Debug {
  45930. /**
  45931. * The Axes viewer will show 3 axes in a specific point in space
  45932. */
  45933. export class AxesViewer {
  45934. private _xAxis;
  45935. private _yAxis;
  45936. private _zAxis;
  45937. private _scaleLinesFactor;
  45938. private _instanced;
  45939. /**
  45940. * Gets the hosting scene
  45941. */
  45942. scene: Scene;
  45943. /**
  45944. * Gets or sets a number used to scale line length
  45945. */
  45946. scaleLines: number;
  45947. /** Gets the node hierarchy used to render x-axis */
  45948. get xAxis(): TransformNode;
  45949. /** Gets the node hierarchy used to render y-axis */
  45950. get yAxis(): TransformNode;
  45951. /** Gets the node hierarchy used to render z-axis */
  45952. get zAxis(): TransformNode;
  45953. /**
  45954. * Creates a new AxesViewer
  45955. * @param scene defines the hosting scene
  45956. * @param scaleLines defines a number used to scale line length (1 by default)
  45957. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  45958. * @param xAxis defines the node hierarchy used to render the x-axis
  45959. * @param yAxis defines the node hierarchy used to render the y-axis
  45960. * @param zAxis defines the node hierarchy used to render the z-axis
  45961. */
  45962. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  45963. /**
  45964. * Force the viewer to update
  45965. * @param position defines the position of the viewer
  45966. * @param xaxis defines the x axis of the viewer
  45967. * @param yaxis defines the y axis of the viewer
  45968. * @param zaxis defines the z axis of the viewer
  45969. */
  45970. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  45971. /**
  45972. * Creates an instance of this axes viewer.
  45973. * @returns a new axes viewer with instanced meshes
  45974. */
  45975. createInstance(): AxesViewer;
  45976. /** Releases resources */
  45977. dispose(): void;
  45978. private static _SetRenderingGroupId;
  45979. }
  45980. }
  45981. declare module BABYLON.Debug {
  45982. /**
  45983. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  45984. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  45985. */
  45986. export class BoneAxesViewer extends AxesViewer {
  45987. /**
  45988. * Gets or sets the target mesh where to display the axes viewer
  45989. */
  45990. mesh: Nullable<Mesh>;
  45991. /**
  45992. * Gets or sets the target bone where to display the axes viewer
  45993. */
  45994. bone: Nullable<Bone>;
  45995. /** Gets current position */
  45996. pos: Vector3;
  45997. /** Gets direction of X axis */
  45998. xaxis: Vector3;
  45999. /** Gets direction of Y axis */
  46000. yaxis: Vector3;
  46001. /** Gets direction of Z axis */
  46002. zaxis: Vector3;
  46003. /**
  46004. * Creates a new BoneAxesViewer
  46005. * @param scene defines the hosting scene
  46006. * @param bone defines the target bone
  46007. * @param mesh defines the target mesh
  46008. * @param scaleLines defines a scaling factor for line length (1 by default)
  46009. */
  46010. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  46011. /**
  46012. * Force the viewer to update
  46013. */
  46014. update(): void;
  46015. /** Releases resources */
  46016. dispose(): void;
  46017. }
  46018. }
  46019. declare module BABYLON {
  46020. /**
  46021. * Interface used to define scene explorer extensibility option
  46022. */
  46023. export interface IExplorerExtensibilityOption {
  46024. /**
  46025. * Define the option label
  46026. */
  46027. label: string;
  46028. /**
  46029. * Defines the action to execute on click
  46030. */
  46031. action: (entity: any) => void;
  46032. }
  46033. /**
  46034. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  46035. */
  46036. export interface IExplorerExtensibilityGroup {
  46037. /**
  46038. * Defines a predicate to test if a given type mut be extended
  46039. */
  46040. predicate: (entity: any) => boolean;
  46041. /**
  46042. * Gets the list of options added to a type
  46043. */
  46044. entries: IExplorerExtensibilityOption[];
  46045. }
  46046. /**
  46047. * Interface used to define the options to use to create the Inspector
  46048. */
  46049. export interface IInspectorOptions {
  46050. /**
  46051. * Display in overlay mode (default: false)
  46052. */
  46053. overlay?: boolean;
  46054. /**
  46055. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  46056. */
  46057. globalRoot?: HTMLElement;
  46058. /**
  46059. * Display the Scene explorer
  46060. */
  46061. showExplorer?: boolean;
  46062. /**
  46063. * Display the property inspector
  46064. */
  46065. showInspector?: boolean;
  46066. /**
  46067. * Display in embed mode (both panes on the right)
  46068. */
  46069. embedMode?: boolean;
  46070. /**
  46071. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  46072. */
  46073. handleResize?: boolean;
  46074. /**
  46075. * Allow the panes to popup (default: true)
  46076. */
  46077. enablePopup?: boolean;
  46078. /**
  46079. * Allow the panes to be closed by users (default: true)
  46080. */
  46081. enableClose?: boolean;
  46082. /**
  46083. * Optional list of extensibility entries
  46084. */
  46085. explorerExtensibility?: IExplorerExtensibilityGroup[];
  46086. /**
  46087. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  46088. */
  46089. inspectorURL?: string;
  46090. /**
  46091. * Optional initial tab (default to DebugLayerTab.Properties)
  46092. */
  46093. initialTab?: DebugLayerTab;
  46094. }
  46095. interface Scene {
  46096. /**
  46097. * @hidden
  46098. * Backing field
  46099. */
  46100. _debugLayer: DebugLayer;
  46101. /**
  46102. * Gets the debug layer (aka Inspector) associated with the scene
  46103. * @see http://doc.babylonjs.com/features/playground_debuglayer
  46104. */
  46105. debugLayer: DebugLayer;
  46106. }
  46107. /**
  46108. * Enum of inspector action tab
  46109. */
  46110. export enum DebugLayerTab {
  46111. /**
  46112. * Properties tag (default)
  46113. */
  46114. Properties = 0,
  46115. /**
  46116. * Debug tab
  46117. */
  46118. Debug = 1,
  46119. /**
  46120. * Statistics tab
  46121. */
  46122. Statistics = 2,
  46123. /**
  46124. * Tools tab
  46125. */
  46126. Tools = 3,
  46127. /**
  46128. * Settings tab
  46129. */
  46130. Settings = 4
  46131. }
  46132. /**
  46133. * The debug layer (aka Inspector) is the go to tool in order to better understand
  46134. * what is happening in your scene
  46135. * @see http://doc.babylonjs.com/features/playground_debuglayer
  46136. */
  46137. export class DebugLayer {
  46138. /**
  46139. * Define the url to get the inspector script from.
  46140. * By default it uses the babylonjs CDN.
  46141. * @ignoreNaming
  46142. */
  46143. static InspectorURL: string;
  46144. private _scene;
  46145. private BJSINSPECTOR;
  46146. private _onPropertyChangedObservable?;
  46147. /**
  46148. * Observable triggered when a property is changed through the inspector.
  46149. */
  46150. get onPropertyChangedObservable(): any;
  46151. /**
  46152. * Instantiates a new debug layer.
  46153. * The debug layer (aka Inspector) is the go to tool in order to better understand
  46154. * what is happening in your scene
  46155. * @see http://doc.babylonjs.com/features/playground_debuglayer
  46156. * @param scene Defines the scene to inspect
  46157. */
  46158. constructor(scene: Scene);
  46159. /** Creates the inspector window. */
  46160. private _createInspector;
  46161. /**
  46162. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  46163. * @param entity defines the entity to select
  46164. * @param lineContainerTitle defines the specific block to highlight
  46165. */
  46166. select(entity: any, lineContainerTitle?: string): void;
  46167. /** Get the inspector from bundle or global */
  46168. private _getGlobalInspector;
  46169. /**
  46170. * Get if the inspector is visible or not.
  46171. * @returns true if visible otherwise, false
  46172. */
  46173. isVisible(): boolean;
  46174. /**
  46175. * Hide the inspector and close its window.
  46176. */
  46177. hide(): void;
  46178. /**
  46179. * Launch the debugLayer.
  46180. * @param config Define the configuration of the inspector
  46181. * @return a promise fulfilled when the debug layer is visible
  46182. */
  46183. show(config?: IInspectorOptions): Promise<DebugLayer>;
  46184. }
  46185. }
  46186. declare module BABYLON {
  46187. /**
  46188. * Class containing static functions to help procedurally build meshes
  46189. */
  46190. export class BoxBuilder {
  46191. /**
  46192. * Creates a box mesh
  46193. * * The parameter `size` sets the size (float) of each box side (default 1)
  46194. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  46195. * * 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)
  46196. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  46197. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46198. * * 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
  46199. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46200. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  46201. * @param name defines the name of the mesh
  46202. * @param options defines the options used to create the mesh
  46203. * @param scene defines the hosting scene
  46204. * @returns the box mesh
  46205. */
  46206. static CreateBox(name: string, options: {
  46207. size?: number;
  46208. width?: number;
  46209. height?: number;
  46210. depth?: number;
  46211. faceUV?: Vector4[];
  46212. faceColors?: Color4[];
  46213. sideOrientation?: number;
  46214. frontUVs?: Vector4;
  46215. backUVs?: Vector4;
  46216. wrap?: boolean;
  46217. topBaseAt?: number;
  46218. bottomBaseAt?: number;
  46219. updatable?: boolean;
  46220. }, scene?: Nullable<Scene>): Mesh;
  46221. }
  46222. }
  46223. declare module BABYLON.Debug {
  46224. /**
  46225. * Used to show the physics impostor around the specific mesh
  46226. */
  46227. export class PhysicsViewer {
  46228. /** @hidden */
  46229. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  46230. /** @hidden */
  46231. protected _meshes: Array<Nullable<AbstractMesh>>;
  46232. /** @hidden */
  46233. protected _scene: Nullable<Scene>;
  46234. /** @hidden */
  46235. protected _numMeshes: number;
  46236. /** @hidden */
  46237. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  46238. private _renderFunction;
  46239. private _utilityLayer;
  46240. private _debugBoxMesh;
  46241. private _debugSphereMesh;
  46242. private _debugCylinderMesh;
  46243. private _debugMaterial;
  46244. private _debugMeshMeshes;
  46245. /**
  46246. * Creates a new PhysicsViewer
  46247. * @param scene defines the hosting scene
  46248. */
  46249. constructor(scene: Scene);
  46250. /** @hidden */
  46251. protected _updateDebugMeshes(): void;
  46252. /**
  46253. * Renders a specified physic impostor
  46254. * @param impostor defines the impostor to render
  46255. * @param targetMesh defines the mesh represented by the impostor
  46256. * @returns the new debug mesh used to render the impostor
  46257. */
  46258. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  46259. /**
  46260. * Hides a specified physic impostor
  46261. * @param impostor defines the impostor to hide
  46262. */
  46263. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  46264. private _getDebugMaterial;
  46265. private _getDebugBoxMesh;
  46266. private _getDebugSphereMesh;
  46267. private _getDebugCylinderMesh;
  46268. private _getDebugMeshMesh;
  46269. private _getDebugMesh;
  46270. /** Releases all resources */
  46271. dispose(): void;
  46272. }
  46273. }
  46274. declare module BABYLON {
  46275. /**
  46276. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  46277. * in order to better appreciate the issue one might have.
  46278. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  46279. */
  46280. export class RayHelper {
  46281. /**
  46282. * Defines the ray we are currently tryin to visualize.
  46283. */
  46284. ray: Nullable<Ray>;
  46285. private _renderPoints;
  46286. private _renderLine;
  46287. private _renderFunction;
  46288. private _scene;
  46289. private _updateToMeshFunction;
  46290. private _attachedToMesh;
  46291. private _meshSpaceDirection;
  46292. private _meshSpaceOrigin;
  46293. /**
  46294. * Helper function to create a colored helper in a scene in one line.
  46295. * @param ray Defines the ray we are currently tryin to visualize
  46296. * @param scene Defines the scene the ray is used in
  46297. * @param color Defines the color we want to see the ray in
  46298. * @returns The newly created ray helper.
  46299. */
  46300. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  46301. /**
  46302. * Instantiate a new ray helper.
  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. * @param ray Defines the ray we are currently tryin to visualize
  46307. */
  46308. constructor(ray: Ray);
  46309. /**
  46310. * Shows the ray we are willing to debug.
  46311. * @param scene Defines the scene the ray needs to be rendered in
  46312. * @param color Defines the color the ray needs to be rendered in
  46313. */
  46314. show(scene: Scene, color?: Color3): void;
  46315. /**
  46316. * Hides the ray we are debugging.
  46317. */
  46318. hide(): void;
  46319. private _render;
  46320. /**
  46321. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  46322. * @param mesh Defines the mesh we want the helper attached to
  46323. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  46324. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  46325. * @param length Defines the length of the ray
  46326. */
  46327. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  46328. /**
  46329. * Detach the ray helper from the mesh it has previously been attached to.
  46330. */
  46331. detachFromMesh(): void;
  46332. private _updateToMesh;
  46333. /**
  46334. * Dispose the helper and release its associated resources.
  46335. */
  46336. dispose(): void;
  46337. }
  46338. }
  46339. declare module BABYLON.Debug {
  46340. /**
  46341. * Class used to render a debug view of a given skeleton
  46342. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  46343. */
  46344. export class SkeletonViewer {
  46345. /** defines the skeleton to render */
  46346. skeleton: Skeleton;
  46347. /** defines the mesh attached to the skeleton */
  46348. mesh: AbstractMesh;
  46349. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  46350. autoUpdateBonesMatrices: boolean;
  46351. /** defines the rendering group id to use with the viewer */
  46352. renderingGroupId: number;
  46353. /** Gets or sets the color used to render the skeleton */
  46354. color: Color3;
  46355. private _scene;
  46356. private _debugLines;
  46357. private _debugMesh;
  46358. private _isEnabled;
  46359. private _renderFunction;
  46360. private _utilityLayer;
  46361. /**
  46362. * Returns the mesh used to render the bones
  46363. */
  46364. get debugMesh(): Nullable<LinesMesh>;
  46365. /**
  46366. * Creates a new SkeletonViewer
  46367. * @param skeleton defines the skeleton to render
  46368. * @param mesh defines the mesh attached to the skeleton
  46369. * @param scene defines the hosting scene
  46370. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  46371. * @param renderingGroupId defines the rendering group id to use with the viewer
  46372. */
  46373. constructor(
  46374. /** defines the skeleton to render */
  46375. skeleton: Skeleton,
  46376. /** defines the mesh attached to the skeleton */
  46377. mesh: AbstractMesh, scene: Scene,
  46378. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  46379. autoUpdateBonesMatrices?: boolean,
  46380. /** defines the rendering group id to use with the viewer */
  46381. renderingGroupId?: number);
  46382. /** Gets or sets a boolean indicating if the viewer is enabled */
  46383. set isEnabled(value: boolean);
  46384. get isEnabled(): boolean;
  46385. private _getBonePosition;
  46386. private _getLinesForBonesWithLength;
  46387. private _getLinesForBonesNoLength;
  46388. /** Update the viewer to sync with current skeleton state */
  46389. update(): void;
  46390. /** Release associated resources */
  46391. dispose(): void;
  46392. }
  46393. }
  46394. declare module BABYLON {
  46395. /**
  46396. * Options to create the null engine
  46397. */
  46398. export class NullEngineOptions {
  46399. /**
  46400. * Render width (Default: 512)
  46401. */
  46402. renderWidth: number;
  46403. /**
  46404. * Render height (Default: 256)
  46405. */
  46406. renderHeight: number;
  46407. /**
  46408. * Texture size (Default: 512)
  46409. */
  46410. textureSize: number;
  46411. /**
  46412. * If delta time between frames should be constant
  46413. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46414. */
  46415. deterministicLockstep: boolean;
  46416. /**
  46417. * Maximum about of steps between frames (Default: 4)
  46418. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46419. */
  46420. lockstepMaxSteps: number;
  46421. }
  46422. /**
  46423. * The null engine class provides support for headless version of babylon.js.
  46424. * This can be used in server side scenario or for testing purposes
  46425. */
  46426. export class NullEngine extends Engine {
  46427. private _options;
  46428. /**
  46429. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  46430. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46431. * @returns true if engine is in deterministic lock step mode
  46432. */
  46433. isDeterministicLockStep(): boolean;
  46434. /**
  46435. * Gets the max steps when engine is running in deterministic lock step
  46436. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46437. * @returns the max steps
  46438. */
  46439. getLockstepMaxSteps(): number;
  46440. /**
  46441. * Gets the current hardware scaling level.
  46442. * By default the hardware scaling level is computed from the window device ratio.
  46443. * 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.
  46444. * @returns a number indicating the current hardware scaling level
  46445. */
  46446. getHardwareScalingLevel(): number;
  46447. constructor(options?: NullEngineOptions);
  46448. /**
  46449. * Creates a vertex buffer
  46450. * @param vertices the data for the vertex buffer
  46451. * @returns the new WebGL static buffer
  46452. */
  46453. createVertexBuffer(vertices: FloatArray): DataBuffer;
  46454. /**
  46455. * Creates a new index buffer
  46456. * @param indices defines the content of the index buffer
  46457. * @param updatable defines if the index buffer must be updatable
  46458. * @returns a new webGL buffer
  46459. */
  46460. createIndexBuffer(indices: IndicesArray): DataBuffer;
  46461. /**
  46462. * Clear the current render buffer or the current render target (if any is set up)
  46463. * @param color defines the color to use
  46464. * @param backBuffer defines if the back buffer must be cleared
  46465. * @param depth defines if the depth buffer must be cleared
  46466. * @param stencil defines if the stencil buffer must be cleared
  46467. */
  46468. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  46469. /**
  46470. * Gets the current render width
  46471. * @param useScreen defines if screen size must be used (or the current render target if any)
  46472. * @returns a number defining the current render width
  46473. */
  46474. getRenderWidth(useScreen?: boolean): number;
  46475. /**
  46476. * Gets the current render height
  46477. * @param useScreen defines if screen size must be used (or the current render target if any)
  46478. * @returns a number defining the current render height
  46479. */
  46480. getRenderHeight(useScreen?: boolean): number;
  46481. /**
  46482. * Set the WebGL's viewport
  46483. * @param viewport defines the viewport element to be used
  46484. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  46485. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  46486. */
  46487. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  46488. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  46489. /**
  46490. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  46491. * @param pipelineContext defines the pipeline context to use
  46492. * @param uniformsNames defines the list of uniform names
  46493. * @returns an array of webGL uniform locations
  46494. */
  46495. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  46496. /**
  46497. * Gets the lsit of active attributes for a given webGL program
  46498. * @param pipelineContext defines the pipeline context to use
  46499. * @param attributesNames defines the list of attribute names to get
  46500. * @returns an array of indices indicating the offset of each attribute
  46501. */
  46502. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  46503. /**
  46504. * Binds an effect to the webGL context
  46505. * @param effect defines the effect to bind
  46506. */
  46507. bindSamplers(effect: Effect): void;
  46508. /**
  46509. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  46510. * @param effect defines the effect to activate
  46511. */
  46512. enableEffect(effect: Effect): void;
  46513. /**
  46514. * Set various states to the webGL context
  46515. * @param culling defines backface culling state
  46516. * @param zOffset defines the value to apply to zOffset (0 by default)
  46517. * @param force defines if states must be applied even if cache is up to date
  46518. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  46519. */
  46520. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  46521. /**
  46522. * Set the value of an uniform to an array of int32
  46523. * @param uniform defines the webGL uniform location where to store the value
  46524. * @param array defines the array of int32 to store
  46525. */
  46526. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  46527. /**
  46528. * Set the value of an uniform to an array of int32 (stored as vec2)
  46529. * @param uniform defines the webGL uniform location where to store the value
  46530. * @param array defines the array of int32 to store
  46531. */
  46532. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  46533. /**
  46534. * Set the value of an uniform to an array of int32 (stored as vec3)
  46535. * @param uniform defines the webGL uniform location where to store the value
  46536. * @param array defines the array of int32 to store
  46537. */
  46538. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  46539. /**
  46540. * Set the value of an uniform to an array of int32 (stored as vec4)
  46541. * @param uniform defines the webGL uniform location where to store the value
  46542. * @param array defines the array of int32 to store
  46543. */
  46544. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  46545. /**
  46546. * Set the value of an uniform to an array of float32
  46547. * @param uniform defines the webGL uniform location where to store the value
  46548. * @param array defines the array of float32 to store
  46549. */
  46550. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  46551. /**
  46552. * Set the value of an uniform to an array of float32 (stored as vec2)
  46553. * @param uniform defines the webGL uniform location where to store the value
  46554. * @param array defines the array of float32 to store
  46555. */
  46556. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  46557. /**
  46558. * Set the value of an uniform to an array of float32 (stored as vec3)
  46559. * @param uniform defines the webGL uniform location where to store the value
  46560. * @param array defines the array of float32 to store
  46561. */
  46562. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  46563. /**
  46564. * Set the value of an uniform to an array of float32 (stored as vec4)
  46565. * @param uniform defines the webGL uniform location where to store the value
  46566. * @param array defines the array of float32 to store
  46567. */
  46568. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  46569. /**
  46570. * Set the value of an uniform to an array of number
  46571. * @param uniform defines the webGL uniform location where to store the value
  46572. * @param array defines the array of number to store
  46573. */
  46574. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  46575. /**
  46576. * Set the value of an uniform to an array of number (stored as vec2)
  46577. * @param uniform defines the webGL uniform location where to store the value
  46578. * @param array defines the array of number to store
  46579. */
  46580. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  46581. /**
  46582. * Set the value of an uniform to an array of number (stored as vec3)
  46583. * @param uniform defines the webGL uniform location where to store the value
  46584. * @param array defines the array of number to store
  46585. */
  46586. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  46587. /**
  46588. * Set the value of an uniform to an array of number (stored as vec4)
  46589. * @param uniform defines the webGL uniform location where to store the value
  46590. * @param array defines the array of number to store
  46591. */
  46592. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  46593. /**
  46594. * Set the value of an uniform to an array of float32 (stored as matrices)
  46595. * @param uniform defines the webGL uniform location where to store the value
  46596. * @param matrices defines the array of float32 to store
  46597. */
  46598. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  46599. /**
  46600. * Set the value of an uniform to a matrix (3x3)
  46601. * @param uniform defines the webGL uniform location where to store the value
  46602. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  46603. */
  46604. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  46605. /**
  46606. * Set the value of an uniform to a matrix (2x2)
  46607. * @param uniform defines the webGL uniform location where to store the value
  46608. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  46609. */
  46610. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  46611. /**
  46612. * Set the value of an uniform to a number (float)
  46613. * @param uniform defines the webGL uniform location where to store the value
  46614. * @param value defines the float number to store
  46615. */
  46616. setFloat(uniform: WebGLUniformLocation, value: number): void;
  46617. /**
  46618. * Set the value of an uniform to a vec2
  46619. * @param uniform defines the webGL uniform location where to store the value
  46620. * @param x defines the 1st component of the value
  46621. * @param y defines the 2nd component of the value
  46622. */
  46623. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  46624. /**
  46625. * Set the value of an uniform to a vec3
  46626. * @param uniform defines the webGL uniform location where to store the value
  46627. * @param x defines the 1st component of the value
  46628. * @param y defines the 2nd component of the value
  46629. * @param z defines the 3rd component of the value
  46630. */
  46631. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  46632. /**
  46633. * Set the value of an uniform to a boolean
  46634. * @param uniform defines the webGL uniform location where to store the value
  46635. * @param bool defines the boolean to store
  46636. */
  46637. setBool(uniform: WebGLUniformLocation, bool: number): void;
  46638. /**
  46639. * Set the value of an uniform to a vec4
  46640. * @param uniform defines the webGL uniform location where to store the value
  46641. * @param x defines the 1st component of the value
  46642. * @param y defines the 2nd component of the value
  46643. * @param z defines the 3rd component of the value
  46644. * @param w defines the 4th component of the value
  46645. */
  46646. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  46647. /**
  46648. * Sets the current alpha mode
  46649. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  46650. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  46651. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  46652. */
  46653. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  46654. /**
  46655. * Bind webGl buffers directly to the webGL context
  46656. * @param vertexBuffers defines the vertex buffer to bind
  46657. * @param indexBuffer defines the index buffer to bind
  46658. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  46659. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  46660. * @param effect defines the effect associated with the vertex buffer
  46661. */
  46662. bindBuffers(vertexBuffers: {
  46663. [key: string]: VertexBuffer;
  46664. }, indexBuffer: DataBuffer, effect: Effect): void;
  46665. /**
  46666. * Force the entire cache to be cleared
  46667. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  46668. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  46669. */
  46670. wipeCaches(bruteForce?: boolean): void;
  46671. /**
  46672. * Send a draw order
  46673. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  46674. * @param indexStart defines the starting index
  46675. * @param indexCount defines the number of index to draw
  46676. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  46677. */
  46678. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  46679. /**
  46680. * Draw a list of indexed primitives
  46681. * @param fillMode defines the primitive to use
  46682. * @param indexStart defines the starting index
  46683. * @param indexCount defines the number of index to draw
  46684. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  46685. */
  46686. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  46687. /**
  46688. * Draw a list of unindexed primitives
  46689. * @param fillMode defines the primitive to use
  46690. * @param verticesStart defines the index of first vertex to draw
  46691. * @param verticesCount defines the count of vertices to draw
  46692. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  46693. */
  46694. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  46695. /** @hidden */
  46696. _createTexture(): WebGLTexture;
  46697. /** @hidden */
  46698. _releaseTexture(texture: InternalTexture): void;
  46699. /**
  46700. * Usually called from Texture.ts.
  46701. * Passed information to create a WebGLTexture
  46702. * @param urlArg defines a value which contains one of the following:
  46703. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  46704. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  46705. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  46706. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  46707. * @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)
  46708. * @param scene needed for loading to the correct scene
  46709. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  46710. * @param onLoad optional callback to be called upon successful completion
  46711. * @param onError optional callback to be called upon failure
  46712. * @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
  46713. * @param fallBack an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  46714. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  46715. * @param forcedExtension defines the extension to use to pick the right loader
  46716. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  46717. * @returns a InternalTexture for assignment back into BABYLON.Texture
  46718. */
  46719. createTexture(urlArg: string, noMipmap: boolean, invertY: boolean, scene: Scene, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<ArrayBuffer | HTMLImageElement>, fallBack?: InternalTexture, format?: number): InternalTexture;
  46720. /**
  46721. * Creates a new render target texture
  46722. * @param size defines the size of the texture
  46723. * @param options defines the options used to create the texture
  46724. * @returns a new render target texture stored in an InternalTexture
  46725. */
  46726. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  46727. /**
  46728. * Update the sampling mode of a given texture
  46729. * @param samplingMode defines the required sampling mode
  46730. * @param texture defines the texture to update
  46731. */
  46732. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  46733. /**
  46734. * Binds the frame buffer to the specified texture.
  46735. * @param texture The texture to render to or null for the default canvas
  46736. * @param faceIndex The face of the texture to render to in case of cube texture
  46737. * @param requiredWidth The width of the target to render to
  46738. * @param requiredHeight The height of the target to render to
  46739. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  46740. * @param lodLevel defines le lod level to bind to the frame buffer
  46741. */
  46742. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  46743. /**
  46744. * Unbind the current render target texture from the webGL context
  46745. * @param texture defines the render target texture to unbind
  46746. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  46747. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  46748. */
  46749. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  46750. /**
  46751. * Creates a dynamic vertex buffer
  46752. * @param vertices the data for the dynamic vertex buffer
  46753. * @returns the new WebGL dynamic buffer
  46754. */
  46755. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  46756. /**
  46757. * Update the content of a dynamic texture
  46758. * @param texture defines the texture to update
  46759. * @param canvas defines the canvas containing the source
  46760. * @param invertY defines if data must be stored with Y axis inverted
  46761. * @param premulAlpha defines if alpha is stored as premultiplied
  46762. * @param format defines the format of the data
  46763. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  46764. */
  46765. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  46766. /**
  46767. * Gets a boolean indicating if all created effects are ready
  46768. * @returns true if all effects are ready
  46769. */
  46770. areAllEffectsReady(): boolean;
  46771. /**
  46772. * @hidden
  46773. * Get the current error code of the webGL context
  46774. * @returns the error code
  46775. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  46776. */
  46777. getError(): number;
  46778. /** @hidden */
  46779. _getUnpackAlignement(): number;
  46780. /** @hidden */
  46781. _unpackFlipY(value: boolean): void;
  46782. /**
  46783. * Update a dynamic index buffer
  46784. * @param indexBuffer defines the target index buffer
  46785. * @param indices defines the data to update
  46786. * @param offset defines the offset in the target index buffer where update should start
  46787. */
  46788. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  46789. /**
  46790. * Updates a dynamic vertex buffer.
  46791. * @param vertexBuffer the vertex buffer to update
  46792. * @param vertices the data used to update the vertex buffer
  46793. * @param byteOffset the byte offset of the data (optional)
  46794. * @param byteLength the byte length of the data (optional)
  46795. */
  46796. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  46797. /** @hidden */
  46798. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  46799. /** @hidden */
  46800. _bindTexture(channel: number, texture: InternalTexture): void;
  46801. protected _deleteBuffer(buffer: WebGLBuffer): void;
  46802. /**
  46803. * 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
  46804. */
  46805. releaseEffects(): void;
  46806. displayLoadingUI(): void;
  46807. hideLoadingUI(): void;
  46808. /** @hidden */
  46809. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46810. /** @hidden */
  46811. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46812. /** @hidden */
  46813. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46814. /** @hidden */
  46815. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  46816. }
  46817. }
  46818. declare module BABYLON {
  46819. /**
  46820. * @hidden
  46821. **/
  46822. export class _TimeToken {
  46823. _startTimeQuery: Nullable<WebGLQuery>;
  46824. _endTimeQuery: Nullable<WebGLQuery>;
  46825. _timeElapsedQuery: Nullable<WebGLQuery>;
  46826. _timeElapsedQueryEnded: boolean;
  46827. }
  46828. }
  46829. declare module BABYLON {
  46830. /** @hidden */
  46831. export class _OcclusionDataStorage {
  46832. /** @hidden */
  46833. occlusionInternalRetryCounter: number;
  46834. /** @hidden */
  46835. isOcclusionQueryInProgress: boolean;
  46836. /** @hidden */
  46837. isOccluded: boolean;
  46838. /** @hidden */
  46839. occlusionRetryCount: number;
  46840. /** @hidden */
  46841. occlusionType: number;
  46842. /** @hidden */
  46843. occlusionQueryAlgorithmType: number;
  46844. }
  46845. interface Engine {
  46846. /**
  46847. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  46848. * @return the new query
  46849. */
  46850. createQuery(): WebGLQuery;
  46851. /**
  46852. * Delete and release a webGL query
  46853. * @param query defines the query to delete
  46854. * @return the current engine
  46855. */
  46856. deleteQuery(query: WebGLQuery): Engine;
  46857. /**
  46858. * Check if a given query has resolved and got its value
  46859. * @param query defines the query to check
  46860. * @returns true if the query got its value
  46861. */
  46862. isQueryResultAvailable(query: WebGLQuery): boolean;
  46863. /**
  46864. * Gets the value of a given query
  46865. * @param query defines the query to check
  46866. * @returns the value of the query
  46867. */
  46868. getQueryResult(query: WebGLQuery): number;
  46869. /**
  46870. * Initiates an occlusion query
  46871. * @param algorithmType defines the algorithm to use
  46872. * @param query defines the query to use
  46873. * @returns the current engine
  46874. * @see http://doc.babylonjs.com/features/occlusionquery
  46875. */
  46876. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  46877. /**
  46878. * Ends an occlusion query
  46879. * @see http://doc.babylonjs.com/features/occlusionquery
  46880. * @param algorithmType defines the algorithm to use
  46881. * @returns the current engine
  46882. */
  46883. endOcclusionQuery(algorithmType: number): Engine;
  46884. /**
  46885. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  46886. * Please note that only one query can be issued at a time
  46887. * @returns a time token used to track the time span
  46888. */
  46889. startTimeQuery(): Nullable<_TimeToken>;
  46890. /**
  46891. * Ends a time query
  46892. * @param token defines the token used to measure the time span
  46893. * @returns the time spent (in ns)
  46894. */
  46895. endTimeQuery(token: _TimeToken): int;
  46896. /** @hidden */
  46897. _currentNonTimestampToken: Nullable<_TimeToken>;
  46898. /** @hidden */
  46899. _createTimeQuery(): WebGLQuery;
  46900. /** @hidden */
  46901. _deleteTimeQuery(query: WebGLQuery): void;
  46902. /** @hidden */
  46903. _getGlAlgorithmType(algorithmType: number): number;
  46904. /** @hidden */
  46905. _getTimeQueryResult(query: WebGLQuery): any;
  46906. /** @hidden */
  46907. _getTimeQueryAvailability(query: WebGLQuery): any;
  46908. }
  46909. interface AbstractMesh {
  46910. /**
  46911. * Backing filed
  46912. * @hidden
  46913. */
  46914. __occlusionDataStorage: _OcclusionDataStorage;
  46915. /**
  46916. * Access property
  46917. * @hidden
  46918. */
  46919. _occlusionDataStorage: _OcclusionDataStorage;
  46920. /**
  46921. * 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.
  46922. * The default value is -1 which means don't break the query and wait till the result
  46923. * @see http://doc.babylonjs.com/features/occlusionquery
  46924. */
  46925. occlusionRetryCount: number;
  46926. /**
  46927. * 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:
  46928. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  46929. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  46930. * * 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.
  46931. * @see http://doc.babylonjs.com/features/occlusionquery
  46932. */
  46933. occlusionType: number;
  46934. /**
  46935. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  46936. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  46937. * * 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.
  46938. * @see http://doc.babylonjs.com/features/occlusionquery
  46939. */
  46940. occlusionQueryAlgorithmType: number;
  46941. /**
  46942. * 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
  46943. * @see http://doc.babylonjs.com/features/occlusionquery
  46944. */
  46945. isOccluded: boolean;
  46946. /**
  46947. * Flag to check the progress status of the query
  46948. * @see http://doc.babylonjs.com/features/occlusionquery
  46949. */
  46950. isOcclusionQueryInProgress: boolean;
  46951. }
  46952. }
  46953. declare module BABYLON {
  46954. /** @hidden */
  46955. export var _forceTransformFeedbackToBundle: boolean;
  46956. interface Engine {
  46957. /**
  46958. * Creates a webGL transform feedback object
  46959. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  46960. * @returns the webGL transform feedback object
  46961. */
  46962. createTransformFeedback(): WebGLTransformFeedback;
  46963. /**
  46964. * Delete a webGL transform feedback object
  46965. * @param value defines the webGL transform feedback object to delete
  46966. */
  46967. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  46968. /**
  46969. * Bind a webGL transform feedback object to the webgl context
  46970. * @param value defines the webGL transform feedback object to bind
  46971. */
  46972. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  46973. /**
  46974. * Begins a transform feedback operation
  46975. * @param usePoints defines if points or triangles must be used
  46976. */
  46977. beginTransformFeedback(usePoints: boolean): void;
  46978. /**
  46979. * Ends a transform feedback operation
  46980. */
  46981. endTransformFeedback(): void;
  46982. /**
  46983. * Specify the varyings to use with transform feedback
  46984. * @param program defines the associated webGL program
  46985. * @param value defines the list of strings representing the varying names
  46986. */
  46987. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  46988. /**
  46989. * Bind a webGL buffer for a transform feedback operation
  46990. * @param value defines the webGL buffer to bind
  46991. */
  46992. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  46993. }
  46994. }
  46995. declare module BABYLON {
  46996. /**
  46997. * Creation options of the multi render target texture.
  46998. */
  46999. export interface IMultiRenderTargetOptions {
  47000. /**
  47001. * Define if the texture needs to create mip maps after render.
  47002. */
  47003. generateMipMaps?: boolean;
  47004. /**
  47005. * Define the types of all the draw buffers we want to create
  47006. */
  47007. types?: number[];
  47008. /**
  47009. * Define the sampling modes of all the draw buffers we want to create
  47010. */
  47011. samplingModes?: number[];
  47012. /**
  47013. * Define if a depth buffer is required
  47014. */
  47015. generateDepthBuffer?: boolean;
  47016. /**
  47017. * Define if a stencil buffer is required
  47018. */
  47019. generateStencilBuffer?: boolean;
  47020. /**
  47021. * Define if a depth texture is required instead of a depth buffer
  47022. */
  47023. generateDepthTexture?: boolean;
  47024. /**
  47025. * Define the number of desired draw buffers
  47026. */
  47027. textureCount?: number;
  47028. /**
  47029. * Define if aspect ratio should be adapted to the texture or stay the scene one
  47030. */
  47031. doNotChangeAspectRatio?: boolean;
  47032. /**
  47033. * Define the default type of the buffers we are creating
  47034. */
  47035. defaultType?: number;
  47036. }
  47037. /**
  47038. * A multi render target, like a render target provides the ability to render to a texture.
  47039. * Unlike the render target, it can render to several draw buffers in one draw.
  47040. * This is specially interesting in deferred rendering or for any effects requiring more than
  47041. * just one color from a single pass.
  47042. */
  47043. export class MultiRenderTarget extends RenderTargetTexture {
  47044. private _internalTextures;
  47045. private _textures;
  47046. private _multiRenderTargetOptions;
  47047. /**
  47048. * Get if draw buffers are currently supported by the used hardware and browser.
  47049. */
  47050. get isSupported(): boolean;
  47051. /**
  47052. * Get the list of textures generated by the multi render target.
  47053. */
  47054. get textures(): Texture[];
  47055. /**
  47056. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  47057. */
  47058. get depthTexture(): Texture;
  47059. /**
  47060. * Set the wrapping mode on U of all the textures we are rendering to.
  47061. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  47062. */
  47063. set wrapU(wrap: number);
  47064. /**
  47065. * Set the wrapping mode on V of all the textures we are rendering to.
  47066. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  47067. */
  47068. set wrapV(wrap: number);
  47069. /**
  47070. * Instantiate a new multi render target texture.
  47071. * A multi render target, like a render target provides the ability to render to a texture.
  47072. * Unlike the render target, it can render to several draw buffers in one draw.
  47073. * This is specially interesting in deferred rendering or for any effects requiring more than
  47074. * just one color from a single pass.
  47075. * @param name Define the name of the texture
  47076. * @param size Define the size of the buffers to render to
  47077. * @param count Define the number of target we are rendering into
  47078. * @param scene Define the scene the texture belongs to
  47079. * @param options Define the options used to create the multi render target
  47080. */
  47081. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  47082. /** @hidden */
  47083. _rebuild(): void;
  47084. private _createInternalTextures;
  47085. private _createTextures;
  47086. /**
  47087. * Define the number of samples used if MSAA is enabled.
  47088. */
  47089. get samples(): number;
  47090. set samples(value: number);
  47091. /**
  47092. * Resize all the textures in the multi render target.
  47093. * Be carrefull as it will recreate all the data in the new texture.
  47094. * @param size Define the new size
  47095. */
  47096. resize(size: any): void;
  47097. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  47098. /**
  47099. * Dispose the render targets and their associated resources
  47100. */
  47101. dispose(): void;
  47102. /**
  47103. * Release all the underlying texture used as draw buffers.
  47104. */
  47105. releaseInternalTextures(): void;
  47106. }
  47107. }
  47108. declare module BABYLON {
  47109. interface ThinEngine {
  47110. /**
  47111. * Unbind a list of render target textures from the webGL context
  47112. * This is used only when drawBuffer extension or webGL2 are active
  47113. * @param textures defines the render target textures to unbind
  47114. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  47115. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  47116. */
  47117. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  47118. /**
  47119. * Create a multi render target texture
  47120. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  47121. * @param size defines the size of the texture
  47122. * @param options defines the creation options
  47123. * @returns the cube texture as an InternalTexture
  47124. */
  47125. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  47126. /**
  47127. * Update the sample count for a given multiple render target texture
  47128. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  47129. * @param textures defines the textures to update
  47130. * @param samples defines the sample count to set
  47131. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  47132. */
  47133. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  47134. }
  47135. }
  47136. declare module BABYLON {
  47137. /**
  47138. * Class used to define an additional view for the engine
  47139. * @see https://doc.babylonjs.com/how_to/multi_canvases
  47140. */
  47141. export class EngineView {
  47142. /** Defines the canvas where to render the view */
  47143. target: HTMLCanvasElement;
  47144. /** Defines an optional camera used to render the view (will use active camera else) */
  47145. camera?: Camera;
  47146. }
  47147. interface Engine {
  47148. /**
  47149. * Gets or sets the HTML element to use for attaching events
  47150. */
  47151. inputElement: Nullable<HTMLElement>;
  47152. /**
  47153. * Gets the current engine view
  47154. * @see https://doc.babylonjs.com/how_to/multi_canvases
  47155. */
  47156. activeView: Nullable<EngineView>;
  47157. /** Gets or sets the list of views */
  47158. views: EngineView[];
  47159. /**
  47160. * Register a new child canvas
  47161. * @param canvas defines the canvas to register
  47162. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  47163. * @returns the associated view
  47164. */
  47165. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  47166. /**
  47167. * Remove a registered child canvas
  47168. * @param canvas defines the canvas to remove
  47169. * @returns the current engine
  47170. */
  47171. unRegisterView(canvas: HTMLCanvasElement): Engine;
  47172. }
  47173. }
  47174. declare module BABYLON {
  47175. /**
  47176. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  47177. */
  47178. export interface CubeMapInfo {
  47179. /**
  47180. * The pixel array for the front face.
  47181. * This is stored in format, left to right, up to down format.
  47182. */
  47183. front: Nullable<ArrayBufferView>;
  47184. /**
  47185. * The pixel array for the back face.
  47186. * This is stored in format, left to right, up to down format.
  47187. */
  47188. back: Nullable<ArrayBufferView>;
  47189. /**
  47190. * The pixel array for the left face.
  47191. * This is stored in format, left to right, up to down format.
  47192. */
  47193. left: Nullable<ArrayBufferView>;
  47194. /**
  47195. * The pixel array for the right face.
  47196. * This is stored in format, left to right, up to down format.
  47197. */
  47198. right: Nullable<ArrayBufferView>;
  47199. /**
  47200. * The pixel array for the up face.
  47201. * This is stored in format, left to right, up to down format.
  47202. */
  47203. up: Nullable<ArrayBufferView>;
  47204. /**
  47205. * The pixel array for the down face.
  47206. * This is stored in format, left to right, up to down format.
  47207. */
  47208. down: Nullable<ArrayBufferView>;
  47209. /**
  47210. * The size of the cubemap stored.
  47211. *
  47212. * Each faces will be size * size pixels.
  47213. */
  47214. size: number;
  47215. /**
  47216. * The format of the texture.
  47217. *
  47218. * RGBA, RGB.
  47219. */
  47220. format: number;
  47221. /**
  47222. * The type of the texture data.
  47223. *
  47224. * UNSIGNED_INT, FLOAT.
  47225. */
  47226. type: number;
  47227. /**
  47228. * Specifies whether the texture is in gamma space.
  47229. */
  47230. gammaSpace: boolean;
  47231. }
  47232. /**
  47233. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  47234. */
  47235. export class PanoramaToCubeMapTools {
  47236. private static FACE_FRONT;
  47237. private static FACE_BACK;
  47238. private static FACE_RIGHT;
  47239. private static FACE_LEFT;
  47240. private static FACE_DOWN;
  47241. private static FACE_UP;
  47242. /**
  47243. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  47244. *
  47245. * @param float32Array The source data.
  47246. * @param inputWidth The width of the input panorama.
  47247. * @param inputHeight The height of the input panorama.
  47248. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  47249. * @return The cubemap data
  47250. */
  47251. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  47252. private static CreateCubemapTexture;
  47253. private static CalcProjectionSpherical;
  47254. }
  47255. }
  47256. declare module BABYLON {
  47257. /**
  47258. * Helper class dealing with the extraction of spherical polynomial dataArray
  47259. * from a cube map.
  47260. */
  47261. export class CubeMapToSphericalPolynomialTools {
  47262. private static FileFaces;
  47263. /**
  47264. * Converts a texture to the according Spherical Polynomial data.
  47265. * This extracts the first 3 orders only as they are the only one used in the lighting.
  47266. *
  47267. * @param texture The texture to extract the information from.
  47268. * @return The Spherical Polynomial data.
  47269. */
  47270. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  47271. /**
  47272. * Converts a cubemap to the according Spherical Polynomial data.
  47273. * This extracts the first 3 orders only as they are the only one used in the lighting.
  47274. *
  47275. * @param cubeInfo The Cube map to extract the information from.
  47276. * @return The Spherical Polynomial data.
  47277. */
  47278. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  47279. }
  47280. }
  47281. declare module BABYLON {
  47282. interface BaseTexture {
  47283. /**
  47284. * Get the polynomial representation of the texture data.
  47285. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  47286. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  47287. */
  47288. sphericalPolynomial: Nullable<SphericalPolynomial>;
  47289. }
  47290. }
  47291. declare module BABYLON {
  47292. /** @hidden */
  47293. export var rgbdEncodePixelShader: {
  47294. name: string;
  47295. shader: string;
  47296. };
  47297. }
  47298. declare module BABYLON {
  47299. /** @hidden */
  47300. export var rgbdDecodePixelShader: {
  47301. name: string;
  47302. shader: string;
  47303. };
  47304. }
  47305. declare module BABYLON {
  47306. /**
  47307. * Raw texture data and descriptor sufficient for WebGL texture upload
  47308. */
  47309. export interface EnvironmentTextureInfo {
  47310. /**
  47311. * Version of the environment map
  47312. */
  47313. version: number;
  47314. /**
  47315. * Width of image
  47316. */
  47317. width: number;
  47318. /**
  47319. * Irradiance information stored in the file.
  47320. */
  47321. irradiance: any;
  47322. /**
  47323. * Specular information stored in the file.
  47324. */
  47325. specular: any;
  47326. }
  47327. /**
  47328. * Defines One Image in the file. It requires only the position in the file
  47329. * as well as the length.
  47330. */
  47331. interface BufferImageData {
  47332. /**
  47333. * Length of the image data.
  47334. */
  47335. length: number;
  47336. /**
  47337. * Position of the data from the null terminator delimiting the end of the JSON.
  47338. */
  47339. position: number;
  47340. }
  47341. /**
  47342. * Defines the specular data enclosed in the file.
  47343. * This corresponds to the version 1 of the data.
  47344. */
  47345. export interface EnvironmentTextureSpecularInfoV1 {
  47346. /**
  47347. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  47348. */
  47349. specularDataPosition?: number;
  47350. /**
  47351. * This contains all the images data needed to reconstruct the cubemap.
  47352. */
  47353. mipmaps: Array<BufferImageData>;
  47354. /**
  47355. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  47356. */
  47357. lodGenerationScale: number;
  47358. }
  47359. /**
  47360. * Sets of helpers addressing the serialization and deserialization of environment texture
  47361. * stored in a BabylonJS env file.
  47362. * Those files are usually stored as .env files.
  47363. */
  47364. export class EnvironmentTextureTools {
  47365. /**
  47366. * Magic number identifying the env file.
  47367. */
  47368. private static _MagicBytes;
  47369. /**
  47370. * Gets the environment info from an env file.
  47371. * @param data The array buffer containing the .env bytes.
  47372. * @returns the environment file info (the json header) if successfully parsed.
  47373. */
  47374. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  47375. /**
  47376. * Creates an environment texture from a loaded cube texture.
  47377. * @param texture defines the cube texture to convert in env file
  47378. * @return a promise containing the environment data if succesfull.
  47379. */
  47380. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  47381. /**
  47382. * Creates a JSON representation of the spherical data.
  47383. * @param texture defines the texture containing the polynomials
  47384. * @return the JSON representation of the spherical info
  47385. */
  47386. private static _CreateEnvTextureIrradiance;
  47387. /**
  47388. * Creates the ArrayBufferViews used for initializing environment texture image data.
  47389. * @param data the image data
  47390. * @param info parameters that determine what views will be created for accessing the underlying buffer
  47391. * @return the views described by info providing access to the underlying buffer
  47392. */
  47393. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  47394. /**
  47395. * Uploads the texture info contained in the env file to the GPU.
  47396. * @param texture defines the internal texture to upload to
  47397. * @param data defines the data to load
  47398. * @param info defines the texture info retrieved through the GetEnvInfo method
  47399. * @returns a promise
  47400. */
  47401. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  47402. private static _OnImageReadyAsync;
  47403. /**
  47404. * Uploads the levels of image data to the GPU.
  47405. * @param texture defines the internal texture to upload to
  47406. * @param imageData defines the array buffer views of image data [mipmap][face]
  47407. * @returns a promise
  47408. */
  47409. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  47410. /**
  47411. * Uploads spherical polynomials information to the texture.
  47412. * @param texture defines the texture we are trying to upload the information to
  47413. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  47414. */
  47415. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  47416. /** @hidden */
  47417. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  47418. }
  47419. }
  47420. declare module BABYLON {
  47421. /**
  47422. * Contains position and normal vectors for a vertex
  47423. */
  47424. export class PositionNormalVertex {
  47425. /** the position of the vertex (defaut: 0,0,0) */
  47426. position: Vector3;
  47427. /** the normal of the vertex (defaut: 0,1,0) */
  47428. normal: Vector3;
  47429. /**
  47430. * Creates a PositionNormalVertex
  47431. * @param position the position of the vertex (defaut: 0,0,0)
  47432. * @param normal the normal of the vertex (defaut: 0,1,0)
  47433. */
  47434. constructor(
  47435. /** the position of the vertex (defaut: 0,0,0) */
  47436. position?: Vector3,
  47437. /** the normal of the vertex (defaut: 0,1,0) */
  47438. normal?: Vector3);
  47439. /**
  47440. * Clones the PositionNormalVertex
  47441. * @returns the cloned PositionNormalVertex
  47442. */
  47443. clone(): PositionNormalVertex;
  47444. }
  47445. /**
  47446. * Contains position, normal and uv vectors for a vertex
  47447. */
  47448. export class PositionNormalTextureVertex {
  47449. /** the position of the vertex (defaut: 0,0,0) */
  47450. position: Vector3;
  47451. /** the normal of the vertex (defaut: 0,1,0) */
  47452. normal: Vector3;
  47453. /** the uv of the vertex (default: 0,0) */
  47454. uv: Vector2;
  47455. /**
  47456. * Creates a PositionNormalTextureVertex
  47457. * @param position the position of the vertex (defaut: 0,0,0)
  47458. * @param normal the normal of the vertex (defaut: 0,1,0)
  47459. * @param uv the uv of the vertex (default: 0,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. /** the uv of the vertex (default: 0,0) */
  47467. uv?: Vector2);
  47468. /**
  47469. * Clones the PositionNormalTextureVertex
  47470. * @returns the cloned PositionNormalTextureVertex
  47471. */
  47472. clone(): PositionNormalTextureVertex;
  47473. }
  47474. }
  47475. declare module BABYLON {
  47476. /** @hidden */
  47477. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  47478. private _genericAttributeLocation;
  47479. private _varyingLocationCount;
  47480. private _varyingLocationMap;
  47481. private _replacements;
  47482. private _textureCount;
  47483. private _uniforms;
  47484. lineProcessor(line: string): string;
  47485. attributeProcessor(attribute: string): string;
  47486. varyingProcessor(varying: string, isFragment: boolean): string;
  47487. uniformProcessor(uniform: string): string;
  47488. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  47489. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  47490. }
  47491. }
  47492. declare module BABYLON {
  47493. /**
  47494. * Container for accessors for natively-stored mesh data buffers.
  47495. */
  47496. class NativeDataBuffer extends DataBuffer {
  47497. /**
  47498. * Accessor value used to identify/retrieve a natively-stored index buffer.
  47499. */
  47500. nativeIndexBuffer?: any;
  47501. /**
  47502. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  47503. */
  47504. nativeVertexBuffer?: any;
  47505. }
  47506. /** @hidden */
  47507. class NativeTexture extends InternalTexture {
  47508. getInternalTexture(): InternalTexture;
  47509. getViewCount(): number;
  47510. }
  47511. /** @hidden */
  47512. export class NativeEngine extends Engine {
  47513. private readonly _native;
  47514. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  47515. private readonly INVALID_HANDLE;
  47516. getHardwareScalingLevel(): number;
  47517. constructor();
  47518. /**
  47519. * Can be used to override the current requestAnimationFrame requester.
  47520. * @hidden
  47521. */
  47522. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  47523. /**
  47524. * Override default engine behavior.
  47525. * @param color
  47526. * @param backBuffer
  47527. * @param depth
  47528. * @param stencil
  47529. */
  47530. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  47531. /**
  47532. * Gets host document
  47533. * @returns the host document object
  47534. */
  47535. getHostDocument(): Nullable<Document>;
  47536. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  47537. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  47538. createVertexBuffer(data: DataArray): NativeDataBuffer;
  47539. recordVertexArrayObject(vertexBuffers: {
  47540. [key: string]: VertexBuffer;
  47541. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  47542. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  47543. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  47544. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  47545. /**
  47546. * Draw a list of indexed primitives
  47547. * @param fillMode defines the primitive to use
  47548. * @param indexStart defines the starting index
  47549. * @param indexCount defines the number of index to draw
  47550. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  47551. */
  47552. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  47553. /**
  47554. * Draw a list of unindexed primitives
  47555. * @param fillMode defines the primitive to use
  47556. * @param verticesStart defines the index of first vertex to draw
  47557. * @param verticesCount defines the count of vertices to draw
  47558. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  47559. */
  47560. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  47561. createPipelineContext(): IPipelineContext;
  47562. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  47563. /** @hidden */
  47564. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  47565. /** @hidden */
  47566. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  47567. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  47568. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  47569. protected _setProgram(program: WebGLProgram): void;
  47570. _releaseEffect(effect: Effect): void;
  47571. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  47572. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  47573. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  47574. bindSamplers(effect: Effect): void;
  47575. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  47576. getRenderWidth(useScreen?: boolean): number;
  47577. getRenderHeight(useScreen?: boolean): number;
  47578. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  47579. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  47580. /**
  47581. * Set the z offset to apply to current rendering
  47582. * @param value defines the offset to apply
  47583. */
  47584. setZOffset(value: number): void;
  47585. /**
  47586. * Gets the current value of the zOffset
  47587. * @returns the current zOffset state
  47588. */
  47589. getZOffset(): number;
  47590. /**
  47591. * Enable or disable depth buffering
  47592. * @param enable defines the state to set
  47593. */
  47594. setDepthBuffer(enable: boolean): void;
  47595. /**
  47596. * Gets a boolean indicating if depth writing is enabled
  47597. * @returns the current depth writing state
  47598. */
  47599. getDepthWrite(): boolean;
  47600. /**
  47601. * Enable or disable depth writing
  47602. * @param enable defines the state to set
  47603. */
  47604. setDepthWrite(enable: boolean): void;
  47605. /**
  47606. * Enable or disable color writing
  47607. * @param enable defines the state to set
  47608. */
  47609. setColorWrite(enable: boolean): void;
  47610. /**
  47611. * Gets a boolean indicating if color writing is enabled
  47612. * @returns the current color writing state
  47613. */
  47614. getColorWrite(): boolean;
  47615. /**
  47616. * Sets alpha constants used by some alpha blending modes
  47617. * @param r defines the red component
  47618. * @param g defines the green component
  47619. * @param b defines the blue component
  47620. * @param a defines the alpha component
  47621. */
  47622. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  47623. /**
  47624. * Sets the current alpha mode
  47625. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  47626. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  47627. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  47628. */
  47629. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  47630. /**
  47631. * Gets the current alpha mode
  47632. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  47633. * @returns the current alpha mode
  47634. */
  47635. getAlphaMode(): number;
  47636. setInt(uniform: WebGLUniformLocation, int: number): void;
  47637. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  47638. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  47639. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  47640. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  47641. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  47642. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  47643. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  47644. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  47645. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  47646. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  47647. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  47648. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  47649. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  47650. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  47651. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  47652. setFloat(uniform: WebGLUniformLocation, value: number): void;
  47653. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  47654. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  47655. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  47656. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  47657. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  47658. wipeCaches(bruteForce?: boolean): void;
  47659. _createTexture(): WebGLTexture;
  47660. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  47661. /**
  47662. * Usually called from BABYLON.Texture.ts.
  47663. * Passed information to create a WebGLTexture
  47664. * @param urlArg defines a value which contains one of the following:
  47665. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  47666. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  47667. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  47668. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  47669. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  47670. * @param scene needed for loading to the correct scene
  47671. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  47672. * @param onLoad optional callback to be called upon successful completion
  47673. * @param onError optional callback to be called upon failure
  47674. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  47675. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  47676. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  47677. * @param forcedExtension defines the extension to use to pick the right loader
  47678. * @returns a InternalTexture for assignment back into BABYLON.Texture
  47679. */
  47680. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<Scene>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | Blob>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>): InternalTexture;
  47681. /**
  47682. * Creates a cube texture
  47683. * @param rootUrl defines the url where the files to load is located
  47684. * @param scene defines the current scene
  47685. * @param files defines the list of files to load (1 per face)
  47686. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  47687. * @param onLoad defines an optional callback raised when the texture is loaded
  47688. * @param onError defines an optional callback raised if there is an issue to load the texture
  47689. * @param format defines the format of the data
  47690. * @param forcedExtension defines the extension to use to pick the right loader
  47691. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  47692. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  47693. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  47694. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  47695. * @returns the cube texture as an InternalTexture
  47696. */
  47697. 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;
  47698. private _getSamplingFilter;
  47699. private static _GetNativeTextureFormat;
  47700. createRenderTargetTexture(size: number | {
  47701. width: number;
  47702. height: number;
  47703. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  47704. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  47705. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  47706. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  47707. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  47708. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  47709. /**
  47710. * Updates a dynamic vertex buffer.
  47711. * @param vertexBuffer the vertex buffer to update
  47712. * @param data the data used to update the vertex buffer
  47713. * @param byteOffset the byte offset of the data (optional)
  47714. * @param byteLength the byte length of the data (optional)
  47715. */
  47716. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  47717. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  47718. private _updateAnisotropicLevel;
  47719. private _getAddressMode;
  47720. /** @hidden */
  47721. _bindTexture(channel: number, texture: InternalTexture): void;
  47722. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  47723. releaseEffects(): void;
  47724. /** @hidden */
  47725. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47726. /** @hidden */
  47727. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47728. /** @hidden */
  47729. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47730. /** @hidden */
  47731. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  47732. }
  47733. }
  47734. declare module BABYLON {
  47735. /**
  47736. * Gather the list of clipboard event types as constants.
  47737. */
  47738. export class ClipboardEventTypes {
  47739. /**
  47740. * The clipboard event is fired when a copy command is active (pressed).
  47741. */
  47742. static readonly COPY: number;
  47743. /**
  47744. * The clipboard event is fired when a cut command is active (pressed).
  47745. */
  47746. static readonly CUT: number;
  47747. /**
  47748. * The clipboard event is fired when a paste command is active (pressed).
  47749. */
  47750. static readonly PASTE: number;
  47751. }
  47752. /**
  47753. * This class is used to store clipboard related info for the onClipboardObservable event.
  47754. */
  47755. export class ClipboardInfo {
  47756. /**
  47757. * Defines the type of event (BABYLON.ClipboardEventTypes)
  47758. */
  47759. type: number;
  47760. /**
  47761. * Defines the related dom event
  47762. */
  47763. event: ClipboardEvent;
  47764. /**
  47765. *Creates an instance of ClipboardInfo.
  47766. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  47767. * @param event Defines the related dom event
  47768. */
  47769. constructor(
  47770. /**
  47771. * Defines the type of event (BABYLON.ClipboardEventTypes)
  47772. */
  47773. type: number,
  47774. /**
  47775. * Defines the related dom event
  47776. */
  47777. event: ClipboardEvent);
  47778. /**
  47779. * Get the clipboard event's type from the keycode.
  47780. * @param keyCode Defines the keyCode for the current keyboard event.
  47781. * @return {number}
  47782. */
  47783. static GetTypeFromCharacter(keyCode: number): number;
  47784. }
  47785. }
  47786. declare module BABYLON {
  47787. /**
  47788. * Google Daydream controller
  47789. */
  47790. export class DaydreamController extends WebVRController {
  47791. /**
  47792. * Base Url for the controller model.
  47793. */
  47794. static MODEL_BASE_URL: string;
  47795. /**
  47796. * File name for the controller model.
  47797. */
  47798. static MODEL_FILENAME: string;
  47799. /**
  47800. * Gamepad Id prefix used to identify Daydream Controller.
  47801. */
  47802. static readonly GAMEPAD_ID_PREFIX: string;
  47803. /**
  47804. * Creates a new DaydreamController from a gamepad
  47805. * @param vrGamepad the gamepad that the controller should be created from
  47806. */
  47807. constructor(vrGamepad: any);
  47808. /**
  47809. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  47810. * @param scene scene in which to add meshes
  47811. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  47812. */
  47813. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  47814. /**
  47815. * Called once for each button that changed state since the last frame
  47816. * @param buttonIdx Which button index changed
  47817. * @param state New state of the button
  47818. * @param changes Which properties on the state changed since last frame
  47819. */
  47820. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  47821. }
  47822. }
  47823. declare module BABYLON {
  47824. /**
  47825. * Gear VR Controller
  47826. */
  47827. export class GearVRController extends WebVRController {
  47828. /**
  47829. * Base Url for the controller model.
  47830. */
  47831. static MODEL_BASE_URL: string;
  47832. /**
  47833. * File name for the controller model.
  47834. */
  47835. static MODEL_FILENAME: string;
  47836. /**
  47837. * Gamepad Id prefix used to identify this controller.
  47838. */
  47839. static readonly GAMEPAD_ID_PREFIX: string;
  47840. private readonly _buttonIndexToObservableNameMap;
  47841. /**
  47842. * Creates a new GearVRController from a gamepad
  47843. * @param vrGamepad the gamepad that the controller should be created from
  47844. */
  47845. constructor(vrGamepad: any);
  47846. /**
  47847. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  47848. * @param scene scene in which to add meshes
  47849. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  47850. */
  47851. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  47852. /**
  47853. * Called once for each button that changed state since the last frame
  47854. * @param buttonIdx Which button index changed
  47855. * @param state New state of the button
  47856. * @param changes Which properties on the state changed since last frame
  47857. */
  47858. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  47859. }
  47860. }
  47861. declare module BABYLON {
  47862. /**
  47863. * Generic Controller
  47864. */
  47865. export class GenericController extends WebVRController {
  47866. /**
  47867. * Base Url for the controller model.
  47868. */
  47869. static readonly MODEL_BASE_URL: string;
  47870. /**
  47871. * File name for the controller model.
  47872. */
  47873. static readonly MODEL_FILENAME: string;
  47874. /**
  47875. * Creates a new GenericController from a gamepad
  47876. * @param vrGamepad the gamepad that the controller should be created from
  47877. */
  47878. constructor(vrGamepad: any);
  47879. /**
  47880. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  47881. * @param scene scene in which to add meshes
  47882. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  47883. */
  47884. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  47885. /**
  47886. * Called once for each button that changed state since the last frame
  47887. * @param buttonIdx Which button index changed
  47888. * @param state New state of the button
  47889. * @param changes Which properties on the state changed since last frame
  47890. */
  47891. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  47892. }
  47893. }
  47894. declare module BABYLON {
  47895. /**
  47896. * Oculus Touch Controller
  47897. */
  47898. export class OculusTouchController extends WebVRController {
  47899. /**
  47900. * Base Url for the controller model.
  47901. */
  47902. static MODEL_BASE_URL: string;
  47903. /**
  47904. * File name for the left controller model.
  47905. */
  47906. static MODEL_LEFT_FILENAME: string;
  47907. /**
  47908. * File name for the right controller model.
  47909. */
  47910. static MODEL_RIGHT_FILENAME: string;
  47911. /**
  47912. * Base Url for the Quest controller model.
  47913. */
  47914. static QUEST_MODEL_BASE_URL: string;
  47915. /**
  47916. * @hidden
  47917. * If the controllers are running on a device that needs the updated Quest controller models
  47918. */
  47919. static _IsQuest: boolean;
  47920. /**
  47921. * Fired when the secondary trigger on this controller is modified
  47922. */
  47923. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  47924. /**
  47925. * Fired when the thumb rest on this controller is modified
  47926. */
  47927. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  47928. /**
  47929. * Creates a new OculusTouchController from a gamepad
  47930. * @param vrGamepad the gamepad that the controller should be created from
  47931. */
  47932. constructor(vrGamepad: any);
  47933. /**
  47934. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  47935. * @param scene scene in which to add meshes
  47936. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  47937. */
  47938. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  47939. /**
  47940. * Fired when the A button on this controller is modified
  47941. */
  47942. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  47943. /**
  47944. * Fired when the B button on this controller is modified
  47945. */
  47946. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  47947. /**
  47948. * Fired when the X button on this controller is modified
  47949. */
  47950. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  47951. /**
  47952. * Fired when the Y button on this controller is modified
  47953. */
  47954. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  47955. /**
  47956. * Called once for each button that changed state since the last frame
  47957. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  47958. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  47959. * 2) secondary trigger (same)
  47960. * 3) A (right) X (left), touch, pressed = value
  47961. * 4) B / Y
  47962. * 5) thumb rest
  47963. * @param buttonIdx Which button index changed
  47964. * @param state New state of the button
  47965. * @param changes Which properties on the state changed since last frame
  47966. */
  47967. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  47968. }
  47969. }
  47970. declare module BABYLON {
  47971. /**
  47972. * Vive Controller
  47973. */
  47974. export class ViveController extends WebVRController {
  47975. /**
  47976. * Base Url for the controller model.
  47977. */
  47978. static MODEL_BASE_URL: string;
  47979. /**
  47980. * File name for the controller model.
  47981. */
  47982. static MODEL_FILENAME: string;
  47983. /**
  47984. * Creates a new ViveController from a gamepad
  47985. * @param vrGamepad the gamepad that the controller should be created from
  47986. */
  47987. constructor(vrGamepad: any);
  47988. /**
  47989. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  47990. * @param scene scene in which to add meshes
  47991. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  47992. */
  47993. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  47994. /**
  47995. * Fired when the left button on this controller is modified
  47996. */
  47997. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  47998. /**
  47999. * Fired when the right button on this controller is modified
  48000. */
  48001. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48002. /**
  48003. * Fired when the menu button on this controller is modified
  48004. */
  48005. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48006. /**
  48007. * Called once for each button that changed state since the last frame
  48008. * Vive mapping:
  48009. * 0: touchpad
  48010. * 1: trigger
  48011. * 2: left AND right buttons
  48012. * 3: menu button
  48013. * @param buttonIdx Which button index changed
  48014. * @param state New state of the button
  48015. * @param changes Which properties on the state changed since last frame
  48016. */
  48017. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48018. }
  48019. }
  48020. declare module BABYLON {
  48021. /**
  48022. * Defines the WindowsMotionController object that the state of the windows motion controller
  48023. */
  48024. export class WindowsMotionController extends WebVRController {
  48025. /**
  48026. * The base url used to load the left and right controller models
  48027. */
  48028. static MODEL_BASE_URL: string;
  48029. /**
  48030. * The name of the left controller model file
  48031. */
  48032. static MODEL_LEFT_FILENAME: string;
  48033. /**
  48034. * The name of the right controller model file
  48035. */
  48036. static MODEL_RIGHT_FILENAME: string;
  48037. /**
  48038. * The controller name prefix for this controller type
  48039. */
  48040. static readonly GAMEPAD_ID_PREFIX: string;
  48041. /**
  48042. * The controller id pattern for this controller type
  48043. */
  48044. private static readonly GAMEPAD_ID_PATTERN;
  48045. private _loadedMeshInfo;
  48046. protected readonly _mapping: {
  48047. buttons: string[];
  48048. buttonMeshNames: {
  48049. 'trigger': string;
  48050. 'menu': string;
  48051. 'grip': string;
  48052. 'thumbstick': string;
  48053. 'trackpad': string;
  48054. };
  48055. buttonObservableNames: {
  48056. 'trigger': string;
  48057. 'menu': string;
  48058. 'grip': string;
  48059. 'thumbstick': string;
  48060. 'trackpad': string;
  48061. };
  48062. axisMeshNames: string[];
  48063. pointingPoseMeshName: string;
  48064. };
  48065. /**
  48066. * Fired when the trackpad on this controller is clicked
  48067. */
  48068. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  48069. /**
  48070. * Fired when the trackpad on this controller is modified
  48071. */
  48072. onTrackpadValuesChangedObservable: Observable<StickValues>;
  48073. /**
  48074. * The current x and y values of this controller's trackpad
  48075. */
  48076. trackpad: StickValues;
  48077. /**
  48078. * Creates a new WindowsMotionController from a gamepad
  48079. * @param vrGamepad the gamepad that the controller should be created from
  48080. */
  48081. constructor(vrGamepad: any);
  48082. /**
  48083. * Fired when the trigger on this controller is modified
  48084. */
  48085. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48086. /**
  48087. * Fired when the menu button on this controller is modified
  48088. */
  48089. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48090. /**
  48091. * Fired when the grip button on this controller is modified
  48092. */
  48093. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48094. /**
  48095. * Fired when the thumbstick button on this controller is modified
  48096. */
  48097. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48098. /**
  48099. * Fired when the touchpad button on this controller is modified
  48100. */
  48101. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48102. /**
  48103. * Fired when the touchpad values on this controller are modified
  48104. */
  48105. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  48106. protected _updateTrackpad(): void;
  48107. /**
  48108. * Called once per frame by the engine.
  48109. */
  48110. update(): void;
  48111. /**
  48112. * Called once for each button that changed state since the last frame
  48113. * @param buttonIdx Which button index changed
  48114. * @param state New state of the button
  48115. * @param changes Which properties on the state changed since last frame
  48116. */
  48117. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48118. /**
  48119. * Moves the buttons on the controller mesh based on their current state
  48120. * @param buttonName the name of the button to move
  48121. * @param buttonValue the value of the button which determines the buttons new position
  48122. */
  48123. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  48124. /**
  48125. * Moves the axis on the controller mesh based on its current state
  48126. * @param axis the index of the axis
  48127. * @param axisValue the value of the axis which determines the meshes new position
  48128. * @hidden
  48129. */
  48130. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  48131. /**
  48132. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48133. * @param scene scene in which to add meshes
  48134. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48135. */
  48136. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  48137. /**
  48138. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  48139. * can be transformed by button presses and axes values, based on this._mapping.
  48140. *
  48141. * @param scene scene in which the meshes exist
  48142. * @param meshes list of meshes that make up the controller model to process
  48143. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  48144. */
  48145. private processModel;
  48146. private createMeshInfo;
  48147. /**
  48148. * Gets the ray of the controller in the direction the controller is pointing
  48149. * @param length the length the resulting ray should be
  48150. * @returns a ray in the direction the controller is pointing
  48151. */
  48152. getForwardRay(length?: number): Ray;
  48153. /**
  48154. * Disposes of the controller
  48155. */
  48156. dispose(): void;
  48157. }
  48158. /**
  48159. * This class represents a new windows motion controller in XR.
  48160. */
  48161. export class XRWindowsMotionController extends WindowsMotionController {
  48162. /**
  48163. * Changing the original WIndowsMotionController mapping to fir the new mapping
  48164. */
  48165. protected readonly _mapping: {
  48166. buttons: string[];
  48167. buttonMeshNames: {
  48168. 'trigger': string;
  48169. 'menu': string;
  48170. 'grip': string;
  48171. 'thumbstick': string;
  48172. 'trackpad': string;
  48173. };
  48174. buttonObservableNames: {
  48175. 'trigger': string;
  48176. 'menu': string;
  48177. 'grip': string;
  48178. 'thumbstick': string;
  48179. 'trackpad': string;
  48180. };
  48181. axisMeshNames: string[];
  48182. pointingPoseMeshName: string;
  48183. };
  48184. /**
  48185. * Construct a new XR-Based windows motion controller
  48186. *
  48187. * @param gamepadInfo the gamepad object from the browser
  48188. */
  48189. constructor(gamepadInfo: any);
  48190. /**
  48191. * holds the thumbstick values (X,Y)
  48192. */
  48193. thumbstickValues: StickValues;
  48194. /**
  48195. * Fired when the thumbstick on this controller is clicked
  48196. */
  48197. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  48198. /**
  48199. * Fired when the thumbstick on this controller is modified
  48200. */
  48201. onThumbstickValuesChangedObservable: Observable<StickValues>;
  48202. /**
  48203. * Fired when the touchpad button on this controller is modified
  48204. */
  48205. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  48206. /**
  48207. * Fired when the touchpad values on this controller are modified
  48208. */
  48209. onTrackpadValuesChangedObservable: Observable<StickValues>;
  48210. /**
  48211. * Fired when the thumbstick button on this controller is modified
  48212. * here to prevent breaking changes
  48213. */
  48214. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48215. /**
  48216. * updating the thumbstick(!) and not the trackpad.
  48217. * This is named this way due to the difference between WebVR and XR and to avoid
  48218. * changing the parent class.
  48219. */
  48220. protected _updateTrackpad(): void;
  48221. /**
  48222. * Disposes the class with joy
  48223. */
  48224. dispose(): void;
  48225. }
  48226. }
  48227. declare module BABYLON {
  48228. /**
  48229. * Class containing static functions to help procedurally build meshes
  48230. */
  48231. export class PolyhedronBuilder {
  48232. /**
  48233. * Creates a polyhedron mesh
  48234. * * 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
  48235. * * The parameter `size` (positive float, default 1) sets the polygon size
  48236. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  48237. * * 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`
  48238. * * 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
  48239. * * 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)`)
  48240. * * 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
  48241. * * 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
  48242. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48243. * * 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
  48244. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48245. * @param name defines the name of the mesh
  48246. * @param options defines the options used to create the mesh
  48247. * @param scene defines the hosting scene
  48248. * @returns the polyhedron mesh
  48249. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  48250. */
  48251. static CreatePolyhedron(name: string, options: {
  48252. type?: number;
  48253. size?: number;
  48254. sizeX?: number;
  48255. sizeY?: number;
  48256. sizeZ?: number;
  48257. custom?: any;
  48258. faceUV?: Vector4[];
  48259. faceColors?: Color4[];
  48260. flat?: boolean;
  48261. updatable?: boolean;
  48262. sideOrientation?: number;
  48263. frontUVs?: Vector4;
  48264. backUVs?: Vector4;
  48265. }, scene?: Nullable<Scene>): Mesh;
  48266. }
  48267. }
  48268. declare module BABYLON {
  48269. /**
  48270. * Gizmo that enables scaling a mesh along 3 axis
  48271. */
  48272. export class ScaleGizmo extends Gizmo {
  48273. /**
  48274. * Internal gizmo used for interactions on the x axis
  48275. */
  48276. xGizmo: AxisScaleGizmo;
  48277. /**
  48278. * Internal gizmo used for interactions on the y axis
  48279. */
  48280. yGizmo: AxisScaleGizmo;
  48281. /**
  48282. * Internal gizmo used for interactions on the z axis
  48283. */
  48284. zGizmo: AxisScaleGizmo;
  48285. /**
  48286. * Internal gizmo used to scale all axis equally
  48287. */
  48288. uniformScaleGizmo: AxisScaleGizmo;
  48289. private _meshAttached;
  48290. private _updateGizmoRotationToMatchAttachedMesh;
  48291. private _snapDistance;
  48292. private _scaleRatio;
  48293. private _uniformScalingMesh;
  48294. private _octahedron;
  48295. private _sensitivity;
  48296. /** Fires an event when any of it's sub gizmos are dragged */
  48297. onDragStartObservable: Observable<unknown>;
  48298. /** Fires an event when any of it's sub gizmos are released from dragging */
  48299. onDragEndObservable: Observable<unknown>;
  48300. get attachedMesh(): Nullable<AbstractMesh>;
  48301. set attachedMesh(mesh: Nullable<AbstractMesh>);
  48302. /**
  48303. * Creates a ScaleGizmo
  48304. * @param gizmoLayer The utility layer the gizmo will be added to
  48305. */
  48306. constructor(gizmoLayer?: UtilityLayerRenderer);
  48307. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  48308. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  48309. /**
  48310. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  48311. */
  48312. set snapDistance(value: number);
  48313. get snapDistance(): number;
  48314. /**
  48315. * Ratio for the scale of the gizmo (Default: 1)
  48316. */
  48317. set scaleRatio(value: number);
  48318. get scaleRatio(): number;
  48319. /**
  48320. * Sensitivity factor for dragging (Default: 1)
  48321. */
  48322. set sensitivity(value: number);
  48323. get sensitivity(): number;
  48324. /**
  48325. * Disposes of the gizmo
  48326. */
  48327. dispose(): void;
  48328. }
  48329. }
  48330. declare module BABYLON {
  48331. /**
  48332. * Single axis scale gizmo
  48333. */
  48334. export class AxisScaleGizmo extends Gizmo {
  48335. /**
  48336. * Drag behavior responsible for the gizmos dragging interactions
  48337. */
  48338. dragBehavior: PointerDragBehavior;
  48339. private _pointerObserver;
  48340. /**
  48341. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  48342. */
  48343. snapDistance: number;
  48344. /**
  48345. * Event that fires each time the gizmo snaps to a new location.
  48346. * * snapDistance is the the change in distance
  48347. */
  48348. onSnapObservable: Observable<{
  48349. snapDistance: number;
  48350. }>;
  48351. /**
  48352. * If the scaling operation should be done on all axis (default: false)
  48353. */
  48354. uniformScaling: boolean;
  48355. /**
  48356. * Custom sensitivity value for the drag strength
  48357. */
  48358. sensitivity: number;
  48359. private _isEnabled;
  48360. private _parent;
  48361. private _arrow;
  48362. private _coloredMaterial;
  48363. private _hoverMaterial;
  48364. /**
  48365. * Creates an AxisScaleGizmo
  48366. * @param gizmoLayer The utility layer the gizmo will be added to
  48367. * @param dragAxis The axis which the gizmo will be able to scale on
  48368. * @param color The color of the gizmo
  48369. */
  48370. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  48371. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  48372. /**
  48373. * If the gizmo is enabled
  48374. */
  48375. set isEnabled(value: boolean);
  48376. get isEnabled(): boolean;
  48377. /**
  48378. * Disposes of the gizmo
  48379. */
  48380. dispose(): void;
  48381. /**
  48382. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  48383. * @param mesh The mesh to replace the default mesh of the gizmo
  48384. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  48385. */
  48386. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  48387. }
  48388. }
  48389. declare module BABYLON {
  48390. /**
  48391. * Bounding box gizmo
  48392. */
  48393. export class BoundingBoxGizmo extends Gizmo {
  48394. private _lineBoundingBox;
  48395. private _rotateSpheresParent;
  48396. private _scaleBoxesParent;
  48397. private _boundingDimensions;
  48398. private _renderObserver;
  48399. private _pointerObserver;
  48400. private _scaleDragSpeed;
  48401. private _tmpQuaternion;
  48402. private _tmpVector;
  48403. private _tmpRotationMatrix;
  48404. /**
  48405. * 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)
  48406. */
  48407. ignoreChildren: boolean;
  48408. /**
  48409. * 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)
  48410. */
  48411. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  48412. /**
  48413. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  48414. */
  48415. rotationSphereSize: number;
  48416. /**
  48417. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  48418. */
  48419. scaleBoxSize: number;
  48420. /**
  48421. * 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)
  48422. */
  48423. fixedDragMeshScreenSize: boolean;
  48424. /**
  48425. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  48426. */
  48427. fixedDragMeshScreenSizeDistanceFactor: number;
  48428. /**
  48429. * Fired when a rotation sphere or scale box is dragged
  48430. */
  48431. onDragStartObservable: Observable<{}>;
  48432. /**
  48433. * Fired when a scale box is dragged
  48434. */
  48435. onScaleBoxDragObservable: Observable<{}>;
  48436. /**
  48437. * Fired when a scale box drag is ended
  48438. */
  48439. onScaleBoxDragEndObservable: Observable<{}>;
  48440. /**
  48441. * Fired when a rotation sphere is dragged
  48442. */
  48443. onRotationSphereDragObservable: Observable<{}>;
  48444. /**
  48445. * Fired when a rotation sphere drag is ended
  48446. */
  48447. onRotationSphereDragEndObservable: Observable<{}>;
  48448. /**
  48449. * 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)
  48450. */
  48451. scalePivot: Nullable<Vector3>;
  48452. /**
  48453. * Mesh used as a pivot to rotate the attached mesh
  48454. */
  48455. private _anchorMesh;
  48456. private _existingMeshScale;
  48457. private _dragMesh;
  48458. private pointerDragBehavior;
  48459. private coloredMaterial;
  48460. private hoverColoredMaterial;
  48461. /**
  48462. * Sets the color of the bounding box gizmo
  48463. * @param color the color to set
  48464. */
  48465. setColor(color: Color3): void;
  48466. /**
  48467. * Creates an BoundingBoxGizmo
  48468. * @param gizmoLayer The utility layer the gizmo will be added to
  48469. * @param color The color of the gizmo
  48470. */
  48471. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  48472. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  48473. private _selectNode;
  48474. /**
  48475. * Updates the bounding box information for the Gizmo
  48476. */
  48477. updateBoundingBox(): void;
  48478. private _updateRotationSpheres;
  48479. private _updateScaleBoxes;
  48480. /**
  48481. * Enables rotation on the specified axis and disables rotation on the others
  48482. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  48483. */
  48484. setEnabledRotationAxis(axis: string): void;
  48485. /**
  48486. * Enables/disables scaling
  48487. * @param enable if scaling should be enabled
  48488. */
  48489. setEnabledScaling(enable: boolean): void;
  48490. private _updateDummy;
  48491. /**
  48492. * Enables a pointer drag behavior on the bounding box of the gizmo
  48493. */
  48494. enableDragBehavior(): void;
  48495. /**
  48496. * Disposes of the gizmo
  48497. */
  48498. dispose(): void;
  48499. /**
  48500. * 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)
  48501. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  48502. * @returns the bounding box mesh with the passed in mesh as a child
  48503. */
  48504. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  48505. /**
  48506. * CustomMeshes are not supported by this gizmo
  48507. * @param mesh The mesh to replace the default mesh of the gizmo
  48508. */
  48509. setCustomMesh(mesh: Mesh): void;
  48510. }
  48511. }
  48512. declare module BABYLON {
  48513. /**
  48514. * Single plane rotation gizmo
  48515. */
  48516. export class PlaneRotationGizmo extends Gizmo {
  48517. /**
  48518. * Drag behavior responsible for the gizmos dragging interactions
  48519. */
  48520. dragBehavior: PointerDragBehavior;
  48521. private _pointerObserver;
  48522. /**
  48523. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  48524. */
  48525. snapDistance: number;
  48526. /**
  48527. * Event that fires each time the gizmo snaps to a new location.
  48528. * * snapDistance is the the change in distance
  48529. */
  48530. onSnapObservable: Observable<{
  48531. snapDistance: number;
  48532. }>;
  48533. private _isEnabled;
  48534. private _parent;
  48535. /**
  48536. * Creates a PlaneRotationGizmo
  48537. * @param gizmoLayer The utility layer the gizmo will be added to
  48538. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  48539. * @param color The color of the gizmo
  48540. * @param tessellation Amount of tessellation to be used when creating rotation circles
  48541. * @param useEulerRotation Use and update Euler angle instead of quaternion
  48542. */
  48543. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  48544. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  48545. /**
  48546. * If the gizmo is enabled
  48547. */
  48548. set isEnabled(value: boolean);
  48549. get isEnabled(): boolean;
  48550. /**
  48551. * Disposes of the gizmo
  48552. */
  48553. dispose(): void;
  48554. }
  48555. }
  48556. declare module BABYLON {
  48557. /**
  48558. * Gizmo that enables rotating a mesh along 3 axis
  48559. */
  48560. export class RotationGizmo extends Gizmo {
  48561. /**
  48562. * Internal gizmo used for interactions on the x axis
  48563. */
  48564. xGizmo: PlaneRotationGizmo;
  48565. /**
  48566. * Internal gizmo used for interactions on the y axis
  48567. */
  48568. yGizmo: PlaneRotationGizmo;
  48569. /**
  48570. * Internal gizmo used for interactions on the z axis
  48571. */
  48572. zGizmo: PlaneRotationGizmo;
  48573. /** Fires an event when any of it's sub gizmos are dragged */
  48574. onDragStartObservable: Observable<unknown>;
  48575. /** Fires an event when any of it's sub gizmos are released from dragging */
  48576. onDragEndObservable: Observable<unknown>;
  48577. private _meshAttached;
  48578. get attachedMesh(): Nullable<AbstractMesh>;
  48579. set attachedMesh(mesh: Nullable<AbstractMesh>);
  48580. /**
  48581. * Creates a RotationGizmo
  48582. * @param gizmoLayer The utility layer the gizmo will be added to
  48583. * @param tessellation Amount of tessellation to be used when creating rotation circles
  48584. * @param useEulerRotation Use and update Euler angle instead of quaternion
  48585. */
  48586. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  48587. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  48588. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  48589. /**
  48590. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  48591. */
  48592. set snapDistance(value: number);
  48593. get snapDistance(): number;
  48594. /**
  48595. * Ratio for the scale of the gizmo (Default: 1)
  48596. */
  48597. set scaleRatio(value: number);
  48598. get scaleRatio(): number;
  48599. /**
  48600. * Disposes of the gizmo
  48601. */
  48602. dispose(): void;
  48603. /**
  48604. * CustomMeshes are not supported by this gizmo
  48605. * @param mesh The mesh to replace the default mesh of the gizmo
  48606. */
  48607. setCustomMesh(mesh: Mesh): void;
  48608. }
  48609. }
  48610. declare module BABYLON {
  48611. /**
  48612. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  48613. */
  48614. export class GizmoManager implements IDisposable {
  48615. private scene;
  48616. /**
  48617. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  48618. */
  48619. gizmos: {
  48620. positionGizmo: Nullable<PositionGizmo>;
  48621. rotationGizmo: Nullable<RotationGizmo>;
  48622. scaleGizmo: Nullable<ScaleGizmo>;
  48623. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  48624. };
  48625. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  48626. clearGizmoOnEmptyPointerEvent: boolean;
  48627. /** Fires an event when the manager is attached to a mesh */
  48628. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  48629. private _gizmosEnabled;
  48630. private _pointerObserver;
  48631. private _attachedMesh;
  48632. private _boundingBoxColor;
  48633. private _defaultUtilityLayer;
  48634. private _defaultKeepDepthUtilityLayer;
  48635. /**
  48636. * When bounding box gizmo is enabled, this can be used to track drag/end events
  48637. */
  48638. boundingBoxDragBehavior: SixDofDragBehavior;
  48639. /**
  48640. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  48641. */
  48642. attachableMeshes: Nullable<Array<AbstractMesh>>;
  48643. /**
  48644. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  48645. */
  48646. usePointerToAttachGizmos: boolean;
  48647. /**
  48648. * Utility layer that the bounding box gizmo belongs to
  48649. */
  48650. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  48651. /**
  48652. * Utility layer that all gizmos besides bounding box belong to
  48653. */
  48654. get utilityLayer(): UtilityLayerRenderer;
  48655. /**
  48656. * Instatiates a gizmo manager
  48657. * @param scene the scene to overlay the gizmos on top of
  48658. */
  48659. constructor(scene: Scene);
  48660. /**
  48661. * Attaches a set of gizmos to the specified mesh
  48662. * @param mesh The mesh the gizmo's should be attached to
  48663. */
  48664. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  48665. /**
  48666. * If the position gizmo is enabled
  48667. */
  48668. set positionGizmoEnabled(value: boolean);
  48669. get positionGizmoEnabled(): boolean;
  48670. /**
  48671. * If the rotation gizmo is enabled
  48672. */
  48673. set rotationGizmoEnabled(value: boolean);
  48674. get rotationGizmoEnabled(): boolean;
  48675. /**
  48676. * If the scale gizmo is enabled
  48677. */
  48678. set scaleGizmoEnabled(value: boolean);
  48679. get scaleGizmoEnabled(): boolean;
  48680. /**
  48681. * If the boundingBox gizmo is enabled
  48682. */
  48683. set boundingBoxGizmoEnabled(value: boolean);
  48684. get boundingBoxGizmoEnabled(): boolean;
  48685. /**
  48686. * Disposes of the gizmo manager
  48687. */
  48688. dispose(): void;
  48689. }
  48690. }
  48691. declare module BABYLON {
  48692. /**
  48693. * A directional light is defined by a direction (what a surprise!).
  48694. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  48695. * 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.
  48696. * Documentation: https://doc.babylonjs.com/babylon101/lights
  48697. */
  48698. export class DirectionalLight extends ShadowLight {
  48699. private _shadowFrustumSize;
  48700. /**
  48701. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  48702. */
  48703. get shadowFrustumSize(): number;
  48704. /**
  48705. * Specifies a fix frustum size for the shadow generation.
  48706. */
  48707. set shadowFrustumSize(value: number);
  48708. private _shadowOrthoScale;
  48709. /**
  48710. * Gets the shadow projection scale against the optimal computed one.
  48711. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  48712. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  48713. */
  48714. get shadowOrthoScale(): number;
  48715. /**
  48716. * Sets the shadow projection scale against the optimal computed one.
  48717. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  48718. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  48719. */
  48720. set shadowOrthoScale(value: number);
  48721. /**
  48722. * Automatically compute the projection matrix to best fit (including all the casters)
  48723. * on each frame.
  48724. */
  48725. autoUpdateExtends: boolean;
  48726. /**
  48727. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  48728. * on each frame. autoUpdateExtends must be set to true for this to work
  48729. */
  48730. autoCalcShadowZBounds: boolean;
  48731. private _orthoLeft;
  48732. private _orthoRight;
  48733. private _orthoTop;
  48734. private _orthoBottom;
  48735. /**
  48736. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  48737. * The directional light is emitted from everywhere in the given direction.
  48738. * It can cast shadows.
  48739. * Documentation : https://doc.babylonjs.com/babylon101/lights
  48740. * @param name The friendly name of the light
  48741. * @param direction The direction of the light
  48742. * @param scene The scene the light belongs to
  48743. */
  48744. constructor(name: string, direction: Vector3, scene: Scene);
  48745. /**
  48746. * Returns the string "DirectionalLight".
  48747. * @return The class name
  48748. */
  48749. getClassName(): string;
  48750. /**
  48751. * Returns the integer 1.
  48752. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  48753. */
  48754. getTypeID(): number;
  48755. /**
  48756. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  48757. * Returns the DirectionalLight Shadow projection matrix.
  48758. */
  48759. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  48760. /**
  48761. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  48762. * Returns the DirectionalLight Shadow projection matrix.
  48763. */
  48764. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  48765. /**
  48766. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  48767. * Returns the DirectionalLight Shadow projection matrix.
  48768. */
  48769. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  48770. protected _buildUniformLayout(): void;
  48771. /**
  48772. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  48773. * @param effect The effect to update
  48774. * @param lightIndex The index of the light in the effect to update
  48775. * @returns The directional light
  48776. */
  48777. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  48778. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  48779. /**
  48780. * Gets the minZ used for shadow according to both the scene and the light.
  48781. *
  48782. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  48783. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  48784. * @param activeCamera The camera we are returning the min for
  48785. * @returns the depth min z
  48786. */
  48787. getDepthMinZ(activeCamera: Camera): number;
  48788. /**
  48789. * Gets the maxZ used for shadow according to both the scene and the light.
  48790. *
  48791. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  48792. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  48793. * @param activeCamera The camera we are returning the max for
  48794. * @returns the depth max z
  48795. */
  48796. getDepthMaxZ(activeCamera: Camera): number;
  48797. /**
  48798. * Prepares the list of defines specific to the light type.
  48799. * @param defines the list of defines
  48800. * @param lightIndex defines the index of the light for the effect
  48801. */
  48802. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  48803. }
  48804. }
  48805. declare module BABYLON {
  48806. /**
  48807. * Class containing static functions to help procedurally build meshes
  48808. */
  48809. export class HemisphereBuilder {
  48810. /**
  48811. * Creates a hemisphere mesh
  48812. * @param name defines the name of the mesh
  48813. * @param options defines the options used to create the mesh
  48814. * @param scene defines the hosting scene
  48815. * @returns the hemisphere mesh
  48816. */
  48817. static CreateHemisphere(name: string, options: {
  48818. segments?: number;
  48819. diameter?: number;
  48820. sideOrientation?: number;
  48821. }, scene: any): Mesh;
  48822. }
  48823. }
  48824. declare module BABYLON {
  48825. /**
  48826. * A spot light is defined by a position, a direction, an angle, and an exponent.
  48827. * These values define a cone of light starting from the position, emitting toward the direction.
  48828. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  48829. * and the exponent defines the speed of the decay of the light with distance (reach).
  48830. * Documentation: https://doc.babylonjs.com/babylon101/lights
  48831. */
  48832. export class SpotLight extends ShadowLight {
  48833. private _angle;
  48834. private _innerAngle;
  48835. private _cosHalfAngle;
  48836. private _lightAngleScale;
  48837. private _lightAngleOffset;
  48838. /**
  48839. * Gets the cone angle of the spot light in Radians.
  48840. */
  48841. get angle(): number;
  48842. /**
  48843. * Sets the cone angle of the spot light in Radians.
  48844. */
  48845. set angle(value: number);
  48846. /**
  48847. * Only used in gltf falloff mode, this defines the angle where
  48848. * the directional falloff will start before cutting at angle which could be seen
  48849. * as outer angle.
  48850. */
  48851. get innerAngle(): number;
  48852. /**
  48853. * Only used in gltf falloff mode, this defines the angle where
  48854. * the directional falloff will start before cutting at angle which could be seen
  48855. * as outer angle.
  48856. */
  48857. set innerAngle(value: number);
  48858. private _shadowAngleScale;
  48859. /**
  48860. * Allows scaling the angle of the light for shadow generation only.
  48861. */
  48862. get shadowAngleScale(): number;
  48863. /**
  48864. * Allows scaling the angle of the light for shadow generation only.
  48865. */
  48866. set shadowAngleScale(value: number);
  48867. /**
  48868. * The light decay speed with the distance from the emission spot.
  48869. */
  48870. exponent: number;
  48871. private _projectionTextureMatrix;
  48872. /**
  48873. * Allows reading the projecton texture
  48874. */
  48875. get projectionTextureMatrix(): Matrix;
  48876. protected _projectionTextureLightNear: number;
  48877. /**
  48878. * Gets the near clip of the Spotlight for texture projection.
  48879. */
  48880. get projectionTextureLightNear(): number;
  48881. /**
  48882. * Sets the near clip of the Spotlight for texture projection.
  48883. */
  48884. set projectionTextureLightNear(value: number);
  48885. protected _projectionTextureLightFar: number;
  48886. /**
  48887. * Gets the far clip of the Spotlight for texture projection.
  48888. */
  48889. get projectionTextureLightFar(): number;
  48890. /**
  48891. * Sets the far clip of the Spotlight for texture projection.
  48892. */
  48893. set projectionTextureLightFar(value: number);
  48894. protected _projectionTextureUpDirection: Vector3;
  48895. /**
  48896. * Gets the Up vector of the Spotlight for texture projection.
  48897. */
  48898. get projectionTextureUpDirection(): Vector3;
  48899. /**
  48900. * Sets the Up vector of the Spotlight for texture projection.
  48901. */
  48902. set projectionTextureUpDirection(value: Vector3);
  48903. private _projectionTexture;
  48904. /**
  48905. * Gets the projection texture of the light.
  48906. */
  48907. get projectionTexture(): Nullable<BaseTexture>;
  48908. /**
  48909. * Sets the projection texture of the light.
  48910. */
  48911. set projectionTexture(value: Nullable<BaseTexture>);
  48912. private _projectionTextureViewLightDirty;
  48913. private _projectionTextureProjectionLightDirty;
  48914. private _projectionTextureDirty;
  48915. private _projectionTextureViewTargetVector;
  48916. private _projectionTextureViewLightMatrix;
  48917. private _projectionTextureProjectionLightMatrix;
  48918. private _projectionTextureScalingMatrix;
  48919. /**
  48920. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  48921. * It can cast shadows.
  48922. * Documentation : https://doc.babylonjs.com/babylon101/lights
  48923. * @param name The light friendly name
  48924. * @param position The position of the spot light in the scene
  48925. * @param direction The direction of the light in the scene
  48926. * @param angle The cone angle of the light in Radians
  48927. * @param exponent The light decay speed with the distance from the emission spot
  48928. * @param scene The scene the lights belongs to
  48929. */
  48930. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  48931. /**
  48932. * Returns the string "SpotLight".
  48933. * @returns the class name
  48934. */
  48935. getClassName(): string;
  48936. /**
  48937. * Returns the integer 2.
  48938. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  48939. */
  48940. getTypeID(): number;
  48941. /**
  48942. * Overrides the direction setter to recompute the projection texture view light Matrix.
  48943. */
  48944. protected _setDirection(value: Vector3): void;
  48945. /**
  48946. * Overrides the position setter to recompute the projection texture view light Matrix.
  48947. */
  48948. protected _setPosition(value: Vector3): void;
  48949. /**
  48950. * 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.
  48951. * Returns the SpotLight.
  48952. */
  48953. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  48954. protected _computeProjectionTextureViewLightMatrix(): void;
  48955. protected _computeProjectionTextureProjectionLightMatrix(): void;
  48956. /**
  48957. * Main function for light texture projection matrix computing.
  48958. */
  48959. protected _computeProjectionTextureMatrix(): void;
  48960. protected _buildUniformLayout(): void;
  48961. private _computeAngleValues;
  48962. /**
  48963. * Sets the passed Effect "effect" with the Light textures.
  48964. * @param effect The effect to update
  48965. * @param lightIndex The index of the light in the effect to update
  48966. * @returns The light
  48967. */
  48968. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  48969. /**
  48970. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  48971. * @param effect The effect to update
  48972. * @param lightIndex The index of the light in the effect to update
  48973. * @returns The spot light
  48974. */
  48975. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  48976. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  48977. /**
  48978. * Disposes the light and the associated resources.
  48979. */
  48980. dispose(): void;
  48981. /**
  48982. * Prepares the list of defines specific to the light type.
  48983. * @param defines the list of defines
  48984. * @param lightIndex defines the index of the light for the effect
  48985. */
  48986. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  48987. }
  48988. }
  48989. declare module BABYLON {
  48990. /**
  48991. * Gizmo that enables viewing a light
  48992. */
  48993. export class LightGizmo extends Gizmo {
  48994. private _lightMesh;
  48995. private _material;
  48996. private _cachedPosition;
  48997. private _cachedForward;
  48998. private _attachedMeshParent;
  48999. /**
  49000. * Creates a LightGizmo
  49001. * @param gizmoLayer The utility layer the gizmo will be added to
  49002. */
  49003. constructor(gizmoLayer?: UtilityLayerRenderer);
  49004. private _light;
  49005. /**
  49006. * The light that the gizmo is attached to
  49007. */
  49008. set light(light: Nullable<Light>);
  49009. get light(): Nullable<Light>;
  49010. /**
  49011. * Gets the material used to render the light gizmo
  49012. */
  49013. get material(): StandardMaterial;
  49014. /**
  49015. * @hidden
  49016. * Updates the gizmo to match the attached mesh's position/rotation
  49017. */
  49018. protected _update(): void;
  49019. private static _Scale;
  49020. /**
  49021. * Creates the lines for a light mesh
  49022. */
  49023. private static _CreateLightLines;
  49024. /**
  49025. * Disposes of the light gizmo
  49026. */
  49027. dispose(): void;
  49028. private static _CreateHemisphericLightMesh;
  49029. private static _CreatePointLightMesh;
  49030. private static _CreateSpotLightMesh;
  49031. private static _CreateDirectionalLightMesh;
  49032. }
  49033. }
  49034. declare module BABYLON {
  49035. /** @hidden */
  49036. export var backgroundFragmentDeclaration: {
  49037. name: string;
  49038. shader: string;
  49039. };
  49040. }
  49041. declare module BABYLON {
  49042. /** @hidden */
  49043. export var backgroundUboDeclaration: {
  49044. name: string;
  49045. shader: string;
  49046. };
  49047. }
  49048. declare module BABYLON {
  49049. /** @hidden */
  49050. export var backgroundPixelShader: {
  49051. name: string;
  49052. shader: string;
  49053. };
  49054. }
  49055. declare module BABYLON {
  49056. /** @hidden */
  49057. export var backgroundVertexDeclaration: {
  49058. name: string;
  49059. shader: string;
  49060. };
  49061. }
  49062. declare module BABYLON {
  49063. /** @hidden */
  49064. export var backgroundVertexShader: {
  49065. name: string;
  49066. shader: string;
  49067. };
  49068. }
  49069. declare module BABYLON {
  49070. /**
  49071. * Background material used to create an efficient environement around your scene.
  49072. */
  49073. export class BackgroundMaterial extends PushMaterial {
  49074. /**
  49075. * Standard reflectance value at parallel view angle.
  49076. */
  49077. static StandardReflectance0: number;
  49078. /**
  49079. * Standard reflectance value at grazing angle.
  49080. */
  49081. static StandardReflectance90: number;
  49082. protected _primaryColor: Color3;
  49083. /**
  49084. * Key light Color (multiply against the environement texture)
  49085. */
  49086. primaryColor: Color3;
  49087. protected __perceptualColor: Nullable<Color3>;
  49088. /**
  49089. * Experimental Internal Use Only.
  49090. *
  49091. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  49092. * This acts as a helper to set the primary color to a more "human friendly" value.
  49093. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  49094. * output color as close as possible from the chosen value.
  49095. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  49096. * part of lighting setup.)
  49097. */
  49098. get _perceptualColor(): Nullable<Color3>;
  49099. set _perceptualColor(value: Nullable<Color3>);
  49100. protected _primaryColorShadowLevel: float;
  49101. /**
  49102. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  49103. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  49104. */
  49105. get primaryColorShadowLevel(): float;
  49106. set primaryColorShadowLevel(value: float);
  49107. protected _primaryColorHighlightLevel: float;
  49108. /**
  49109. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  49110. * The primary color is used at the level chosen to define what the white area would look.
  49111. */
  49112. get primaryColorHighlightLevel(): float;
  49113. set primaryColorHighlightLevel(value: float);
  49114. protected _reflectionTexture: Nullable<BaseTexture>;
  49115. /**
  49116. * Reflection Texture used in the material.
  49117. * Should be author in a specific way for the best result (refer to the documentation).
  49118. */
  49119. reflectionTexture: Nullable<BaseTexture>;
  49120. protected _reflectionBlur: float;
  49121. /**
  49122. * Reflection Texture level of blur.
  49123. *
  49124. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  49125. * texture twice.
  49126. */
  49127. reflectionBlur: float;
  49128. protected _diffuseTexture: Nullable<BaseTexture>;
  49129. /**
  49130. * Diffuse Texture used in the material.
  49131. * Should be author in a specific way for the best result (refer to the documentation).
  49132. */
  49133. diffuseTexture: Nullable<BaseTexture>;
  49134. protected _shadowLights: Nullable<IShadowLight[]>;
  49135. /**
  49136. * Specify the list of lights casting shadow on the material.
  49137. * All scene shadow lights will be included if null.
  49138. */
  49139. shadowLights: Nullable<IShadowLight[]>;
  49140. protected _shadowLevel: float;
  49141. /**
  49142. * Helps adjusting the shadow to a softer level if required.
  49143. * 0 means black shadows and 1 means no shadows.
  49144. */
  49145. shadowLevel: float;
  49146. protected _sceneCenter: Vector3;
  49147. /**
  49148. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  49149. * It is usually zero but might be interesting to modify according to your setup.
  49150. */
  49151. sceneCenter: Vector3;
  49152. protected _opacityFresnel: boolean;
  49153. /**
  49154. * This helps specifying that the material is falling off to the sky box at grazing angle.
  49155. * This helps ensuring a nice transition when the camera goes under the ground.
  49156. */
  49157. opacityFresnel: boolean;
  49158. protected _reflectionFresnel: boolean;
  49159. /**
  49160. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  49161. * This helps adding a mirror texture on the ground.
  49162. */
  49163. reflectionFresnel: boolean;
  49164. protected _reflectionFalloffDistance: number;
  49165. /**
  49166. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  49167. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  49168. */
  49169. reflectionFalloffDistance: number;
  49170. protected _reflectionAmount: number;
  49171. /**
  49172. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  49173. */
  49174. reflectionAmount: number;
  49175. protected _reflectionReflectance0: number;
  49176. /**
  49177. * This specifies the weight of the reflection at grazing angle.
  49178. */
  49179. reflectionReflectance0: number;
  49180. protected _reflectionReflectance90: number;
  49181. /**
  49182. * This specifies the weight of the reflection at a perpendicular point of view.
  49183. */
  49184. reflectionReflectance90: number;
  49185. /**
  49186. * Sets the reflection reflectance fresnel values according to the default standard
  49187. * empirically know to work well :-)
  49188. */
  49189. set reflectionStandardFresnelWeight(value: number);
  49190. protected _useRGBColor: boolean;
  49191. /**
  49192. * Helps to directly use the maps channels instead of their level.
  49193. */
  49194. useRGBColor: boolean;
  49195. protected _enableNoise: boolean;
  49196. /**
  49197. * This helps reducing the banding effect that could occur on the background.
  49198. */
  49199. enableNoise: boolean;
  49200. /**
  49201. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  49202. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  49203. * Recommended to be keep at 1.0 except for special cases.
  49204. */
  49205. get fovMultiplier(): number;
  49206. set fovMultiplier(value: number);
  49207. private _fovMultiplier;
  49208. /**
  49209. * Enable the FOV adjustment feature controlled by fovMultiplier.
  49210. */
  49211. useEquirectangularFOV: boolean;
  49212. private _maxSimultaneousLights;
  49213. /**
  49214. * Number of Simultaneous lights allowed on the material.
  49215. */
  49216. maxSimultaneousLights: int;
  49217. /**
  49218. * Default configuration related to image processing available in the Background Material.
  49219. */
  49220. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  49221. /**
  49222. * Keep track of the image processing observer to allow dispose and replace.
  49223. */
  49224. private _imageProcessingObserver;
  49225. /**
  49226. * Attaches a new image processing configuration to the PBR Material.
  49227. * @param configuration (if null the scene configuration will be use)
  49228. */
  49229. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  49230. /**
  49231. * Gets the image processing configuration used either in this material.
  49232. */
  49233. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  49234. /**
  49235. * Sets the Default image processing configuration used either in the this material.
  49236. *
  49237. * If sets to null, the scene one is in use.
  49238. */
  49239. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  49240. /**
  49241. * Gets wether the color curves effect is enabled.
  49242. */
  49243. get cameraColorCurvesEnabled(): boolean;
  49244. /**
  49245. * Sets wether the color curves effect is enabled.
  49246. */
  49247. set cameraColorCurvesEnabled(value: boolean);
  49248. /**
  49249. * Gets wether the color grading effect is enabled.
  49250. */
  49251. get cameraColorGradingEnabled(): boolean;
  49252. /**
  49253. * Gets wether the color grading effect is enabled.
  49254. */
  49255. set cameraColorGradingEnabled(value: boolean);
  49256. /**
  49257. * Gets wether tonemapping is enabled or not.
  49258. */
  49259. get cameraToneMappingEnabled(): boolean;
  49260. /**
  49261. * Sets wether tonemapping is enabled or not
  49262. */
  49263. set cameraToneMappingEnabled(value: boolean);
  49264. /**
  49265. * The camera exposure used on this material.
  49266. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  49267. * This corresponds to a photographic exposure.
  49268. */
  49269. get cameraExposure(): float;
  49270. /**
  49271. * The camera exposure used on this material.
  49272. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  49273. * This corresponds to a photographic exposure.
  49274. */
  49275. set cameraExposure(value: float);
  49276. /**
  49277. * Gets The camera contrast used on this material.
  49278. */
  49279. get cameraContrast(): float;
  49280. /**
  49281. * Sets The camera contrast used on this material.
  49282. */
  49283. set cameraContrast(value: float);
  49284. /**
  49285. * Gets the Color Grading 2D Lookup Texture.
  49286. */
  49287. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  49288. /**
  49289. * Sets the Color Grading 2D Lookup Texture.
  49290. */
  49291. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  49292. /**
  49293. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  49294. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  49295. * 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;
  49296. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  49297. */
  49298. get cameraColorCurves(): Nullable<ColorCurves>;
  49299. /**
  49300. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  49301. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  49302. * 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;
  49303. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  49304. */
  49305. set cameraColorCurves(value: Nullable<ColorCurves>);
  49306. /**
  49307. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  49308. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  49309. */
  49310. switchToBGR: boolean;
  49311. private _renderTargets;
  49312. private _reflectionControls;
  49313. private _white;
  49314. private _primaryShadowColor;
  49315. private _primaryHighlightColor;
  49316. /**
  49317. * Instantiates a Background Material in the given scene
  49318. * @param name The friendly name of the material
  49319. * @param scene The scene to add the material to
  49320. */
  49321. constructor(name: string, scene: Scene);
  49322. /**
  49323. * Gets a boolean indicating that current material needs to register RTT
  49324. */
  49325. get hasRenderTargetTextures(): boolean;
  49326. /**
  49327. * The entire material has been created in order to prevent overdraw.
  49328. * @returns false
  49329. */
  49330. needAlphaTesting(): boolean;
  49331. /**
  49332. * The entire material has been created in order to prevent overdraw.
  49333. * @returns true if blending is enable
  49334. */
  49335. needAlphaBlending(): boolean;
  49336. /**
  49337. * Checks wether the material is ready to be rendered for a given mesh.
  49338. * @param mesh The mesh to render
  49339. * @param subMesh The submesh to check against
  49340. * @param useInstances Specify wether or not the material is used with instances
  49341. * @returns true if all the dependencies are ready (Textures, Effects...)
  49342. */
  49343. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  49344. /**
  49345. * Compute the primary color according to the chosen perceptual color.
  49346. */
  49347. private _computePrimaryColorFromPerceptualColor;
  49348. /**
  49349. * Compute the highlights and shadow colors according to their chosen levels.
  49350. */
  49351. private _computePrimaryColors;
  49352. /**
  49353. * Build the uniform buffer used in the material.
  49354. */
  49355. buildUniformLayout(): void;
  49356. /**
  49357. * Unbind the material.
  49358. */
  49359. unbind(): void;
  49360. /**
  49361. * Bind only the world matrix to the material.
  49362. * @param world The world matrix to bind.
  49363. */
  49364. bindOnlyWorldMatrix(world: Matrix): void;
  49365. /**
  49366. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  49367. * @param world The world matrix to bind.
  49368. * @param subMesh The submesh to bind for.
  49369. */
  49370. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  49371. /**
  49372. * Checks to see if a texture is used in the material.
  49373. * @param texture - Base texture to use.
  49374. * @returns - Boolean specifying if a texture is used in the material.
  49375. */
  49376. hasTexture(texture: BaseTexture): boolean;
  49377. /**
  49378. * Dispose the material.
  49379. * @param forceDisposeEffect Force disposal of the associated effect.
  49380. * @param forceDisposeTextures Force disposal of the associated textures.
  49381. */
  49382. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  49383. /**
  49384. * Clones the material.
  49385. * @param name The cloned name.
  49386. * @returns The cloned material.
  49387. */
  49388. clone(name: string): BackgroundMaterial;
  49389. /**
  49390. * Serializes the current material to its JSON representation.
  49391. * @returns The JSON representation.
  49392. */
  49393. serialize(): any;
  49394. /**
  49395. * Gets the class name of the material
  49396. * @returns "BackgroundMaterial"
  49397. */
  49398. getClassName(): string;
  49399. /**
  49400. * Parse a JSON input to create back a background material.
  49401. * @param source The JSON data to parse
  49402. * @param scene The scene to create the parsed material in
  49403. * @param rootUrl The root url of the assets the material depends upon
  49404. * @returns the instantiated BackgroundMaterial.
  49405. */
  49406. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  49407. }
  49408. }
  49409. declare module BABYLON {
  49410. /**
  49411. * Represents the different options available during the creation of
  49412. * a Environment helper.
  49413. *
  49414. * This can control the default ground, skybox and image processing setup of your scene.
  49415. */
  49416. export interface IEnvironmentHelperOptions {
  49417. /**
  49418. * Specifies whether or not to create a ground.
  49419. * True by default.
  49420. */
  49421. createGround: boolean;
  49422. /**
  49423. * Specifies the ground size.
  49424. * 15 by default.
  49425. */
  49426. groundSize: number;
  49427. /**
  49428. * The texture used on the ground for the main color.
  49429. * Comes from the BabylonJS CDN by default.
  49430. *
  49431. * Remarks: Can be either a texture or a url.
  49432. */
  49433. groundTexture: string | BaseTexture;
  49434. /**
  49435. * The color mixed in the ground texture by default.
  49436. * BabylonJS clearColor by default.
  49437. */
  49438. groundColor: Color3;
  49439. /**
  49440. * Specifies the ground opacity.
  49441. * 1 by default.
  49442. */
  49443. groundOpacity: number;
  49444. /**
  49445. * Enables the ground to receive shadows.
  49446. * True by default.
  49447. */
  49448. enableGroundShadow: boolean;
  49449. /**
  49450. * Helps preventing the shadow to be fully black on the ground.
  49451. * 0.5 by default.
  49452. */
  49453. groundShadowLevel: number;
  49454. /**
  49455. * Creates a mirror texture attach to the ground.
  49456. * false by default.
  49457. */
  49458. enableGroundMirror: boolean;
  49459. /**
  49460. * Specifies the ground mirror size ratio.
  49461. * 0.3 by default as the default kernel is 64.
  49462. */
  49463. groundMirrorSizeRatio: number;
  49464. /**
  49465. * Specifies the ground mirror blur kernel size.
  49466. * 64 by default.
  49467. */
  49468. groundMirrorBlurKernel: number;
  49469. /**
  49470. * Specifies the ground mirror visibility amount.
  49471. * 1 by default
  49472. */
  49473. groundMirrorAmount: number;
  49474. /**
  49475. * Specifies the ground mirror reflectance weight.
  49476. * This uses the standard weight of the background material to setup the fresnel effect
  49477. * of the mirror.
  49478. * 1 by default.
  49479. */
  49480. groundMirrorFresnelWeight: number;
  49481. /**
  49482. * Specifies the ground mirror Falloff distance.
  49483. * This can helps reducing the size of the reflection.
  49484. * 0 by Default.
  49485. */
  49486. groundMirrorFallOffDistance: number;
  49487. /**
  49488. * Specifies the ground mirror texture type.
  49489. * Unsigned Int by Default.
  49490. */
  49491. groundMirrorTextureType: number;
  49492. /**
  49493. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  49494. * the shown objects.
  49495. */
  49496. groundYBias: number;
  49497. /**
  49498. * Specifies whether or not to create a skybox.
  49499. * True by default.
  49500. */
  49501. createSkybox: boolean;
  49502. /**
  49503. * Specifies the skybox size.
  49504. * 20 by default.
  49505. */
  49506. skyboxSize: number;
  49507. /**
  49508. * The texture used on the skybox for the main color.
  49509. * Comes from the BabylonJS CDN by default.
  49510. *
  49511. * Remarks: Can be either a texture or a url.
  49512. */
  49513. skyboxTexture: string | BaseTexture;
  49514. /**
  49515. * The color mixed in the skybox texture by default.
  49516. * BabylonJS clearColor by default.
  49517. */
  49518. skyboxColor: Color3;
  49519. /**
  49520. * The background rotation around the Y axis of the scene.
  49521. * This helps aligning the key lights of your scene with the background.
  49522. * 0 by default.
  49523. */
  49524. backgroundYRotation: number;
  49525. /**
  49526. * Compute automatically the size of the elements to best fit with the scene.
  49527. */
  49528. sizeAuto: boolean;
  49529. /**
  49530. * Default position of the rootMesh if autoSize is not true.
  49531. */
  49532. rootPosition: Vector3;
  49533. /**
  49534. * Sets up the image processing in the scene.
  49535. * true by default.
  49536. */
  49537. setupImageProcessing: boolean;
  49538. /**
  49539. * The texture used as your environment texture in the scene.
  49540. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  49541. *
  49542. * Remarks: Can be either a texture or a url.
  49543. */
  49544. environmentTexture: string | BaseTexture;
  49545. /**
  49546. * The value of the exposure to apply to the scene.
  49547. * 0.6 by default if setupImageProcessing is true.
  49548. */
  49549. cameraExposure: number;
  49550. /**
  49551. * The value of the contrast to apply to the scene.
  49552. * 1.6 by default if setupImageProcessing is true.
  49553. */
  49554. cameraContrast: number;
  49555. /**
  49556. * Specifies whether or not tonemapping should be enabled in the scene.
  49557. * true by default if setupImageProcessing is true.
  49558. */
  49559. toneMappingEnabled: boolean;
  49560. }
  49561. /**
  49562. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  49563. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  49564. * It also helps with the default setup of your imageProcessing configuration.
  49565. */
  49566. export class EnvironmentHelper {
  49567. /**
  49568. * Default ground texture URL.
  49569. */
  49570. private static _groundTextureCDNUrl;
  49571. /**
  49572. * Default skybox texture URL.
  49573. */
  49574. private static _skyboxTextureCDNUrl;
  49575. /**
  49576. * Default environment texture URL.
  49577. */
  49578. private static _environmentTextureCDNUrl;
  49579. /**
  49580. * Creates the default options for the helper.
  49581. */
  49582. private static _getDefaultOptions;
  49583. private _rootMesh;
  49584. /**
  49585. * Gets the root mesh created by the helper.
  49586. */
  49587. get rootMesh(): Mesh;
  49588. private _skybox;
  49589. /**
  49590. * Gets the skybox created by the helper.
  49591. */
  49592. get skybox(): Nullable<Mesh>;
  49593. private _skyboxTexture;
  49594. /**
  49595. * Gets the skybox texture created by the helper.
  49596. */
  49597. get skyboxTexture(): Nullable<BaseTexture>;
  49598. private _skyboxMaterial;
  49599. /**
  49600. * Gets the skybox material created by the helper.
  49601. */
  49602. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  49603. private _ground;
  49604. /**
  49605. * Gets the ground mesh created by the helper.
  49606. */
  49607. get ground(): Nullable<Mesh>;
  49608. private _groundTexture;
  49609. /**
  49610. * Gets the ground texture created by the helper.
  49611. */
  49612. get groundTexture(): Nullable<BaseTexture>;
  49613. private _groundMirror;
  49614. /**
  49615. * Gets the ground mirror created by the helper.
  49616. */
  49617. get groundMirror(): Nullable<MirrorTexture>;
  49618. /**
  49619. * Gets the ground mirror render list to helps pushing the meshes
  49620. * you wish in the ground reflection.
  49621. */
  49622. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  49623. private _groundMaterial;
  49624. /**
  49625. * Gets the ground material created by the helper.
  49626. */
  49627. get groundMaterial(): Nullable<BackgroundMaterial>;
  49628. /**
  49629. * Stores the creation options.
  49630. */
  49631. private readonly _scene;
  49632. private _options;
  49633. /**
  49634. * This observable will be notified with any error during the creation of the environment,
  49635. * mainly texture creation errors.
  49636. */
  49637. onErrorObservable: Observable<{
  49638. message?: string;
  49639. exception?: any;
  49640. }>;
  49641. /**
  49642. * constructor
  49643. * @param options Defines the options we want to customize the helper
  49644. * @param scene The scene to add the material to
  49645. */
  49646. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  49647. /**
  49648. * Updates the background according to the new options
  49649. * @param options
  49650. */
  49651. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  49652. /**
  49653. * Sets the primary color of all the available elements.
  49654. * @param color the main color to affect to the ground and the background
  49655. */
  49656. setMainColor(color: Color3): void;
  49657. /**
  49658. * Setup the image processing according to the specified options.
  49659. */
  49660. private _setupImageProcessing;
  49661. /**
  49662. * Setup the environment texture according to the specified options.
  49663. */
  49664. private _setupEnvironmentTexture;
  49665. /**
  49666. * Setup the background according to the specified options.
  49667. */
  49668. private _setupBackground;
  49669. /**
  49670. * Get the scene sizes according to the setup.
  49671. */
  49672. private _getSceneSize;
  49673. /**
  49674. * Setup the ground according to the specified options.
  49675. */
  49676. private _setupGround;
  49677. /**
  49678. * Setup the ground material according to the specified options.
  49679. */
  49680. private _setupGroundMaterial;
  49681. /**
  49682. * Setup the ground diffuse texture according to the specified options.
  49683. */
  49684. private _setupGroundDiffuseTexture;
  49685. /**
  49686. * Setup the ground mirror texture according to the specified options.
  49687. */
  49688. private _setupGroundMirrorTexture;
  49689. /**
  49690. * Setup the ground to receive the mirror texture.
  49691. */
  49692. private _setupMirrorInGroundMaterial;
  49693. /**
  49694. * Setup the skybox according to the specified options.
  49695. */
  49696. private _setupSkybox;
  49697. /**
  49698. * Setup the skybox material according to the specified options.
  49699. */
  49700. private _setupSkyboxMaterial;
  49701. /**
  49702. * Setup the skybox reflection texture according to the specified options.
  49703. */
  49704. private _setupSkyboxReflectionTexture;
  49705. private _errorHandler;
  49706. /**
  49707. * Dispose all the elements created by the Helper.
  49708. */
  49709. dispose(): void;
  49710. }
  49711. }
  49712. declare module BABYLON {
  49713. /**
  49714. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  49715. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  49716. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  49717. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  49718. */
  49719. export class PhotoDome extends TransformNode {
  49720. /**
  49721. * Define the image as a Monoscopic panoramic 360 image.
  49722. */
  49723. static readonly MODE_MONOSCOPIC: number;
  49724. /**
  49725. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  49726. */
  49727. static readonly MODE_TOPBOTTOM: number;
  49728. /**
  49729. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  49730. */
  49731. static readonly MODE_SIDEBYSIDE: number;
  49732. private _useDirectMapping;
  49733. /**
  49734. * The texture being displayed on the sphere
  49735. */
  49736. protected _photoTexture: Texture;
  49737. /**
  49738. * Gets or sets the texture being displayed on the sphere
  49739. */
  49740. get photoTexture(): Texture;
  49741. set photoTexture(value: Texture);
  49742. /**
  49743. * Observable raised when an error occured while loading the 360 image
  49744. */
  49745. onLoadErrorObservable: Observable<string>;
  49746. /**
  49747. * The skybox material
  49748. */
  49749. protected _material: BackgroundMaterial;
  49750. /**
  49751. * The surface used for the skybox
  49752. */
  49753. protected _mesh: Mesh;
  49754. /**
  49755. * Gets the mesh used for the skybox.
  49756. */
  49757. get mesh(): Mesh;
  49758. /**
  49759. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  49760. * Also see the options.resolution property.
  49761. */
  49762. get fovMultiplier(): number;
  49763. set fovMultiplier(value: number);
  49764. private _imageMode;
  49765. /**
  49766. * Gets or set the current video mode for the video. It can be:
  49767. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  49768. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  49769. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  49770. */
  49771. get imageMode(): number;
  49772. set imageMode(value: number);
  49773. /**
  49774. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  49775. * @param name Element's name, child elements will append suffixes for their own names.
  49776. * @param urlsOfPhoto defines the url of the photo to display
  49777. * @param options defines an object containing optional or exposed sub element properties
  49778. * @param onError defines a callback called when an error occured while loading the texture
  49779. */
  49780. constructor(name: string, urlOfPhoto: string, options: {
  49781. resolution?: number;
  49782. size?: number;
  49783. useDirectMapping?: boolean;
  49784. faceForward?: boolean;
  49785. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  49786. private _onBeforeCameraRenderObserver;
  49787. private _changeImageMode;
  49788. /**
  49789. * Releases resources associated with this node.
  49790. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  49791. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  49792. */
  49793. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  49794. }
  49795. }
  49796. declare module BABYLON {
  49797. /**
  49798. * Class used to host RGBD texture specific utilities
  49799. */
  49800. export class RGBDTextureTools {
  49801. /**
  49802. * Expand the RGBD Texture from RGBD to Half Float if possible.
  49803. * @param texture the texture to expand.
  49804. */
  49805. static ExpandRGBDTexture(texture: Texture): void;
  49806. }
  49807. }
  49808. declare module BABYLON {
  49809. /**
  49810. * Class used to host texture specific utilities
  49811. */
  49812. export class BRDFTextureTools {
  49813. /**
  49814. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  49815. * @param scene defines the hosting scene
  49816. * @returns the environment BRDF texture
  49817. */
  49818. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  49819. private static _environmentBRDFBase64Texture;
  49820. }
  49821. }
  49822. declare module BABYLON {
  49823. /**
  49824. * @hidden
  49825. */
  49826. export interface IMaterialClearCoatDefines {
  49827. CLEARCOAT: boolean;
  49828. CLEARCOAT_DEFAULTIOR: boolean;
  49829. CLEARCOAT_TEXTURE: boolean;
  49830. CLEARCOAT_TEXTUREDIRECTUV: number;
  49831. CLEARCOAT_BUMP: boolean;
  49832. CLEARCOAT_BUMPDIRECTUV: number;
  49833. CLEARCOAT_TINT: boolean;
  49834. CLEARCOAT_TINT_TEXTURE: boolean;
  49835. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  49836. /** @hidden */
  49837. _areTexturesDirty: boolean;
  49838. }
  49839. /**
  49840. * Define the code related to the clear coat parameters of the pbr material.
  49841. */
  49842. export class PBRClearCoatConfiguration {
  49843. /**
  49844. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  49845. * The default fits with a polyurethane material.
  49846. */
  49847. private static readonly _DefaultIndexOfRefraction;
  49848. private _isEnabled;
  49849. /**
  49850. * Defines if the clear coat is enabled in the material.
  49851. */
  49852. isEnabled: boolean;
  49853. /**
  49854. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  49855. */
  49856. intensity: number;
  49857. /**
  49858. * Defines the clear coat layer roughness.
  49859. */
  49860. roughness: number;
  49861. private _indexOfRefraction;
  49862. /**
  49863. * Defines the index of refraction of the clear coat.
  49864. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  49865. * The default fits with a polyurethane material.
  49866. * Changing the default value is more performance intensive.
  49867. */
  49868. indexOfRefraction: number;
  49869. private _texture;
  49870. /**
  49871. * Stores the clear coat values in a texture.
  49872. */
  49873. texture: Nullable<BaseTexture>;
  49874. private _bumpTexture;
  49875. /**
  49876. * Define the clear coat specific bump texture.
  49877. */
  49878. bumpTexture: Nullable<BaseTexture>;
  49879. private _isTintEnabled;
  49880. /**
  49881. * Defines if the clear coat tint is enabled in the material.
  49882. */
  49883. isTintEnabled: boolean;
  49884. /**
  49885. * Defines the clear coat tint of the material.
  49886. * This is only use if tint is enabled
  49887. */
  49888. tintColor: Color3;
  49889. /**
  49890. * Defines the distance at which the tint color should be found in the
  49891. * clear coat media.
  49892. * This is only use if tint is enabled
  49893. */
  49894. tintColorAtDistance: number;
  49895. /**
  49896. * Defines the clear coat layer thickness.
  49897. * This is only use if tint is enabled
  49898. */
  49899. tintThickness: number;
  49900. private _tintTexture;
  49901. /**
  49902. * Stores the clear tint values in a texture.
  49903. * rgb is tint
  49904. * a is a thickness factor
  49905. */
  49906. tintTexture: Nullable<BaseTexture>;
  49907. /** @hidden */
  49908. private _internalMarkAllSubMeshesAsTexturesDirty;
  49909. /** @hidden */
  49910. _markAllSubMeshesAsTexturesDirty(): void;
  49911. /**
  49912. * Instantiate a new istance of clear coat configuration.
  49913. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  49914. */
  49915. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  49916. /**
  49917. * Gets wehter the submesh is ready to be used or not.
  49918. * @param defines the list of "defines" to update.
  49919. * @param scene defines the scene the material belongs to.
  49920. * @param engine defines the engine the material belongs to.
  49921. * @param disableBumpMap defines wether the material disables bump or not.
  49922. * @returns - boolean indicating that the submesh is ready or not.
  49923. */
  49924. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  49925. /**
  49926. * Checks to see if a texture is used in the material.
  49927. * @param defines the list of "defines" to update.
  49928. * @param scene defines the scene to the material belongs to.
  49929. */
  49930. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  49931. /**
  49932. * Binds the material data.
  49933. * @param uniformBuffer defines the Uniform buffer to fill in.
  49934. * @param scene defines the scene the material belongs to.
  49935. * @param engine defines the engine the material belongs to.
  49936. * @param disableBumpMap defines wether the material disables bump or not.
  49937. * @param isFrozen defines wether the material is frozen or not.
  49938. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  49939. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  49940. */
  49941. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  49942. /**
  49943. * Checks to see if a texture is used in the material.
  49944. * @param texture - Base texture to use.
  49945. * @returns - Boolean specifying if a texture is used in the material.
  49946. */
  49947. hasTexture(texture: BaseTexture): boolean;
  49948. /**
  49949. * Returns an array of the actively used textures.
  49950. * @param activeTextures Array of BaseTextures
  49951. */
  49952. getActiveTextures(activeTextures: BaseTexture[]): void;
  49953. /**
  49954. * Returns the animatable textures.
  49955. * @param animatables Array of animatable textures.
  49956. */
  49957. getAnimatables(animatables: IAnimatable[]): void;
  49958. /**
  49959. * Disposes the resources of the material.
  49960. * @param forceDisposeTextures - Forces the disposal of all textures.
  49961. */
  49962. dispose(forceDisposeTextures?: boolean): void;
  49963. /**
  49964. * Get the current class name of the texture useful for serialization or dynamic coding.
  49965. * @returns "PBRClearCoatConfiguration"
  49966. */
  49967. getClassName(): string;
  49968. /**
  49969. * Add fallbacks to the effect fallbacks list.
  49970. * @param defines defines the Base texture to use.
  49971. * @param fallbacks defines the current fallback list.
  49972. * @param currentRank defines the current fallback rank.
  49973. * @returns the new fallback rank.
  49974. */
  49975. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  49976. /**
  49977. * Add the required uniforms to the current list.
  49978. * @param uniforms defines the current uniform list.
  49979. */
  49980. static AddUniforms(uniforms: string[]): void;
  49981. /**
  49982. * Add the required samplers to the current list.
  49983. * @param samplers defines the current sampler list.
  49984. */
  49985. static AddSamplers(samplers: string[]): void;
  49986. /**
  49987. * Add the required uniforms to the current buffer.
  49988. * @param uniformBuffer defines the current uniform buffer.
  49989. */
  49990. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  49991. /**
  49992. * Makes a duplicate of the current configuration into another one.
  49993. * @param clearCoatConfiguration define the config where to copy the info
  49994. */
  49995. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  49996. /**
  49997. * Serializes this clear coat configuration.
  49998. * @returns - An object with the serialized config.
  49999. */
  50000. serialize(): any;
  50001. /**
  50002. * Parses a anisotropy Configuration from a serialized object.
  50003. * @param source - Serialized object.
  50004. * @param scene Defines the scene we are parsing for
  50005. * @param rootUrl Defines the rootUrl to load from
  50006. */
  50007. parse(source: any, scene: Scene, rootUrl: string): void;
  50008. }
  50009. }
  50010. declare module BABYLON {
  50011. /**
  50012. * @hidden
  50013. */
  50014. export interface IMaterialAnisotropicDefines {
  50015. ANISOTROPIC: boolean;
  50016. ANISOTROPIC_TEXTURE: boolean;
  50017. ANISOTROPIC_TEXTUREDIRECTUV: number;
  50018. MAINUV1: boolean;
  50019. _areTexturesDirty: boolean;
  50020. _needUVs: boolean;
  50021. }
  50022. /**
  50023. * Define the code related to the anisotropic parameters of the pbr material.
  50024. */
  50025. export class PBRAnisotropicConfiguration {
  50026. private _isEnabled;
  50027. /**
  50028. * Defines if the anisotropy is enabled in the material.
  50029. */
  50030. isEnabled: boolean;
  50031. /**
  50032. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  50033. */
  50034. intensity: number;
  50035. /**
  50036. * Defines if the effect is along the tangents, bitangents or in between.
  50037. * By default, the effect is "strectching" the highlights along the tangents.
  50038. */
  50039. direction: Vector2;
  50040. private _texture;
  50041. /**
  50042. * Stores the anisotropy values in a texture.
  50043. * rg is direction (like normal from -1 to 1)
  50044. * b is a intensity
  50045. */
  50046. texture: Nullable<BaseTexture>;
  50047. /** @hidden */
  50048. private _internalMarkAllSubMeshesAsTexturesDirty;
  50049. /** @hidden */
  50050. _markAllSubMeshesAsTexturesDirty(): void;
  50051. /**
  50052. * Instantiate a new istance of anisotropy configuration.
  50053. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  50054. */
  50055. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  50056. /**
  50057. * Specifies that the submesh is ready to be used.
  50058. * @param defines the list of "defines" to update.
  50059. * @param scene defines the scene the material belongs to.
  50060. * @returns - boolean indicating that the submesh is ready or not.
  50061. */
  50062. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  50063. /**
  50064. * Checks to see if a texture is used in the material.
  50065. * @param defines the list of "defines" to update.
  50066. * @param mesh the mesh we are preparing the defines for.
  50067. * @param scene defines the scene the material belongs to.
  50068. */
  50069. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  50070. /**
  50071. * Binds the material data.
  50072. * @param uniformBuffer defines the Uniform buffer to fill in.
  50073. * @param scene defines the scene the material belongs to.
  50074. * @param isFrozen defines wether the material is frozen or not.
  50075. */
  50076. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  50077. /**
  50078. * Checks to see if a texture is used in the material.
  50079. * @param texture - Base texture to use.
  50080. * @returns - Boolean specifying if a texture is used in the material.
  50081. */
  50082. hasTexture(texture: BaseTexture): boolean;
  50083. /**
  50084. * Returns an array of the actively used textures.
  50085. * @param activeTextures Array of BaseTextures
  50086. */
  50087. getActiveTextures(activeTextures: BaseTexture[]): void;
  50088. /**
  50089. * Returns the animatable textures.
  50090. * @param animatables Array of animatable textures.
  50091. */
  50092. getAnimatables(animatables: IAnimatable[]): void;
  50093. /**
  50094. * Disposes the resources of the material.
  50095. * @param forceDisposeTextures - Forces the disposal of all textures.
  50096. */
  50097. dispose(forceDisposeTextures?: boolean): void;
  50098. /**
  50099. * Get the current class name of the texture useful for serialization or dynamic coding.
  50100. * @returns "PBRAnisotropicConfiguration"
  50101. */
  50102. getClassName(): string;
  50103. /**
  50104. * Add fallbacks to the effect fallbacks list.
  50105. * @param defines defines the Base texture to use.
  50106. * @param fallbacks defines the current fallback list.
  50107. * @param currentRank defines the current fallback rank.
  50108. * @returns the new fallback rank.
  50109. */
  50110. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  50111. /**
  50112. * Add the required uniforms to the current list.
  50113. * @param uniforms defines the current uniform list.
  50114. */
  50115. static AddUniforms(uniforms: string[]): void;
  50116. /**
  50117. * Add the required uniforms to the current buffer.
  50118. * @param uniformBuffer defines the current uniform buffer.
  50119. */
  50120. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  50121. /**
  50122. * Add the required samplers to the current list.
  50123. * @param samplers defines the current sampler list.
  50124. */
  50125. static AddSamplers(samplers: string[]): void;
  50126. /**
  50127. * Makes a duplicate of the current configuration into another one.
  50128. * @param anisotropicConfiguration define the config where to copy the info
  50129. */
  50130. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  50131. /**
  50132. * Serializes this anisotropy configuration.
  50133. * @returns - An object with the serialized config.
  50134. */
  50135. serialize(): any;
  50136. /**
  50137. * Parses a anisotropy Configuration from a serialized object.
  50138. * @param source - Serialized object.
  50139. * @param scene Defines the scene we are parsing for
  50140. * @param rootUrl Defines the rootUrl to load from
  50141. */
  50142. parse(source: any, scene: Scene, rootUrl: string): void;
  50143. }
  50144. }
  50145. declare module BABYLON {
  50146. /**
  50147. * @hidden
  50148. */
  50149. export interface IMaterialBRDFDefines {
  50150. BRDF_V_HEIGHT_CORRELATED: boolean;
  50151. MS_BRDF_ENERGY_CONSERVATION: boolean;
  50152. SPHERICAL_HARMONICS: boolean;
  50153. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  50154. /** @hidden */
  50155. _areMiscDirty: boolean;
  50156. }
  50157. /**
  50158. * Define the code related to the BRDF parameters of the pbr material.
  50159. */
  50160. export class PBRBRDFConfiguration {
  50161. /**
  50162. * Default value used for the energy conservation.
  50163. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  50164. */
  50165. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  50166. /**
  50167. * Default value used for the Smith Visibility Height Correlated mode.
  50168. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  50169. */
  50170. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  50171. /**
  50172. * Default value used for the IBL diffuse part.
  50173. * This can help switching back to the polynomials mode globally which is a tiny bit
  50174. * less GPU intensive at the drawback of a lower quality.
  50175. */
  50176. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  50177. /**
  50178. * Default value used for activating energy conservation for the specular workflow.
  50179. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  50180. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  50181. */
  50182. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  50183. private _useEnergyConservation;
  50184. /**
  50185. * Defines if the material uses energy conservation.
  50186. */
  50187. useEnergyConservation: boolean;
  50188. private _useSmithVisibilityHeightCorrelated;
  50189. /**
  50190. * LEGACY Mode set to false
  50191. * Defines if the material uses height smith correlated visibility term.
  50192. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  50193. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  50194. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  50195. * Not relying on height correlated will also disable energy conservation.
  50196. */
  50197. useSmithVisibilityHeightCorrelated: boolean;
  50198. private _useSphericalHarmonics;
  50199. /**
  50200. * LEGACY Mode set to false
  50201. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  50202. * diffuse part of the IBL.
  50203. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  50204. * to the ground truth.
  50205. */
  50206. useSphericalHarmonics: boolean;
  50207. private _useSpecularGlossinessInputEnergyConservation;
  50208. /**
  50209. * Defines if the material uses energy conservation, when the specular workflow is active.
  50210. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  50211. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  50212. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  50213. */
  50214. useSpecularGlossinessInputEnergyConservation: boolean;
  50215. /** @hidden */
  50216. private _internalMarkAllSubMeshesAsMiscDirty;
  50217. /** @hidden */
  50218. _markAllSubMeshesAsMiscDirty(): void;
  50219. /**
  50220. * Instantiate a new istance of clear coat configuration.
  50221. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  50222. */
  50223. constructor(markAllSubMeshesAsMiscDirty: () => void);
  50224. /**
  50225. * Checks to see if a texture is used in the material.
  50226. * @param defines the list of "defines" to update.
  50227. */
  50228. prepareDefines(defines: IMaterialBRDFDefines): void;
  50229. /**
  50230. * Get the current class name of the texture useful for serialization or dynamic coding.
  50231. * @returns "PBRClearCoatConfiguration"
  50232. */
  50233. getClassName(): string;
  50234. /**
  50235. * Makes a duplicate of the current configuration into another one.
  50236. * @param brdfConfiguration define the config where to copy the info
  50237. */
  50238. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  50239. /**
  50240. * Serializes this BRDF configuration.
  50241. * @returns - An object with the serialized config.
  50242. */
  50243. serialize(): any;
  50244. /**
  50245. * Parses a anisotropy Configuration from a serialized object.
  50246. * @param source - Serialized object.
  50247. * @param scene Defines the scene we are parsing for
  50248. * @param rootUrl Defines the rootUrl to load from
  50249. */
  50250. parse(source: any, scene: Scene, rootUrl: string): void;
  50251. }
  50252. }
  50253. declare module BABYLON {
  50254. /**
  50255. * @hidden
  50256. */
  50257. export interface IMaterialSheenDefines {
  50258. SHEEN: boolean;
  50259. SHEEN_TEXTURE: boolean;
  50260. SHEEN_TEXTUREDIRECTUV: number;
  50261. SHEEN_LINKWITHALBEDO: boolean;
  50262. /** @hidden */
  50263. _areTexturesDirty: boolean;
  50264. }
  50265. /**
  50266. * Define the code related to the Sheen parameters of the pbr material.
  50267. */
  50268. export class PBRSheenConfiguration {
  50269. private _isEnabled;
  50270. /**
  50271. * Defines if the material uses sheen.
  50272. */
  50273. isEnabled: boolean;
  50274. private _linkSheenWithAlbedo;
  50275. /**
  50276. * Defines if the sheen is linked to the sheen color.
  50277. */
  50278. linkSheenWithAlbedo: boolean;
  50279. /**
  50280. * Defines the sheen intensity.
  50281. */
  50282. intensity: number;
  50283. /**
  50284. * Defines the sheen color.
  50285. */
  50286. color: Color3;
  50287. private _texture;
  50288. /**
  50289. * Stores the sheen tint values in a texture.
  50290. * rgb is tint
  50291. * a is a intensity
  50292. */
  50293. texture: Nullable<BaseTexture>;
  50294. /** @hidden */
  50295. private _internalMarkAllSubMeshesAsTexturesDirty;
  50296. /** @hidden */
  50297. _markAllSubMeshesAsTexturesDirty(): void;
  50298. /**
  50299. * Instantiate a new istance of clear coat configuration.
  50300. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  50301. */
  50302. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  50303. /**
  50304. * Specifies that the submesh is ready to be used.
  50305. * @param defines the list of "defines" to update.
  50306. * @param scene defines the scene the material belongs to.
  50307. * @returns - boolean indicating that the submesh is ready or not.
  50308. */
  50309. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  50310. /**
  50311. * Checks to see if a texture is used in the material.
  50312. * @param defines the list of "defines" to update.
  50313. * @param scene defines the scene the material belongs to.
  50314. */
  50315. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  50316. /**
  50317. * Binds the material data.
  50318. * @param uniformBuffer defines the Uniform buffer to fill in.
  50319. * @param scene defines the scene the material belongs to.
  50320. * @param isFrozen defines wether the material is frozen or not.
  50321. */
  50322. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  50323. /**
  50324. * Checks to see if a texture is used in the material.
  50325. * @param texture - Base texture to use.
  50326. * @returns - Boolean specifying if a texture is used in the material.
  50327. */
  50328. hasTexture(texture: BaseTexture): boolean;
  50329. /**
  50330. * Returns an array of the actively used textures.
  50331. * @param activeTextures Array of BaseTextures
  50332. */
  50333. getActiveTextures(activeTextures: BaseTexture[]): void;
  50334. /**
  50335. * Returns the animatable textures.
  50336. * @param animatables Array of animatable textures.
  50337. */
  50338. getAnimatables(animatables: IAnimatable[]): void;
  50339. /**
  50340. * Disposes the resources of the material.
  50341. * @param forceDisposeTextures - Forces the disposal of all textures.
  50342. */
  50343. dispose(forceDisposeTextures?: boolean): void;
  50344. /**
  50345. * Get the current class name of the texture useful for serialization or dynamic coding.
  50346. * @returns "PBRSheenConfiguration"
  50347. */
  50348. getClassName(): string;
  50349. /**
  50350. * Add fallbacks to the effect fallbacks list.
  50351. * @param defines defines the Base texture to use.
  50352. * @param fallbacks defines the current fallback list.
  50353. * @param currentRank defines the current fallback rank.
  50354. * @returns the new fallback rank.
  50355. */
  50356. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  50357. /**
  50358. * Add the required uniforms to the current list.
  50359. * @param uniforms defines the current uniform list.
  50360. */
  50361. static AddUniforms(uniforms: string[]): void;
  50362. /**
  50363. * Add the required uniforms to the current buffer.
  50364. * @param uniformBuffer defines the current uniform buffer.
  50365. */
  50366. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  50367. /**
  50368. * Add the required samplers to the current list.
  50369. * @param samplers defines the current sampler list.
  50370. */
  50371. static AddSamplers(samplers: string[]): void;
  50372. /**
  50373. * Makes a duplicate of the current configuration into another one.
  50374. * @param sheenConfiguration define the config where to copy the info
  50375. */
  50376. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  50377. /**
  50378. * Serializes this BRDF configuration.
  50379. * @returns - An object with the serialized config.
  50380. */
  50381. serialize(): any;
  50382. /**
  50383. * Parses a anisotropy Configuration from a serialized object.
  50384. * @param source - Serialized object.
  50385. * @param scene Defines the scene we are parsing for
  50386. * @param rootUrl Defines the rootUrl to load from
  50387. */
  50388. parse(source: any, scene: Scene, rootUrl: string): void;
  50389. }
  50390. }
  50391. declare module BABYLON {
  50392. /**
  50393. * @hidden
  50394. */
  50395. export interface IMaterialSubSurfaceDefines {
  50396. SUBSURFACE: boolean;
  50397. SS_REFRACTION: boolean;
  50398. SS_TRANSLUCENCY: boolean;
  50399. SS_SCATERRING: boolean;
  50400. SS_THICKNESSANDMASK_TEXTURE: boolean;
  50401. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  50402. SS_REFRACTIONMAP_3D: boolean;
  50403. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  50404. SS_LODINREFRACTIONALPHA: boolean;
  50405. SS_GAMMAREFRACTION: boolean;
  50406. SS_RGBDREFRACTION: boolean;
  50407. SS_LINEARSPECULARREFRACTION: boolean;
  50408. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  50409. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  50410. /** @hidden */
  50411. _areTexturesDirty: boolean;
  50412. }
  50413. /**
  50414. * Define the code related to the sub surface parameters of the pbr material.
  50415. */
  50416. export class PBRSubSurfaceConfiguration {
  50417. private _isRefractionEnabled;
  50418. /**
  50419. * Defines if the refraction is enabled in the material.
  50420. */
  50421. isRefractionEnabled: boolean;
  50422. private _isTranslucencyEnabled;
  50423. /**
  50424. * Defines if the translucency is enabled in the material.
  50425. */
  50426. isTranslucencyEnabled: boolean;
  50427. private _isScatteringEnabled;
  50428. /**
  50429. * Defines the refraction intensity of the material.
  50430. * The refraction when enabled replaces the Diffuse part of the material.
  50431. * The intensity helps transitionning between diffuse and refraction.
  50432. */
  50433. refractionIntensity: number;
  50434. /**
  50435. * Defines the translucency intensity of the material.
  50436. * When translucency has been enabled, this defines how much of the "translucency"
  50437. * is addded to the diffuse part of the material.
  50438. */
  50439. translucencyIntensity: number;
  50440. /**
  50441. * Defines the scattering intensity of the material.
  50442. * When scattering has been enabled, this defines how much of the "scattered light"
  50443. * is addded to the diffuse part of the material.
  50444. */
  50445. scatteringIntensity: number;
  50446. private _thicknessTexture;
  50447. /**
  50448. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  50449. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  50450. * 0 would mean minimumThickness
  50451. * 1 would mean maximumThickness
  50452. * The other channels might be use as a mask to vary the different effects intensity.
  50453. */
  50454. thicknessTexture: Nullable<BaseTexture>;
  50455. private _refractionTexture;
  50456. /**
  50457. * Defines the texture to use for refraction.
  50458. */
  50459. refractionTexture: Nullable<BaseTexture>;
  50460. private _indexOfRefraction;
  50461. /**
  50462. * Defines the index of refraction used in the material.
  50463. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  50464. */
  50465. indexOfRefraction: number;
  50466. private _invertRefractionY;
  50467. /**
  50468. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  50469. */
  50470. invertRefractionY: boolean;
  50471. private _linkRefractionWithTransparency;
  50472. /**
  50473. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  50474. * Materials half opaque for instance using refraction could benefit from this control.
  50475. */
  50476. linkRefractionWithTransparency: boolean;
  50477. /**
  50478. * Defines the minimum thickness stored in the thickness map.
  50479. * If no thickness map is defined, this value will be used to simulate thickness.
  50480. */
  50481. minimumThickness: number;
  50482. /**
  50483. * Defines the maximum thickness stored in the thickness map.
  50484. */
  50485. maximumThickness: number;
  50486. /**
  50487. * Defines the volume tint of the material.
  50488. * This is used for both translucency and scattering.
  50489. */
  50490. tintColor: Color3;
  50491. /**
  50492. * Defines the distance at which the tint color should be found in the media.
  50493. * This is used for refraction only.
  50494. */
  50495. tintColorAtDistance: number;
  50496. /**
  50497. * Defines how far each channel transmit through the media.
  50498. * It is defined as a color to simplify it selection.
  50499. */
  50500. diffusionDistance: Color3;
  50501. private _useMaskFromThicknessTexture;
  50502. /**
  50503. * Stores the intensity of the different subsurface effects in the thickness texture.
  50504. * * the green channel is the translucency intensity.
  50505. * * the blue channel is the scattering intensity.
  50506. * * the alpha channel is the refraction intensity.
  50507. */
  50508. useMaskFromThicknessTexture: boolean;
  50509. /** @hidden */
  50510. private _internalMarkAllSubMeshesAsTexturesDirty;
  50511. /** @hidden */
  50512. _markAllSubMeshesAsTexturesDirty(): void;
  50513. /**
  50514. * Instantiate a new istance of sub surface configuration.
  50515. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  50516. */
  50517. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  50518. /**
  50519. * Gets wehter the submesh is ready to be used or not.
  50520. * @param defines the list of "defines" to update.
  50521. * @param scene defines the scene the material belongs to.
  50522. * @returns - boolean indicating that the submesh is ready or not.
  50523. */
  50524. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  50525. /**
  50526. * Checks to see if a texture is used in the material.
  50527. * @param defines the list of "defines" to update.
  50528. * @param scene defines the scene to the material belongs to.
  50529. */
  50530. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  50531. /**
  50532. * Binds the material data.
  50533. * @param uniformBuffer defines the Uniform buffer to fill in.
  50534. * @param scene defines the scene the material belongs to.
  50535. * @param engine defines the engine the material belongs to.
  50536. * @param isFrozen defines wether the material is frozen or not.
  50537. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  50538. */
  50539. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  50540. /**
  50541. * Unbinds the material from the mesh.
  50542. * @param activeEffect defines the effect that should be unbound from.
  50543. * @returns true if unbound, otherwise false
  50544. */
  50545. unbind(activeEffect: Effect): boolean;
  50546. /**
  50547. * Returns the texture used for refraction or null if none is used.
  50548. * @param scene defines the scene the material belongs to.
  50549. * @returns - Refraction texture if present. If no refraction texture and refraction
  50550. * is linked with transparency, returns environment texture. Otherwise, returns null.
  50551. */
  50552. private _getRefractionTexture;
  50553. /**
  50554. * Returns true if alpha blending should be disabled.
  50555. */
  50556. get disableAlphaBlending(): boolean;
  50557. /**
  50558. * Fills the list of render target textures.
  50559. * @param renderTargets the list of render targets to update
  50560. */
  50561. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  50562. /**
  50563. * Checks to see if a texture is used in the material.
  50564. * @param texture - Base texture to use.
  50565. * @returns - Boolean specifying if a texture is used in the material.
  50566. */
  50567. hasTexture(texture: BaseTexture): boolean;
  50568. /**
  50569. * Gets a boolean indicating that current material needs to register RTT
  50570. * @returns true if this uses a render target otherwise false.
  50571. */
  50572. hasRenderTargetTextures(): boolean;
  50573. /**
  50574. * Returns an array of the actively used textures.
  50575. * @param activeTextures Array of BaseTextures
  50576. */
  50577. getActiveTextures(activeTextures: BaseTexture[]): void;
  50578. /**
  50579. * Returns the animatable textures.
  50580. * @param animatables Array of animatable textures.
  50581. */
  50582. getAnimatables(animatables: IAnimatable[]): void;
  50583. /**
  50584. * Disposes the resources of the material.
  50585. * @param forceDisposeTextures - Forces the disposal of all textures.
  50586. */
  50587. dispose(forceDisposeTextures?: boolean): void;
  50588. /**
  50589. * Get the current class name of the texture useful for serialization or dynamic coding.
  50590. * @returns "PBRSubSurfaceConfiguration"
  50591. */
  50592. getClassName(): string;
  50593. /**
  50594. * Add fallbacks to the effect fallbacks list.
  50595. * @param defines defines the Base texture to use.
  50596. * @param fallbacks defines the current fallback list.
  50597. * @param currentRank defines the current fallback rank.
  50598. * @returns the new fallback rank.
  50599. */
  50600. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  50601. /**
  50602. * Add the required uniforms to the current list.
  50603. * @param uniforms defines the current uniform list.
  50604. */
  50605. static AddUniforms(uniforms: string[]): void;
  50606. /**
  50607. * Add the required samplers to the current list.
  50608. * @param samplers defines the current sampler list.
  50609. */
  50610. static AddSamplers(samplers: string[]): void;
  50611. /**
  50612. * Add the required uniforms to the current buffer.
  50613. * @param uniformBuffer defines the current uniform buffer.
  50614. */
  50615. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  50616. /**
  50617. * Makes a duplicate of the current configuration into another one.
  50618. * @param configuration define the config where to copy the info
  50619. */
  50620. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  50621. /**
  50622. * Serializes this Sub Surface configuration.
  50623. * @returns - An object with the serialized config.
  50624. */
  50625. serialize(): any;
  50626. /**
  50627. * Parses a anisotropy Configuration from a serialized object.
  50628. * @param source - Serialized object.
  50629. * @param scene Defines the scene we are parsing for
  50630. * @param rootUrl Defines the rootUrl to load from
  50631. */
  50632. parse(source: any, scene: Scene, rootUrl: string): void;
  50633. }
  50634. }
  50635. declare module BABYLON {
  50636. /** @hidden */
  50637. export var pbrFragmentDeclaration: {
  50638. name: string;
  50639. shader: string;
  50640. };
  50641. }
  50642. declare module BABYLON {
  50643. /** @hidden */
  50644. export var pbrUboDeclaration: {
  50645. name: string;
  50646. shader: string;
  50647. };
  50648. }
  50649. declare module BABYLON {
  50650. /** @hidden */
  50651. export var pbrFragmentExtraDeclaration: {
  50652. name: string;
  50653. shader: string;
  50654. };
  50655. }
  50656. declare module BABYLON {
  50657. /** @hidden */
  50658. export var pbrFragmentSamplersDeclaration: {
  50659. name: string;
  50660. shader: string;
  50661. };
  50662. }
  50663. declare module BABYLON {
  50664. /** @hidden */
  50665. export var pbrHelperFunctions: {
  50666. name: string;
  50667. shader: string;
  50668. };
  50669. }
  50670. declare module BABYLON {
  50671. /** @hidden */
  50672. export var harmonicsFunctions: {
  50673. name: string;
  50674. shader: string;
  50675. };
  50676. }
  50677. declare module BABYLON {
  50678. /** @hidden */
  50679. export var pbrDirectLightingSetupFunctions: {
  50680. name: string;
  50681. shader: string;
  50682. };
  50683. }
  50684. declare module BABYLON {
  50685. /** @hidden */
  50686. export var pbrDirectLightingFalloffFunctions: {
  50687. name: string;
  50688. shader: string;
  50689. };
  50690. }
  50691. declare module BABYLON {
  50692. /** @hidden */
  50693. export var pbrBRDFFunctions: {
  50694. name: string;
  50695. shader: string;
  50696. };
  50697. }
  50698. declare module BABYLON {
  50699. /** @hidden */
  50700. export var pbrDirectLightingFunctions: {
  50701. name: string;
  50702. shader: string;
  50703. };
  50704. }
  50705. declare module BABYLON {
  50706. /** @hidden */
  50707. export var pbrIBLFunctions: {
  50708. name: string;
  50709. shader: string;
  50710. };
  50711. }
  50712. declare module BABYLON {
  50713. /** @hidden */
  50714. export var pbrDebug: {
  50715. name: string;
  50716. shader: string;
  50717. };
  50718. }
  50719. declare module BABYLON {
  50720. /** @hidden */
  50721. export var pbrPixelShader: {
  50722. name: string;
  50723. shader: string;
  50724. };
  50725. }
  50726. declare module BABYLON {
  50727. /** @hidden */
  50728. export var pbrVertexDeclaration: {
  50729. name: string;
  50730. shader: string;
  50731. };
  50732. }
  50733. declare module BABYLON {
  50734. /** @hidden */
  50735. export var pbrVertexShader: {
  50736. name: string;
  50737. shader: string;
  50738. };
  50739. }
  50740. declare module BABYLON {
  50741. /**
  50742. * Manages the defines for the PBR Material.
  50743. * @hidden
  50744. */
  50745. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  50746. PBR: boolean;
  50747. MAINUV1: boolean;
  50748. MAINUV2: boolean;
  50749. UV1: boolean;
  50750. UV2: boolean;
  50751. ALBEDO: boolean;
  50752. ALBEDODIRECTUV: number;
  50753. VERTEXCOLOR: boolean;
  50754. AMBIENT: boolean;
  50755. AMBIENTDIRECTUV: number;
  50756. AMBIENTINGRAYSCALE: boolean;
  50757. OPACITY: boolean;
  50758. VERTEXALPHA: boolean;
  50759. OPACITYDIRECTUV: number;
  50760. OPACITYRGB: boolean;
  50761. ALPHATEST: boolean;
  50762. DEPTHPREPASS: boolean;
  50763. ALPHABLEND: boolean;
  50764. ALPHAFROMALBEDO: boolean;
  50765. ALPHATESTVALUE: string;
  50766. SPECULAROVERALPHA: boolean;
  50767. RADIANCEOVERALPHA: boolean;
  50768. ALPHAFRESNEL: boolean;
  50769. LINEARALPHAFRESNEL: boolean;
  50770. PREMULTIPLYALPHA: boolean;
  50771. EMISSIVE: boolean;
  50772. EMISSIVEDIRECTUV: number;
  50773. REFLECTIVITY: boolean;
  50774. REFLECTIVITYDIRECTUV: number;
  50775. SPECULARTERM: boolean;
  50776. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  50777. MICROSURFACEAUTOMATIC: boolean;
  50778. LODBASEDMICROSFURACE: boolean;
  50779. MICROSURFACEMAP: boolean;
  50780. MICROSURFACEMAPDIRECTUV: number;
  50781. METALLICWORKFLOW: boolean;
  50782. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  50783. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  50784. METALLNESSSTOREINMETALMAPBLUE: boolean;
  50785. AOSTOREINMETALMAPRED: boolean;
  50786. METALLICF0FACTORFROMMETALLICMAP: boolean;
  50787. ENVIRONMENTBRDF: boolean;
  50788. ENVIRONMENTBRDF_RGBD: boolean;
  50789. NORMAL: boolean;
  50790. TANGENT: boolean;
  50791. BUMP: boolean;
  50792. BUMPDIRECTUV: number;
  50793. OBJECTSPACE_NORMALMAP: boolean;
  50794. PARALLAX: boolean;
  50795. PARALLAXOCCLUSION: boolean;
  50796. NORMALXYSCALE: boolean;
  50797. LIGHTMAP: boolean;
  50798. LIGHTMAPDIRECTUV: number;
  50799. USELIGHTMAPASSHADOWMAP: boolean;
  50800. GAMMALIGHTMAP: boolean;
  50801. RGBDLIGHTMAP: boolean;
  50802. REFLECTION: boolean;
  50803. REFLECTIONMAP_3D: boolean;
  50804. REFLECTIONMAP_SPHERICAL: boolean;
  50805. REFLECTIONMAP_PLANAR: boolean;
  50806. REFLECTIONMAP_CUBIC: boolean;
  50807. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  50808. REFLECTIONMAP_PROJECTION: boolean;
  50809. REFLECTIONMAP_SKYBOX: boolean;
  50810. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  50811. REFLECTIONMAP_EXPLICIT: boolean;
  50812. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  50813. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  50814. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  50815. INVERTCUBICMAP: boolean;
  50816. USESPHERICALFROMREFLECTIONMAP: boolean;
  50817. USEIRRADIANCEMAP: boolean;
  50818. SPHERICAL_HARMONICS: boolean;
  50819. USESPHERICALINVERTEX: boolean;
  50820. REFLECTIONMAP_OPPOSITEZ: boolean;
  50821. LODINREFLECTIONALPHA: boolean;
  50822. GAMMAREFLECTION: boolean;
  50823. RGBDREFLECTION: boolean;
  50824. LINEARSPECULARREFLECTION: boolean;
  50825. RADIANCEOCCLUSION: boolean;
  50826. HORIZONOCCLUSION: boolean;
  50827. INSTANCES: boolean;
  50828. NUM_BONE_INFLUENCERS: number;
  50829. BonesPerMesh: number;
  50830. BONETEXTURE: boolean;
  50831. NONUNIFORMSCALING: boolean;
  50832. MORPHTARGETS: boolean;
  50833. MORPHTARGETS_NORMAL: boolean;
  50834. MORPHTARGETS_TANGENT: boolean;
  50835. MORPHTARGETS_UV: boolean;
  50836. NUM_MORPH_INFLUENCERS: number;
  50837. IMAGEPROCESSING: boolean;
  50838. VIGNETTE: boolean;
  50839. VIGNETTEBLENDMODEMULTIPLY: boolean;
  50840. VIGNETTEBLENDMODEOPAQUE: boolean;
  50841. TONEMAPPING: boolean;
  50842. TONEMAPPING_ACES: boolean;
  50843. CONTRAST: boolean;
  50844. COLORCURVES: boolean;
  50845. COLORGRADING: boolean;
  50846. COLORGRADING3D: boolean;
  50847. SAMPLER3DGREENDEPTH: boolean;
  50848. SAMPLER3DBGRMAP: boolean;
  50849. IMAGEPROCESSINGPOSTPROCESS: boolean;
  50850. EXPOSURE: boolean;
  50851. MULTIVIEW: boolean;
  50852. USEPHYSICALLIGHTFALLOFF: boolean;
  50853. USEGLTFLIGHTFALLOFF: boolean;
  50854. TWOSIDEDLIGHTING: boolean;
  50855. SHADOWFLOAT: boolean;
  50856. CLIPPLANE: boolean;
  50857. CLIPPLANE2: boolean;
  50858. CLIPPLANE3: boolean;
  50859. CLIPPLANE4: boolean;
  50860. CLIPPLANE5: boolean;
  50861. CLIPPLANE6: boolean;
  50862. POINTSIZE: boolean;
  50863. FOG: boolean;
  50864. LOGARITHMICDEPTH: boolean;
  50865. FORCENORMALFORWARD: boolean;
  50866. SPECULARAA: boolean;
  50867. CLEARCOAT: boolean;
  50868. CLEARCOAT_DEFAULTIOR: boolean;
  50869. CLEARCOAT_TEXTURE: boolean;
  50870. CLEARCOAT_TEXTUREDIRECTUV: number;
  50871. CLEARCOAT_BUMP: boolean;
  50872. CLEARCOAT_BUMPDIRECTUV: number;
  50873. CLEARCOAT_TINT: boolean;
  50874. CLEARCOAT_TINT_TEXTURE: boolean;
  50875. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  50876. ANISOTROPIC: boolean;
  50877. ANISOTROPIC_TEXTURE: boolean;
  50878. ANISOTROPIC_TEXTUREDIRECTUV: number;
  50879. BRDF_V_HEIGHT_CORRELATED: boolean;
  50880. MS_BRDF_ENERGY_CONSERVATION: boolean;
  50881. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  50882. SHEEN: boolean;
  50883. SHEEN_TEXTURE: boolean;
  50884. SHEEN_TEXTUREDIRECTUV: number;
  50885. SHEEN_LINKWITHALBEDO: boolean;
  50886. SUBSURFACE: boolean;
  50887. SS_REFRACTION: boolean;
  50888. SS_TRANSLUCENCY: boolean;
  50889. SS_SCATERRING: boolean;
  50890. SS_THICKNESSANDMASK_TEXTURE: boolean;
  50891. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  50892. SS_REFRACTIONMAP_3D: boolean;
  50893. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  50894. SS_LODINREFRACTIONALPHA: boolean;
  50895. SS_GAMMAREFRACTION: boolean;
  50896. SS_RGBDREFRACTION: boolean;
  50897. SS_LINEARSPECULARREFRACTION: boolean;
  50898. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  50899. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  50900. UNLIT: boolean;
  50901. DEBUGMODE: number;
  50902. /**
  50903. * Initializes the PBR Material defines.
  50904. */
  50905. constructor();
  50906. /**
  50907. * Resets the PBR Material defines.
  50908. */
  50909. reset(): void;
  50910. }
  50911. /**
  50912. * The Physically based material base class of BJS.
  50913. *
  50914. * This offers the main features of a standard PBR material.
  50915. * For more information, please refer to the documentation :
  50916. * https://doc.babylonjs.com/how_to/physically_based_rendering
  50917. */
  50918. export abstract class PBRBaseMaterial extends PushMaterial {
  50919. /**
  50920. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  50921. */
  50922. static readonly PBRMATERIAL_OPAQUE: number;
  50923. /**
  50924. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  50925. */
  50926. static readonly PBRMATERIAL_ALPHATEST: number;
  50927. /**
  50928. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  50929. */
  50930. static readonly PBRMATERIAL_ALPHABLEND: number;
  50931. /**
  50932. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  50933. * They are also discarded below the alpha cutoff threshold to improve performances.
  50934. */
  50935. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  50936. /**
  50937. * Defines the default value of how much AO map is occluding the analytical lights
  50938. * (point spot...).
  50939. */
  50940. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  50941. /**
  50942. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  50943. */
  50944. static readonly LIGHTFALLOFF_PHYSICAL: number;
  50945. /**
  50946. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  50947. * to enhance interoperability with other engines.
  50948. */
  50949. static readonly LIGHTFALLOFF_GLTF: number;
  50950. /**
  50951. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  50952. * to enhance interoperability with other materials.
  50953. */
  50954. static readonly LIGHTFALLOFF_STANDARD: number;
  50955. /**
  50956. * Intensity of the direct lights e.g. the four lights available in your scene.
  50957. * This impacts both the direct diffuse and specular highlights.
  50958. */
  50959. protected _directIntensity: number;
  50960. /**
  50961. * Intensity of the emissive part of the material.
  50962. * This helps controlling the emissive effect without modifying the emissive color.
  50963. */
  50964. protected _emissiveIntensity: number;
  50965. /**
  50966. * Intensity of the environment e.g. how much the environment will light the object
  50967. * either through harmonics for rough material or through the refelction for shiny ones.
  50968. */
  50969. protected _environmentIntensity: number;
  50970. /**
  50971. * This is a special control allowing the reduction of the specular highlights coming from the
  50972. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  50973. */
  50974. protected _specularIntensity: number;
  50975. /**
  50976. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  50977. */
  50978. private _lightingInfos;
  50979. /**
  50980. * Debug Control allowing disabling the bump map on this material.
  50981. */
  50982. protected _disableBumpMap: boolean;
  50983. /**
  50984. * AKA Diffuse Texture in standard nomenclature.
  50985. */
  50986. protected _albedoTexture: Nullable<BaseTexture>;
  50987. /**
  50988. * AKA Occlusion Texture in other nomenclature.
  50989. */
  50990. protected _ambientTexture: Nullable<BaseTexture>;
  50991. /**
  50992. * AKA Occlusion Texture Intensity in other nomenclature.
  50993. */
  50994. protected _ambientTextureStrength: number;
  50995. /**
  50996. * Defines how much the AO map is occluding the analytical lights (point spot...).
  50997. * 1 means it completely occludes it
  50998. * 0 mean it has no impact
  50999. */
  51000. protected _ambientTextureImpactOnAnalyticalLights: number;
  51001. /**
  51002. * Stores the alpha values in a texture.
  51003. */
  51004. protected _opacityTexture: Nullable<BaseTexture>;
  51005. /**
  51006. * Stores the reflection values in a texture.
  51007. */
  51008. protected _reflectionTexture: Nullable<BaseTexture>;
  51009. /**
  51010. * Stores the emissive values in a texture.
  51011. */
  51012. protected _emissiveTexture: Nullable<BaseTexture>;
  51013. /**
  51014. * AKA Specular texture in other nomenclature.
  51015. */
  51016. protected _reflectivityTexture: Nullable<BaseTexture>;
  51017. /**
  51018. * Used to switch from specular/glossiness to metallic/roughness workflow.
  51019. */
  51020. protected _metallicTexture: Nullable<BaseTexture>;
  51021. /**
  51022. * Specifies the metallic scalar of the metallic/roughness workflow.
  51023. * Can also be used to scale the metalness values of the metallic texture.
  51024. */
  51025. protected _metallic: Nullable<number>;
  51026. /**
  51027. * Specifies the roughness scalar of the metallic/roughness workflow.
  51028. * Can also be used to scale the roughness values of the metallic texture.
  51029. */
  51030. protected _roughness: Nullable<number>;
  51031. /**
  51032. * Specifies the an F0 factor to help configuring the material F0.
  51033. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  51034. * to 0.5 the previously hard coded value stays the same.
  51035. * Can also be used to scale the F0 values of the metallic texture.
  51036. */
  51037. protected _metallicF0Factor: number;
  51038. /**
  51039. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  51040. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  51041. * your expectation as it multiplies with the texture data.
  51042. */
  51043. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  51044. /**
  51045. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  51046. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  51047. */
  51048. protected _microSurfaceTexture: Nullable<BaseTexture>;
  51049. /**
  51050. * Stores surface normal data used to displace a mesh in a texture.
  51051. */
  51052. protected _bumpTexture: Nullable<BaseTexture>;
  51053. /**
  51054. * Stores the pre-calculated light information of a mesh in a texture.
  51055. */
  51056. protected _lightmapTexture: Nullable<BaseTexture>;
  51057. /**
  51058. * The color of a material in ambient lighting.
  51059. */
  51060. protected _ambientColor: Color3;
  51061. /**
  51062. * AKA Diffuse Color in other nomenclature.
  51063. */
  51064. protected _albedoColor: Color3;
  51065. /**
  51066. * AKA Specular Color in other nomenclature.
  51067. */
  51068. protected _reflectivityColor: Color3;
  51069. /**
  51070. * The color applied when light is reflected from a material.
  51071. */
  51072. protected _reflectionColor: Color3;
  51073. /**
  51074. * The color applied when light is emitted from a material.
  51075. */
  51076. protected _emissiveColor: Color3;
  51077. /**
  51078. * AKA Glossiness in other nomenclature.
  51079. */
  51080. protected _microSurface: number;
  51081. /**
  51082. * Specifies that the material will use the light map as a show map.
  51083. */
  51084. protected _useLightmapAsShadowmap: boolean;
  51085. /**
  51086. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  51087. * makes the reflect vector face the model (under horizon).
  51088. */
  51089. protected _useHorizonOcclusion: boolean;
  51090. /**
  51091. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  51092. * too much the area relying on ambient texture to define their ambient occlusion.
  51093. */
  51094. protected _useRadianceOcclusion: boolean;
  51095. /**
  51096. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  51097. */
  51098. protected _useAlphaFromAlbedoTexture: boolean;
  51099. /**
  51100. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  51101. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  51102. */
  51103. protected _useSpecularOverAlpha: boolean;
  51104. /**
  51105. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  51106. */
  51107. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  51108. /**
  51109. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  51110. */
  51111. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  51112. /**
  51113. * Specifies if the metallic texture contains the roughness information in its green channel.
  51114. */
  51115. protected _useRoughnessFromMetallicTextureGreen: boolean;
  51116. /**
  51117. * Specifies if the metallic texture contains the metallness information in its blue channel.
  51118. */
  51119. protected _useMetallnessFromMetallicTextureBlue: boolean;
  51120. /**
  51121. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  51122. */
  51123. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  51124. /**
  51125. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  51126. */
  51127. protected _useAmbientInGrayScale: boolean;
  51128. /**
  51129. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  51130. * The material will try to infer what glossiness each pixel should be.
  51131. */
  51132. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  51133. /**
  51134. * Defines the falloff type used in this material.
  51135. * It by default is Physical.
  51136. */
  51137. protected _lightFalloff: number;
  51138. /**
  51139. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  51140. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  51141. */
  51142. protected _useRadianceOverAlpha: boolean;
  51143. /**
  51144. * Allows using an object space normal map (instead of tangent space).
  51145. */
  51146. protected _useObjectSpaceNormalMap: boolean;
  51147. /**
  51148. * Allows using the bump map in parallax mode.
  51149. */
  51150. protected _useParallax: boolean;
  51151. /**
  51152. * Allows using the bump map in parallax occlusion mode.
  51153. */
  51154. protected _useParallaxOcclusion: boolean;
  51155. /**
  51156. * Controls the scale bias of the parallax mode.
  51157. */
  51158. protected _parallaxScaleBias: number;
  51159. /**
  51160. * If sets to true, disables all the lights affecting the material.
  51161. */
  51162. protected _disableLighting: boolean;
  51163. /**
  51164. * Number of Simultaneous lights allowed on the material.
  51165. */
  51166. protected _maxSimultaneousLights: number;
  51167. /**
  51168. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  51169. */
  51170. protected _invertNormalMapX: boolean;
  51171. /**
  51172. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  51173. */
  51174. protected _invertNormalMapY: boolean;
  51175. /**
  51176. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  51177. */
  51178. protected _twoSidedLighting: boolean;
  51179. /**
  51180. * Defines the alpha limits in alpha test mode.
  51181. */
  51182. protected _alphaCutOff: number;
  51183. /**
  51184. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  51185. */
  51186. protected _forceAlphaTest: boolean;
  51187. /**
  51188. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  51189. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  51190. */
  51191. protected _useAlphaFresnel: boolean;
  51192. /**
  51193. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  51194. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  51195. */
  51196. protected _useLinearAlphaFresnel: boolean;
  51197. /**
  51198. * The transparency mode of the material.
  51199. */
  51200. protected _transparencyMode: Nullable<number>;
  51201. /**
  51202. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  51203. * from cos thetav and roughness:
  51204. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  51205. */
  51206. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  51207. /**
  51208. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  51209. */
  51210. protected _forceIrradianceInFragment: boolean;
  51211. /**
  51212. * Force normal to face away from face.
  51213. */
  51214. protected _forceNormalForward: boolean;
  51215. /**
  51216. * Enables specular anti aliasing in the PBR shader.
  51217. * It will both interacts on the Geometry for analytical and IBL lighting.
  51218. * It also prefilter the roughness map based on the bump values.
  51219. */
  51220. protected _enableSpecularAntiAliasing: boolean;
  51221. /**
  51222. * Default configuration related to image processing available in the PBR Material.
  51223. */
  51224. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  51225. /**
  51226. * Keep track of the image processing observer to allow dispose and replace.
  51227. */
  51228. private _imageProcessingObserver;
  51229. /**
  51230. * Attaches a new image processing configuration to the PBR Material.
  51231. * @param configuration
  51232. */
  51233. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  51234. /**
  51235. * Stores the available render targets.
  51236. */
  51237. private _renderTargets;
  51238. /**
  51239. * Sets the global ambient color for the material used in lighting calculations.
  51240. */
  51241. private _globalAmbientColor;
  51242. /**
  51243. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  51244. */
  51245. private _useLogarithmicDepth;
  51246. /**
  51247. * If set to true, no lighting calculations will be applied.
  51248. */
  51249. private _unlit;
  51250. private _debugMode;
  51251. /**
  51252. * @hidden
  51253. * This is reserved for the inspector.
  51254. * Defines the material debug mode.
  51255. * It helps seeing only some components of the material while troubleshooting.
  51256. */
  51257. debugMode: number;
  51258. /**
  51259. * @hidden
  51260. * This is reserved for the inspector.
  51261. * Specify from where on screen the debug mode should start.
  51262. * The value goes from -1 (full screen) to 1 (not visible)
  51263. * It helps with side by side comparison against the final render
  51264. * This defaults to -1
  51265. */
  51266. private debugLimit;
  51267. /**
  51268. * @hidden
  51269. * This is reserved for the inspector.
  51270. * As the default viewing range might not be enough (if the ambient is really small for instance)
  51271. * You can use the factor to better multiply the final value.
  51272. */
  51273. private debugFactor;
  51274. /**
  51275. * Defines the clear coat layer parameters for the material.
  51276. */
  51277. readonly clearCoat: PBRClearCoatConfiguration;
  51278. /**
  51279. * Defines the anisotropic parameters for the material.
  51280. */
  51281. readonly anisotropy: PBRAnisotropicConfiguration;
  51282. /**
  51283. * Defines the BRDF parameters for the material.
  51284. */
  51285. readonly brdf: PBRBRDFConfiguration;
  51286. /**
  51287. * Defines the Sheen parameters for the material.
  51288. */
  51289. readonly sheen: PBRSheenConfiguration;
  51290. /**
  51291. * Defines the SubSurface parameters for the material.
  51292. */
  51293. readonly subSurface: PBRSubSurfaceConfiguration;
  51294. /**
  51295. * Custom callback helping to override the default shader used in the material.
  51296. */
  51297. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  51298. protected _rebuildInParallel: boolean;
  51299. /**
  51300. * Instantiates a new PBRMaterial instance.
  51301. *
  51302. * @param name The material name
  51303. * @param scene The scene the material will be use in.
  51304. */
  51305. constructor(name: string, scene: Scene);
  51306. /**
  51307. * Gets a boolean indicating that current material needs to register RTT
  51308. */
  51309. get hasRenderTargetTextures(): boolean;
  51310. /**
  51311. * Gets the name of the material class.
  51312. */
  51313. getClassName(): string;
  51314. /**
  51315. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  51316. */
  51317. get useLogarithmicDepth(): boolean;
  51318. /**
  51319. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  51320. */
  51321. set useLogarithmicDepth(value: boolean);
  51322. /**
  51323. * Gets the current transparency mode.
  51324. */
  51325. get transparencyMode(): Nullable<number>;
  51326. /**
  51327. * Sets the transparency mode of the material.
  51328. *
  51329. * | Value | Type | Description |
  51330. * | ----- | ----------------------------------- | ----------- |
  51331. * | 0 | OPAQUE | |
  51332. * | 1 | ALPHATEST | |
  51333. * | 2 | ALPHABLEND | |
  51334. * | 3 | ALPHATESTANDBLEND | |
  51335. *
  51336. */
  51337. set transparencyMode(value: Nullable<number>);
  51338. /**
  51339. * Returns true if alpha blending should be disabled.
  51340. */
  51341. private get _disableAlphaBlending();
  51342. /**
  51343. * Specifies whether or not this material should be rendered in alpha blend mode.
  51344. */
  51345. needAlphaBlending(): boolean;
  51346. /**
  51347. * Specifies if the mesh will require alpha blending.
  51348. * @param mesh - BJS mesh.
  51349. */
  51350. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  51351. /**
  51352. * Specifies whether or not this material should be rendered in alpha test mode.
  51353. */
  51354. needAlphaTesting(): boolean;
  51355. /**
  51356. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  51357. */
  51358. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  51359. /**
  51360. * Gets the texture used for the alpha test.
  51361. */
  51362. getAlphaTestTexture(): Nullable<BaseTexture>;
  51363. /**
  51364. * Specifies that the submesh is ready to be used.
  51365. * @param mesh - BJS mesh.
  51366. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  51367. * @param useInstances - Specifies that instances should be used.
  51368. * @returns - boolean indicating that the submesh is ready or not.
  51369. */
  51370. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  51371. /**
  51372. * Specifies if the material uses metallic roughness workflow.
  51373. * @returns boolean specifiying if the material uses metallic roughness workflow.
  51374. */
  51375. isMetallicWorkflow(): boolean;
  51376. private _prepareEffect;
  51377. private _prepareDefines;
  51378. /**
  51379. * Force shader compilation
  51380. */
  51381. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  51382. /**
  51383. * Initializes the uniform buffer layout for the shader.
  51384. */
  51385. buildUniformLayout(): void;
  51386. /**
  51387. * Unbinds the material from the mesh
  51388. */
  51389. unbind(): void;
  51390. /**
  51391. * Binds the submesh data.
  51392. * @param world - The world matrix.
  51393. * @param mesh - The BJS mesh.
  51394. * @param subMesh - A submesh of the BJS mesh.
  51395. */
  51396. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  51397. /**
  51398. * Returns the animatable textures.
  51399. * @returns - Array of animatable textures.
  51400. */
  51401. getAnimatables(): IAnimatable[];
  51402. /**
  51403. * Returns the texture used for reflections.
  51404. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  51405. */
  51406. private _getReflectionTexture;
  51407. /**
  51408. * Returns an array of the actively used textures.
  51409. * @returns - Array of BaseTextures
  51410. */
  51411. getActiveTextures(): BaseTexture[];
  51412. /**
  51413. * Checks to see if a texture is used in the material.
  51414. * @param texture - Base texture to use.
  51415. * @returns - Boolean specifying if a texture is used in the material.
  51416. */
  51417. hasTexture(texture: BaseTexture): boolean;
  51418. /**
  51419. * Disposes the resources of the material.
  51420. * @param forceDisposeEffect - Forces the disposal of effects.
  51421. * @param forceDisposeTextures - Forces the disposal of all textures.
  51422. */
  51423. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  51424. }
  51425. }
  51426. declare module BABYLON {
  51427. /**
  51428. * The Physically based material of BJS.
  51429. *
  51430. * This offers the main features of a standard PBR material.
  51431. * For more information, please refer to the documentation :
  51432. * https://doc.babylonjs.com/how_to/physically_based_rendering
  51433. */
  51434. export class PBRMaterial extends PBRBaseMaterial {
  51435. /**
  51436. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  51437. */
  51438. static readonly PBRMATERIAL_OPAQUE: number;
  51439. /**
  51440. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  51441. */
  51442. static readonly PBRMATERIAL_ALPHATEST: number;
  51443. /**
  51444. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  51445. */
  51446. static readonly PBRMATERIAL_ALPHABLEND: number;
  51447. /**
  51448. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  51449. * They are also discarded below the alpha cutoff threshold to improve performances.
  51450. */
  51451. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  51452. /**
  51453. * Defines the default value of how much AO map is occluding the analytical lights
  51454. * (point spot...).
  51455. */
  51456. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  51457. /**
  51458. * Intensity of the direct lights e.g. the four lights available in your scene.
  51459. * This impacts both the direct diffuse and specular highlights.
  51460. */
  51461. directIntensity: number;
  51462. /**
  51463. * Intensity of the emissive part of the material.
  51464. * This helps controlling the emissive effect without modifying the emissive color.
  51465. */
  51466. emissiveIntensity: number;
  51467. /**
  51468. * Intensity of the environment e.g. how much the environment will light the object
  51469. * either through harmonics for rough material or through the refelction for shiny ones.
  51470. */
  51471. environmentIntensity: number;
  51472. /**
  51473. * This is a special control allowing the reduction of the specular highlights coming from the
  51474. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  51475. */
  51476. specularIntensity: number;
  51477. /**
  51478. * Debug Control allowing disabling the bump map on this material.
  51479. */
  51480. disableBumpMap: boolean;
  51481. /**
  51482. * AKA Diffuse Texture in standard nomenclature.
  51483. */
  51484. albedoTexture: BaseTexture;
  51485. /**
  51486. * AKA Occlusion Texture in other nomenclature.
  51487. */
  51488. ambientTexture: BaseTexture;
  51489. /**
  51490. * AKA Occlusion Texture Intensity in other nomenclature.
  51491. */
  51492. ambientTextureStrength: number;
  51493. /**
  51494. * Defines how much the AO map is occluding the analytical lights (point spot...).
  51495. * 1 means it completely occludes it
  51496. * 0 mean it has no impact
  51497. */
  51498. ambientTextureImpactOnAnalyticalLights: number;
  51499. /**
  51500. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  51501. */
  51502. opacityTexture: BaseTexture;
  51503. /**
  51504. * Stores the reflection values in a texture.
  51505. */
  51506. reflectionTexture: Nullable<BaseTexture>;
  51507. /**
  51508. * Stores the emissive values in a texture.
  51509. */
  51510. emissiveTexture: BaseTexture;
  51511. /**
  51512. * AKA Specular texture in other nomenclature.
  51513. */
  51514. reflectivityTexture: BaseTexture;
  51515. /**
  51516. * Used to switch from specular/glossiness to metallic/roughness workflow.
  51517. */
  51518. metallicTexture: BaseTexture;
  51519. /**
  51520. * Specifies the metallic scalar of the metallic/roughness workflow.
  51521. * Can also be used to scale the metalness values of the metallic texture.
  51522. */
  51523. metallic: Nullable<number>;
  51524. /**
  51525. * Specifies the roughness scalar of the metallic/roughness workflow.
  51526. * Can also be used to scale the roughness values of the metallic texture.
  51527. */
  51528. roughness: Nullable<number>;
  51529. /**
  51530. * Specifies the an F0 factor to help configuring the material F0.
  51531. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  51532. * to 0.5 the previously hard coded value stays the same.
  51533. * Can also be used to scale the F0 values of the metallic texture.
  51534. */
  51535. metallicF0Factor: number;
  51536. /**
  51537. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  51538. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  51539. * your expectation as it multiplies with the texture data.
  51540. */
  51541. useMetallicF0FactorFromMetallicTexture: boolean;
  51542. /**
  51543. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  51544. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  51545. */
  51546. microSurfaceTexture: BaseTexture;
  51547. /**
  51548. * Stores surface normal data used to displace a mesh in a texture.
  51549. */
  51550. bumpTexture: BaseTexture;
  51551. /**
  51552. * Stores the pre-calculated light information of a mesh in a texture.
  51553. */
  51554. lightmapTexture: BaseTexture;
  51555. /**
  51556. * Stores the refracted light information in a texture.
  51557. */
  51558. get refractionTexture(): Nullable<BaseTexture>;
  51559. set refractionTexture(value: Nullable<BaseTexture>);
  51560. /**
  51561. * The color of a material in ambient lighting.
  51562. */
  51563. ambientColor: Color3;
  51564. /**
  51565. * AKA Diffuse Color in other nomenclature.
  51566. */
  51567. albedoColor: Color3;
  51568. /**
  51569. * AKA Specular Color in other nomenclature.
  51570. */
  51571. reflectivityColor: Color3;
  51572. /**
  51573. * The color reflected from the material.
  51574. */
  51575. reflectionColor: Color3;
  51576. /**
  51577. * The color emitted from the material.
  51578. */
  51579. emissiveColor: Color3;
  51580. /**
  51581. * AKA Glossiness in other nomenclature.
  51582. */
  51583. microSurface: number;
  51584. /**
  51585. * source material index of refraction (IOR)' / 'destination material IOR.
  51586. */
  51587. get indexOfRefraction(): number;
  51588. set indexOfRefraction(value: number);
  51589. /**
  51590. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  51591. */
  51592. get invertRefractionY(): boolean;
  51593. set invertRefractionY(value: boolean);
  51594. /**
  51595. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  51596. * Materials half opaque for instance using refraction could benefit from this control.
  51597. */
  51598. get linkRefractionWithTransparency(): boolean;
  51599. set linkRefractionWithTransparency(value: boolean);
  51600. /**
  51601. * If true, the light map contains occlusion information instead of lighting info.
  51602. */
  51603. useLightmapAsShadowmap: boolean;
  51604. /**
  51605. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  51606. */
  51607. useAlphaFromAlbedoTexture: boolean;
  51608. /**
  51609. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  51610. */
  51611. forceAlphaTest: boolean;
  51612. /**
  51613. * Defines the alpha limits in alpha test mode.
  51614. */
  51615. alphaCutOff: number;
  51616. /**
  51617. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  51618. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  51619. */
  51620. useSpecularOverAlpha: boolean;
  51621. /**
  51622. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  51623. */
  51624. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  51625. /**
  51626. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  51627. */
  51628. useRoughnessFromMetallicTextureAlpha: boolean;
  51629. /**
  51630. * Specifies if the metallic texture contains the roughness information in its green channel.
  51631. */
  51632. useRoughnessFromMetallicTextureGreen: boolean;
  51633. /**
  51634. * Specifies if the metallic texture contains the metallness information in its blue channel.
  51635. */
  51636. useMetallnessFromMetallicTextureBlue: boolean;
  51637. /**
  51638. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  51639. */
  51640. useAmbientOcclusionFromMetallicTextureRed: boolean;
  51641. /**
  51642. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  51643. */
  51644. useAmbientInGrayScale: boolean;
  51645. /**
  51646. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  51647. * The material will try to infer what glossiness each pixel should be.
  51648. */
  51649. useAutoMicroSurfaceFromReflectivityMap: boolean;
  51650. /**
  51651. * BJS is using an harcoded light falloff based on a manually sets up range.
  51652. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  51653. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  51654. */
  51655. get usePhysicalLightFalloff(): boolean;
  51656. /**
  51657. * BJS is using an harcoded light falloff based on a manually sets up range.
  51658. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  51659. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  51660. */
  51661. set usePhysicalLightFalloff(value: boolean);
  51662. /**
  51663. * In order to support the falloff compatibility with gltf, a special mode has been added
  51664. * to reproduce the gltf light falloff.
  51665. */
  51666. get useGLTFLightFalloff(): boolean;
  51667. /**
  51668. * In order to support the falloff compatibility with gltf, a special mode has been added
  51669. * to reproduce the gltf light falloff.
  51670. */
  51671. set useGLTFLightFalloff(value: boolean);
  51672. /**
  51673. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  51674. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  51675. */
  51676. useRadianceOverAlpha: boolean;
  51677. /**
  51678. * Allows using an object space normal map (instead of tangent space).
  51679. */
  51680. useObjectSpaceNormalMap: boolean;
  51681. /**
  51682. * Allows using the bump map in parallax mode.
  51683. */
  51684. useParallax: boolean;
  51685. /**
  51686. * Allows using the bump map in parallax occlusion mode.
  51687. */
  51688. useParallaxOcclusion: boolean;
  51689. /**
  51690. * Controls the scale bias of the parallax mode.
  51691. */
  51692. parallaxScaleBias: number;
  51693. /**
  51694. * If sets to true, disables all the lights affecting the material.
  51695. */
  51696. disableLighting: boolean;
  51697. /**
  51698. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  51699. */
  51700. forceIrradianceInFragment: boolean;
  51701. /**
  51702. * Number of Simultaneous lights allowed on the material.
  51703. */
  51704. maxSimultaneousLights: number;
  51705. /**
  51706. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  51707. */
  51708. invertNormalMapX: boolean;
  51709. /**
  51710. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  51711. */
  51712. invertNormalMapY: boolean;
  51713. /**
  51714. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  51715. */
  51716. twoSidedLighting: boolean;
  51717. /**
  51718. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  51719. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  51720. */
  51721. useAlphaFresnel: boolean;
  51722. /**
  51723. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  51724. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  51725. */
  51726. useLinearAlphaFresnel: boolean;
  51727. /**
  51728. * Let user defines the brdf lookup texture used for IBL.
  51729. * A default 8bit version is embedded but you could point at :
  51730. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  51731. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  51732. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  51733. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  51734. */
  51735. environmentBRDFTexture: Nullable<BaseTexture>;
  51736. /**
  51737. * Force normal to face away from face.
  51738. */
  51739. forceNormalForward: boolean;
  51740. /**
  51741. * Enables specular anti aliasing in the PBR shader.
  51742. * It will both interacts on the Geometry for analytical and IBL lighting.
  51743. * It also prefilter the roughness map based on the bump values.
  51744. */
  51745. enableSpecularAntiAliasing: boolean;
  51746. /**
  51747. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  51748. * makes the reflect vector face the model (under horizon).
  51749. */
  51750. useHorizonOcclusion: boolean;
  51751. /**
  51752. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  51753. * too much the area relying on ambient texture to define their ambient occlusion.
  51754. */
  51755. useRadianceOcclusion: boolean;
  51756. /**
  51757. * If set to true, no lighting calculations will be applied.
  51758. */
  51759. unlit: boolean;
  51760. /**
  51761. * Gets the image processing configuration used either in this material.
  51762. */
  51763. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  51764. /**
  51765. * Sets the Default image processing configuration used either in the this material.
  51766. *
  51767. * If sets to null, the scene one is in use.
  51768. */
  51769. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  51770. /**
  51771. * Gets wether the color curves effect is enabled.
  51772. */
  51773. get cameraColorCurvesEnabled(): boolean;
  51774. /**
  51775. * Sets wether the color curves effect is enabled.
  51776. */
  51777. set cameraColorCurvesEnabled(value: boolean);
  51778. /**
  51779. * Gets wether the color grading effect is enabled.
  51780. */
  51781. get cameraColorGradingEnabled(): boolean;
  51782. /**
  51783. * Gets wether the color grading effect is enabled.
  51784. */
  51785. set cameraColorGradingEnabled(value: boolean);
  51786. /**
  51787. * Gets wether tonemapping is enabled or not.
  51788. */
  51789. get cameraToneMappingEnabled(): boolean;
  51790. /**
  51791. * Sets wether tonemapping is enabled or not
  51792. */
  51793. set cameraToneMappingEnabled(value: boolean);
  51794. /**
  51795. * The camera exposure used on this material.
  51796. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  51797. * This corresponds to a photographic exposure.
  51798. */
  51799. get cameraExposure(): number;
  51800. /**
  51801. * The camera exposure used on this material.
  51802. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  51803. * This corresponds to a photographic exposure.
  51804. */
  51805. set cameraExposure(value: number);
  51806. /**
  51807. * Gets The camera contrast used on this material.
  51808. */
  51809. get cameraContrast(): number;
  51810. /**
  51811. * Sets The camera contrast used on this material.
  51812. */
  51813. set cameraContrast(value: number);
  51814. /**
  51815. * Gets the Color Grading 2D Lookup Texture.
  51816. */
  51817. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  51818. /**
  51819. * Sets the Color Grading 2D Lookup Texture.
  51820. */
  51821. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  51822. /**
  51823. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  51824. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  51825. * 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;
  51826. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  51827. */
  51828. get cameraColorCurves(): Nullable<ColorCurves>;
  51829. /**
  51830. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  51831. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  51832. * 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;
  51833. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  51834. */
  51835. set cameraColorCurves(value: Nullable<ColorCurves>);
  51836. /**
  51837. * Instantiates a new PBRMaterial instance.
  51838. *
  51839. * @param name The material name
  51840. * @param scene The scene the material will be use in.
  51841. */
  51842. constructor(name: string, scene: Scene);
  51843. /**
  51844. * Returns the name of this material class.
  51845. */
  51846. getClassName(): string;
  51847. /**
  51848. * Makes a duplicate of the current material.
  51849. * @param name - name to use for the new material.
  51850. */
  51851. clone(name: string): PBRMaterial;
  51852. /**
  51853. * Serializes this PBR Material.
  51854. * @returns - An object with the serialized material.
  51855. */
  51856. serialize(): any;
  51857. /**
  51858. * Parses a PBR Material from a serialized object.
  51859. * @param source - Serialized object.
  51860. * @param scene - BJS scene instance.
  51861. * @param rootUrl - url for the scene object
  51862. * @returns - PBRMaterial
  51863. */
  51864. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  51865. }
  51866. }
  51867. declare module BABYLON {
  51868. /**
  51869. * Direct draw surface info
  51870. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  51871. */
  51872. export interface DDSInfo {
  51873. /**
  51874. * Width of the texture
  51875. */
  51876. width: number;
  51877. /**
  51878. * Width of the texture
  51879. */
  51880. height: number;
  51881. /**
  51882. * Number of Mipmaps for the texture
  51883. * @see https://en.wikipedia.org/wiki/Mipmap
  51884. */
  51885. mipmapCount: number;
  51886. /**
  51887. * If the textures format is a known fourCC format
  51888. * @see https://www.fourcc.org/
  51889. */
  51890. isFourCC: boolean;
  51891. /**
  51892. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  51893. */
  51894. isRGB: boolean;
  51895. /**
  51896. * If the texture is a lumincance format
  51897. */
  51898. isLuminance: boolean;
  51899. /**
  51900. * If this is a cube texture
  51901. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  51902. */
  51903. isCube: boolean;
  51904. /**
  51905. * If the texture is a compressed format eg. FOURCC_DXT1
  51906. */
  51907. isCompressed: boolean;
  51908. /**
  51909. * The dxgiFormat of the texture
  51910. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  51911. */
  51912. dxgiFormat: number;
  51913. /**
  51914. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  51915. */
  51916. textureType: number;
  51917. /**
  51918. * Sphericle polynomial created for the dds texture
  51919. */
  51920. sphericalPolynomial?: SphericalPolynomial;
  51921. }
  51922. /**
  51923. * Class used to provide DDS decompression tools
  51924. */
  51925. export class DDSTools {
  51926. /**
  51927. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  51928. */
  51929. static StoreLODInAlphaChannel: boolean;
  51930. /**
  51931. * Gets DDS information from an array buffer
  51932. * @param data defines the array buffer view to read data from
  51933. * @returns the DDS information
  51934. */
  51935. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  51936. private static _FloatView;
  51937. private static _Int32View;
  51938. private static _ToHalfFloat;
  51939. private static _FromHalfFloat;
  51940. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  51941. private static _GetHalfFloatRGBAArrayBuffer;
  51942. private static _GetFloatRGBAArrayBuffer;
  51943. private static _GetFloatAsUIntRGBAArrayBuffer;
  51944. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  51945. private static _GetRGBAArrayBuffer;
  51946. private static _ExtractLongWordOrder;
  51947. private static _GetRGBArrayBuffer;
  51948. private static _GetLuminanceArrayBuffer;
  51949. /**
  51950. * Uploads DDS Levels to a Babylon Texture
  51951. * @hidden
  51952. */
  51953. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  51954. }
  51955. interface ThinEngine {
  51956. /**
  51957. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  51958. * @param rootUrl defines the url where the file to load is located
  51959. * @param scene defines the current scene
  51960. * @param lodScale defines scale to apply to the mip map selection
  51961. * @param lodOffset defines offset to apply to the mip map selection
  51962. * @param onLoad defines an optional callback raised when the texture is loaded
  51963. * @param onError defines an optional callback raised if there is an issue to load the texture
  51964. * @param format defines the format of the data
  51965. * @param forcedExtension defines the extension to use to pick the right loader
  51966. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  51967. * @returns the cube texture as an InternalTexture
  51968. */
  51969. 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;
  51970. }
  51971. }
  51972. declare module BABYLON {
  51973. /**
  51974. * Implementation of the DDS Texture Loader.
  51975. * @hidden
  51976. */
  51977. export class _DDSTextureLoader implements IInternalTextureLoader {
  51978. /**
  51979. * Defines wether the loader supports cascade loading the different faces.
  51980. */
  51981. readonly supportCascades: boolean;
  51982. /**
  51983. * This returns if the loader support the current file information.
  51984. * @param extension defines the file extension of the file being loaded
  51985. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51986. * @param fallback defines the fallback internal texture if any
  51987. * @param isBase64 defines whether the texture is encoded as a base64
  51988. * @param isBuffer defines whether the texture data are stored as a buffer
  51989. * @returns true if the loader can load the specified file
  51990. */
  51991. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  51992. /**
  51993. * Transform the url before loading if required.
  51994. * @param rootUrl the url of the texture
  51995. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51996. * @returns the transformed texture
  51997. */
  51998. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  51999. /**
  52000. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  52001. * @param rootUrl the url of the texture
  52002. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52003. * @returns the fallback texture
  52004. */
  52005. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  52006. /**
  52007. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  52008. * @param data contains the texture data
  52009. * @param texture defines the BabylonJS internal texture
  52010. * @param createPolynomials will be true if polynomials have been requested
  52011. * @param onLoad defines the callback to trigger once the texture is ready
  52012. * @param onError defines the callback to trigger in case of error
  52013. */
  52014. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  52015. /**
  52016. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  52017. * @param data contains the texture data
  52018. * @param texture defines the BabylonJS internal texture
  52019. * @param callback defines the method to call once ready to upload
  52020. */
  52021. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  52022. }
  52023. }
  52024. declare module BABYLON {
  52025. /**
  52026. * Implementation of the ENV Texture Loader.
  52027. * @hidden
  52028. */
  52029. export class _ENVTextureLoader implements IInternalTextureLoader {
  52030. /**
  52031. * Defines wether the loader supports cascade loading the different faces.
  52032. */
  52033. readonly supportCascades: boolean;
  52034. /**
  52035. * This returns if the loader support the current file information.
  52036. * @param extension defines the file extension of the file being loaded
  52037. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52038. * @param fallback defines the fallback internal texture if any
  52039. * @param isBase64 defines whether the texture is encoded as a base64
  52040. * @param isBuffer defines whether the texture data are stored as a buffer
  52041. * @returns true if the loader can load the specified file
  52042. */
  52043. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  52044. /**
  52045. * Transform the url before loading if required.
  52046. * @param rootUrl the url of the texture
  52047. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52048. * @returns the transformed texture
  52049. */
  52050. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  52051. /**
  52052. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  52053. * @param rootUrl the url of the texture
  52054. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52055. * @returns the fallback texture
  52056. */
  52057. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  52058. /**
  52059. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  52060. * @param data contains the texture data
  52061. * @param texture defines the BabylonJS internal texture
  52062. * @param createPolynomials will be true if polynomials have been requested
  52063. * @param onLoad defines the callback to trigger once the texture is ready
  52064. * @param onError defines the callback to trigger in case of error
  52065. */
  52066. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  52067. /**
  52068. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  52069. * @param data contains the texture data
  52070. * @param texture defines the BabylonJS internal texture
  52071. * @param callback defines the method to call once ready to upload
  52072. */
  52073. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  52074. }
  52075. }
  52076. declare module BABYLON {
  52077. /**
  52078. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  52079. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  52080. */
  52081. export class KhronosTextureContainer {
  52082. /** contents of the KTX container file */
  52083. data: ArrayBufferView;
  52084. private static HEADER_LEN;
  52085. private static COMPRESSED_2D;
  52086. private static COMPRESSED_3D;
  52087. private static TEX_2D;
  52088. private static TEX_3D;
  52089. /**
  52090. * Gets the openGL type
  52091. */
  52092. glType: number;
  52093. /**
  52094. * Gets the openGL type size
  52095. */
  52096. glTypeSize: number;
  52097. /**
  52098. * Gets the openGL format
  52099. */
  52100. glFormat: number;
  52101. /**
  52102. * Gets the openGL internal format
  52103. */
  52104. glInternalFormat: number;
  52105. /**
  52106. * Gets the base internal format
  52107. */
  52108. glBaseInternalFormat: number;
  52109. /**
  52110. * Gets image width in pixel
  52111. */
  52112. pixelWidth: number;
  52113. /**
  52114. * Gets image height in pixel
  52115. */
  52116. pixelHeight: number;
  52117. /**
  52118. * Gets image depth in pixels
  52119. */
  52120. pixelDepth: number;
  52121. /**
  52122. * Gets the number of array elements
  52123. */
  52124. numberOfArrayElements: number;
  52125. /**
  52126. * Gets the number of faces
  52127. */
  52128. numberOfFaces: number;
  52129. /**
  52130. * Gets the number of mipmap levels
  52131. */
  52132. numberOfMipmapLevels: number;
  52133. /**
  52134. * Gets the bytes of key value data
  52135. */
  52136. bytesOfKeyValueData: number;
  52137. /**
  52138. * Gets the load type
  52139. */
  52140. loadType: number;
  52141. /**
  52142. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  52143. */
  52144. isInvalid: boolean;
  52145. /**
  52146. * Creates a new KhronosTextureContainer
  52147. * @param data contents of the KTX container file
  52148. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  52149. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  52150. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  52151. */
  52152. constructor(
  52153. /** contents of the KTX container file */
  52154. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  52155. /**
  52156. * Uploads KTX content to a Babylon Texture.
  52157. * It is assumed that the texture has already been created & is currently bound
  52158. * @hidden
  52159. */
  52160. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  52161. private _upload2DCompressedLevels;
  52162. }
  52163. }
  52164. declare module BABYLON {
  52165. /**
  52166. * Implementation of the KTX Texture Loader.
  52167. * @hidden
  52168. */
  52169. export class _KTXTextureLoader implements IInternalTextureLoader {
  52170. /**
  52171. * Defines wether the loader supports cascade loading the different faces.
  52172. */
  52173. readonly supportCascades: boolean;
  52174. /**
  52175. * This returns if the loader support the current file information.
  52176. * @param extension defines the file extension of the file being loaded
  52177. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52178. * @param fallback defines the fallback internal texture if any
  52179. * @param isBase64 defines whether the texture is encoded as a base64
  52180. * @param isBuffer defines whether the texture data are stored as a buffer
  52181. * @returns true if the loader can load the specified file
  52182. */
  52183. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  52184. /**
  52185. * Transform the url before loading if required.
  52186. * @param rootUrl the url of the texture
  52187. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52188. * @returns the transformed texture
  52189. */
  52190. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  52191. /**
  52192. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  52193. * @param rootUrl the url of the texture
  52194. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52195. * @returns the fallback texture
  52196. */
  52197. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  52198. /**
  52199. * Uploads the cube texture data to the WebGl Texture. It has alreday 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 alreday 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. * Force the stencil to the normal expected value for none glowing parts
  53429. */
  53430. private _defaultStencilReference;
  53431. /**
  53432. * Free any resources and references associated to a mesh.
  53433. * Internal use
  53434. * @param mesh The mesh to free.
  53435. * @hidden
  53436. */
  53437. _disposeMesh(mesh: Mesh): void;
  53438. /**
  53439. * Dispose the highlight layer and free resources.
  53440. */
  53441. dispose(): void;
  53442. /**
  53443. * Gets the class name of the effect layer
  53444. * @returns the string with the class name of the effect layer
  53445. */
  53446. getClassName(): string;
  53447. /**
  53448. * Serializes this Highlight layer
  53449. * @returns a serialized Highlight layer object
  53450. */
  53451. serialize(): any;
  53452. /**
  53453. * Creates a Highlight layer from parsed Highlight layer data
  53454. * @param parsedHightlightLayer defines the Highlight layer data
  53455. * @param scene defines the current scene
  53456. * @param rootUrl defines the root URL containing the Highlight layer information
  53457. * @returns a parsed Highlight layer
  53458. */
  53459. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  53460. }
  53461. }
  53462. declare module BABYLON {
  53463. interface AbstractScene {
  53464. /**
  53465. * The list of layers (background and foreground) of the scene
  53466. */
  53467. layers: Array<Layer>;
  53468. }
  53469. /**
  53470. * Defines the layer scene component responsible to manage any layers
  53471. * in a given scene.
  53472. */
  53473. export class LayerSceneComponent implements ISceneComponent {
  53474. /**
  53475. * The component name helpfull to identify the component in the list of scene components.
  53476. */
  53477. readonly name: string;
  53478. /**
  53479. * The scene the component belongs to.
  53480. */
  53481. scene: Scene;
  53482. private _engine;
  53483. /**
  53484. * Creates a new instance of the component for the given scene
  53485. * @param scene Defines the scene to register the component in
  53486. */
  53487. constructor(scene: Scene);
  53488. /**
  53489. * Registers the component in a given scene
  53490. */
  53491. register(): void;
  53492. /**
  53493. * Rebuilds the elements related to this component in case of
  53494. * context lost for instance.
  53495. */
  53496. rebuild(): void;
  53497. /**
  53498. * Disposes the component and the associated ressources.
  53499. */
  53500. dispose(): void;
  53501. private _draw;
  53502. private _drawCameraPredicate;
  53503. private _drawCameraBackground;
  53504. private _drawCameraForeground;
  53505. private _drawRenderTargetPredicate;
  53506. private _drawRenderTargetBackground;
  53507. private _drawRenderTargetForeground;
  53508. /**
  53509. * Adds all the elements from the container to the scene
  53510. * @param container the container holding the elements
  53511. */
  53512. addFromContainer(container: AbstractScene): void;
  53513. /**
  53514. * Removes all the elements in the container from the scene
  53515. * @param container contains the elements to remove
  53516. * @param dispose if the removed element should be disposed (default: false)
  53517. */
  53518. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  53519. }
  53520. }
  53521. declare module BABYLON {
  53522. /** @hidden */
  53523. export var layerPixelShader: {
  53524. name: string;
  53525. shader: string;
  53526. };
  53527. }
  53528. declare module BABYLON {
  53529. /** @hidden */
  53530. export var layerVertexShader: {
  53531. name: string;
  53532. shader: string;
  53533. };
  53534. }
  53535. declare module BABYLON {
  53536. /**
  53537. * This represents a full screen 2d layer.
  53538. * This can be useful to display a picture in the background of your scene for instance.
  53539. * @see https://www.babylonjs-playground.com/#08A2BS#1
  53540. */
  53541. export class Layer {
  53542. /**
  53543. * Define the name of the layer.
  53544. */
  53545. name: string;
  53546. /**
  53547. * Define the texture the layer should display.
  53548. */
  53549. texture: Nullable<Texture>;
  53550. /**
  53551. * Is the layer in background or foreground.
  53552. */
  53553. isBackground: boolean;
  53554. /**
  53555. * Define the color of the layer (instead of texture).
  53556. */
  53557. color: Color4;
  53558. /**
  53559. * Define the scale of the layer in order to zoom in out of the texture.
  53560. */
  53561. scale: Vector2;
  53562. /**
  53563. * Define an offset for the layer in order to shift the texture.
  53564. */
  53565. offset: Vector2;
  53566. /**
  53567. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  53568. */
  53569. alphaBlendingMode: number;
  53570. /**
  53571. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  53572. * Alpha test will not mix with the background color in case of transparency.
  53573. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  53574. */
  53575. alphaTest: boolean;
  53576. /**
  53577. * Define a mask to restrict the layer to only some of the scene cameras.
  53578. */
  53579. layerMask: number;
  53580. /**
  53581. * Define the list of render target the layer is visible into.
  53582. */
  53583. renderTargetTextures: RenderTargetTexture[];
  53584. /**
  53585. * Define if the layer is only used in renderTarget or if it also
  53586. * renders in the main frame buffer of the canvas.
  53587. */
  53588. renderOnlyInRenderTargetTextures: boolean;
  53589. private _scene;
  53590. private _vertexBuffers;
  53591. private _indexBuffer;
  53592. private _effect;
  53593. private _previousDefines;
  53594. /**
  53595. * An event triggered when the layer is disposed.
  53596. */
  53597. onDisposeObservable: Observable<Layer>;
  53598. private _onDisposeObserver;
  53599. /**
  53600. * Back compatibility with callback before the onDisposeObservable existed.
  53601. * The set callback will be triggered when the layer has been disposed.
  53602. */
  53603. set onDispose(callback: () => void);
  53604. /**
  53605. * An event triggered before rendering the scene
  53606. */
  53607. onBeforeRenderObservable: Observable<Layer>;
  53608. private _onBeforeRenderObserver;
  53609. /**
  53610. * Back compatibility with callback before the onBeforeRenderObservable existed.
  53611. * The set callback will be triggered just before rendering the layer.
  53612. */
  53613. set onBeforeRender(callback: () => void);
  53614. /**
  53615. * An event triggered after rendering the scene
  53616. */
  53617. onAfterRenderObservable: Observable<Layer>;
  53618. private _onAfterRenderObserver;
  53619. /**
  53620. * Back compatibility with callback before the onAfterRenderObservable existed.
  53621. * The set callback will be triggered just after rendering the layer.
  53622. */
  53623. set onAfterRender(callback: () => void);
  53624. /**
  53625. * Instantiates a new layer.
  53626. * This represents a full screen 2d layer.
  53627. * This can be useful to display a picture in the background of your scene for instance.
  53628. * @see https://www.babylonjs-playground.com/#08A2BS#1
  53629. * @param name Define the name of the layer in the scene
  53630. * @param imgUrl Define the url of the texture to display in the layer
  53631. * @param scene Define the scene the layer belongs to
  53632. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  53633. * @param color Defines a color for the layer
  53634. */
  53635. constructor(
  53636. /**
  53637. * Define the name of the layer.
  53638. */
  53639. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  53640. private _createIndexBuffer;
  53641. /** @hidden */
  53642. _rebuild(): void;
  53643. /**
  53644. * Renders the layer in the scene.
  53645. */
  53646. render(): void;
  53647. /**
  53648. * Disposes and releases the associated ressources.
  53649. */
  53650. dispose(): void;
  53651. }
  53652. }
  53653. declare module BABYLON {
  53654. /** @hidden */
  53655. export var lensFlarePixelShader: {
  53656. name: string;
  53657. shader: string;
  53658. };
  53659. }
  53660. declare module BABYLON {
  53661. /** @hidden */
  53662. export var lensFlareVertexShader: {
  53663. name: string;
  53664. shader: string;
  53665. };
  53666. }
  53667. declare module BABYLON {
  53668. /**
  53669. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  53670. * It is usually composed of several `lensFlare`.
  53671. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53672. */
  53673. export class LensFlareSystem {
  53674. /**
  53675. * Define the name of the lens flare system
  53676. */
  53677. name: string;
  53678. /**
  53679. * List of lens flares used in this system.
  53680. */
  53681. lensFlares: LensFlare[];
  53682. /**
  53683. * Define a limit from the border the lens flare can be visible.
  53684. */
  53685. borderLimit: number;
  53686. /**
  53687. * Define a viewport border we do not want to see the lens flare in.
  53688. */
  53689. viewportBorder: number;
  53690. /**
  53691. * Define a predicate which could limit the list of meshes able to occlude the effect.
  53692. */
  53693. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  53694. /**
  53695. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  53696. */
  53697. layerMask: number;
  53698. /**
  53699. * Define the id of the lens flare system in the scene.
  53700. * (equal to name by default)
  53701. */
  53702. id: string;
  53703. private _scene;
  53704. private _emitter;
  53705. private _vertexBuffers;
  53706. private _indexBuffer;
  53707. private _effect;
  53708. private _positionX;
  53709. private _positionY;
  53710. private _isEnabled;
  53711. /** @hidden */
  53712. static _SceneComponentInitialization: (scene: Scene) => void;
  53713. /**
  53714. * Instantiates a lens flare system.
  53715. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  53716. * It is usually composed of several `lensFlare`.
  53717. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53718. * @param name Define the name of the lens flare system in the scene
  53719. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  53720. * @param scene Define the scene the lens flare system belongs to
  53721. */
  53722. constructor(
  53723. /**
  53724. * Define the name of the lens flare system
  53725. */
  53726. name: string, emitter: any, scene: Scene);
  53727. /**
  53728. * Define if the lens flare system is enabled.
  53729. */
  53730. get isEnabled(): boolean;
  53731. set isEnabled(value: boolean);
  53732. /**
  53733. * Get the scene the effects belongs to.
  53734. * @returns the scene holding the lens flare system
  53735. */
  53736. getScene(): Scene;
  53737. /**
  53738. * Get the emitter of the lens flare system.
  53739. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  53740. * @returns the emitter of the lens flare system
  53741. */
  53742. getEmitter(): any;
  53743. /**
  53744. * Set the emitter of the lens flare system.
  53745. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  53746. * @param newEmitter Define the new emitter of the system
  53747. */
  53748. setEmitter(newEmitter: any): void;
  53749. /**
  53750. * Get the lens flare system emitter position.
  53751. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  53752. * @returns the position
  53753. */
  53754. getEmitterPosition(): Vector3;
  53755. /**
  53756. * @hidden
  53757. */
  53758. computeEffectivePosition(globalViewport: Viewport): boolean;
  53759. /** @hidden */
  53760. _isVisible(): boolean;
  53761. /**
  53762. * @hidden
  53763. */
  53764. render(): boolean;
  53765. /**
  53766. * Dispose and release the lens flare with its associated resources.
  53767. */
  53768. dispose(): void;
  53769. /**
  53770. * Parse a lens flare system from a JSON repressentation
  53771. * @param parsedLensFlareSystem Define the JSON to parse
  53772. * @param scene Define the scene the parsed system should be instantiated in
  53773. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  53774. * @returns the parsed system
  53775. */
  53776. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  53777. /**
  53778. * Serialize the current Lens Flare System into a JSON representation.
  53779. * @returns the serialized JSON
  53780. */
  53781. serialize(): any;
  53782. }
  53783. }
  53784. declare module BABYLON {
  53785. /**
  53786. * This represents one of the lens effect in a `lensFlareSystem`.
  53787. * It controls one of the indiviual texture used in the effect.
  53788. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53789. */
  53790. export class LensFlare {
  53791. /**
  53792. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  53793. */
  53794. size: number;
  53795. /**
  53796. * 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.
  53797. */
  53798. position: number;
  53799. /**
  53800. * Define the lens color.
  53801. */
  53802. color: Color3;
  53803. /**
  53804. * Define the lens texture.
  53805. */
  53806. texture: Nullable<Texture>;
  53807. /**
  53808. * Define the alpha mode to render this particular lens.
  53809. */
  53810. alphaMode: number;
  53811. private _system;
  53812. /**
  53813. * Creates a new Lens Flare.
  53814. * This represents one of the lens effect in a `lensFlareSystem`.
  53815. * It controls one of the indiviual texture used in the effect.
  53816. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53817. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  53818. * @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.
  53819. * @param color Define the lens color
  53820. * @param imgUrl Define the lens texture url
  53821. * @param system Define the `lensFlareSystem` this flare is part of
  53822. * @returns The newly created Lens Flare
  53823. */
  53824. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  53825. /**
  53826. * Instantiates a new Lens Flare.
  53827. * This represents one of the lens effect in a `lensFlareSystem`.
  53828. * It controls one of the indiviual texture used in the effect.
  53829. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53830. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  53831. * @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.
  53832. * @param color Define the lens color
  53833. * @param imgUrl Define the lens texture url
  53834. * @param system Define the `lensFlareSystem` this flare is part of
  53835. */
  53836. constructor(
  53837. /**
  53838. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  53839. */
  53840. size: number,
  53841. /**
  53842. * 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.
  53843. */
  53844. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  53845. /**
  53846. * Dispose and release the lens flare with its associated resources.
  53847. */
  53848. dispose(): void;
  53849. }
  53850. }
  53851. declare module BABYLON {
  53852. interface AbstractScene {
  53853. /**
  53854. * The list of lens flare system added to the scene
  53855. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53856. */
  53857. lensFlareSystems: Array<LensFlareSystem>;
  53858. /**
  53859. * Removes the given lens flare system from this scene.
  53860. * @param toRemove The lens flare system to remove
  53861. * @returns The index of the removed lens flare system
  53862. */
  53863. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  53864. /**
  53865. * Adds the given lens flare system to this scene
  53866. * @param newLensFlareSystem The lens flare system to add
  53867. */
  53868. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  53869. /**
  53870. * Gets a lens flare system using its name
  53871. * @param name defines the name to look for
  53872. * @returns the lens flare system or null if not found
  53873. */
  53874. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  53875. /**
  53876. * Gets a lens flare system using its id
  53877. * @param id defines the id to look for
  53878. * @returns the lens flare system or null if not found
  53879. */
  53880. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  53881. }
  53882. /**
  53883. * Defines the lens flare scene component responsible to manage any lens flares
  53884. * in a given scene.
  53885. */
  53886. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  53887. /**
  53888. * The component name helpfull to identify the component in the list of scene components.
  53889. */
  53890. readonly name: string;
  53891. /**
  53892. * The scene the component belongs to.
  53893. */
  53894. scene: Scene;
  53895. /**
  53896. * Creates a new instance of the component for the given scene
  53897. * @param scene Defines the scene to register the component in
  53898. */
  53899. constructor(scene: Scene);
  53900. /**
  53901. * Registers the component in a given scene
  53902. */
  53903. register(): void;
  53904. /**
  53905. * Rebuilds the elements related to this component in case of
  53906. * context lost for instance.
  53907. */
  53908. rebuild(): void;
  53909. /**
  53910. * Adds all the elements from the container to the scene
  53911. * @param container the container holding the elements
  53912. */
  53913. addFromContainer(container: AbstractScene): void;
  53914. /**
  53915. * Removes all the elements in the container from the scene
  53916. * @param container contains the elements to remove
  53917. * @param dispose if the removed element should be disposed (default: false)
  53918. */
  53919. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  53920. /**
  53921. * Serializes the component data to the specified json object
  53922. * @param serializationObject The object to serialize to
  53923. */
  53924. serialize(serializationObject: any): void;
  53925. /**
  53926. * Disposes the component and the associated ressources.
  53927. */
  53928. dispose(): void;
  53929. private _draw;
  53930. }
  53931. }
  53932. declare module BABYLON {
  53933. /** @hidden */
  53934. export var depthPixelShader: {
  53935. name: string;
  53936. shader: string;
  53937. };
  53938. }
  53939. declare module BABYLON {
  53940. /** @hidden */
  53941. export var depthVertexShader: {
  53942. name: string;
  53943. shader: string;
  53944. };
  53945. }
  53946. declare module BABYLON {
  53947. /**
  53948. * This represents a depth renderer in Babylon.
  53949. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  53950. */
  53951. export class DepthRenderer {
  53952. private _scene;
  53953. private _depthMap;
  53954. private _effect;
  53955. private readonly _storeNonLinearDepth;
  53956. private readonly _clearColor;
  53957. /** Get if the depth renderer is using packed depth or not */
  53958. readonly isPacked: boolean;
  53959. private _cachedDefines;
  53960. private _camera;
  53961. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  53962. enabled: boolean;
  53963. /**
  53964. * Specifiess that the depth renderer will only be used within
  53965. * the camera it is created for.
  53966. * This can help forcing its rendering during the camera processing.
  53967. */
  53968. useOnlyInActiveCamera: boolean;
  53969. /** @hidden */
  53970. static _SceneComponentInitialization: (scene: Scene) => void;
  53971. /**
  53972. * Instantiates a depth renderer
  53973. * @param scene The scene the renderer belongs to
  53974. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  53975. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  53976. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  53977. */
  53978. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  53979. /**
  53980. * Creates the depth rendering effect and checks if the effect is ready.
  53981. * @param subMesh The submesh to be used to render the depth map of
  53982. * @param useInstances If multiple world instances should be used
  53983. * @returns if the depth renderer is ready to render the depth map
  53984. */
  53985. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  53986. /**
  53987. * Gets the texture which the depth map will be written to.
  53988. * @returns The depth map texture
  53989. */
  53990. getDepthMap(): RenderTargetTexture;
  53991. /**
  53992. * Disposes of the depth renderer.
  53993. */
  53994. dispose(): void;
  53995. }
  53996. }
  53997. declare module BABYLON {
  53998. /** @hidden */
  53999. export var minmaxReduxPixelShader: {
  54000. name: string;
  54001. shader: string;
  54002. };
  54003. }
  54004. declare module BABYLON {
  54005. /**
  54006. * This class computes a min/max reduction from a texture: it means it computes the minimum
  54007. * and maximum values from all values of the texture.
  54008. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  54009. * The source values are read from the red channel of the texture.
  54010. */
  54011. export class MinMaxReducer {
  54012. /**
  54013. * Observable triggered when the computation has been performed
  54014. */
  54015. onAfterReductionPerformed: Observable<{
  54016. min: number;
  54017. max: number;
  54018. }>;
  54019. protected _camera: Camera;
  54020. protected _sourceTexture: Nullable<RenderTargetTexture>;
  54021. protected _reductionSteps: Nullable<Array<PostProcess>>;
  54022. protected _postProcessManager: PostProcessManager;
  54023. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  54024. protected _forceFullscreenViewport: boolean;
  54025. /**
  54026. * Creates a min/max reducer
  54027. * @param camera The camera to use for the post processes
  54028. */
  54029. constructor(camera: Camera);
  54030. /**
  54031. * Gets the texture used to read the values from.
  54032. */
  54033. get sourceTexture(): Nullable<RenderTargetTexture>;
  54034. /**
  54035. * Sets the source texture to read the values from.
  54036. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  54037. * because in such textures '1' value must not be taken into account to compute the maximum
  54038. * as this value is used to clear the texture.
  54039. * Note that the computation is not activated by calling this function, you must call activate() for that!
  54040. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  54041. * @param depthRedux Indicates if the texture is a depth texture or not
  54042. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  54043. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  54044. */
  54045. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  54046. /**
  54047. * Defines the refresh rate of the computation.
  54048. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  54049. */
  54050. get refreshRate(): number;
  54051. set refreshRate(value: number);
  54052. protected _activated: boolean;
  54053. /**
  54054. * Gets the activation status of the reducer
  54055. */
  54056. get activated(): boolean;
  54057. /**
  54058. * Activates the reduction computation.
  54059. * When activated, the observers registered in onAfterReductionPerformed are
  54060. * called after the compuation is performed
  54061. */
  54062. activate(): void;
  54063. /**
  54064. * Deactivates the reduction computation.
  54065. */
  54066. deactivate(): void;
  54067. /**
  54068. * Disposes the min/max reducer
  54069. * @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.
  54070. */
  54071. dispose(disposeAll?: boolean): void;
  54072. }
  54073. }
  54074. declare module BABYLON {
  54075. /**
  54076. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  54077. */
  54078. export class DepthReducer extends MinMaxReducer {
  54079. private _depthRenderer;
  54080. private _depthRendererId;
  54081. /**
  54082. * Gets the depth renderer used for the computation.
  54083. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  54084. */
  54085. get depthRenderer(): Nullable<DepthRenderer>;
  54086. /**
  54087. * Creates a depth reducer
  54088. * @param camera The camera used to render the depth texture
  54089. */
  54090. constructor(camera: Camera);
  54091. /**
  54092. * Sets the depth renderer to use to generate the depth map
  54093. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  54094. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  54095. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  54096. */
  54097. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  54098. /** @hidden */
  54099. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  54100. /**
  54101. * Activates the reduction computation.
  54102. * When activated, the observers registered in onAfterReductionPerformed are
  54103. * called after the compuation is performed
  54104. */
  54105. activate(): void;
  54106. /**
  54107. * Deactivates the reduction computation.
  54108. */
  54109. deactivate(): void;
  54110. /**
  54111. * Disposes the depth reducer
  54112. * @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.
  54113. */
  54114. dispose(disposeAll?: boolean): void;
  54115. }
  54116. }
  54117. declare module BABYLON {
  54118. /**
  54119. * A CSM implementation allowing casting shadows on large scenes.
  54120. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  54121. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  54122. */
  54123. export class CascadedShadowGenerator extends ShadowGenerator {
  54124. private static readonly frustumCornersNDCSpace;
  54125. /**
  54126. * Name of the CSM class
  54127. */
  54128. static CLASSNAME: string;
  54129. /**
  54130. * Defines the default number of cascades used by the CSM.
  54131. */
  54132. static readonly DEFAULT_CASCADES_COUNT: number;
  54133. /**
  54134. * Defines the minimum number of cascades used by the CSM.
  54135. */
  54136. static readonly MIN_CASCADES_COUNT: number;
  54137. /**
  54138. * Defines the maximum number of cascades used by the CSM.
  54139. */
  54140. static readonly MAX_CASCADES_COUNT: number;
  54141. protected _validateFilter(filter: number): number;
  54142. /**
  54143. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  54144. */
  54145. penumbraDarkness: number;
  54146. private _numCascades;
  54147. /**
  54148. * Gets or set the number of cascades used by the CSM.
  54149. */
  54150. get numCascades(): number;
  54151. set numCascades(value: number);
  54152. /**
  54153. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  54154. * The trade off is that you loose some precision in the shadow rendering when enabling this setting.
  54155. */
  54156. stabilizeCascades: boolean;
  54157. private _freezeShadowCastersBoundingInfo;
  54158. private _freezeShadowCastersBoundingInfoObservable;
  54159. /**
  54160. * Enables or disables the shadow casters bounding info computation.
  54161. * If your shadow casters don't move, you can disable this feature.
  54162. * If it is enabled, the bounding box computation is done every frame.
  54163. */
  54164. get freezeShadowCastersBoundingInfo(): boolean;
  54165. set freezeShadowCastersBoundingInfo(freeze: boolean);
  54166. private _scbiMin;
  54167. private _scbiMax;
  54168. protected _computeShadowCastersBoundingInfo(): void;
  54169. protected _shadowCastersBoundingInfo: BoundingInfo;
  54170. /**
  54171. * Gets or sets the shadow casters bounding info.
  54172. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  54173. * so that the system won't overwrite the bounds you provide
  54174. */
  54175. get shadowCastersBoundingInfo(): BoundingInfo;
  54176. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  54177. protected _breaksAreDirty: boolean;
  54178. protected _minDistance: number;
  54179. protected _maxDistance: number;
  54180. /**
  54181. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  54182. *
  54183. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  54184. * If you don't know these values, simply leave them to their defaults and don't call this function.
  54185. * @param min minimal distance for the breaks (default to 0.)
  54186. * @param max maximal distance for the breaks (default to 1.)
  54187. */
  54188. setMinMaxDistance(min: number, max: number): void;
  54189. /** Gets the minimal distance used in the cascade break computation */
  54190. get minDistance(): number;
  54191. /** Gets the maximal distance used in the cascade break computation */
  54192. get maxDistance(): number;
  54193. /**
  54194. * Gets the class name of that object
  54195. * @returns "CascadedShadowGenerator"
  54196. */
  54197. getClassName(): string;
  54198. private _cascadeMinExtents;
  54199. private _cascadeMaxExtents;
  54200. /**
  54201. * Gets a cascade minimum extents
  54202. * @param cascadeIndex index of the cascade
  54203. * @returns the minimum cascade extents
  54204. */
  54205. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  54206. /**
  54207. * Gets a cascade maximum extents
  54208. * @param cascadeIndex index of the cascade
  54209. * @returns the maximum cascade extents
  54210. */
  54211. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  54212. private _cascades;
  54213. private _currentLayer;
  54214. private _viewSpaceFrustumsZ;
  54215. private _viewMatrices;
  54216. private _projectionMatrices;
  54217. private _transformMatrices;
  54218. private _transformMatricesAsArray;
  54219. private _frustumLengths;
  54220. private _lightSizeUVCorrection;
  54221. private _depthCorrection;
  54222. private _frustumCornersWorldSpace;
  54223. private _frustumCenter;
  54224. private _shadowCameraPos;
  54225. private _shadowMaxZ;
  54226. /**
  54227. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  54228. * It defaults to camera.maxZ
  54229. */
  54230. get shadowMaxZ(): number;
  54231. /**
  54232. * Sets the shadow max z distance.
  54233. */
  54234. set shadowMaxZ(value: number);
  54235. protected _debug: boolean;
  54236. /**
  54237. * Gets or sets the debug flag.
  54238. * When enabled, the cascades are materialized by different colors on the screen.
  54239. */
  54240. get debug(): boolean;
  54241. set debug(dbg: boolean);
  54242. private _depthClamp;
  54243. /**
  54244. * Gets or sets the depth clamping value.
  54245. *
  54246. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  54247. * to account for the shadow casters far away.
  54248. *
  54249. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  54250. */
  54251. get depthClamp(): boolean;
  54252. set depthClamp(value: boolean);
  54253. private _cascadeBlendPercentage;
  54254. /**
  54255. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  54256. * It defaults to 0.1 (10% blending).
  54257. */
  54258. get cascadeBlendPercentage(): number;
  54259. set cascadeBlendPercentage(value: number);
  54260. private _lambda;
  54261. /**
  54262. * Gets or set the lambda parameter.
  54263. * This parameter is used to split the camera frustum and create the cascades.
  54264. * 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.
  54265. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  54266. */
  54267. get lambda(): number;
  54268. set lambda(value: number);
  54269. /**
  54270. * Gets the view matrix corresponding to a given cascade
  54271. * @param cascadeNum cascade to retrieve the view matrix from
  54272. * @returns the cascade view matrix
  54273. */
  54274. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  54275. /**
  54276. * Gets the projection matrix corresponding to a given cascade
  54277. * @param cascadeNum cascade to retrieve the projection matrix from
  54278. * @returns the cascade projection matrix
  54279. */
  54280. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  54281. /**
  54282. * Gets the transformation matrix corresponding to a given cascade
  54283. * @param cascadeNum cascade to retrieve the transformation matrix from
  54284. * @returns the cascade transformation matrix
  54285. */
  54286. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  54287. private _depthRenderer;
  54288. /**
  54289. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  54290. *
  54291. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  54292. *
  54293. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  54294. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  54295. * @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
  54296. */
  54297. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  54298. private _depthReducer;
  54299. private _autoCalcDepthBounds;
  54300. /**
  54301. * Gets or sets the autoCalcDepthBounds property.
  54302. *
  54303. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  54304. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  54305. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  54306. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  54307. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  54308. */
  54309. get autoCalcDepthBounds(): boolean;
  54310. set autoCalcDepthBounds(value: boolean);
  54311. /**
  54312. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  54313. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  54314. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  54315. * for setting the refresh rate on the renderer yourself!
  54316. */
  54317. get autoCalcDepthBoundsRefreshRate(): number;
  54318. set autoCalcDepthBoundsRefreshRate(value: number);
  54319. /**
  54320. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  54321. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  54322. * you change the camera near/far planes!
  54323. */
  54324. splitFrustum(): void;
  54325. private _splitFrustum;
  54326. private _computeMatrices;
  54327. private _computeFrustumInWorldSpace;
  54328. private _computeCascadeFrustum;
  54329. /** @hidden */
  54330. static _SceneComponentInitialization: (scene: Scene) => void;
  54331. /**
  54332. * Creates a Cascaded Shadow Generator object.
  54333. * A ShadowGenerator is the required tool to use the shadows.
  54334. * Each directional light casting shadows needs to use its own ShadowGenerator.
  54335. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  54336. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  54337. * @param light The directional light object generating the shadows.
  54338. * @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.
  54339. */
  54340. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  54341. protected _initializeGenerator(): void;
  54342. protected _createTargetRenderTexture(): void;
  54343. protected _initializeShadowMap(): void;
  54344. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect): void;
  54345. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  54346. /**
  54347. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  54348. * @param defines Defines of the material we want to update
  54349. * @param lightIndex Index of the light in the enabled light list of the material
  54350. */
  54351. prepareDefines(defines: any, lightIndex: number): void;
  54352. /**
  54353. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  54354. * defined in the generator but impacting the effect).
  54355. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  54356. * @param effect The effect we are binfing the information for
  54357. */
  54358. bindShadowLight(lightIndex: string, effect: Effect): void;
  54359. /**
  54360. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  54361. * (eq to view projection * shadow projection matrices)
  54362. * @returns The transform matrix used to create the shadow map
  54363. */
  54364. getTransformMatrix(): Matrix;
  54365. /**
  54366. * Disposes the ShadowGenerator.
  54367. * Returns nothing.
  54368. */
  54369. dispose(): void;
  54370. /**
  54371. * Serializes the shadow generator setup to a json object.
  54372. * @returns The serialized JSON object
  54373. */
  54374. serialize(): any;
  54375. /**
  54376. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  54377. * @param parsedShadowGenerator The JSON object to parse
  54378. * @param scene The scene to create the shadow map for
  54379. * @returns The parsed shadow generator
  54380. */
  54381. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  54382. }
  54383. }
  54384. declare module BABYLON {
  54385. /**
  54386. * Defines the shadow generator component responsible to manage any shadow generators
  54387. * in a given scene.
  54388. */
  54389. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  54390. /**
  54391. * The component name helpfull to identify the component in the list of scene components.
  54392. */
  54393. readonly name: string;
  54394. /**
  54395. * The scene the component belongs to.
  54396. */
  54397. scene: Scene;
  54398. /**
  54399. * Creates a new instance of the component for the given scene
  54400. * @param scene Defines the scene to register the component in
  54401. */
  54402. constructor(scene: Scene);
  54403. /**
  54404. * Registers the component in a given scene
  54405. */
  54406. register(): void;
  54407. /**
  54408. * Rebuilds the elements related to this component in case of
  54409. * context lost for instance.
  54410. */
  54411. rebuild(): void;
  54412. /**
  54413. * Serializes the component data to the specified json object
  54414. * @param serializationObject The object to serialize to
  54415. */
  54416. serialize(serializationObject: any): void;
  54417. /**
  54418. * Adds all the elements from the container to the scene
  54419. * @param container the container holding the elements
  54420. */
  54421. addFromContainer(container: AbstractScene): void;
  54422. /**
  54423. * Removes all the elements in the container from the scene
  54424. * @param container contains the elements to remove
  54425. * @param dispose if the removed element should be disposed (default: false)
  54426. */
  54427. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  54428. /**
  54429. * Rebuilds the elements related to this component in case of
  54430. * context lost for instance.
  54431. */
  54432. dispose(): void;
  54433. private _gatherRenderTargets;
  54434. }
  54435. }
  54436. declare module BABYLON {
  54437. /**
  54438. * A point light is a light defined by an unique point in world space.
  54439. * The light is emitted in every direction from this point.
  54440. * A good example of a point light is a standard light bulb.
  54441. * Documentation: https://doc.babylonjs.com/babylon101/lights
  54442. */
  54443. export class PointLight extends ShadowLight {
  54444. private _shadowAngle;
  54445. /**
  54446. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  54447. * This specifies what angle the shadow will use to be created.
  54448. *
  54449. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  54450. */
  54451. get shadowAngle(): number;
  54452. /**
  54453. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  54454. * This specifies what angle the shadow will use to be created.
  54455. *
  54456. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  54457. */
  54458. set shadowAngle(value: number);
  54459. /**
  54460. * Gets the direction if it has been set.
  54461. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  54462. */
  54463. get direction(): Vector3;
  54464. /**
  54465. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  54466. */
  54467. set direction(value: Vector3);
  54468. /**
  54469. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  54470. * A PointLight emits the light in every direction.
  54471. * It can cast shadows.
  54472. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  54473. * ```javascript
  54474. * var pointLight = new PointLight("pl", camera.position, scene);
  54475. * ```
  54476. * Documentation : https://doc.babylonjs.com/babylon101/lights
  54477. * @param name The light friendly name
  54478. * @param position The position of the point light in the scene
  54479. * @param scene The scene the lights belongs to
  54480. */
  54481. constructor(name: string, position: Vector3, scene: Scene);
  54482. /**
  54483. * Returns the string "PointLight"
  54484. * @returns the class name
  54485. */
  54486. getClassName(): string;
  54487. /**
  54488. * Returns the integer 0.
  54489. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  54490. */
  54491. getTypeID(): number;
  54492. /**
  54493. * Specifies wether or not the shadowmap should be a cube texture.
  54494. * @returns true if the shadowmap needs to be a cube texture.
  54495. */
  54496. needCube(): boolean;
  54497. /**
  54498. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  54499. * @param faceIndex The index of the face we are computed the direction to generate shadow
  54500. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  54501. */
  54502. getShadowDirection(faceIndex?: number): Vector3;
  54503. /**
  54504. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  54505. * - fov = PI / 2
  54506. * - aspect ratio : 1.0
  54507. * - z-near and far equal to the active camera minZ and maxZ.
  54508. * Returns the PointLight.
  54509. */
  54510. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  54511. protected _buildUniformLayout(): void;
  54512. /**
  54513. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  54514. * @param effect The effect to update
  54515. * @param lightIndex The index of the light in the effect to update
  54516. * @returns The point light
  54517. */
  54518. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  54519. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  54520. /**
  54521. * Prepares the list of defines specific to the light type.
  54522. * @param defines the list of defines
  54523. * @param lightIndex defines the index of the light for the effect
  54524. */
  54525. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  54526. }
  54527. }
  54528. declare module BABYLON {
  54529. /**
  54530. * Header information of HDR texture files.
  54531. */
  54532. export interface HDRInfo {
  54533. /**
  54534. * The height of the texture in pixels.
  54535. */
  54536. height: number;
  54537. /**
  54538. * The width of the texture in pixels.
  54539. */
  54540. width: number;
  54541. /**
  54542. * The index of the beginning of the data in the binary file.
  54543. */
  54544. dataPosition: number;
  54545. }
  54546. /**
  54547. * This groups tools to convert HDR texture to native colors array.
  54548. */
  54549. export class HDRTools {
  54550. private static Ldexp;
  54551. private static Rgbe2float;
  54552. private static readStringLine;
  54553. /**
  54554. * Reads header information from an RGBE texture stored in a native array.
  54555. * More information on this format are available here:
  54556. * https://en.wikipedia.org/wiki/RGBE_image_format
  54557. *
  54558. * @param uint8array The binary file stored in native array.
  54559. * @return The header information.
  54560. */
  54561. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  54562. /**
  54563. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  54564. * This RGBE texture needs to store the information as a panorama.
  54565. *
  54566. * More information on this format are available here:
  54567. * https://en.wikipedia.org/wiki/RGBE_image_format
  54568. *
  54569. * @param buffer The binary file stored in an array buffer.
  54570. * @param size The expected size of the extracted cubemap.
  54571. * @return The Cube Map information.
  54572. */
  54573. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  54574. /**
  54575. * Returns the pixels data extracted from an RGBE texture.
  54576. * This pixels will be stored left to right up to down in the R G B order in one array.
  54577. *
  54578. * More information on this format are available here:
  54579. * https://en.wikipedia.org/wiki/RGBE_image_format
  54580. *
  54581. * @param uint8array The binary file stored in an array buffer.
  54582. * @param hdrInfo The header information of the file.
  54583. * @return The pixels data in RGB right to left up to down order.
  54584. */
  54585. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  54586. private static RGBE_ReadPixels_RLE;
  54587. }
  54588. }
  54589. declare module BABYLON {
  54590. /**
  54591. * This represents a texture coming from an HDR input.
  54592. *
  54593. * The only supported format is currently panorama picture stored in RGBE format.
  54594. * Example of such files can be found on HDRLib: http://hdrlib.com/
  54595. */
  54596. export class HDRCubeTexture extends BaseTexture {
  54597. private static _facesMapping;
  54598. private _generateHarmonics;
  54599. private _noMipmap;
  54600. private _textureMatrix;
  54601. private _size;
  54602. private _onLoad;
  54603. private _onError;
  54604. /**
  54605. * The texture URL.
  54606. */
  54607. url: string;
  54608. /**
  54609. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  54610. */
  54611. coordinatesMode: number;
  54612. protected _isBlocking: boolean;
  54613. /**
  54614. * Sets wether or not the texture is blocking during loading.
  54615. */
  54616. set isBlocking(value: boolean);
  54617. /**
  54618. * Gets wether or not the texture is blocking during loading.
  54619. */
  54620. get isBlocking(): boolean;
  54621. protected _rotationY: number;
  54622. /**
  54623. * Sets texture matrix rotation angle around Y axis in radians.
  54624. */
  54625. set rotationY(value: number);
  54626. /**
  54627. * Gets texture matrix rotation angle around Y axis radians.
  54628. */
  54629. get rotationY(): number;
  54630. /**
  54631. * Gets or sets the center of the bounding box associated with the cube texture
  54632. * It must define where the camera used to render the texture was set
  54633. */
  54634. boundingBoxPosition: Vector3;
  54635. private _boundingBoxSize;
  54636. /**
  54637. * Gets or sets the size of the bounding box associated with the cube texture
  54638. * When defined, the cubemap will switch to local mode
  54639. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  54640. * @example https://www.babylonjs-playground.com/#RNASML
  54641. */
  54642. set boundingBoxSize(value: Vector3);
  54643. get boundingBoxSize(): Vector3;
  54644. /**
  54645. * Instantiates an HDRTexture from the following parameters.
  54646. *
  54647. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  54648. * @param scene The scene the texture will be used in
  54649. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  54650. * @param noMipmap Forces to not generate the mipmap if true
  54651. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  54652. * @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)
  54653. * @param reserved Reserved flag for internal use.
  54654. */
  54655. 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>);
  54656. /**
  54657. * Get the current class name of the texture useful for serialization or dynamic coding.
  54658. * @returns "HDRCubeTexture"
  54659. */
  54660. getClassName(): string;
  54661. /**
  54662. * Occurs when the file is raw .hdr file.
  54663. */
  54664. private loadTexture;
  54665. clone(): HDRCubeTexture;
  54666. delayLoad(): void;
  54667. /**
  54668. * Get the texture reflection matrix used to rotate/transform the reflection.
  54669. * @returns the reflection matrix
  54670. */
  54671. getReflectionTextureMatrix(): Matrix;
  54672. /**
  54673. * Set the texture reflection matrix used to rotate/transform the reflection.
  54674. * @param value Define the reflection matrix to set
  54675. */
  54676. setReflectionTextureMatrix(value: Matrix): void;
  54677. /**
  54678. * Parses a JSON representation of an HDR Texture in order to create the texture
  54679. * @param parsedTexture Define the JSON representation
  54680. * @param scene Define the scene the texture should be created in
  54681. * @param rootUrl Define the root url in case we need to load relative dependencies
  54682. * @returns the newly created texture after parsing
  54683. */
  54684. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  54685. serialize(): any;
  54686. }
  54687. }
  54688. declare module BABYLON {
  54689. /**
  54690. * Class used to control physics engine
  54691. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  54692. */
  54693. export class PhysicsEngine implements IPhysicsEngine {
  54694. private _physicsPlugin;
  54695. /**
  54696. * Global value used to control the smallest number supported by the simulation
  54697. */
  54698. static Epsilon: number;
  54699. private _impostors;
  54700. private _joints;
  54701. private _subTimeStep;
  54702. /**
  54703. * Gets the gravity vector used by the simulation
  54704. */
  54705. gravity: Vector3;
  54706. /**
  54707. * Factory used to create the default physics plugin.
  54708. * @returns The default physics plugin
  54709. */
  54710. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  54711. /**
  54712. * Creates a new Physics Engine
  54713. * @param gravity defines the gravity vector used by the simulation
  54714. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  54715. */
  54716. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  54717. /**
  54718. * Sets the gravity vector used by the simulation
  54719. * @param gravity defines the gravity vector to use
  54720. */
  54721. setGravity(gravity: Vector3): void;
  54722. /**
  54723. * Set the time step of the physics engine.
  54724. * Default is 1/60.
  54725. * To slow it down, enter 1/600 for example.
  54726. * To speed it up, 1/30
  54727. * @param newTimeStep defines the new timestep to apply to this world.
  54728. */
  54729. setTimeStep(newTimeStep?: number): void;
  54730. /**
  54731. * Get the time step of the physics engine.
  54732. * @returns the current time step
  54733. */
  54734. getTimeStep(): number;
  54735. /**
  54736. * Set the sub time step of the physics engine.
  54737. * Default is 0 meaning there is no sub steps
  54738. * To increase physics resolution precision, set a small value (like 1 ms)
  54739. * @param subTimeStep defines the new sub timestep used for physics resolution.
  54740. */
  54741. setSubTimeStep(subTimeStep?: number): void;
  54742. /**
  54743. * Get the sub time step of the physics engine.
  54744. * @returns the current sub time step
  54745. */
  54746. getSubTimeStep(): number;
  54747. /**
  54748. * Release all resources
  54749. */
  54750. dispose(): void;
  54751. /**
  54752. * Gets the name of the current physics plugin
  54753. * @returns the name of the plugin
  54754. */
  54755. getPhysicsPluginName(): string;
  54756. /**
  54757. * Adding a new impostor for the impostor tracking.
  54758. * This will be done by the impostor itself.
  54759. * @param impostor the impostor to add
  54760. */
  54761. addImpostor(impostor: PhysicsImpostor): void;
  54762. /**
  54763. * Remove an impostor from the engine.
  54764. * This impostor and its mesh will not longer be updated by the physics engine.
  54765. * @param impostor the impostor to remove
  54766. */
  54767. removeImpostor(impostor: PhysicsImpostor): void;
  54768. /**
  54769. * Add a joint to the physics engine
  54770. * @param mainImpostor defines the main impostor to which the joint is added.
  54771. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  54772. * @param joint defines the joint that will connect both impostors.
  54773. */
  54774. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  54775. /**
  54776. * Removes a joint from the simulation
  54777. * @param mainImpostor defines the impostor used with the joint
  54778. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  54779. * @param joint defines the joint to remove
  54780. */
  54781. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  54782. /**
  54783. * Called by the scene. No need to call it.
  54784. * @param delta defines the timespam between frames
  54785. */
  54786. _step(delta: number): void;
  54787. /**
  54788. * Gets the current plugin used to run the simulation
  54789. * @returns current plugin
  54790. */
  54791. getPhysicsPlugin(): IPhysicsEnginePlugin;
  54792. /**
  54793. * Gets the list of physic impostors
  54794. * @returns an array of PhysicsImpostor
  54795. */
  54796. getImpostors(): Array<PhysicsImpostor>;
  54797. /**
  54798. * Gets the impostor for a physics enabled object
  54799. * @param object defines the object impersonated by the impostor
  54800. * @returns the PhysicsImpostor or null if not found
  54801. */
  54802. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  54803. /**
  54804. * Gets the impostor for a physics body object
  54805. * @param body defines physics body used by the impostor
  54806. * @returns the PhysicsImpostor or null if not found
  54807. */
  54808. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  54809. /**
  54810. * Does a raycast in the physics world
  54811. * @param from when should the ray start?
  54812. * @param to when should the ray end?
  54813. * @returns PhysicsRaycastResult
  54814. */
  54815. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  54816. }
  54817. }
  54818. declare module BABYLON {
  54819. /** @hidden */
  54820. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  54821. private _useDeltaForWorldStep;
  54822. world: any;
  54823. name: string;
  54824. private _physicsMaterials;
  54825. private _fixedTimeStep;
  54826. private _cannonRaycastResult;
  54827. private _raycastResult;
  54828. private _physicsBodysToRemoveAfterStep;
  54829. BJSCANNON: any;
  54830. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  54831. setGravity(gravity: Vector3): void;
  54832. setTimeStep(timeStep: number): void;
  54833. getTimeStep(): number;
  54834. executeStep(delta: number): void;
  54835. private _removeMarkedPhysicsBodiesFromWorld;
  54836. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  54837. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  54838. generatePhysicsBody(impostor: PhysicsImpostor): void;
  54839. private _processChildMeshes;
  54840. removePhysicsBody(impostor: PhysicsImpostor): void;
  54841. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  54842. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  54843. private _addMaterial;
  54844. private _checkWithEpsilon;
  54845. private _createShape;
  54846. private _createHeightmap;
  54847. private _minus90X;
  54848. private _plus90X;
  54849. private _tmpPosition;
  54850. private _tmpDeltaPosition;
  54851. private _tmpUnityRotation;
  54852. private _updatePhysicsBodyTransformation;
  54853. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  54854. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  54855. isSupported(): boolean;
  54856. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  54857. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  54858. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  54859. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  54860. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  54861. getBodyMass(impostor: PhysicsImpostor): number;
  54862. getBodyFriction(impostor: PhysicsImpostor): number;
  54863. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  54864. getBodyRestitution(impostor: PhysicsImpostor): number;
  54865. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  54866. sleepBody(impostor: PhysicsImpostor): void;
  54867. wakeUpBody(impostor: PhysicsImpostor): void;
  54868. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  54869. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  54870. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  54871. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  54872. getRadius(impostor: PhysicsImpostor): number;
  54873. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  54874. dispose(): void;
  54875. private _extendNamespace;
  54876. /**
  54877. * Does a raycast in the physics world
  54878. * @param from when should the ray start?
  54879. * @param to when should the ray end?
  54880. * @returns PhysicsRaycastResult
  54881. */
  54882. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  54883. }
  54884. }
  54885. declare module BABYLON {
  54886. /** @hidden */
  54887. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  54888. world: any;
  54889. name: string;
  54890. BJSOIMO: any;
  54891. private _raycastResult;
  54892. constructor(iterations?: number, oimoInjection?: any);
  54893. setGravity(gravity: Vector3): void;
  54894. setTimeStep(timeStep: number): void;
  54895. getTimeStep(): number;
  54896. private _tmpImpostorsArray;
  54897. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  54898. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  54899. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  54900. generatePhysicsBody(impostor: PhysicsImpostor): void;
  54901. private _tmpPositionVector;
  54902. removePhysicsBody(impostor: PhysicsImpostor): void;
  54903. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  54904. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  54905. isSupported(): boolean;
  54906. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  54907. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  54908. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  54909. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  54910. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  54911. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  54912. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  54913. getBodyMass(impostor: PhysicsImpostor): number;
  54914. getBodyFriction(impostor: PhysicsImpostor): number;
  54915. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  54916. getBodyRestitution(impostor: PhysicsImpostor): number;
  54917. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  54918. sleepBody(impostor: PhysicsImpostor): void;
  54919. wakeUpBody(impostor: PhysicsImpostor): void;
  54920. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  54921. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  54922. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  54923. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  54924. getRadius(impostor: PhysicsImpostor): number;
  54925. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  54926. dispose(): void;
  54927. /**
  54928. * Does a raycast in the physics world
  54929. * @param from when should the ray start?
  54930. * @param to when should the ray end?
  54931. * @returns PhysicsRaycastResult
  54932. */
  54933. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  54934. }
  54935. }
  54936. declare module BABYLON {
  54937. /**
  54938. * Class containing static functions to help procedurally build meshes
  54939. */
  54940. export class RibbonBuilder {
  54941. /**
  54942. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  54943. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  54944. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  54945. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  54946. * * 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
  54947. * * 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
  54948. * * 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
  54949. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54950. * * 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
  54951. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  54952. * * 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
  54953. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  54954. * * 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
  54955. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  54956. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54957. * @param name defines the name of the mesh
  54958. * @param options defines the options used to create the mesh
  54959. * @param scene defines the hosting scene
  54960. * @returns the ribbon mesh
  54961. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  54962. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  54963. */
  54964. static CreateRibbon(name: string, options: {
  54965. pathArray: Vector3[][];
  54966. closeArray?: boolean;
  54967. closePath?: boolean;
  54968. offset?: number;
  54969. updatable?: boolean;
  54970. sideOrientation?: number;
  54971. frontUVs?: Vector4;
  54972. backUVs?: Vector4;
  54973. instance?: Mesh;
  54974. invertUV?: boolean;
  54975. uvs?: Vector2[];
  54976. colors?: Color4[];
  54977. }, scene?: Nullable<Scene>): Mesh;
  54978. }
  54979. }
  54980. declare module BABYLON {
  54981. /**
  54982. * Class containing static functions to help procedurally build meshes
  54983. */
  54984. export class ShapeBuilder {
  54985. /**
  54986. * 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.
  54987. * * 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.
  54988. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  54989. * * 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.
  54990. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  54991. * * 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
  54992. * * 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
  54993. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  54994. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54995. * * 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
  54996. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  54997. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  54998. * @param name defines the name of the mesh
  54999. * @param options defines the options used to create the mesh
  55000. * @param scene defines the hosting scene
  55001. * @returns the extruded shape mesh
  55002. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55003. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  55004. */
  55005. static ExtrudeShape(name: string, options: {
  55006. shape: Vector3[];
  55007. path: Vector3[];
  55008. scale?: number;
  55009. rotation?: number;
  55010. cap?: number;
  55011. updatable?: boolean;
  55012. sideOrientation?: number;
  55013. frontUVs?: Vector4;
  55014. backUVs?: Vector4;
  55015. instance?: Mesh;
  55016. invertUV?: boolean;
  55017. }, scene?: Nullable<Scene>): Mesh;
  55018. /**
  55019. * Creates an custom extruded shape mesh.
  55020. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  55021. * * 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.
  55022. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  55023. * * 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
  55024. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  55025. * * 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
  55026. * * It must returns a float value that will be the scale value applied to the shape on each path point
  55027. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  55028. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  55029. * * 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
  55030. * * 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
  55031. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  55032. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55033. * * 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
  55034. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55035. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55036. * @param name defines the name of the mesh
  55037. * @param options defines the options used to create the mesh
  55038. * @param scene defines the hosting scene
  55039. * @returns the custom extruded shape mesh
  55040. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  55041. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55042. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  55043. */
  55044. static ExtrudeShapeCustom(name: string, options: {
  55045. shape: Vector3[];
  55046. path: Vector3[];
  55047. scaleFunction?: any;
  55048. rotationFunction?: any;
  55049. ribbonCloseArray?: boolean;
  55050. ribbonClosePath?: boolean;
  55051. cap?: number;
  55052. updatable?: boolean;
  55053. sideOrientation?: number;
  55054. frontUVs?: Vector4;
  55055. backUVs?: Vector4;
  55056. instance?: Mesh;
  55057. invertUV?: boolean;
  55058. }, scene?: Nullable<Scene>): Mesh;
  55059. private static _ExtrudeShapeGeneric;
  55060. }
  55061. }
  55062. declare module BABYLON {
  55063. /**
  55064. * AmmoJS Physics plugin
  55065. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  55066. * @see https://github.com/kripken/ammo.js/
  55067. */
  55068. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  55069. private _useDeltaForWorldStep;
  55070. /**
  55071. * Reference to the Ammo library
  55072. */
  55073. bjsAMMO: any;
  55074. /**
  55075. * Created ammoJS world which physics bodies are added to
  55076. */
  55077. world: any;
  55078. /**
  55079. * Name of the plugin
  55080. */
  55081. name: string;
  55082. private _timeStep;
  55083. private _fixedTimeStep;
  55084. private _maxSteps;
  55085. private _tmpQuaternion;
  55086. private _tmpAmmoTransform;
  55087. private _tmpAmmoQuaternion;
  55088. private _tmpAmmoConcreteContactResultCallback;
  55089. private _collisionConfiguration;
  55090. private _dispatcher;
  55091. private _overlappingPairCache;
  55092. private _solver;
  55093. private _softBodySolver;
  55094. private _tmpAmmoVectorA;
  55095. private _tmpAmmoVectorB;
  55096. private _tmpAmmoVectorC;
  55097. private _tmpAmmoVectorD;
  55098. private _tmpContactCallbackResult;
  55099. private _tmpAmmoVectorRCA;
  55100. private _tmpAmmoVectorRCB;
  55101. private _raycastResult;
  55102. private static readonly DISABLE_COLLISION_FLAG;
  55103. private static readonly KINEMATIC_FLAG;
  55104. private static readonly DISABLE_DEACTIVATION_FLAG;
  55105. /**
  55106. * Initializes the ammoJS plugin
  55107. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  55108. * @param ammoInjection can be used to inject your own ammo reference
  55109. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  55110. */
  55111. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  55112. /**
  55113. * Sets the gravity of the physics world (m/(s^2))
  55114. * @param gravity Gravity to set
  55115. */
  55116. setGravity(gravity: Vector3): void;
  55117. /**
  55118. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  55119. * @param timeStep timestep to use in seconds
  55120. */
  55121. setTimeStep(timeStep: number): void;
  55122. /**
  55123. * 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)
  55124. * @param fixedTimeStep fixedTimeStep to use in seconds
  55125. */
  55126. setFixedTimeStep(fixedTimeStep: number): void;
  55127. /**
  55128. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  55129. * @param maxSteps the maximum number of steps by the physics engine per frame
  55130. */
  55131. setMaxSteps(maxSteps: number): void;
  55132. /**
  55133. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  55134. * @returns the current timestep in seconds
  55135. */
  55136. getTimeStep(): number;
  55137. /**
  55138. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  55139. */
  55140. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  55141. private _isImpostorInContact;
  55142. private _isImpostorPairInContact;
  55143. private _stepSimulation;
  55144. /**
  55145. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  55146. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  55147. * After the step the babylon meshes are set to the position of the physics imposters
  55148. * @param delta amount of time to step forward
  55149. * @param impostors array of imposters to update before/after the step
  55150. */
  55151. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  55152. /**
  55153. * Update babylon mesh to match physics world object
  55154. * @param impostor imposter to match
  55155. */
  55156. private _afterSoftStep;
  55157. /**
  55158. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  55159. * @param impostor imposter to match
  55160. */
  55161. private _ropeStep;
  55162. /**
  55163. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  55164. * @param impostor imposter to match
  55165. */
  55166. private _softbodyOrClothStep;
  55167. private _tmpVector;
  55168. private _tmpMatrix;
  55169. /**
  55170. * Applies an impulse on the imposter
  55171. * @param impostor imposter to apply impulse to
  55172. * @param force amount of force to be applied to the imposter
  55173. * @param contactPoint the location to apply the impulse on the imposter
  55174. */
  55175. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55176. /**
  55177. * Applies a force on the imposter
  55178. * @param impostor imposter to apply force
  55179. * @param force amount of force to be applied to the imposter
  55180. * @param contactPoint the location to apply the force on the imposter
  55181. */
  55182. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55183. /**
  55184. * Creates a physics body using the plugin
  55185. * @param impostor the imposter to create the physics body on
  55186. */
  55187. generatePhysicsBody(impostor: PhysicsImpostor): void;
  55188. /**
  55189. * Removes the physics body from the imposter and disposes of the body's memory
  55190. * @param impostor imposter to remove the physics body from
  55191. */
  55192. removePhysicsBody(impostor: PhysicsImpostor): void;
  55193. /**
  55194. * Generates a joint
  55195. * @param impostorJoint the imposter joint to create the joint with
  55196. */
  55197. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  55198. /**
  55199. * Removes a joint
  55200. * @param impostorJoint the imposter joint to remove the joint from
  55201. */
  55202. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  55203. private _addMeshVerts;
  55204. /**
  55205. * Initialise the soft body vertices to match its object's (mesh) vertices
  55206. * Softbody vertices (nodes) are in world space and to match this
  55207. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  55208. * @param impostor to create the softbody for
  55209. */
  55210. private _softVertexData;
  55211. /**
  55212. * Create an impostor's soft body
  55213. * @param impostor to create the softbody for
  55214. */
  55215. private _createSoftbody;
  55216. /**
  55217. * Create cloth for an impostor
  55218. * @param impostor to create the softbody for
  55219. */
  55220. private _createCloth;
  55221. /**
  55222. * Create rope for an impostor
  55223. * @param impostor to create the softbody for
  55224. */
  55225. private _createRope;
  55226. /**
  55227. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  55228. * @param impostor to create the custom physics shape for
  55229. */
  55230. private _createCustom;
  55231. private _addHullVerts;
  55232. private _createShape;
  55233. /**
  55234. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  55235. * @param impostor imposter containing the physics body and babylon object
  55236. */
  55237. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  55238. /**
  55239. * Sets the babylon object's position/rotation from the physics body's position/rotation
  55240. * @param impostor imposter containing the physics body and babylon object
  55241. * @param newPosition new position
  55242. * @param newRotation new rotation
  55243. */
  55244. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  55245. /**
  55246. * If this plugin is supported
  55247. * @returns true if its supported
  55248. */
  55249. isSupported(): boolean;
  55250. /**
  55251. * Sets the linear velocity of the physics body
  55252. * @param impostor imposter to set the velocity on
  55253. * @param velocity velocity to set
  55254. */
  55255. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55256. /**
  55257. * Sets the angular velocity of the physics body
  55258. * @param impostor imposter to set the velocity on
  55259. * @param velocity velocity to set
  55260. */
  55261. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55262. /**
  55263. * gets the linear velocity
  55264. * @param impostor imposter to get linear velocity from
  55265. * @returns linear velocity
  55266. */
  55267. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55268. /**
  55269. * gets the angular velocity
  55270. * @param impostor imposter to get angular velocity from
  55271. * @returns angular velocity
  55272. */
  55273. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55274. /**
  55275. * Sets the mass of physics body
  55276. * @param impostor imposter to set the mass on
  55277. * @param mass mass to set
  55278. */
  55279. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  55280. /**
  55281. * Gets the mass of the physics body
  55282. * @param impostor imposter to get the mass from
  55283. * @returns mass
  55284. */
  55285. getBodyMass(impostor: PhysicsImpostor): number;
  55286. /**
  55287. * Gets friction of the impostor
  55288. * @param impostor impostor to get friction from
  55289. * @returns friction value
  55290. */
  55291. getBodyFriction(impostor: PhysicsImpostor): number;
  55292. /**
  55293. * Sets friction of the impostor
  55294. * @param impostor impostor to set friction on
  55295. * @param friction friction value
  55296. */
  55297. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  55298. /**
  55299. * Gets restitution of the impostor
  55300. * @param impostor impostor to get restitution from
  55301. * @returns restitution value
  55302. */
  55303. getBodyRestitution(impostor: PhysicsImpostor): number;
  55304. /**
  55305. * Sets resitution of the impostor
  55306. * @param impostor impostor to set resitution on
  55307. * @param restitution resitution value
  55308. */
  55309. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  55310. /**
  55311. * Gets pressure inside the impostor
  55312. * @param impostor impostor to get pressure from
  55313. * @returns pressure value
  55314. */
  55315. getBodyPressure(impostor: PhysicsImpostor): number;
  55316. /**
  55317. * Sets pressure inside a soft body impostor
  55318. * Cloth and rope must remain 0 pressure
  55319. * @param impostor impostor to set pressure on
  55320. * @param pressure pressure value
  55321. */
  55322. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  55323. /**
  55324. * Gets stiffness of the impostor
  55325. * @param impostor impostor to get stiffness from
  55326. * @returns pressure value
  55327. */
  55328. getBodyStiffness(impostor: PhysicsImpostor): number;
  55329. /**
  55330. * Sets stiffness of the impostor
  55331. * @param impostor impostor to set stiffness on
  55332. * @param stiffness stiffness value from 0 to 1
  55333. */
  55334. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  55335. /**
  55336. * Gets velocityIterations of the impostor
  55337. * @param impostor impostor to get velocity iterations from
  55338. * @returns velocityIterations value
  55339. */
  55340. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  55341. /**
  55342. * Sets velocityIterations of the impostor
  55343. * @param impostor impostor to set velocity iterations on
  55344. * @param velocityIterations velocityIterations value
  55345. */
  55346. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  55347. /**
  55348. * Gets positionIterations of the impostor
  55349. * @param impostor impostor to get position iterations from
  55350. * @returns positionIterations value
  55351. */
  55352. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  55353. /**
  55354. * Sets positionIterations of the impostor
  55355. * @param impostor impostor to set position on
  55356. * @param positionIterations positionIterations value
  55357. */
  55358. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  55359. /**
  55360. * Append an anchor to a cloth object
  55361. * @param impostor is the cloth impostor to add anchor to
  55362. * @param otherImpostor is the rigid impostor to anchor to
  55363. * @param width ratio across width from 0 to 1
  55364. * @param height ratio up height from 0 to 1
  55365. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  55366. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  55367. */
  55368. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  55369. /**
  55370. * Append an hook to a rope object
  55371. * @param impostor is the rope impostor to add hook to
  55372. * @param otherImpostor is the rigid impostor to hook to
  55373. * @param length ratio along the rope from 0 to 1
  55374. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  55375. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  55376. */
  55377. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  55378. /**
  55379. * Sleeps the physics body and stops it from being active
  55380. * @param impostor impostor to sleep
  55381. */
  55382. sleepBody(impostor: PhysicsImpostor): void;
  55383. /**
  55384. * Activates the physics body
  55385. * @param impostor impostor to activate
  55386. */
  55387. wakeUpBody(impostor: PhysicsImpostor): void;
  55388. /**
  55389. * Updates the distance parameters of the joint
  55390. * @param joint joint to update
  55391. * @param maxDistance maximum distance of the joint
  55392. * @param minDistance minimum distance of the joint
  55393. */
  55394. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  55395. /**
  55396. * Sets a motor on the joint
  55397. * @param joint joint to set motor on
  55398. * @param speed speed of the motor
  55399. * @param maxForce maximum force of the motor
  55400. * @param motorIndex index of the motor
  55401. */
  55402. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  55403. /**
  55404. * Sets the motors limit
  55405. * @param joint joint to set limit on
  55406. * @param upperLimit upper limit
  55407. * @param lowerLimit lower limit
  55408. */
  55409. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  55410. /**
  55411. * Syncs the position and rotation of a mesh with the impostor
  55412. * @param mesh mesh to sync
  55413. * @param impostor impostor to update the mesh with
  55414. */
  55415. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  55416. /**
  55417. * Gets the radius of the impostor
  55418. * @param impostor impostor to get radius from
  55419. * @returns the radius
  55420. */
  55421. getRadius(impostor: PhysicsImpostor): number;
  55422. /**
  55423. * Gets the box size of the impostor
  55424. * @param impostor impostor to get box size from
  55425. * @param result the resulting box size
  55426. */
  55427. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  55428. /**
  55429. * Disposes of the impostor
  55430. */
  55431. dispose(): void;
  55432. /**
  55433. * Does a raycast in the physics world
  55434. * @param from when should the ray start?
  55435. * @param to when should the ray end?
  55436. * @returns PhysicsRaycastResult
  55437. */
  55438. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  55439. }
  55440. }
  55441. declare module BABYLON {
  55442. interface AbstractScene {
  55443. /**
  55444. * The list of reflection probes added to the scene
  55445. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  55446. */
  55447. reflectionProbes: Array<ReflectionProbe>;
  55448. /**
  55449. * Removes the given reflection probe from this scene.
  55450. * @param toRemove The reflection probe to remove
  55451. * @returns The index of the removed reflection probe
  55452. */
  55453. removeReflectionProbe(toRemove: ReflectionProbe): number;
  55454. /**
  55455. * Adds the given reflection probe to this scene.
  55456. * @param newReflectionProbe The reflection probe to add
  55457. */
  55458. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  55459. }
  55460. /**
  55461. * Class used to generate realtime reflection / refraction cube textures
  55462. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  55463. */
  55464. export class ReflectionProbe {
  55465. /** defines the name of the probe */
  55466. name: string;
  55467. private _scene;
  55468. private _renderTargetTexture;
  55469. private _projectionMatrix;
  55470. private _viewMatrix;
  55471. private _target;
  55472. private _add;
  55473. private _attachedMesh;
  55474. private _invertYAxis;
  55475. /** Gets or sets probe position (center of the cube map) */
  55476. position: Vector3;
  55477. /**
  55478. * Creates a new reflection probe
  55479. * @param name defines the name of the probe
  55480. * @param size defines the texture resolution (for each face)
  55481. * @param scene defines the hosting scene
  55482. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  55483. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  55484. */
  55485. constructor(
  55486. /** defines the name of the probe */
  55487. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  55488. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  55489. get samples(): number;
  55490. set samples(value: number);
  55491. /** Gets or sets the refresh rate to use (on every frame by default) */
  55492. get refreshRate(): number;
  55493. set refreshRate(value: number);
  55494. /**
  55495. * Gets the hosting scene
  55496. * @returns a Scene
  55497. */
  55498. getScene(): Scene;
  55499. /** Gets the internal CubeTexture used to render to */
  55500. get cubeTexture(): RenderTargetTexture;
  55501. /** Gets the list of meshes to render */
  55502. get renderList(): Nullable<AbstractMesh[]>;
  55503. /**
  55504. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  55505. * @param mesh defines the mesh to attach to
  55506. */
  55507. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  55508. /**
  55509. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  55510. * @param renderingGroupId The rendering group id corresponding to its index
  55511. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  55512. */
  55513. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  55514. /**
  55515. * Clean all associated resources
  55516. */
  55517. dispose(): void;
  55518. /**
  55519. * Converts the reflection probe information to a readable string for debug purpose.
  55520. * @param fullDetails Supports for multiple levels of logging within scene loading
  55521. * @returns the human readable reflection probe info
  55522. */
  55523. toString(fullDetails?: boolean): string;
  55524. /**
  55525. * Get the class name of the relfection probe.
  55526. * @returns "ReflectionProbe"
  55527. */
  55528. getClassName(): string;
  55529. /**
  55530. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  55531. * @returns The JSON representation of the texture
  55532. */
  55533. serialize(): any;
  55534. /**
  55535. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  55536. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  55537. * @param scene Define the scene the parsed reflection probe should be instantiated in
  55538. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  55539. * @returns The parsed reflection probe if successful
  55540. */
  55541. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  55542. }
  55543. }
  55544. declare module BABYLON {
  55545. /** @hidden */
  55546. export var _BabylonLoaderRegistered: boolean;
  55547. /**
  55548. * Helps setting up some configuration for the babylon file loader.
  55549. */
  55550. export class BabylonFileLoaderConfiguration {
  55551. /**
  55552. * The loader does not allow injecting custom physix engine into the plugins.
  55553. * Unfortunately in ES6, we need to manually inject them into the plugin.
  55554. * So you could set this variable to your engine import to make it work.
  55555. */
  55556. static LoaderInjectedPhysicsEngine: any;
  55557. }
  55558. }
  55559. declare module BABYLON {
  55560. /**
  55561. * The Physically based simple base material of BJS.
  55562. *
  55563. * This enables better naming and convention enforcements on top of the pbrMaterial.
  55564. * It is used as the base class for both the specGloss and metalRough conventions.
  55565. */
  55566. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  55567. /**
  55568. * Number of Simultaneous lights allowed on the material.
  55569. */
  55570. maxSimultaneousLights: number;
  55571. /**
  55572. * If sets to true, disables all the lights affecting the material.
  55573. */
  55574. disableLighting: boolean;
  55575. /**
  55576. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  55577. */
  55578. environmentTexture: BaseTexture;
  55579. /**
  55580. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  55581. */
  55582. invertNormalMapX: boolean;
  55583. /**
  55584. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  55585. */
  55586. invertNormalMapY: boolean;
  55587. /**
  55588. * Normal map used in the model.
  55589. */
  55590. normalTexture: BaseTexture;
  55591. /**
  55592. * Emissivie color used to self-illuminate the model.
  55593. */
  55594. emissiveColor: Color3;
  55595. /**
  55596. * Emissivie texture used to self-illuminate the model.
  55597. */
  55598. emissiveTexture: BaseTexture;
  55599. /**
  55600. * Occlusion Channel Strenght.
  55601. */
  55602. occlusionStrength: number;
  55603. /**
  55604. * Occlusion Texture of the material (adding extra occlusion effects).
  55605. */
  55606. occlusionTexture: BaseTexture;
  55607. /**
  55608. * Defines the alpha limits in alpha test mode.
  55609. */
  55610. alphaCutOff: number;
  55611. /**
  55612. * Gets the current double sided mode.
  55613. */
  55614. get doubleSided(): boolean;
  55615. /**
  55616. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  55617. */
  55618. set doubleSided(value: boolean);
  55619. /**
  55620. * Stores the pre-calculated light information of a mesh in a texture.
  55621. */
  55622. lightmapTexture: BaseTexture;
  55623. /**
  55624. * If true, the light map contains occlusion information instead of lighting info.
  55625. */
  55626. useLightmapAsShadowmap: boolean;
  55627. /**
  55628. * Instantiates a new PBRMaterial instance.
  55629. *
  55630. * @param name The material name
  55631. * @param scene The scene the material will be use in.
  55632. */
  55633. constructor(name: string, scene: Scene);
  55634. getClassName(): string;
  55635. }
  55636. }
  55637. declare module BABYLON {
  55638. /**
  55639. * The PBR material of BJS following the metal roughness convention.
  55640. *
  55641. * This fits to the PBR convention in the GLTF definition:
  55642. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  55643. */
  55644. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  55645. /**
  55646. * The base color has two different interpretations depending on the value of metalness.
  55647. * When the material is a metal, the base color is the specific measured reflectance value
  55648. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  55649. * of the material.
  55650. */
  55651. baseColor: Color3;
  55652. /**
  55653. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  55654. * well as opacity information in the alpha channel.
  55655. */
  55656. baseTexture: BaseTexture;
  55657. /**
  55658. * Specifies the metallic scalar value of the material.
  55659. * Can also be used to scale the metalness values of the metallic texture.
  55660. */
  55661. metallic: number;
  55662. /**
  55663. * Specifies the roughness scalar value of the material.
  55664. * Can also be used to scale the roughness values of the metallic texture.
  55665. */
  55666. roughness: number;
  55667. /**
  55668. * Texture containing both the metallic value in the B channel and the
  55669. * roughness value in the G channel to keep better precision.
  55670. */
  55671. metallicRoughnessTexture: BaseTexture;
  55672. /**
  55673. * Instantiates a new PBRMetalRoughnessMaterial instance.
  55674. *
  55675. * @param name The material name
  55676. * @param scene The scene the material will be use in.
  55677. */
  55678. constructor(name: string, scene: Scene);
  55679. /**
  55680. * Return the currrent class name of the material.
  55681. */
  55682. getClassName(): string;
  55683. /**
  55684. * Makes a duplicate of the current material.
  55685. * @param name - name to use for the new material.
  55686. */
  55687. clone(name: string): PBRMetallicRoughnessMaterial;
  55688. /**
  55689. * Serialize the material to a parsable JSON object.
  55690. */
  55691. serialize(): any;
  55692. /**
  55693. * Parses a JSON object correponding to the serialize function.
  55694. */
  55695. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  55696. }
  55697. }
  55698. declare module BABYLON {
  55699. /**
  55700. * The PBR material of BJS following the specular glossiness convention.
  55701. *
  55702. * This fits to the PBR convention in the GLTF definition:
  55703. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  55704. */
  55705. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  55706. /**
  55707. * Specifies the diffuse color of the material.
  55708. */
  55709. diffuseColor: Color3;
  55710. /**
  55711. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  55712. * channel.
  55713. */
  55714. diffuseTexture: BaseTexture;
  55715. /**
  55716. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  55717. */
  55718. specularColor: Color3;
  55719. /**
  55720. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  55721. */
  55722. glossiness: number;
  55723. /**
  55724. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  55725. */
  55726. specularGlossinessTexture: BaseTexture;
  55727. /**
  55728. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  55729. *
  55730. * @param name The material name
  55731. * @param scene The scene the material will be use in.
  55732. */
  55733. constructor(name: string, scene: Scene);
  55734. /**
  55735. * Return the currrent class name of the material.
  55736. */
  55737. getClassName(): string;
  55738. /**
  55739. * Makes a duplicate of the current material.
  55740. * @param name - name to use for the new material.
  55741. */
  55742. clone(name: string): PBRSpecularGlossinessMaterial;
  55743. /**
  55744. * Serialize the material to a parsable JSON object.
  55745. */
  55746. serialize(): any;
  55747. /**
  55748. * Parses a JSON object correponding to the serialize function.
  55749. */
  55750. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  55751. }
  55752. }
  55753. declare module BABYLON {
  55754. /**
  55755. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  55756. * It can help converting any input color in a desired output one. This can then be used to create effects
  55757. * from sepia, black and white to sixties or futuristic rendering...
  55758. *
  55759. * The only supported format is currently 3dl.
  55760. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  55761. */
  55762. export class ColorGradingTexture extends BaseTexture {
  55763. /**
  55764. * The current texture matrix. (will always be identity in color grading texture)
  55765. */
  55766. private _textureMatrix;
  55767. /**
  55768. * The texture URL.
  55769. */
  55770. url: string;
  55771. /**
  55772. * Empty line regex stored for GC.
  55773. */
  55774. private static _noneEmptyLineRegex;
  55775. private _engine;
  55776. /**
  55777. * Instantiates a ColorGradingTexture from the following parameters.
  55778. *
  55779. * @param url The location of the color gradind data (currently only supporting 3dl)
  55780. * @param scene The scene the texture will be used in
  55781. */
  55782. constructor(url: string, scene: Scene);
  55783. /**
  55784. * Returns the texture matrix used in most of the material.
  55785. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  55786. */
  55787. getTextureMatrix(): Matrix;
  55788. /**
  55789. * Occurs when the file being loaded is a .3dl LUT file.
  55790. */
  55791. private load3dlTexture;
  55792. /**
  55793. * Starts the loading process of the texture.
  55794. */
  55795. private loadTexture;
  55796. /**
  55797. * Clones the color gradind texture.
  55798. */
  55799. clone(): ColorGradingTexture;
  55800. /**
  55801. * Called during delayed load for textures.
  55802. */
  55803. delayLoad(): void;
  55804. /**
  55805. * Parses a color grading texture serialized by Babylon.
  55806. * @param parsedTexture The texture information being parsedTexture
  55807. * @param scene The scene to load the texture in
  55808. * @param rootUrl The root url of the data assets to load
  55809. * @return A color gradind texture
  55810. */
  55811. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  55812. /**
  55813. * Serializes the LUT texture to json format.
  55814. */
  55815. serialize(): any;
  55816. }
  55817. }
  55818. declare module BABYLON {
  55819. /**
  55820. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  55821. */
  55822. export class EquiRectangularCubeTexture extends BaseTexture {
  55823. /** The six faces of the cube. */
  55824. private static _FacesMapping;
  55825. private _noMipmap;
  55826. private _onLoad;
  55827. private _onError;
  55828. /** The size of the cubemap. */
  55829. private _size;
  55830. /** The buffer of the image. */
  55831. private _buffer;
  55832. /** The width of the input image. */
  55833. private _width;
  55834. /** The height of the input image. */
  55835. private _height;
  55836. /** The URL to the image. */
  55837. url: string;
  55838. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  55839. coordinatesMode: number;
  55840. /**
  55841. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  55842. * @param url The location of the image
  55843. * @param scene The scene the texture will be used in
  55844. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  55845. * @param noMipmap Forces to not generate the mipmap if true
  55846. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  55847. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  55848. * @param onLoad — defines a callback called when texture is loaded
  55849. * @param onError — defines a callback called if there is an error
  55850. */
  55851. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  55852. /**
  55853. * Load the image data, by putting the image on a canvas and extracting its buffer.
  55854. */
  55855. private loadImage;
  55856. /**
  55857. * Convert the image buffer into a cubemap and create a CubeTexture.
  55858. */
  55859. private loadTexture;
  55860. /**
  55861. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  55862. * @param buffer The ArrayBuffer that should be converted.
  55863. * @returns The buffer as Float32Array.
  55864. */
  55865. private getFloat32ArrayFromArrayBuffer;
  55866. /**
  55867. * Get the current class name of the texture useful for serialization or dynamic coding.
  55868. * @returns "EquiRectangularCubeTexture"
  55869. */
  55870. getClassName(): string;
  55871. /**
  55872. * Create a clone of the current EquiRectangularCubeTexture and return it.
  55873. * @returns A clone of the current EquiRectangularCubeTexture.
  55874. */
  55875. clone(): EquiRectangularCubeTexture;
  55876. }
  55877. }
  55878. declare module BABYLON {
  55879. /**
  55880. * Based on jsTGALoader - Javascript loader for TGA file
  55881. * By Vincent Thibault
  55882. * @see http://blog.robrowser.com/javascript-tga-loader.html
  55883. */
  55884. export class TGATools {
  55885. private static _TYPE_INDEXED;
  55886. private static _TYPE_RGB;
  55887. private static _TYPE_GREY;
  55888. private static _TYPE_RLE_INDEXED;
  55889. private static _TYPE_RLE_RGB;
  55890. private static _TYPE_RLE_GREY;
  55891. private static _ORIGIN_MASK;
  55892. private static _ORIGIN_SHIFT;
  55893. private static _ORIGIN_BL;
  55894. private static _ORIGIN_BR;
  55895. private static _ORIGIN_UL;
  55896. private static _ORIGIN_UR;
  55897. /**
  55898. * Gets the header of a TGA file
  55899. * @param data defines the TGA data
  55900. * @returns the header
  55901. */
  55902. static GetTGAHeader(data: Uint8Array): any;
  55903. /**
  55904. * Uploads TGA content to a Babylon Texture
  55905. * @hidden
  55906. */
  55907. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  55908. /** @hidden */
  55909. 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;
  55910. /** @hidden */
  55911. 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;
  55912. /** @hidden */
  55913. 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;
  55914. /** @hidden */
  55915. 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;
  55916. /** @hidden */
  55917. 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;
  55918. /** @hidden */
  55919. 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;
  55920. }
  55921. }
  55922. declare module BABYLON {
  55923. /**
  55924. * Implementation of the TGA Texture Loader.
  55925. * @hidden
  55926. */
  55927. export class _TGATextureLoader implements IInternalTextureLoader {
  55928. /**
  55929. * Defines wether the loader supports cascade loading the different faces.
  55930. */
  55931. readonly supportCascades: boolean;
  55932. /**
  55933. * This returns if the loader support the current file information.
  55934. * @param extension defines the file extension of the file being loaded
  55935. * @param textureFormatInUse defines the current compressed format in use iun the engine
  55936. * @param fallback defines the fallback internal texture if any
  55937. * @param isBase64 defines whether the texture is encoded as a base64
  55938. * @param isBuffer defines whether the texture data are stored as a buffer
  55939. * @returns true if the loader can load the specified file
  55940. */
  55941. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  55942. /**
  55943. * Transform the url before loading if required.
  55944. * @param rootUrl the url of the texture
  55945. * @param textureFormatInUse defines the current compressed format in use iun the engine
  55946. * @returns the transformed texture
  55947. */
  55948. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  55949. /**
  55950. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  55951. * @param rootUrl the url of the texture
  55952. * @param textureFormatInUse defines the current compressed format in use iun the engine
  55953. * @returns the fallback texture
  55954. */
  55955. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  55956. /**
  55957. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  55958. * @param data contains the texture data
  55959. * @param texture defines the BabylonJS internal texture
  55960. * @param createPolynomials will be true if polynomials have been requested
  55961. * @param onLoad defines the callback to trigger once the texture is ready
  55962. * @param onError defines the callback to trigger in case of error
  55963. */
  55964. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  55965. /**
  55966. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  55967. * @param data contains the texture data
  55968. * @param texture defines the BabylonJS internal texture
  55969. * @param callback defines the method to call once ready to upload
  55970. */
  55971. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  55972. }
  55973. }
  55974. declare module BABYLON {
  55975. /**
  55976. * Info about the .basis files
  55977. */
  55978. class BasisFileInfo {
  55979. /**
  55980. * If the file has alpha
  55981. */
  55982. hasAlpha: boolean;
  55983. /**
  55984. * Info about each image of the basis file
  55985. */
  55986. images: Array<{
  55987. levels: Array<{
  55988. width: number;
  55989. height: number;
  55990. transcodedPixels: ArrayBufferView;
  55991. }>;
  55992. }>;
  55993. }
  55994. /**
  55995. * Result of transcoding a basis file
  55996. */
  55997. class TranscodeResult {
  55998. /**
  55999. * Info about the .basis file
  56000. */
  56001. fileInfo: BasisFileInfo;
  56002. /**
  56003. * Format to use when loading the file
  56004. */
  56005. format: number;
  56006. }
  56007. /**
  56008. * Configuration options for the Basis transcoder
  56009. */
  56010. export class BasisTranscodeConfiguration {
  56011. /**
  56012. * Supported compression formats used to determine the supported output format of the transcoder
  56013. */
  56014. supportedCompressionFormats?: {
  56015. /**
  56016. * etc1 compression format
  56017. */
  56018. etc1?: boolean;
  56019. /**
  56020. * s3tc compression format
  56021. */
  56022. s3tc?: boolean;
  56023. /**
  56024. * pvrtc compression format
  56025. */
  56026. pvrtc?: boolean;
  56027. /**
  56028. * etc2 compression format
  56029. */
  56030. etc2?: boolean;
  56031. };
  56032. /**
  56033. * If mipmap levels should be loaded for transcoded images (Default: true)
  56034. */
  56035. loadMipmapLevels?: boolean;
  56036. /**
  56037. * Index of a single image to load (Default: all images)
  56038. */
  56039. loadSingleImage?: number;
  56040. }
  56041. /**
  56042. * Used to load .Basis files
  56043. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  56044. */
  56045. export class BasisTools {
  56046. private static _IgnoreSupportedFormats;
  56047. /**
  56048. * URL to use when loading the basis transcoder
  56049. */
  56050. static JSModuleURL: string;
  56051. /**
  56052. * URL to use when loading the wasm module for the transcoder
  56053. */
  56054. static WasmModuleURL: string;
  56055. /**
  56056. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  56057. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  56058. * @returns internal format corresponding to the Basis format
  56059. */
  56060. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  56061. private static _WorkerPromise;
  56062. private static _Worker;
  56063. private static _actionId;
  56064. private static _CreateWorkerAsync;
  56065. /**
  56066. * Transcodes a loaded image file to compressed pixel data
  56067. * @param data image data to transcode
  56068. * @param config configuration options for the transcoding
  56069. * @returns a promise resulting in the transcoded image
  56070. */
  56071. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  56072. /**
  56073. * Loads a texture from the transcode result
  56074. * @param texture texture load to
  56075. * @param transcodeResult the result of transcoding the basis file to load from
  56076. */
  56077. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  56078. }
  56079. }
  56080. declare module BABYLON {
  56081. /**
  56082. * Loader for .basis file format
  56083. */
  56084. export class _BasisTextureLoader implements IInternalTextureLoader {
  56085. /**
  56086. * Defines whether the loader supports cascade loading the different faces.
  56087. */
  56088. readonly supportCascades: boolean;
  56089. /**
  56090. * This returns if the loader support the current file information.
  56091. * @param extension defines the file extension of the file being loaded
  56092. * @param textureFormatInUse defines the current compressed format in use iun the engine
  56093. * @param fallback defines the fallback internal texture if any
  56094. * @param isBase64 defines whether the texture is encoded as a base64
  56095. * @param isBuffer defines whether the texture data are stored as a buffer
  56096. * @returns true if the loader can load the specified file
  56097. */
  56098. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  56099. /**
  56100. * Transform the url before loading if required.
  56101. * @param rootUrl the url of the texture
  56102. * @param textureFormatInUse defines the current compressed format in use iun the engine
  56103. * @returns the transformed texture
  56104. */
  56105. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  56106. /**
  56107. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  56108. * @param rootUrl the url of the texture
  56109. * @param textureFormatInUse defines the current compressed format in use iun the engine
  56110. * @returns the fallback texture
  56111. */
  56112. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  56113. /**
  56114. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  56115. * @param data contains the texture data
  56116. * @param texture defines the BabylonJS internal texture
  56117. * @param createPolynomials will be true if polynomials have been requested
  56118. * @param onLoad defines the callback to trigger once the texture is ready
  56119. * @param onError defines the callback to trigger in case of error
  56120. */
  56121. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  56122. /**
  56123. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  56124. * @param data contains the texture data
  56125. * @param texture defines the BabylonJS internal texture
  56126. * @param callback defines the method to call once ready to upload
  56127. */
  56128. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  56129. }
  56130. }
  56131. declare module BABYLON {
  56132. /**
  56133. * 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.
  56134. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  56135. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  56136. */
  56137. export class CustomProceduralTexture extends ProceduralTexture {
  56138. private _animate;
  56139. private _time;
  56140. private _config;
  56141. private _texturePath;
  56142. /**
  56143. * Instantiates a new Custom Procedural Texture.
  56144. * 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.
  56145. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  56146. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  56147. * @param name Define the name of the texture
  56148. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  56149. * @param size Define the size of the texture to create
  56150. * @param scene Define the scene the texture belongs to
  56151. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  56152. * @param generateMipMaps Define if the texture should creates mip maps or not
  56153. */
  56154. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  56155. private _loadJson;
  56156. /**
  56157. * Is the texture ready to be used ? (rendered at least once)
  56158. * @returns true if ready, otherwise, false.
  56159. */
  56160. isReady(): boolean;
  56161. /**
  56162. * Render the texture to its associated render target.
  56163. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  56164. */
  56165. render(useCameraPostProcess?: boolean): void;
  56166. /**
  56167. * Update the list of dependant textures samplers in the shader.
  56168. */
  56169. updateTextures(): void;
  56170. /**
  56171. * Update the uniform values of the procedural texture in the shader.
  56172. */
  56173. updateShaderUniforms(): void;
  56174. /**
  56175. * Define if the texture animates or not.
  56176. */
  56177. get animate(): boolean;
  56178. set animate(value: boolean);
  56179. }
  56180. }
  56181. declare module BABYLON {
  56182. /** @hidden */
  56183. export var noisePixelShader: {
  56184. name: string;
  56185. shader: string;
  56186. };
  56187. }
  56188. declare module BABYLON {
  56189. /**
  56190. * Class used to generate noise procedural textures
  56191. */
  56192. export class NoiseProceduralTexture extends ProceduralTexture {
  56193. private _time;
  56194. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  56195. brightness: number;
  56196. /** Defines the number of octaves to process */
  56197. octaves: number;
  56198. /** Defines the level of persistence (0.8 by default) */
  56199. persistence: number;
  56200. /** Gets or sets animation speed factor (default is 1) */
  56201. animationSpeedFactor: number;
  56202. /**
  56203. * Creates a new NoiseProceduralTexture
  56204. * @param name defines the name fo the texture
  56205. * @param size defines the size of the texture (default is 256)
  56206. * @param scene defines the hosting scene
  56207. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  56208. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  56209. */
  56210. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  56211. private _updateShaderUniforms;
  56212. protected _getDefines(): string;
  56213. /** Generate the current state of the procedural texture */
  56214. render(useCameraPostProcess?: boolean): void;
  56215. /**
  56216. * Serializes this noise procedural texture
  56217. * @returns a serialized noise procedural texture object
  56218. */
  56219. serialize(): any;
  56220. /**
  56221. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  56222. * @param parsedTexture defines parsed texture data
  56223. * @param scene defines the current scene
  56224. * @param rootUrl defines the root URL containing noise procedural texture information
  56225. * @returns a parsed NoiseProceduralTexture
  56226. */
  56227. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  56228. }
  56229. }
  56230. declare module BABYLON {
  56231. /**
  56232. * Raw cube texture where the raw buffers are passed in
  56233. */
  56234. export class RawCubeTexture extends CubeTexture {
  56235. /**
  56236. * Creates a cube texture where the raw buffers are passed in.
  56237. * @param scene defines the scene the texture is attached to
  56238. * @param data defines the array of data to use to create each face
  56239. * @param size defines the size of the textures
  56240. * @param format defines the format of the data
  56241. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  56242. * @param generateMipMaps defines if the engine should generate the mip levels
  56243. * @param invertY defines if data must be stored with Y axis inverted
  56244. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  56245. * @param compression defines the compression used (null by default)
  56246. */
  56247. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  56248. /**
  56249. * Updates the raw cube texture.
  56250. * @param data defines the data to store
  56251. * @param format defines the data format
  56252. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  56253. * @param invertY defines if data must be stored with Y axis inverted
  56254. * @param compression defines the compression used (null by default)
  56255. * @param level defines which level of the texture to update
  56256. */
  56257. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  56258. /**
  56259. * Updates a raw cube texture with RGBD encoded data.
  56260. * @param data defines the array of data [mipmap][face] to use to create each face
  56261. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  56262. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  56263. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  56264. * @returns a promsie that resolves when the operation is complete
  56265. */
  56266. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  56267. /**
  56268. * Clones the raw cube texture.
  56269. * @return a new cube texture
  56270. */
  56271. clone(): CubeTexture;
  56272. /** @hidden */
  56273. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  56274. }
  56275. }
  56276. declare module BABYLON {
  56277. /**
  56278. * Class used to store 3D textures containing user data
  56279. */
  56280. export class RawTexture3D extends Texture {
  56281. /** Gets or sets the texture format to use */
  56282. format: number;
  56283. private _engine;
  56284. /**
  56285. * Create a new RawTexture3D
  56286. * @param data defines the data of the texture
  56287. * @param width defines the width of the texture
  56288. * @param height defines the height of the texture
  56289. * @param depth defines the depth of the texture
  56290. * @param format defines the texture format to use
  56291. * @param scene defines the hosting scene
  56292. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  56293. * @param invertY defines if texture must be stored with Y axis inverted
  56294. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  56295. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  56296. */
  56297. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  56298. /** Gets or sets the texture format to use */
  56299. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  56300. /**
  56301. * Update the texture with new data
  56302. * @param data defines the data to store in the texture
  56303. */
  56304. update(data: ArrayBufferView): void;
  56305. }
  56306. }
  56307. declare module BABYLON {
  56308. /**
  56309. * Class used to store 2D array textures containing user data
  56310. */
  56311. export class RawTexture2DArray extends Texture {
  56312. /** Gets or sets the texture format to use */
  56313. format: number;
  56314. private _engine;
  56315. /**
  56316. * Create a new RawTexture2DArray
  56317. * @param data defines the data of the texture
  56318. * @param width defines the width of the texture
  56319. * @param height defines the height of the texture
  56320. * @param depth defines the number of layers of the texture
  56321. * @param format defines the texture format to use
  56322. * @param scene defines the hosting scene
  56323. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  56324. * @param invertY defines if texture must be stored with Y axis inverted
  56325. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  56326. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  56327. */
  56328. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  56329. /** Gets or sets the texture format to use */
  56330. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  56331. /**
  56332. * Update the texture with new data
  56333. * @param data defines the data to store in the texture
  56334. */
  56335. update(data: ArrayBufferView): void;
  56336. }
  56337. }
  56338. declare module BABYLON {
  56339. /**
  56340. * Creates a refraction texture used by refraction channel of the standard material.
  56341. * It is like a mirror but to see through a material.
  56342. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  56343. */
  56344. export class RefractionTexture extends RenderTargetTexture {
  56345. /**
  56346. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  56347. * 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.
  56348. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  56349. */
  56350. refractionPlane: Plane;
  56351. /**
  56352. * Define how deep under the surface we should see.
  56353. */
  56354. depth: number;
  56355. /**
  56356. * Creates a refraction texture used by refraction channel of the standard material.
  56357. * It is like a mirror but to see through a material.
  56358. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  56359. * @param name Define the texture name
  56360. * @param size Define the size of the underlying texture
  56361. * @param scene Define the scene the refraction belongs to
  56362. * @param generateMipMaps Define if we need to generate mips level for the refraction
  56363. */
  56364. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  56365. /**
  56366. * Clone the refraction texture.
  56367. * @returns the cloned texture
  56368. */
  56369. clone(): RefractionTexture;
  56370. /**
  56371. * Serialize the texture to a JSON representation you could use in Parse later on
  56372. * @returns the serialized JSON representation
  56373. */
  56374. serialize(): any;
  56375. }
  56376. }
  56377. declare module BABYLON {
  56378. /**
  56379. * Defines the options related to the creation of an HtmlElementTexture
  56380. */
  56381. export interface IHtmlElementTextureOptions {
  56382. /**
  56383. * Defines wether mip maps should be created or not.
  56384. */
  56385. generateMipMaps?: boolean;
  56386. /**
  56387. * Defines the sampling mode of the texture.
  56388. */
  56389. samplingMode?: number;
  56390. /**
  56391. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  56392. */
  56393. engine: Nullable<ThinEngine>;
  56394. /**
  56395. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  56396. */
  56397. scene: Nullable<Scene>;
  56398. }
  56399. /**
  56400. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  56401. * To be as efficient as possible depending on your constraints nothing aside the first upload
  56402. * is automatically managed.
  56403. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  56404. * in your application.
  56405. *
  56406. * As the update is not automatic, you need to call them manually.
  56407. */
  56408. export class HtmlElementTexture extends BaseTexture {
  56409. /**
  56410. * The texture URL.
  56411. */
  56412. element: HTMLVideoElement | HTMLCanvasElement;
  56413. private static readonly DefaultOptions;
  56414. private _textureMatrix;
  56415. private _engine;
  56416. private _isVideo;
  56417. private _generateMipMaps;
  56418. private _samplingMode;
  56419. /**
  56420. * Instantiates a HtmlElementTexture from the following parameters.
  56421. *
  56422. * @param name Defines the name of the texture
  56423. * @param element Defines the video or canvas the texture is filled with
  56424. * @param options Defines the other none mandatory texture creation options
  56425. */
  56426. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  56427. private _createInternalTexture;
  56428. /**
  56429. * Returns the texture matrix used in most of the material.
  56430. */
  56431. getTextureMatrix(): Matrix;
  56432. /**
  56433. * Updates the content of the texture.
  56434. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  56435. */
  56436. update(invertY?: Nullable<boolean>): void;
  56437. }
  56438. }
  56439. declare module BABYLON {
  56440. /**
  56441. * Defines the basic options interface of a TexturePacker Frame
  56442. */
  56443. export interface ITexturePackerFrame {
  56444. /**
  56445. * The frame ID
  56446. */
  56447. id: number;
  56448. /**
  56449. * The frames Scale
  56450. */
  56451. scale: Vector2;
  56452. /**
  56453. * The Frames offset
  56454. */
  56455. offset: Vector2;
  56456. }
  56457. /**
  56458. * This is a support class for frame Data on texture packer sets.
  56459. */
  56460. export class TexturePackerFrame implements ITexturePackerFrame {
  56461. /**
  56462. * The frame ID
  56463. */
  56464. id: number;
  56465. /**
  56466. * The frames Scale
  56467. */
  56468. scale: Vector2;
  56469. /**
  56470. * The Frames offset
  56471. */
  56472. offset: Vector2;
  56473. /**
  56474. * Initializes a texture package frame.
  56475. * @param id The numerical frame identifier
  56476. * @param scale Scalar Vector2 for UV frame
  56477. * @param offset Vector2 for the frame position in UV units.
  56478. * @returns TexturePackerFrame
  56479. */
  56480. constructor(id: number, scale: Vector2, offset: Vector2);
  56481. }
  56482. }
  56483. declare module BABYLON {
  56484. /**
  56485. * Defines the basic options interface of a TexturePacker
  56486. */
  56487. export interface ITexturePackerOptions {
  56488. /**
  56489. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  56490. */
  56491. map?: string[];
  56492. /**
  56493. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  56494. */
  56495. uvsIn?: string;
  56496. /**
  56497. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  56498. */
  56499. uvsOut?: string;
  56500. /**
  56501. * number representing the layout style. Defaults to LAYOUT_STRIP
  56502. */
  56503. layout?: number;
  56504. /**
  56505. * number of columns if using custom column count layout(2). This defaults to 4.
  56506. */
  56507. colnum?: number;
  56508. /**
  56509. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  56510. */
  56511. updateInputMeshes?: boolean;
  56512. /**
  56513. * boolean flag to dispose all the source textures. Defaults to true.
  56514. */
  56515. disposeSources?: boolean;
  56516. /**
  56517. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  56518. */
  56519. fillBlanks?: boolean;
  56520. /**
  56521. * string value representing the context fill style color. Defaults to 'black'.
  56522. */
  56523. customFillColor?: string;
  56524. /**
  56525. * Width and Height Value of each Frame in the TexturePacker Sets
  56526. */
  56527. frameSize?: number;
  56528. /**
  56529. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  56530. */
  56531. paddingRatio?: number;
  56532. /**
  56533. * Number that declares the fill method for the padding gutter.
  56534. */
  56535. paddingMode?: number;
  56536. /**
  56537. * If in SUBUV_COLOR padding mode what color to use.
  56538. */
  56539. paddingColor?: Color3 | Color4;
  56540. }
  56541. /**
  56542. * Defines the basic interface of a TexturePacker JSON File
  56543. */
  56544. export interface ITexturePackerJSON {
  56545. /**
  56546. * The frame ID
  56547. */
  56548. name: string;
  56549. /**
  56550. * The base64 channel data
  56551. */
  56552. sets: any;
  56553. /**
  56554. * The options of the Packer
  56555. */
  56556. options: ITexturePackerOptions;
  56557. /**
  56558. * The frame data of the Packer
  56559. */
  56560. frames: Array<number>;
  56561. }
  56562. /**
  56563. * This is a support class that generates a series of packed texture sets.
  56564. * @see https://doc.babylonjs.com/babylon101/materials
  56565. */
  56566. export class TexturePacker {
  56567. /** Packer Layout Constant 0 */
  56568. static readonly LAYOUT_STRIP: number;
  56569. /** Packer Layout Constant 1 */
  56570. static readonly LAYOUT_POWER2: number;
  56571. /** Packer Layout Constant 2 */
  56572. static readonly LAYOUT_COLNUM: number;
  56573. /** Packer Layout Constant 0 */
  56574. static readonly SUBUV_WRAP: number;
  56575. /** Packer Layout Constant 1 */
  56576. static readonly SUBUV_EXTEND: number;
  56577. /** Packer Layout Constant 2 */
  56578. static readonly SUBUV_COLOR: number;
  56579. /** The Name of the Texture Package */
  56580. name: string;
  56581. /** The scene scope of the TexturePacker */
  56582. scene: Scene;
  56583. /** The Meshes to target */
  56584. meshes: AbstractMesh[];
  56585. /** Arguments passed with the Constructor */
  56586. options: ITexturePackerOptions;
  56587. /** The promise that is started upon initialization */
  56588. promise: Nullable<Promise<TexturePacker | string>>;
  56589. /** The Container object for the channel sets that are generated */
  56590. sets: object;
  56591. /** The Container array for the frames that are generated */
  56592. frames: TexturePackerFrame[];
  56593. /** The expected number of textures the system is parsing. */
  56594. private _expecting;
  56595. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  56596. private _paddingValue;
  56597. /**
  56598. * Initializes a texture package series from an array of meshes or a single mesh.
  56599. * @param name The name of the package
  56600. * @param meshes The target meshes to compose the package from
  56601. * @param options The arguments that texture packer should follow while building.
  56602. * @param scene The scene which the textures are scoped to.
  56603. * @returns TexturePacker
  56604. */
  56605. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  56606. /**
  56607. * Starts the package process
  56608. * @param resolve The promises resolution function
  56609. * @returns TexturePacker
  56610. */
  56611. private _createFrames;
  56612. /**
  56613. * Calculates the Size of the Channel Sets
  56614. * @returns Vector2
  56615. */
  56616. private _calculateSize;
  56617. /**
  56618. * Calculates the UV data for the frames.
  56619. * @param baseSize the base frameSize
  56620. * @param padding the base frame padding
  56621. * @param dtSize size of the Dynamic Texture for that channel
  56622. * @param dtUnits is 1/dtSize
  56623. * @param update flag to update the input meshes
  56624. */
  56625. private _calculateMeshUVFrames;
  56626. /**
  56627. * Calculates the frames Offset.
  56628. * @param index of the frame
  56629. * @returns Vector2
  56630. */
  56631. private _getFrameOffset;
  56632. /**
  56633. * Updates a Mesh to the frame data
  56634. * @param mesh that is the target
  56635. * @param frameID or the frame index
  56636. */
  56637. private _updateMeshUV;
  56638. /**
  56639. * Updates a Meshes materials to use the texture packer channels
  56640. * @param m is the mesh to target
  56641. * @param force all channels on the packer to be set.
  56642. */
  56643. private _updateTextureReferences;
  56644. /**
  56645. * Public method to set a Mesh to a frame
  56646. * @param m that is the target
  56647. * @param frameID or the frame index
  56648. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  56649. */
  56650. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  56651. /**
  56652. * Starts the async promise to compile the texture packer.
  56653. * @returns Promise<void>
  56654. */
  56655. processAsync(): Promise<void>;
  56656. /**
  56657. * Disposes all textures associated with this packer
  56658. */
  56659. dispose(): void;
  56660. /**
  56661. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  56662. * @param imageType is the image type to use.
  56663. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  56664. */
  56665. download(imageType?: string, quality?: number): void;
  56666. /**
  56667. * Public method to load a texturePacker JSON file.
  56668. * @param data of the JSON file in string format.
  56669. */
  56670. updateFromJSON(data: string): void;
  56671. }
  56672. }
  56673. declare module BABYLON {
  56674. /**
  56675. * Enum used to define the target of a block
  56676. */
  56677. export enum NodeMaterialBlockTargets {
  56678. /** Vertex shader */
  56679. Vertex = 1,
  56680. /** Fragment shader */
  56681. Fragment = 2,
  56682. /** Neutral */
  56683. Neutral = 4,
  56684. /** Vertex and Fragment */
  56685. VertexAndFragment = 3
  56686. }
  56687. }
  56688. declare module BABYLON {
  56689. /**
  56690. * Defines the kind of connection point for node based material
  56691. */
  56692. export enum NodeMaterialBlockConnectionPointTypes {
  56693. /** Float */
  56694. Float = 1,
  56695. /** Int */
  56696. Int = 2,
  56697. /** Vector2 */
  56698. Vector2 = 4,
  56699. /** Vector3 */
  56700. Vector3 = 8,
  56701. /** Vector4 */
  56702. Vector4 = 16,
  56703. /** Color3 */
  56704. Color3 = 32,
  56705. /** Color4 */
  56706. Color4 = 64,
  56707. /** Matrix */
  56708. Matrix = 128,
  56709. /** Detect type based on connection */
  56710. AutoDetect = 1024,
  56711. /** Output type that will be defined by input type */
  56712. BasedOnInput = 2048
  56713. }
  56714. }
  56715. declare module BABYLON {
  56716. /**
  56717. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  56718. */
  56719. export enum NodeMaterialBlockConnectionPointMode {
  56720. /** Value is an uniform */
  56721. Uniform = 0,
  56722. /** Value is a mesh attribute */
  56723. Attribute = 1,
  56724. /** Value is a varying between vertex and fragment shaders */
  56725. Varying = 2,
  56726. /** Mode is undefined */
  56727. Undefined = 3
  56728. }
  56729. }
  56730. declare module BABYLON {
  56731. /**
  56732. * Enum used to define system values e.g. values automatically provided by the system
  56733. */
  56734. export enum NodeMaterialSystemValues {
  56735. /** World */
  56736. World = 1,
  56737. /** View */
  56738. View = 2,
  56739. /** Projection */
  56740. Projection = 3,
  56741. /** ViewProjection */
  56742. ViewProjection = 4,
  56743. /** WorldView */
  56744. WorldView = 5,
  56745. /** WorldViewProjection */
  56746. WorldViewProjection = 6,
  56747. /** CameraPosition */
  56748. CameraPosition = 7,
  56749. /** Fog Color */
  56750. FogColor = 8,
  56751. /** Delta time */
  56752. DeltaTime = 9
  56753. }
  56754. }
  56755. declare module BABYLON {
  56756. /**
  56757. * Root class for all node material optimizers
  56758. */
  56759. export class NodeMaterialOptimizer {
  56760. /**
  56761. * Function used to optimize a NodeMaterial graph
  56762. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  56763. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  56764. */
  56765. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  56766. }
  56767. }
  56768. declare module BABYLON {
  56769. /**
  56770. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  56771. */
  56772. export class TransformBlock extends NodeMaterialBlock {
  56773. /**
  56774. * Defines the value to use to complement W value to transform it to a Vector4
  56775. */
  56776. complementW: number;
  56777. /**
  56778. * Defines the value to use to complement z value to transform it to a Vector4
  56779. */
  56780. complementZ: number;
  56781. /**
  56782. * Creates a new TransformBlock
  56783. * @param name defines the block name
  56784. */
  56785. constructor(name: string);
  56786. /**
  56787. * Gets the current class name
  56788. * @returns the class name
  56789. */
  56790. getClassName(): string;
  56791. /**
  56792. * Gets the vector input
  56793. */
  56794. get vector(): NodeMaterialConnectionPoint;
  56795. /**
  56796. * Gets the output component
  56797. */
  56798. get output(): NodeMaterialConnectionPoint;
  56799. /**
  56800. * Gets the matrix transform input
  56801. */
  56802. get transform(): NodeMaterialConnectionPoint;
  56803. protected _buildBlock(state: NodeMaterialBuildState): this;
  56804. serialize(): any;
  56805. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56806. protected _dumpPropertiesCode(): string;
  56807. }
  56808. }
  56809. declare module BABYLON {
  56810. /**
  56811. * Block used to output the vertex position
  56812. */
  56813. export class VertexOutputBlock extends NodeMaterialBlock {
  56814. /**
  56815. * Creates a new VertexOutputBlock
  56816. * @param name defines the block name
  56817. */
  56818. constructor(name: string);
  56819. /**
  56820. * Gets the current class name
  56821. * @returns the class name
  56822. */
  56823. getClassName(): string;
  56824. /**
  56825. * Gets the vector input component
  56826. */
  56827. get vector(): NodeMaterialConnectionPoint;
  56828. protected _buildBlock(state: NodeMaterialBuildState): this;
  56829. }
  56830. }
  56831. declare module BABYLON {
  56832. /**
  56833. * Block used to output the final color
  56834. */
  56835. export class FragmentOutputBlock extends NodeMaterialBlock {
  56836. /**
  56837. * Create a new FragmentOutputBlock
  56838. * @param name defines the block name
  56839. */
  56840. constructor(name: string);
  56841. /**
  56842. * Gets the current class name
  56843. * @returns the class name
  56844. */
  56845. getClassName(): string;
  56846. /**
  56847. * Gets the rgba input component
  56848. */
  56849. get rgba(): NodeMaterialConnectionPoint;
  56850. /**
  56851. * Gets the rgb input component
  56852. */
  56853. get rgb(): NodeMaterialConnectionPoint;
  56854. /**
  56855. * Gets the a input component
  56856. */
  56857. get a(): NodeMaterialConnectionPoint;
  56858. protected _buildBlock(state: NodeMaterialBuildState): this;
  56859. }
  56860. }
  56861. declare module BABYLON {
  56862. /**
  56863. * Block used to read a reflection texture from a sampler
  56864. */
  56865. export class ReflectionTextureBlock extends NodeMaterialBlock {
  56866. private _define3DName;
  56867. private _defineCubicName;
  56868. private _defineExplicitName;
  56869. private _defineProjectionName;
  56870. private _defineLocalCubicName;
  56871. private _defineSphericalName;
  56872. private _definePlanarName;
  56873. private _defineEquirectangularName;
  56874. private _defineMirroredEquirectangularFixedName;
  56875. private _defineEquirectangularFixedName;
  56876. private _defineSkyboxName;
  56877. private _cubeSamplerName;
  56878. private _2DSamplerName;
  56879. private _positionUVWName;
  56880. private _directionWName;
  56881. private _reflectionCoordsName;
  56882. private _reflection2DCoordsName;
  56883. private _reflectionColorName;
  56884. private _reflectionMatrixName;
  56885. /**
  56886. * Gets or sets the texture associated with the node
  56887. */
  56888. texture: Nullable<BaseTexture>;
  56889. /**
  56890. * Create a new TextureBlock
  56891. * @param name defines the block name
  56892. */
  56893. constructor(name: string);
  56894. /**
  56895. * Gets the current class name
  56896. * @returns the class name
  56897. */
  56898. getClassName(): string;
  56899. /**
  56900. * Gets the world position input component
  56901. */
  56902. get position(): NodeMaterialConnectionPoint;
  56903. /**
  56904. * Gets the world position input component
  56905. */
  56906. get worldPosition(): NodeMaterialConnectionPoint;
  56907. /**
  56908. * Gets the world normal input component
  56909. */
  56910. get worldNormal(): NodeMaterialConnectionPoint;
  56911. /**
  56912. * Gets the world input component
  56913. */
  56914. get world(): NodeMaterialConnectionPoint;
  56915. /**
  56916. * Gets the camera (or eye) position component
  56917. */
  56918. get cameraPosition(): NodeMaterialConnectionPoint;
  56919. /**
  56920. * Gets the view input component
  56921. */
  56922. get view(): NodeMaterialConnectionPoint;
  56923. /**
  56924. * Gets the rgb output component
  56925. */
  56926. get rgb(): NodeMaterialConnectionPoint;
  56927. /**
  56928. * Gets the r output component
  56929. */
  56930. get r(): NodeMaterialConnectionPoint;
  56931. /**
  56932. * Gets the g output component
  56933. */
  56934. get g(): NodeMaterialConnectionPoint;
  56935. /**
  56936. * Gets the b output component
  56937. */
  56938. get b(): NodeMaterialConnectionPoint;
  56939. autoConfigure(material: NodeMaterial): void;
  56940. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56941. isReady(): boolean;
  56942. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56943. private _injectVertexCode;
  56944. private _writeOutput;
  56945. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  56946. protected _dumpPropertiesCode(): string;
  56947. serialize(): any;
  56948. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56949. }
  56950. }
  56951. declare module BABYLON {
  56952. /**
  56953. * Interface used to configure the node material editor
  56954. */
  56955. export interface INodeMaterialEditorOptions {
  56956. /** Define the URl to load node editor script */
  56957. editorURL?: string;
  56958. }
  56959. /** @hidden */
  56960. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  56961. NORMAL: boolean;
  56962. TANGENT: boolean;
  56963. UV1: boolean;
  56964. /** BONES */
  56965. NUM_BONE_INFLUENCERS: number;
  56966. BonesPerMesh: number;
  56967. BONETEXTURE: boolean;
  56968. /** MORPH TARGETS */
  56969. MORPHTARGETS: boolean;
  56970. MORPHTARGETS_NORMAL: boolean;
  56971. MORPHTARGETS_TANGENT: boolean;
  56972. MORPHTARGETS_UV: boolean;
  56973. NUM_MORPH_INFLUENCERS: number;
  56974. /** IMAGE PROCESSING */
  56975. IMAGEPROCESSING: boolean;
  56976. VIGNETTE: boolean;
  56977. VIGNETTEBLENDMODEMULTIPLY: boolean;
  56978. VIGNETTEBLENDMODEOPAQUE: boolean;
  56979. TONEMAPPING: boolean;
  56980. TONEMAPPING_ACES: boolean;
  56981. CONTRAST: boolean;
  56982. EXPOSURE: boolean;
  56983. COLORCURVES: boolean;
  56984. COLORGRADING: boolean;
  56985. COLORGRADING3D: boolean;
  56986. SAMPLER3DGREENDEPTH: boolean;
  56987. SAMPLER3DBGRMAP: boolean;
  56988. IMAGEPROCESSINGPOSTPROCESS: boolean;
  56989. /** MISC. */
  56990. BUMPDIRECTUV: number;
  56991. constructor();
  56992. setValue(name: string, value: boolean): void;
  56993. }
  56994. /**
  56995. * Class used to configure NodeMaterial
  56996. */
  56997. export interface INodeMaterialOptions {
  56998. /**
  56999. * Defines if blocks should emit comments
  57000. */
  57001. emitComments: boolean;
  57002. }
  57003. /**
  57004. * Class used to create a node based material built by assembling shader blocks
  57005. */
  57006. export class NodeMaterial extends PushMaterial {
  57007. private static _BuildIdGenerator;
  57008. private _options;
  57009. private _vertexCompilationState;
  57010. private _fragmentCompilationState;
  57011. private _sharedData;
  57012. private _buildId;
  57013. private _buildWasSuccessful;
  57014. private _cachedWorldViewMatrix;
  57015. private _cachedWorldViewProjectionMatrix;
  57016. private _optimizers;
  57017. private _animationFrame;
  57018. /** Define the Url to load node editor script */
  57019. static EditorURL: string;
  57020. /** Define the Url to load snippets */
  57021. static SnippetUrl: string;
  57022. private BJSNODEMATERIALEDITOR;
  57023. /** Get the inspector from bundle or global */
  57024. private _getGlobalNodeMaterialEditor;
  57025. /**
  57026. * Gets or sets data used by visual editor
  57027. * @see https://nme.babylonjs.com
  57028. */
  57029. editorData: any;
  57030. /**
  57031. * 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)
  57032. */
  57033. ignoreAlpha: boolean;
  57034. /**
  57035. * Defines the maximum number of lights that can be used in the material
  57036. */
  57037. maxSimultaneousLights: number;
  57038. /**
  57039. * Observable raised when the material is built
  57040. */
  57041. onBuildObservable: Observable<NodeMaterial>;
  57042. /**
  57043. * Gets or sets the root nodes of the material vertex shader
  57044. */
  57045. _vertexOutputNodes: NodeMaterialBlock[];
  57046. /**
  57047. * Gets or sets the root nodes of the material fragment (pixel) shader
  57048. */
  57049. _fragmentOutputNodes: NodeMaterialBlock[];
  57050. /** Gets or sets options to control the node material overall behavior */
  57051. get options(): INodeMaterialOptions;
  57052. set options(options: INodeMaterialOptions);
  57053. /**
  57054. * Default configuration related to image processing available in the standard Material.
  57055. */
  57056. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  57057. /**
  57058. * Gets the image processing configuration used either in this material.
  57059. */
  57060. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  57061. /**
  57062. * Sets the Default image processing configuration used either in the this material.
  57063. *
  57064. * If sets to null, the scene one is in use.
  57065. */
  57066. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  57067. /**
  57068. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  57069. */
  57070. attachedBlocks: NodeMaterialBlock[];
  57071. /**
  57072. * Create a new node based material
  57073. * @param name defines the material name
  57074. * @param scene defines the hosting scene
  57075. * @param options defines creation option
  57076. */
  57077. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  57078. /**
  57079. * Gets the current class name of the material e.g. "NodeMaterial"
  57080. * @returns the class name
  57081. */
  57082. getClassName(): string;
  57083. /**
  57084. * Keep track of the image processing observer to allow dispose and replace.
  57085. */
  57086. private _imageProcessingObserver;
  57087. /**
  57088. * Attaches a new image processing configuration to the Standard Material.
  57089. * @param configuration
  57090. */
  57091. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  57092. /**
  57093. * Get a block by its name
  57094. * @param name defines the name of the block to retrieve
  57095. * @returns the required block or null if not found
  57096. */
  57097. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  57098. /**
  57099. * Get a block by its name
  57100. * @param predicate defines the predicate used to find the good candidate
  57101. * @returns the required block or null if not found
  57102. */
  57103. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  57104. /**
  57105. * Get an input block by its name
  57106. * @param predicate defines the predicate used to find the good candidate
  57107. * @returns the required input block or null if not found
  57108. */
  57109. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  57110. /**
  57111. * Gets the list of input blocks attached to this material
  57112. * @returns an array of InputBlocks
  57113. */
  57114. getInputBlocks(): InputBlock[];
  57115. /**
  57116. * Adds a new optimizer to the list of optimizers
  57117. * @param optimizer defines the optimizers to add
  57118. * @returns the current material
  57119. */
  57120. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  57121. /**
  57122. * Remove an optimizer from the list of optimizers
  57123. * @param optimizer defines the optimizers to remove
  57124. * @returns the current material
  57125. */
  57126. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  57127. /**
  57128. * Add a new block to the list of output nodes
  57129. * @param node defines the node to add
  57130. * @returns the current material
  57131. */
  57132. addOutputNode(node: NodeMaterialBlock): this;
  57133. /**
  57134. * Remove a block from the list of root nodes
  57135. * @param node defines the node to remove
  57136. * @returns the current material
  57137. */
  57138. removeOutputNode(node: NodeMaterialBlock): this;
  57139. private _addVertexOutputNode;
  57140. private _removeVertexOutputNode;
  57141. private _addFragmentOutputNode;
  57142. private _removeFragmentOutputNode;
  57143. /**
  57144. * Specifies if the material will require alpha blending
  57145. * @returns a boolean specifying if alpha blending is needed
  57146. */
  57147. needAlphaBlending(): boolean;
  57148. /**
  57149. * Specifies if this material should be rendered in alpha test mode
  57150. * @returns a boolean specifying if an alpha test is needed.
  57151. */
  57152. needAlphaTesting(): boolean;
  57153. private _initializeBlock;
  57154. private _resetDualBlocks;
  57155. /**
  57156. * Remove a block from the current node material
  57157. * @param block defines the block to remove
  57158. */
  57159. removeBlock(block: NodeMaterialBlock): void;
  57160. /**
  57161. * Build the material and generates the inner effect
  57162. * @param verbose defines if the build should log activity
  57163. */
  57164. build(verbose?: boolean): void;
  57165. /**
  57166. * Runs an otpimization phase to try to improve the shader code
  57167. */
  57168. optimize(): void;
  57169. private _prepareDefinesForAttributes;
  57170. /**
  57171. * Get if the submesh is ready to be used and all its information available.
  57172. * Child classes can use it to update shaders
  57173. * @param mesh defines the mesh to check
  57174. * @param subMesh defines which submesh to check
  57175. * @param useInstances specifies that instances should be used
  57176. * @returns a boolean indicating that the submesh is ready or not
  57177. */
  57178. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  57179. /**
  57180. * Get a string representing the shaders built by the current node graph
  57181. */
  57182. get compiledShaders(): string;
  57183. /**
  57184. * Binds the world matrix to the material
  57185. * @param world defines the world transformation matrix
  57186. */
  57187. bindOnlyWorldMatrix(world: Matrix): void;
  57188. /**
  57189. * Binds the submesh to this material by preparing the effect and shader to draw
  57190. * @param world defines the world transformation matrix
  57191. * @param mesh defines the mesh containing the submesh
  57192. * @param subMesh defines the submesh to bind the material to
  57193. */
  57194. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  57195. /**
  57196. * Gets the active textures from the material
  57197. * @returns an array of textures
  57198. */
  57199. getActiveTextures(): BaseTexture[];
  57200. /**
  57201. * Gets the list of texture blocks
  57202. * @returns an array of texture blocks
  57203. */
  57204. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  57205. /**
  57206. * Specifies if the material uses a texture
  57207. * @param texture defines the texture to check against the material
  57208. * @returns a boolean specifying if the material uses the texture
  57209. */
  57210. hasTexture(texture: BaseTexture): boolean;
  57211. /**
  57212. * Disposes the material
  57213. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  57214. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  57215. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  57216. */
  57217. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  57218. /** Creates the node editor window. */
  57219. private _createNodeEditor;
  57220. /**
  57221. * Launch the node material editor
  57222. * @param config Define the configuration of the editor
  57223. * @return a promise fulfilled when the node editor is visible
  57224. */
  57225. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  57226. /**
  57227. * Clear the current material
  57228. */
  57229. clear(): void;
  57230. /**
  57231. * Clear the current material and set it to a default state
  57232. */
  57233. setToDefault(): void;
  57234. /**
  57235. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  57236. * @param url defines the url to load from
  57237. * @returns a promise that will fullfil when the material is fully loaded
  57238. */
  57239. loadAsync(url: string): Promise<void>;
  57240. private _gatherBlocks;
  57241. /**
  57242. * Generate a string containing the code declaration required to create an equivalent of this material
  57243. * @returns a string
  57244. */
  57245. generateCode(): string;
  57246. /**
  57247. * Serializes this material in a JSON representation
  57248. * @returns the serialized material object
  57249. */
  57250. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  57251. private _restoreConnections;
  57252. /**
  57253. * Clear the current graph and load a new one from a serialization object
  57254. * @param source defines the JSON representation of the material
  57255. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  57256. */
  57257. loadFromSerialization(source: any, rootUrl?: string): void;
  57258. /**
  57259. * Creates a node material from parsed material data
  57260. * @param source defines the JSON representation of the material
  57261. * @param scene defines the hosting scene
  57262. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  57263. * @returns a new node material
  57264. */
  57265. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  57266. /**
  57267. * Creates a node material from a snippet saved in a remote file
  57268. * @param name defines the name of the material to create
  57269. * @param url defines the url to load from
  57270. * @param scene defines the hosting scene
  57271. * @returns a promise that will resolve to the new node material
  57272. */
  57273. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  57274. /**
  57275. * Creates a node material from a snippet saved by the node material editor
  57276. * @param snippetId defines the snippet to load
  57277. * @param scene defines the hosting scene
  57278. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  57279. * @returns a promise that will resolve to the new node material
  57280. */
  57281. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<NodeMaterial>;
  57282. /**
  57283. * Creates a new node material set to default basic configuration
  57284. * @param name defines the name of the material
  57285. * @param scene defines the hosting scene
  57286. * @returns a new NodeMaterial
  57287. */
  57288. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  57289. }
  57290. }
  57291. declare module BABYLON {
  57292. /**
  57293. * Block used to read a texture from a sampler
  57294. */
  57295. export class TextureBlock extends NodeMaterialBlock {
  57296. private _defineName;
  57297. private _linearDefineName;
  57298. private _tempTextureRead;
  57299. private _samplerName;
  57300. private _transformedUVName;
  57301. private _textureTransformName;
  57302. private _textureInfoName;
  57303. private _mainUVName;
  57304. private _mainUVDefineName;
  57305. /**
  57306. * Gets or sets the texture associated with the node
  57307. */
  57308. texture: Nullable<Texture>;
  57309. /**
  57310. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  57311. */
  57312. convertToGammaSpace: boolean;
  57313. /**
  57314. * Create a new TextureBlock
  57315. * @param name defines the block name
  57316. */
  57317. constructor(name: string);
  57318. /**
  57319. * Gets the current class name
  57320. * @returns the class name
  57321. */
  57322. getClassName(): string;
  57323. /**
  57324. * Gets the uv input component
  57325. */
  57326. get uv(): NodeMaterialConnectionPoint;
  57327. /**
  57328. * Gets the rgba output component
  57329. */
  57330. get rgba(): NodeMaterialConnectionPoint;
  57331. /**
  57332. * Gets the rgb output component
  57333. */
  57334. get rgb(): NodeMaterialConnectionPoint;
  57335. /**
  57336. * Gets the r output component
  57337. */
  57338. get r(): NodeMaterialConnectionPoint;
  57339. /**
  57340. * Gets the g output component
  57341. */
  57342. get g(): NodeMaterialConnectionPoint;
  57343. /**
  57344. * Gets the b output component
  57345. */
  57346. get b(): NodeMaterialConnectionPoint;
  57347. /**
  57348. * Gets the a output component
  57349. */
  57350. get a(): NodeMaterialConnectionPoint;
  57351. get target(): NodeMaterialBlockTargets;
  57352. autoConfigure(material: NodeMaterial): void;
  57353. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  57354. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57355. isReady(): boolean;
  57356. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57357. private get _isMixed();
  57358. private _injectVertexCode;
  57359. private _writeTextureRead;
  57360. private _writeOutput;
  57361. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  57362. protected _dumpPropertiesCode(): string;
  57363. serialize(): any;
  57364. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57365. }
  57366. }
  57367. declare module BABYLON {
  57368. /**
  57369. * Class used to store shared data between 2 NodeMaterialBuildState
  57370. */
  57371. export class NodeMaterialBuildStateSharedData {
  57372. /**
  57373. * Gets the list of emitted varyings
  57374. */
  57375. temps: string[];
  57376. /**
  57377. * Gets the list of emitted varyings
  57378. */
  57379. varyings: string[];
  57380. /**
  57381. * Gets the varying declaration string
  57382. */
  57383. varyingDeclaration: string;
  57384. /**
  57385. * Input blocks
  57386. */
  57387. inputBlocks: InputBlock[];
  57388. /**
  57389. * Input blocks
  57390. */
  57391. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  57392. /**
  57393. * Bindable blocks (Blocks that need to set data to the effect)
  57394. */
  57395. bindableBlocks: NodeMaterialBlock[];
  57396. /**
  57397. * List of blocks that can provide a compilation fallback
  57398. */
  57399. blocksWithFallbacks: NodeMaterialBlock[];
  57400. /**
  57401. * List of blocks that can provide a define update
  57402. */
  57403. blocksWithDefines: NodeMaterialBlock[];
  57404. /**
  57405. * List of blocks that can provide a repeatable content
  57406. */
  57407. repeatableContentBlocks: NodeMaterialBlock[];
  57408. /**
  57409. * List of blocks that can provide a dynamic list of uniforms
  57410. */
  57411. dynamicUniformBlocks: NodeMaterialBlock[];
  57412. /**
  57413. * List of blocks that can block the isReady function for the material
  57414. */
  57415. blockingBlocks: NodeMaterialBlock[];
  57416. /**
  57417. * Gets the list of animated inputs
  57418. */
  57419. animatedInputs: InputBlock[];
  57420. /**
  57421. * Build Id used to avoid multiple recompilations
  57422. */
  57423. buildId: number;
  57424. /** List of emitted variables */
  57425. variableNames: {
  57426. [key: string]: number;
  57427. };
  57428. /** List of emitted defines */
  57429. defineNames: {
  57430. [key: string]: number;
  57431. };
  57432. /** Should emit comments? */
  57433. emitComments: boolean;
  57434. /** Emit build activity */
  57435. verbose: boolean;
  57436. /** Gets or sets the hosting scene */
  57437. scene: Scene;
  57438. /**
  57439. * Gets the compilation hints emitted at compilation time
  57440. */
  57441. hints: {
  57442. needWorldViewMatrix: boolean;
  57443. needWorldViewProjectionMatrix: boolean;
  57444. needAlphaBlending: boolean;
  57445. needAlphaTesting: boolean;
  57446. };
  57447. /**
  57448. * List of compilation checks
  57449. */
  57450. checks: {
  57451. emitVertex: boolean;
  57452. emitFragment: boolean;
  57453. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  57454. };
  57455. /** Creates a new shared data */
  57456. constructor();
  57457. /**
  57458. * Emits console errors and exceptions if there is a failing check
  57459. */
  57460. emitErrors(): void;
  57461. }
  57462. }
  57463. declare module BABYLON {
  57464. /**
  57465. * Class used to store node based material build state
  57466. */
  57467. export class NodeMaterialBuildState {
  57468. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  57469. supportUniformBuffers: boolean;
  57470. /**
  57471. * Gets the list of emitted attributes
  57472. */
  57473. attributes: string[];
  57474. /**
  57475. * Gets the list of emitted uniforms
  57476. */
  57477. uniforms: string[];
  57478. /**
  57479. * Gets the list of emitted constants
  57480. */
  57481. constants: string[];
  57482. /**
  57483. * Gets the list of emitted samplers
  57484. */
  57485. samplers: string[];
  57486. /**
  57487. * Gets the list of emitted functions
  57488. */
  57489. functions: {
  57490. [key: string]: string;
  57491. };
  57492. /**
  57493. * Gets the list of emitted extensions
  57494. */
  57495. extensions: {
  57496. [key: string]: string;
  57497. };
  57498. /**
  57499. * Gets the target of the compilation state
  57500. */
  57501. target: NodeMaterialBlockTargets;
  57502. /**
  57503. * Gets the list of emitted counters
  57504. */
  57505. counters: {
  57506. [key: string]: number;
  57507. };
  57508. /**
  57509. * Shared data between multiple NodeMaterialBuildState instances
  57510. */
  57511. sharedData: NodeMaterialBuildStateSharedData;
  57512. /** @hidden */
  57513. _vertexState: NodeMaterialBuildState;
  57514. /** @hidden */
  57515. _attributeDeclaration: string;
  57516. /** @hidden */
  57517. _uniformDeclaration: string;
  57518. /** @hidden */
  57519. _constantDeclaration: string;
  57520. /** @hidden */
  57521. _samplerDeclaration: string;
  57522. /** @hidden */
  57523. _varyingTransfer: string;
  57524. private _repeatableContentAnchorIndex;
  57525. /** @hidden */
  57526. _builtCompilationString: string;
  57527. /**
  57528. * Gets the emitted compilation strings
  57529. */
  57530. compilationString: string;
  57531. /**
  57532. * Finalize the compilation strings
  57533. * @param state defines the current compilation state
  57534. */
  57535. finalize(state: NodeMaterialBuildState): void;
  57536. /** @hidden */
  57537. get _repeatableContentAnchor(): string;
  57538. /** @hidden */
  57539. _getFreeVariableName(prefix: string): string;
  57540. /** @hidden */
  57541. _getFreeDefineName(prefix: string): string;
  57542. /** @hidden */
  57543. _excludeVariableName(name: string): void;
  57544. /** @hidden */
  57545. _emit2DSampler(name: string): void;
  57546. /** @hidden */
  57547. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  57548. /** @hidden */
  57549. _emitExtension(name: string, extension: string): void;
  57550. /** @hidden */
  57551. _emitFunction(name: string, code: string, comments: string): void;
  57552. /** @hidden */
  57553. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  57554. replaceStrings?: {
  57555. search: RegExp;
  57556. replace: string;
  57557. }[];
  57558. repeatKey?: string;
  57559. }): string;
  57560. /** @hidden */
  57561. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  57562. repeatKey?: string;
  57563. removeAttributes?: boolean;
  57564. removeUniforms?: boolean;
  57565. removeVaryings?: boolean;
  57566. removeIfDef?: boolean;
  57567. replaceStrings?: {
  57568. search: RegExp;
  57569. replace: string;
  57570. }[];
  57571. }, storeKey?: string): void;
  57572. /** @hidden */
  57573. _registerTempVariable(name: string): boolean;
  57574. /** @hidden */
  57575. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  57576. /** @hidden */
  57577. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  57578. /** @hidden */
  57579. _emitFloat(value: number): string;
  57580. }
  57581. }
  57582. declare module BABYLON {
  57583. /**
  57584. * Defines a block that can be used inside a node based material
  57585. */
  57586. export class NodeMaterialBlock {
  57587. private _buildId;
  57588. private _buildTarget;
  57589. private _target;
  57590. private _isFinalMerger;
  57591. private _isInput;
  57592. protected _isUnique: boolean;
  57593. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  57594. inputsAreExclusive: boolean;
  57595. /** @hidden */
  57596. _codeVariableName: string;
  57597. /** @hidden */
  57598. _inputs: NodeMaterialConnectionPoint[];
  57599. /** @hidden */
  57600. _outputs: NodeMaterialConnectionPoint[];
  57601. /** @hidden */
  57602. _preparationId: number;
  57603. /**
  57604. * Gets or sets the name of the block
  57605. */
  57606. name: string;
  57607. /**
  57608. * Gets or sets the unique id of the node
  57609. */
  57610. uniqueId: number;
  57611. /**
  57612. * Gets or sets the comments associated with this block
  57613. */
  57614. comments: string;
  57615. /**
  57616. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  57617. */
  57618. get isUnique(): boolean;
  57619. /**
  57620. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  57621. */
  57622. get isFinalMerger(): boolean;
  57623. /**
  57624. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  57625. */
  57626. get isInput(): boolean;
  57627. /**
  57628. * Gets or sets the build Id
  57629. */
  57630. get buildId(): number;
  57631. set buildId(value: number);
  57632. /**
  57633. * Gets or sets the target of the block
  57634. */
  57635. get target(): NodeMaterialBlockTargets;
  57636. set target(value: NodeMaterialBlockTargets);
  57637. /**
  57638. * Gets the list of input points
  57639. */
  57640. get inputs(): NodeMaterialConnectionPoint[];
  57641. /** Gets the list of output points */
  57642. get outputs(): NodeMaterialConnectionPoint[];
  57643. /**
  57644. * Find an input by its name
  57645. * @param name defines the name of the input to look for
  57646. * @returns the input or null if not found
  57647. */
  57648. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  57649. /**
  57650. * Find an output by its name
  57651. * @param name defines the name of the outputto look for
  57652. * @returns the output or null if not found
  57653. */
  57654. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  57655. /**
  57656. * Creates a new NodeMaterialBlock
  57657. * @param name defines the block name
  57658. * @param target defines the target of that block (Vertex by default)
  57659. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  57660. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  57661. */
  57662. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  57663. /**
  57664. * Initialize the block and prepare the context for build
  57665. * @param state defines the state that will be used for the build
  57666. */
  57667. initialize(state: NodeMaterialBuildState): void;
  57668. /**
  57669. * Bind data to effect. Will only be called for blocks with isBindable === true
  57670. * @param effect defines the effect to bind data to
  57671. * @param nodeMaterial defines the hosting NodeMaterial
  57672. * @param mesh defines the mesh that will be rendered
  57673. */
  57674. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57675. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  57676. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  57677. protected _writeFloat(value: number): string;
  57678. /**
  57679. * Gets the current class name e.g. "NodeMaterialBlock"
  57680. * @returns the class name
  57681. */
  57682. getClassName(): string;
  57683. /**
  57684. * Register a new input. Must be called inside a block constructor
  57685. * @param name defines the connection point name
  57686. * @param type defines the connection point type
  57687. * @param isOptional defines a boolean indicating that this input can be omitted
  57688. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  57689. * @returns the current block
  57690. */
  57691. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  57692. /**
  57693. * Register a new output. Must be called inside a block constructor
  57694. * @param name defines the connection point name
  57695. * @param type defines the connection point type
  57696. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  57697. * @returns the current block
  57698. */
  57699. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  57700. /**
  57701. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  57702. * @param forOutput defines an optional connection point to check compatibility with
  57703. * @returns the first available input or null
  57704. */
  57705. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  57706. /**
  57707. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  57708. * @param forBlock defines an optional block to check compatibility with
  57709. * @returns the first available input or null
  57710. */
  57711. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  57712. /**
  57713. * Gets the sibling of the given output
  57714. * @param current defines the current output
  57715. * @returns the next output in the list or null
  57716. */
  57717. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  57718. /**
  57719. * Connect current block with another block
  57720. * @param other defines the block to connect with
  57721. * @param options define the various options to help pick the right connections
  57722. * @returns the current block
  57723. */
  57724. connectTo(other: NodeMaterialBlock, options?: {
  57725. input?: string;
  57726. output?: string;
  57727. outputSwizzle?: string;
  57728. }): this | undefined;
  57729. protected _buildBlock(state: NodeMaterialBuildState): void;
  57730. /**
  57731. * Add uniforms, samplers and uniform buffers at compilation time
  57732. * @param state defines the state to update
  57733. * @param nodeMaterial defines the node material requesting the update
  57734. * @param defines defines the material defines to update
  57735. * @param uniformBuffers defines the list of uniform buffer names
  57736. */
  57737. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  57738. /**
  57739. * Add potential fallbacks if shader compilation fails
  57740. * @param mesh defines the mesh to be rendered
  57741. * @param fallbacks defines the current prioritized list of fallbacks
  57742. */
  57743. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  57744. /**
  57745. * Initialize defines for shader compilation
  57746. * @param mesh defines the mesh to be rendered
  57747. * @param nodeMaterial defines the node material requesting the update
  57748. * @param defines defines the material defines to update
  57749. * @param useInstances specifies that instances should be used
  57750. */
  57751. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  57752. /**
  57753. * Update defines for shader compilation
  57754. * @param mesh defines the mesh to be rendered
  57755. * @param nodeMaterial defines the node material requesting the update
  57756. * @param defines defines the material defines to update
  57757. * @param useInstances specifies that instances should be used
  57758. */
  57759. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  57760. /**
  57761. * Lets the block try to connect some inputs automatically
  57762. * @param material defines the hosting NodeMaterial
  57763. */
  57764. autoConfigure(material: NodeMaterial): void;
  57765. /**
  57766. * Function called when a block is declared as repeatable content generator
  57767. * @param vertexShaderState defines the current compilation state for the vertex shader
  57768. * @param fragmentShaderState defines the current compilation state for the fragment shader
  57769. * @param mesh defines the mesh to be rendered
  57770. * @param defines defines the material defines to update
  57771. */
  57772. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  57773. /**
  57774. * Checks if the block is ready
  57775. * @param mesh defines the mesh to be rendered
  57776. * @param nodeMaterial defines the node material requesting the update
  57777. * @param defines defines the material defines to update
  57778. * @param useInstances specifies that instances should be used
  57779. * @returns true if the block is ready
  57780. */
  57781. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  57782. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  57783. private _processBuild;
  57784. /**
  57785. * Compile the current node and generate the shader code
  57786. * @param state defines the current compilation state (uniforms, samplers, current string)
  57787. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  57788. * @returns true if already built
  57789. */
  57790. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  57791. protected _inputRename(name: string): string;
  57792. protected _outputRename(name: string): string;
  57793. protected _dumpPropertiesCode(): string;
  57794. /** @hidden */
  57795. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  57796. /** @hidden */
  57797. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  57798. /**
  57799. * Clone the current block to a new identical block
  57800. * @param scene defines the hosting scene
  57801. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  57802. * @returns a copy of the current block
  57803. */
  57804. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  57805. /**
  57806. * Serializes this block in a JSON representation
  57807. * @returns the serialized block object
  57808. */
  57809. serialize(): any;
  57810. /** @hidden */
  57811. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57812. /**
  57813. * Release resources
  57814. */
  57815. dispose(): void;
  57816. }
  57817. }
  57818. declare module BABYLON {
  57819. /**
  57820. * Enum defining the type of animations supported by InputBlock
  57821. */
  57822. export enum AnimatedInputBlockTypes {
  57823. /** No animation */
  57824. None = 0,
  57825. /** Time based animation. Will only work for floats */
  57826. Time = 1
  57827. }
  57828. }
  57829. declare module BABYLON {
  57830. /**
  57831. * Block used to expose an input value
  57832. */
  57833. export class InputBlock extends NodeMaterialBlock {
  57834. private _mode;
  57835. private _associatedVariableName;
  57836. private _storedValue;
  57837. private _valueCallback;
  57838. private _type;
  57839. private _animationType;
  57840. /** Gets or set a value used to limit the range of float values */
  57841. min: number;
  57842. /** Gets or set a value used to limit the range of float values */
  57843. max: number;
  57844. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  57845. isBoolean: boolean;
  57846. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  57847. matrixMode: number;
  57848. /** @hidden */
  57849. _systemValue: Nullable<NodeMaterialSystemValues>;
  57850. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  57851. visibleInInspector: boolean;
  57852. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  57853. isConstant: boolean;
  57854. /** Gets or sets the group to use to display this block in the Inspector */
  57855. groupInInspector: string;
  57856. /**
  57857. * Gets or sets the connection point type (default is float)
  57858. */
  57859. get type(): NodeMaterialBlockConnectionPointTypes;
  57860. /**
  57861. * Creates a new InputBlock
  57862. * @param name defines the block name
  57863. * @param target defines the target of that block (Vertex by default)
  57864. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  57865. */
  57866. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  57867. /**
  57868. * Gets the output component
  57869. */
  57870. get output(): NodeMaterialConnectionPoint;
  57871. /**
  57872. * Set the source of this connection point to a vertex attribute
  57873. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  57874. * @returns the current connection point
  57875. */
  57876. setAsAttribute(attributeName?: string): InputBlock;
  57877. /**
  57878. * Set the source of this connection point to a system value
  57879. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  57880. * @returns the current connection point
  57881. */
  57882. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  57883. /**
  57884. * Gets or sets the value of that point.
  57885. * Please note that this value will be ignored if valueCallback is defined
  57886. */
  57887. get value(): any;
  57888. set value(value: any);
  57889. /**
  57890. * Gets or sets a callback used to get the value of that point.
  57891. * Please note that setting this value will force the connection point to ignore the value property
  57892. */
  57893. get valueCallback(): () => any;
  57894. set valueCallback(value: () => any);
  57895. /**
  57896. * Gets or sets the associated variable name in the shader
  57897. */
  57898. get associatedVariableName(): string;
  57899. set associatedVariableName(value: string);
  57900. /** Gets or sets the type of animation applied to the input */
  57901. get animationType(): AnimatedInputBlockTypes;
  57902. set animationType(value: AnimatedInputBlockTypes);
  57903. /**
  57904. * Gets a boolean indicating that this connection point not defined yet
  57905. */
  57906. get isUndefined(): boolean;
  57907. /**
  57908. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  57909. * In this case the connection point name must be the name of the uniform to use.
  57910. * Can only be set on inputs
  57911. */
  57912. get isUniform(): boolean;
  57913. set isUniform(value: boolean);
  57914. /**
  57915. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  57916. * In this case the connection point name must be the name of the attribute to use
  57917. * Can only be set on inputs
  57918. */
  57919. get isAttribute(): boolean;
  57920. set isAttribute(value: boolean);
  57921. /**
  57922. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  57923. * Can only be set on exit points
  57924. */
  57925. get isVarying(): boolean;
  57926. set isVarying(value: boolean);
  57927. /**
  57928. * Gets a boolean indicating that the current connection point is a system value
  57929. */
  57930. get isSystemValue(): boolean;
  57931. /**
  57932. * Gets or sets the current well known value or null if not defined as a system value
  57933. */
  57934. get systemValue(): Nullable<NodeMaterialSystemValues>;
  57935. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  57936. /**
  57937. * Gets the current class name
  57938. * @returns the class name
  57939. */
  57940. getClassName(): string;
  57941. /**
  57942. * Animate the input if animationType !== None
  57943. * @param scene defines the rendering scene
  57944. */
  57945. animate(scene: Scene): void;
  57946. private _emitDefine;
  57947. initialize(state: NodeMaterialBuildState): void;
  57948. /**
  57949. * Set the input block to its default value (based on its type)
  57950. */
  57951. setDefaultValue(): void;
  57952. private _emitConstant;
  57953. private _emit;
  57954. /** @hidden */
  57955. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  57956. /** @hidden */
  57957. _transmit(effect: Effect, scene: Scene): void;
  57958. protected _buildBlock(state: NodeMaterialBuildState): void;
  57959. protected _dumpPropertiesCode(): string;
  57960. serialize(): any;
  57961. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57962. }
  57963. }
  57964. declare module BABYLON {
  57965. /**
  57966. * Enum used to define the compatibility state between two connection points
  57967. */
  57968. export enum NodeMaterialConnectionPointCompatibilityStates {
  57969. /** Points are compatibles */
  57970. Compatible = 0,
  57971. /** Points are incompatible because of their types */
  57972. TypeIncompatible = 1,
  57973. /** Points are incompatible because of their targets (vertex vs fragment) */
  57974. TargetIncompatible = 2
  57975. }
  57976. /**
  57977. * Defines the direction of a connection point
  57978. */
  57979. export enum NodeMaterialConnectionPointDirection {
  57980. /** Input */
  57981. Input = 0,
  57982. /** Output */
  57983. Output = 1
  57984. }
  57985. /**
  57986. * Defines a connection point for a block
  57987. */
  57988. export class NodeMaterialConnectionPoint {
  57989. /** @hidden */
  57990. _ownerBlock: NodeMaterialBlock;
  57991. /** @hidden */
  57992. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  57993. private _endpoints;
  57994. private _associatedVariableName;
  57995. private _direction;
  57996. /** @hidden */
  57997. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  57998. /** @hidden */
  57999. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  58000. private _type;
  58001. /** @hidden */
  58002. _enforceAssociatedVariableName: boolean;
  58003. /** Gets the direction of the point */
  58004. get direction(): NodeMaterialConnectionPointDirection;
  58005. /**
  58006. * Gets or sets the additional types supported by this connection point
  58007. */
  58008. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  58009. /**
  58010. * Gets or sets the additional types excluded by this connection point
  58011. */
  58012. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  58013. /**
  58014. * Observable triggered when this point is connected
  58015. */
  58016. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  58017. /**
  58018. * Gets or sets the associated variable name in the shader
  58019. */
  58020. get associatedVariableName(): string;
  58021. set associatedVariableName(value: string);
  58022. /** Get the inner type (ie AutoDetect for isntance instead of the inferred one) */
  58023. get innerType(): NodeMaterialBlockConnectionPointTypes;
  58024. /**
  58025. * Gets or sets the connection point type (default is float)
  58026. */
  58027. get type(): NodeMaterialBlockConnectionPointTypes;
  58028. set type(value: NodeMaterialBlockConnectionPointTypes);
  58029. /**
  58030. * Gets or sets the connection point name
  58031. */
  58032. name: string;
  58033. /**
  58034. * Gets or sets a boolean indicating that this connection point can be omitted
  58035. */
  58036. isOptional: boolean;
  58037. /**
  58038. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  58039. */
  58040. define: string;
  58041. /** @hidden */
  58042. _prioritizeVertex: boolean;
  58043. private _target;
  58044. /** Gets or sets the target of that connection point */
  58045. get target(): NodeMaterialBlockTargets;
  58046. set target(value: NodeMaterialBlockTargets);
  58047. /**
  58048. * Gets a boolean indicating that the current point is connected
  58049. */
  58050. get isConnected(): boolean;
  58051. /**
  58052. * Gets a boolean indicating that the current point is connected to an input block
  58053. */
  58054. get isConnectedToInputBlock(): boolean;
  58055. /**
  58056. * Gets a the connected input block (if any)
  58057. */
  58058. get connectInputBlock(): Nullable<InputBlock>;
  58059. /** Get the other side of the connection (if any) */
  58060. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  58061. /** Get the block that owns this connection point */
  58062. get ownerBlock(): NodeMaterialBlock;
  58063. /** Get the block connected on the other side of this connection (if any) */
  58064. get sourceBlock(): Nullable<NodeMaterialBlock>;
  58065. /** Get the block connected on the endpoints of this connection (if any) */
  58066. get connectedBlocks(): Array<NodeMaterialBlock>;
  58067. /** Gets the list of connected endpoints */
  58068. get endpoints(): NodeMaterialConnectionPoint[];
  58069. /** Gets a boolean indicating if that output point is connected to at least one input */
  58070. get hasEndpoints(): boolean;
  58071. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  58072. get isConnectedInVertexShader(): boolean;
  58073. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  58074. get isConnectedInFragmentShader(): boolean;
  58075. /**
  58076. * Creates a new connection point
  58077. * @param name defines the connection point name
  58078. * @param ownerBlock defines the block hosting this connection point
  58079. * @param direction defines the direction of the connection point
  58080. */
  58081. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  58082. /**
  58083. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  58084. * @returns the class name
  58085. */
  58086. getClassName(): string;
  58087. /**
  58088. * Gets a boolean indicating if the current point can be connected to another point
  58089. * @param connectionPoint defines the other connection point
  58090. * @returns a boolean
  58091. */
  58092. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  58093. /**
  58094. * Gets a number indicating if the current point can be connected to another point
  58095. * @param connectionPoint defines the other connection point
  58096. * @returns a number defining the compatibility state
  58097. */
  58098. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  58099. /**
  58100. * Connect this point to another connection point
  58101. * @param connectionPoint defines the other connection point
  58102. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  58103. * @returns the current connection point
  58104. */
  58105. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  58106. /**
  58107. * Disconnect this point from one of his endpoint
  58108. * @param endpoint defines the other connection point
  58109. * @returns the current connection point
  58110. */
  58111. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  58112. /**
  58113. * Serializes this point in a JSON representation
  58114. * @returns the serialized point object
  58115. */
  58116. serialize(): any;
  58117. /**
  58118. * Release resources
  58119. */
  58120. dispose(): void;
  58121. }
  58122. }
  58123. declare module BABYLON {
  58124. /**
  58125. * Block used to add support for vertex skinning (bones)
  58126. */
  58127. export class BonesBlock extends NodeMaterialBlock {
  58128. /**
  58129. * Creates a new BonesBlock
  58130. * @param name defines the block name
  58131. */
  58132. constructor(name: string);
  58133. /**
  58134. * Initialize the block and prepare the context for build
  58135. * @param state defines the state that will be used for the build
  58136. */
  58137. initialize(state: NodeMaterialBuildState): void;
  58138. /**
  58139. * Gets the current class name
  58140. * @returns the class name
  58141. */
  58142. getClassName(): string;
  58143. /**
  58144. * Gets the matrix indices input component
  58145. */
  58146. get matricesIndices(): NodeMaterialConnectionPoint;
  58147. /**
  58148. * Gets the matrix weights input component
  58149. */
  58150. get matricesWeights(): NodeMaterialConnectionPoint;
  58151. /**
  58152. * Gets the extra matrix indices input component
  58153. */
  58154. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  58155. /**
  58156. * Gets the extra matrix weights input component
  58157. */
  58158. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  58159. /**
  58160. * Gets the world input component
  58161. */
  58162. get world(): NodeMaterialConnectionPoint;
  58163. /**
  58164. * Gets the output component
  58165. */
  58166. get output(): NodeMaterialConnectionPoint;
  58167. autoConfigure(material: NodeMaterial): void;
  58168. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  58169. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58170. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58171. protected _buildBlock(state: NodeMaterialBuildState): this;
  58172. }
  58173. }
  58174. declare module BABYLON {
  58175. /**
  58176. * Block used to add support for instances
  58177. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  58178. */
  58179. export class InstancesBlock extends NodeMaterialBlock {
  58180. /**
  58181. * Creates a new InstancesBlock
  58182. * @param name defines the block name
  58183. */
  58184. constructor(name: string);
  58185. /**
  58186. * Gets the current class name
  58187. * @returns the class name
  58188. */
  58189. getClassName(): string;
  58190. /**
  58191. * Gets the first world row input component
  58192. */
  58193. get world0(): NodeMaterialConnectionPoint;
  58194. /**
  58195. * Gets the second world row input component
  58196. */
  58197. get world1(): NodeMaterialConnectionPoint;
  58198. /**
  58199. * Gets the third world row input component
  58200. */
  58201. get world2(): NodeMaterialConnectionPoint;
  58202. /**
  58203. * Gets the forth world row input component
  58204. */
  58205. get world3(): NodeMaterialConnectionPoint;
  58206. /**
  58207. * Gets the world input component
  58208. */
  58209. get world(): NodeMaterialConnectionPoint;
  58210. /**
  58211. * Gets the output component
  58212. */
  58213. get output(): NodeMaterialConnectionPoint;
  58214. /**
  58215. * Gets the isntanceID component
  58216. */
  58217. get instanceID(): NodeMaterialConnectionPoint;
  58218. autoConfigure(material: NodeMaterial): void;
  58219. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  58220. protected _buildBlock(state: NodeMaterialBuildState): this;
  58221. }
  58222. }
  58223. declare module BABYLON {
  58224. /**
  58225. * Block used to add morph targets support to vertex shader
  58226. */
  58227. export class MorphTargetsBlock extends NodeMaterialBlock {
  58228. private _repeatableContentAnchor;
  58229. /**
  58230. * Create a new MorphTargetsBlock
  58231. * @param name defines the block name
  58232. */
  58233. constructor(name: string);
  58234. /**
  58235. * Gets the current class name
  58236. * @returns the class name
  58237. */
  58238. getClassName(): string;
  58239. /**
  58240. * Gets the position input component
  58241. */
  58242. get position(): NodeMaterialConnectionPoint;
  58243. /**
  58244. * Gets the normal input component
  58245. */
  58246. get normal(): NodeMaterialConnectionPoint;
  58247. /**
  58248. * Gets the tangent input component
  58249. */
  58250. get tangent(): NodeMaterialConnectionPoint;
  58251. /**
  58252. * Gets the tangent input component
  58253. */
  58254. get uv(): NodeMaterialConnectionPoint;
  58255. /**
  58256. * Gets the position output component
  58257. */
  58258. get positionOutput(): NodeMaterialConnectionPoint;
  58259. /**
  58260. * Gets the normal output component
  58261. */
  58262. get normalOutput(): NodeMaterialConnectionPoint;
  58263. /**
  58264. * Gets the tangent output component
  58265. */
  58266. get tangentOutput(): NodeMaterialConnectionPoint;
  58267. /**
  58268. * Gets the tangent output component
  58269. */
  58270. get uvOutput(): NodeMaterialConnectionPoint;
  58271. initialize(state: NodeMaterialBuildState): void;
  58272. autoConfigure(material: NodeMaterial): void;
  58273. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58274. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58275. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  58276. protected _buildBlock(state: NodeMaterialBuildState): this;
  58277. }
  58278. }
  58279. declare module BABYLON {
  58280. /**
  58281. * Block used to get data information from a light
  58282. */
  58283. export class LightInformationBlock extends NodeMaterialBlock {
  58284. private _lightDataUniformName;
  58285. private _lightColorUniformName;
  58286. private _lightTypeDefineName;
  58287. /**
  58288. * Gets or sets the light associated with this block
  58289. */
  58290. light: Nullable<Light>;
  58291. /**
  58292. * Creates a new LightInformationBlock
  58293. * @param name defines the block name
  58294. */
  58295. constructor(name: string);
  58296. /**
  58297. * Gets the current class name
  58298. * @returns the class name
  58299. */
  58300. getClassName(): string;
  58301. /**
  58302. * Gets the world position input component
  58303. */
  58304. get worldPosition(): NodeMaterialConnectionPoint;
  58305. /**
  58306. * Gets the direction output component
  58307. */
  58308. get direction(): NodeMaterialConnectionPoint;
  58309. /**
  58310. * Gets the direction output component
  58311. */
  58312. get color(): NodeMaterialConnectionPoint;
  58313. /**
  58314. * Gets the direction output component
  58315. */
  58316. get intensity(): NodeMaterialConnectionPoint;
  58317. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58318. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58319. protected _buildBlock(state: NodeMaterialBuildState): this;
  58320. serialize(): any;
  58321. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58322. }
  58323. }
  58324. declare module BABYLON {
  58325. /**
  58326. * Block used to add image processing support to fragment shader
  58327. */
  58328. export class ImageProcessingBlock extends NodeMaterialBlock {
  58329. /**
  58330. * Create a new ImageProcessingBlock
  58331. * @param name defines the block name
  58332. */
  58333. constructor(name: string);
  58334. /**
  58335. * Gets the current class name
  58336. * @returns the class name
  58337. */
  58338. getClassName(): string;
  58339. /**
  58340. * Gets the color input component
  58341. */
  58342. get color(): NodeMaterialConnectionPoint;
  58343. /**
  58344. * Gets the output component
  58345. */
  58346. get output(): NodeMaterialConnectionPoint;
  58347. /**
  58348. * Initialize the block and prepare the context for build
  58349. * @param state defines the state that will be used for the build
  58350. */
  58351. initialize(state: NodeMaterialBuildState): void;
  58352. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  58353. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58354. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58355. protected _buildBlock(state: NodeMaterialBuildState): this;
  58356. }
  58357. }
  58358. declare module BABYLON {
  58359. /**
  58360. * Block used to pertub normals based on a normal map
  58361. */
  58362. export class PerturbNormalBlock extends NodeMaterialBlock {
  58363. private _tangentSpaceParameterName;
  58364. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  58365. invertX: boolean;
  58366. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  58367. invertY: boolean;
  58368. /**
  58369. * Create a new PerturbNormalBlock
  58370. * @param name defines the block name
  58371. */
  58372. constructor(name: string);
  58373. /**
  58374. * Gets the current class name
  58375. * @returns the class name
  58376. */
  58377. getClassName(): string;
  58378. /**
  58379. * Gets the world position input component
  58380. */
  58381. get worldPosition(): NodeMaterialConnectionPoint;
  58382. /**
  58383. * Gets the world normal input component
  58384. */
  58385. get worldNormal(): NodeMaterialConnectionPoint;
  58386. /**
  58387. * Gets the world tangent input component
  58388. */
  58389. get worldTangent(): NodeMaterialConnectionPoint;
  58390. /**
  58391. * Gets the uv input component
  58392. */
  58393. get uv(): NodeMaterialConnectionPoint;
  58394. /**
  58395. * Gets the normal map color input component
  58396. */
  58397. get normalMapColor(): NodeMaterialConnectionPoint;
  58398. /**
  58399. * Gets the strength input component
  58400. */
  58401. get strength(): NodeMaterialConnectionPoint;
  58402. /**
  58403. * Gets the output component
  58404. */
  58405. get output(): NodeMaterialConnectionPoint;
  58406. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58407. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58408. autoConfigure(material: NodeMaterial): void;
  58409. protected _buildBlock(state: NodeMaterialBuildState): this;
  58410. protected _dumpPropertiesCode(): string;
  58411. serialize(): any;
  58412. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58413. }
  58414. }
  58415. declare module BABYLON {
  58416. /**
  58417. * Block used to discard a pixel if a value is smaller than a cutoff
  58418. */
  58419. export class DiscardBlock extends NodeMaterialBlock {
  58420. /**
  58421. * Create a new DiscardBlock
  58422. * @param name defines the block name
  58423. */
  58424. constructor(name: string);
  58425. /**
  58426. * Gets the current class name
  58427. * @returns the class name
  58428. */
  58429. getClassName(): string;
  58430. /**
  58431. * Gets the color input component
  58432. */
  58433. get value(): NodeMaterialConnectionPoint;
  58434. /**
  58435. * Gets the cutoff input component
  58436. */
  58437. get cutoff(): NodeMaterialConnectionPoint;
  58438. protected _buildBlock(state: NodeMaterialBuildState): this;
  58439. }
  58440. }
  58441. declare module BABYLON {
  58442. /**
  58443. * Block used to test if the fragment shader is front facing
  58444. */
  58445. export class FrontFacingBlock extends NodeMaterialBlock {
  58446. /**
  58447. * Creates a new FrontFacingBlock
  58448. * @param name defines the block name
  58449. */
  58450. constructor(name: string);
  58451. /**
  58452. * Gets the current class name
  58453. * @returns the class name
  58454. */
  58455. getClassName(): string;
  58456. /**
  58457. * Gets the output component
  58458. */
  58459. get output(): NodeMaterialConnectionPoint;
  58460. protected _buildBlock(state: NodeMaterialBuildState): this;
  58461. }
  58462. }
  58463. declare module BABYLON {
  58464. /**
  58465. * Block used to get the derivative value on x and y of a given input
  58466. */
  58467. export class DerivativeBlock extends NodeMaterialBlock {
  58468. /**
  58469. * Create a new DerivativeBlock
  58470. * @param name defines the block name
  58471. */
  58472. constructor(name: string);
  58473. /**
  58474. * Gets the current class name
  58475. * @returns the class name
  58476. */
  58477. getClassName(): string;
  58478. /**
  58479. * Gets the input component
  58480. */
  58481. get input(): NodeMaterialConnectionPoint;
  58482. /**
  58483. * Gets the derivative output on x
  58484. */
  58485. get dx(): NodeMaterialConnectionPoint;
  58486. /**
  58487. * Gets the derivative output on y
  58488. */
  58489. get dy(): NodeMaterialConnectionPoint;
  58490. protected _buildBlock(state: NodeMaterialBuildState): this;
  58491. }
  58492. }
  58493. declare module BABYLON {
  58494. /**
  58495. * Block used to add support for scene fog
  58496. */
  58497. export class FogBlock extends NodeMaterialBlock {
  58498. private _fogDistanceName;
  58499. private _fogParameters;
  58500. /**
  58501. * Create a new FogBlock
  58502. * @param name defines the block name
  58503. */
  58504. constructor(name: string);
  58505. /**
  58506. * Gets the current class name
  58507. * @returns the class name
  58508. */
  58509. getClassName(): string;
  58510. /**
  58511. * Gets the world position input component
  58512. */
  58513. get worldPosition(): NodeMaterialConnectionPoint;
  58514. /**
  58515. * Gets the view input component
  58516. */
  58517. get view(): NodeMaterialConnectionPoint;
  58518. /**
  58519. * Gets the color input component
  58520. */
  58521. get input(): NodeMaterialConnectionPoint;
  58522. /**
  58523. * Gets the fog color input component
  58524. */
  58525. get fogColor(): NodeMaterialConnectionPoint;
  58526. /**
  58527. * Gets the output component
  58528. */
  58529. get output(): NodeMaterialConnectionPoint;
  58530. autoConfigure(material: NodeMaterial): void;
  58531. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58532. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58533. protected _buildBlock(state: NodeMaterialBuildState): this;
  58534. }
  58535. }
  58536. declare module BABYLON {
  58537. /**
  58538. * Block used to add light in the fragment shader
  58539. */
  58540. export class LightBlock extends NodeMaterialBlock {
  58541. private _lightId;
  58542. /**
  58543. * Gets or sets the light associated with this block
  58544. */
  58545. light: Nullable<Light>;
  58546. /**
  58547. * Create a new LightBlock
  58548. * @param name defines the block name
  58549. */
  58550. constructor(name: string);
  58551. /**
  58552. * Gets the current class name
  58553. * @returns the class name
  58554. */
  58555. getClassName(): string;
  58556. /**
  58557. * Gets the world position input component
  58558. */
  58559. get worldPosition(): NodeMaterialConnectionPoint;
  58560. /**
  58561. * Gets the world normal input component
  58562. */
  58563. get worldNormal(): NodeMaterialConnectionPoint;
  58564. /**
  58565. * Gets the camera (or eye) position component
  58566. */
  58567. get cameraPosition(): NodeMaterialConnectionPoint;
  58568. /**
  58569. * Gets the glossiness component
  58570. */
  58571. get glossiness(): NodeMaterialConnectionPoint;
  58572. /**
  58573. * Gets the glossinness power component
  58574. */
  58575. get glossPower(): NodeMaterialConnectionPoint;
  58576. /**
  58577. * Gets the diffuse color component
  58578. */
  58579. get diffuseColor(): NodeMaterialConnectionPoint;
  58580. /**
  58581. * Gets the specular color component
  58582. */
  58583. get specularColor(): NodeMaterialConnectionPoint;
  58584. /**
  58585. * Gets the diffuse output component
  58586. */
  58587. get diffuseOutput(): NodeMaterialConnectionPoint;
  58588. /**
  58589. * Gets the specular output component
  58590. */
  58591. get specularOutput(): NodeMaterialConnectionPoint;
  58592. /**
  58593. * Gets the shadow output component
  58594. */
  58595. get shadow(): NodeMaterialConnectionPoint;
  58596. autoConfigure(material: NodeMaterial): void;
  58597. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58598. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  58599. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58600. private _injectVertexCode;
  58601. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  58602. serialize(): any;
  58603. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58604. }
  58605. }
  58606. declare module BABYLON {
  58607. /**
  58608. * Block used to multiply 2 values
  58609. */
  58610. export class MultiplyBlock extends NodeMaterialBlock {
  58611. /**
  58612. * Creates a new MultiplyBlock
  58613. * @param name defines the block name
  58614. */
  58615. constructor(name: string);
  58616. /**
  58617. * Gets the current class name
  58618. * @returns the class name
  58619. */
  58620. getClassName(): string;
  58621. /**
  58622. * Gets the left operand input component
  58623. */
  58624. get left(): NodeMaterialConnectionPoint;
  58625. /**
  58626. * Gets the right operand input component
  58627. */
  58628. get right(): NodeMaterialConnectionPoint;
  58629. /**
  58630. * Gets the output component
  58631. */
  58632. get output(): NodeMaterialConnectionPoint;
  58633. protected _buildBlock(state: NodeMaterialBuildState): this;
  58634. }
  58635. }
  58636. declare module BABYLON {
  58637. /**
  58638. * Block used to add 2 vectors
  58639. */
  58640. export class AddBlock extends NodeMaterialBlock {
  58641. /**
  58642. * Creates a new AddBlock
  58643. * @param name defines the block name
  58644. */
  58645. constructor(name: string);
  58646. /**
  58647. * Gets the current class name
  58648. * @returns the class name
  58649. */
  58650. getClassName(): string;
  58651. /**
  58652. * Gets the left operand input component
  58653. */
  58654. get left(): NodeMaterialConnectionPoint;
  58655. /**
  58656. * Gets the right operand input component
  58657. */
  58658. get right(): NodeMaterialConnectionPoint;
  58659. /**
  58660. * Gets the output component
  58661. */
  58662. get output(): NodeMaterialConnectionPoint;
  58663. protected _buildBlock(state: NodeMaterialBuildState): this;
  58664. }
  58665. }
  58666. declare module BABYLON {
  58667. /**
  58668. * Block used to scale a vector by a float
  58669. */
  58670. export class ScaleBlock extends NodeMaterialBlock {
  58671. /**
  58672. * Creates a new ScaleBlock
  58673. * @param name defines the block name
  58674. */
  58675. constructor(name: string);
  58676. /**
  58677. * Gets the current class name
  58678. * @returns the class name
  58679. */
  58680. getClassName(): string;
  58681. /**
  58682. * Gets the input component
  58683. */
  58684. get input(): NodeMaterialConnectionPoint;
  58685. /**
  58686. * Gets the factor input component
  58687. */
  58688. get factor(): NodeMaterialConnectionPoint;
  58689. /**
  58690. * Gets the output component
  58691. */
  58692. get output(): NodeMaterialConnectionPoint;
  58693. protected _buildBlock(state: NodeMaterialBuildState): this;
  58694. }
  58695. }
  58696. declare module BABYLON {
  58697. /**
  58698. * Block used to clamp a float
  58699. */
  58700. export class ClampBlock extends NodeMaterialBlock {
  58701. /** Gets or sets the minimum range */
  58702. minimum: number;
  58703. /** Gets or sets the maximum range */
  58704. maximum: number;
  58705. /**
  58706. * Creates a new ClampBlock
  58707. * @param name defines the block name
  58708. */
  58709. constructor(name: string);
  58710. /**
  58711. * Gets the current class name
  58712. * @returns the class name
  58713. */
  58714. getClassName(): string;
  58715. /**
  58716. * Gets the value input component
  58717. */
  58718. get value(): NodeMaterialConnectionPoint;
  58719. /**
  58720. * Gets the output component
  58721. */
  58722. get output(): NodeMaterialConnectionPoint;
  58723. protected _buildBlock(state: NodeMaterialBuildState): this;
  58724. protected _dumpPropertiesCode(): string;
  58725. serialize(): any;
  58726. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58727. }
  58728. }
  58729. declare module BABYLON {
  58730. /**
  58731. * Block used to apply a cross product between 2 vectors
  58732. */
  58733. export class CrossBlock extends NodeMaterialBlock {
  58734. /**
  58735. * Creates a new CrossBlock
  58736. * @param name defines the block name
  58737. */
  58738. constructor(name: string);
  58739. /**
  58740. * Gets the current class name
  58741. * @returns the class name
  58742. */
  58743. getClassName(): string;
  58744. /**
  58745. * Gets the left operand input component
  58746. */
  58747. get left(): NodeMaterialConnectionPoint;
  58748. /**
  58749. * Gets the right operand input component
  58750. */
  58751. get right(): NodeMaterialConnectionPoint;
  58752. /**
  58753. * Gets the output component
  58754. */
  58755. get output(): NodeMaterialConnectionPoint;
  58756. protected _buildBlock(state: NodeMaterialBuildState): this;
  58757. }
  58758. }
  58759. declare module BABYLON {
  58760. /**
  58761. * Block used to apply a dot product between 2 vectors
  58762. */
  58763. export class DotBlock extends NodeMaterialBlock {
  58764. /**
  58765. * Creates a new DotBlock
  58766. * @param name defines the block name
  58767. */
  58768. constructor(name: string);
  58769. /**
  58770. * Gets the current class name
  58771. * @returns the class name
  58772. */
  58773. getClassName(): string;
  58774. /**
  58775. * Gets the left operand input component
  58776. */
  58777. get left(): NodeMaterialConnectionPoint;
  58778. /**
  58779. * Gets the right operand input component
  58780. */
  58781. get right(): NodeMaterialConnectionPoint;
  58782. /**
  58783. * Gets the output component
  58784. */
  58785. get output(): NodeMaterialConnectionPoint;
  58786. protected _buildBlock(state: NodeMaterialBuildState): this;
  58787. }
  58788. }
  58789. declare module BABYLON {
  58790. /**
  58791. * Block used to remap a float from a range to a new one
  58792. */
  58793. export class RemapBlock extends NodeMaterialBlock {
  58794. /**
  58795. * Gets or sets the source range
  58796. */
  58797. sourceRange: Vector2;
  58798. /**
  58799. * Gets or sets the target range
  58800. */
  58801. targetRange: Vector2;
  58802. /**
  58803. * Creates a new RemapBlock
  58804. * @param name defines the block name
  58805. */
  58806. constructor(name: string);
  58807. /**
  58808. * Gets the current class name
  58809. * @returns the class name
  58810. */
  58811. getClassName(): string;
  58812. /**
  58813. * Gets the input component
  58814. */
  58815. get input(): NodeMaterialConnectionPoint;
  58816. /**
  58817. * Gets the source min input component
  58818. */
  58819. get sourceMin(): NodeMaterialConnectionPoint;
  58820. /**
  58821. * Gets the source max input component
  58822. */
  58823. get sourceMax(): NodeMaterialConnectionPoint;
  58824. /**
  58825. * Gets the target min input component
  58826. */
  58827. get targetMin(): NodeMaterialConnectionPoint;
  58828. /**
  58829. * Gets the target max input component
  58830. */
  58831. get targetMax(): NodeMaterialConnectionPoint;
  58832. /**
  58833. * Gets the output component
  58834. */
  58835. get output(): NodeMaterialConnectionPoint;
  58836. protected _buildBlock(state: NodeMaterialBuildState): this;
  58837. protected _dumpPropertiesCode(): string;
  58838. serialize(): any;
  58839. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58840. }
  58841. }
  58842. declare module BABYLON {
  58843. /**
  58844. * Block used to normalize a vector
  58845. */
  58846. export class NormalizeBlock extends NodeMaterialBlock {
  58847. /**
  58848. * Creates a new NormalizeBlock
  58849. * @param name defines the block name
  58850. */
  58851. constructor(name: string);
  58852. /**
  58853. * Gets the current class name
  58854. * @returns the class name
  58855. */
  58856. getClassName(): string;
  58857. /**
  58858. * Gets the input component
  58859. */
  58860. get input(): NodeMaterialConnectionPoint;
  58861. /**
  58862. * Gets the output component
  58863. */
  58864. get output(): NodeMaterialConnectionPoint;
  58865. protected _buildBlock(state: NodeMaterialBuildState): this;
  58866. }
  58867. }
  58868. declare module BABYLON {
  58869. /**
  58870. * Operations supported by the Trigonometry block
  58871. */
  58872. export enum TrigonometryBlockOperations {
  58873. /** Cos */
  58874. Cos = 0,
  58875. /** Sin */
  58876. Sin = 1,
  58877. /** Abs */
  58878. Abs = 2,
  58879. /** Exp */
  58880. Exp = 3,
  58881. /** Exp2 */
  58882. Exp2 = 4,
  58883. /** Round */
  58884. Round = 5,
  58885. /** Floor */
  58886. Floor = 6,
  58887. /** Ceiling */
  58888. Ceiling = 7,
  58889. /** Square root */
  58890. Sqrt = 8,
  58891. /** Log */
  58892. Log = 9,
  58893. /** Tangent */
  58894. Tan = 10,
  58895. /** Arc tangent */
  58896. ArcTan = 11,
  58897. /** Arc cosinus */
  58898. ArcCos = 12,
  58899. /** Arc sinus */
  58900. ArcSin = 13,
  58901. /** Fraction */
  58902. Fract = 14,
  58903. /** Sign */
  58904. Sign = 15,
  58905. /** To radians (from degrees) */
  58906. Radians = 16,
  58907. /** To degrees (from radians) */
  58908. Degrees = 17
  58909. }
  58910. /**
  58911. * Block used to apply trigonometry operation to floats
  58912. */
  58913. export class TrigonometryBlock extends NodeMaterialBlock {
  58914. /**
  58915. * Gets or sets the operation applied by the block
  58916. */
  58917. operation: TrigonometryBlockOperations;
  58918. /**
  58919. * Creates a new TrigonometryBlock
  58920. * @param name defines the block name
  58921. */
  58922. constructor(name: string);
  58923. /**
  58924. * Gets the current class name
  58925. * @returns the class name
  58926. */
  58927. getClassName(): string;
  58928. /**
  58929. * Gets the input component
  58930. */
  58931. get input(): NodeMaterialConnectionPoint;
  58932. /**
  58933. * Gets the output component
  58934. */
  58935. get output(): NodeMaterialConnectionPoint;
  58936. protected _buildBlock(state: NodeMaterialBuildState): this;
  58937. serialize(): any;
  58938. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58939. protected _dumpPropertiesCode(): string;
  58940. }
  58941. }
  58942. declare module BABYLON {
  58943. /**
  58944. * Block used to create a Color3/4 out of individual inputs (one for each component)
  58945. */
  58946. export class ColorMergerBlock extends NodeMaterialBlock {
  58947. /**
  58948. * Create a new ColorMergerBlock
  58949. * @param name defines the block name
  58950. */
  58951. constructor(name: string);
  58952. /**
  58953. * Gets the current class name
  58954. * @returns the class name
  58955. */
  58956. getClassName(): string;
  58957. /**
  58958. * Gets the rgb component (input)
  58959. */
  58960. get rgbIn(): NodeMaterialConnectionPoint;
  58961. /**
  58962. * Gets the r component (input)
  58963. */
  58964. get r(): NodeMaterialConnectionPoint;
  58965. /**
  58966. * Gets the g component (input)
  58967. */
  58968. get g(): NodeMaterialConnectionPoint;
  58969. /**
  58970. * Gets the b component (input)
  58971. */
  58972. get b(): NodeMaterialConnectionPoint;
  58973. /**
  58974. * Gets the a component (input)
  58975. */
  58976. get a(): NodeMaterialConnectionPoint;
  58977. /**
  58978. * Gets the rgba component (output)
  58979. */
  58980. get rgba(): NodeMaterialConnectionPoint;
  58981. /**
  58982. * Gets the rgb component (output)
  58983. */
  58984. get rgbOut(): NodeMaterialConnectionPoint;
  58985. /**
  58986. * Gets the rgb component (output)
  58987. * @deprecated Please use rgbOut instead.
  58988. */
  58989. get rgb(): NodeMaterialConnectionPoint;
  58990. protected _buildBlock(state: NodeMaterialBuildState): this;
  58991. }
  58992. }
  58993. declare module BABYLON {
  58994. /**
  58995. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  58996. */
  58997. export class VectorMergerBlock extends NodeMaterialBlock {
  58998. /**
  58999. * Create a new VectorMergerBlock
  59000. * @param name defines the block name
  59001. */
  59002. constructor(name: string);
  59003. /**
  59004. * Gets the current class name
  59005. * @returns the class name
  59006. */
  59007. getClassName(): string;
  59008. /**
  59009. * Gets the xyz component (input)
  59010. */
  59011. get xyzIn(): NodeMaterialConnectionPoint;
  59012. /**
  59013. * Gets the xy component (input)
  59014. */
  59015. get xyIn(): NodeMaterialConnectionPoint;
  59016. /**
  59017. * Gets the x component (input)
  59018. */
  59019. get x(): NodeMaterialConnectionPoint;
  59020. /**
  59021. * Gets the y component (input)
  59022. */
  59023. get y(): NodeMaterialConnectionPoint;
  59024. /**
  59025. * Gets the z component (input)
  59026. */
  59027. get z(): NodeMaterialConnectionPoint;
  59028. /**
  59029. * Gets the w component (input)
  59030. */
  59031. get w(): NodeMaterialConnectionPoint;
  59032. /**
  59033. * Gets the xyzw component (output)
  59034. */
  59035. get xyzw(): NodeMaterialConnectionPoint;
  59036. /**
  59037. * Gets the xyz component (output)
  59038. */
  59039. get xyzOut(): NodeMaterialConnectionPoint;
  59040. /**
  59041. * Gets the xy component (output)
  59042. */
  59043. get xyOut(): NodeMaterialConnectionPoint;
  59044. /**
  59045. * Gets the xy component (output)
  59046. * @deprecated Please use xyOut instead.
  59047. */
  59048. get xy(): NodeMaterialConnectionPoint;
  59049. /**
  59050. * Gets the xyz component (output)
  59051. * @deprecated Please use xyzOut instead.
  59052. */
  59053. get xyz(): NodeMaterialConnectionPoint;
  59054. protected _buildBlock(state: NodeMaterialBuildState): this;
  59055. }
  59056. }
  59057. declare module BABYLON {
  59058. /**
  59059. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  59060. */
  59061. export class ColorSplitterBlock extends NodeMaterialBlock {
  59062. /**
  59063. * Create a new ColorSplitterBlock
  59064. * @param name defines the block name
  59065. */
  59066. constructor(name: string);
  59067. /**
  59068. * Gets the current class name
  59069. * @returns the class name
  59070. */
  59071. getClassName(): string;
  59072. /**
  59073. * Gets the rgba component (input)
  59074. */
  59075. get rgba(): NodeMaterialConnectionPoint;
  59076. /**
  59077. * Gets the rgb component (input)
  59078. */
  59079. get rgbIn(): NodeMaterialConnectionPoint;
  59080. /**
  59081. * Gets the rgb component (output)
  59082. */
  59083. get rgbOut(): NodeMaterialConnectionPoint;
  59084. /**
  59085. * Gets the r component (output)
  59086. */
  59087. get r(): NodeMaterialConnectionPoint;
  59088. /**
  59089. * Gets the g component (output)
  59090. */
  59091. get g(): NodeMaterialConnectionPoint;
  59092. /**
  59093. * Gets the b component (output)
  59094. */
  59095. get b(): NodeMaterialConnectionPoint;
  59096. /**
  59097. * Gets the a component (output)
  59098. */
  59099. get a(): NodeMaterialConnectionPoint;
  59100. protected _inputRename(name: string): string;
  59101. protected _outputRename(name: string): string;
  59102. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  59103. }
  59104. }
  59105. declare module BABYLON {
  59106. /**
  59107. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  59108. */
  59109. export class VectorSplitterBlock extends NodeMaterialBlock {
  59110. /**
  59111. * Create a new VectorSplitterBlock
  59112. * @param name defines the block name
  59113. */
  59114. constructor(name: string);
  59115. /**
  59116. * Gets the current class name
  59117. * @returns the class name
  59118. */
  59119. getClassName(): string;
  59120. /**
  59121. * Gets the xyzw component (input)
  59122. */
  59123. get xyzw(): NodeMaterialConnectionPoint;
  59124. /**
  59125. * Gets the xyz component (input)
  59126. */
  59127. get xyzIn(): NodeMaterialConnectionPoint;
  59128. /**
  59129. * Gets the xy component (input)
  59130. */
  59131. get xyIn(): NodeMaterialConnectionPoint;
  59132. /**
  59133. * Gets the xyz component (output)
  59134. */
  59135. get xyzOut(): NodeMaterialConnectionPoint;
  59136. /**
  59137. * Gets the xy component (output)
  59138. */
  59139. get xyOut(): NodeMaterialConnectionPoint;
  59140. /**
  59141. * Gets the x component (output)
  59142. */
  59143. get x(): NodeMaterialConnectionPoint;
  59144. /**
  59145. * Gets the y component (output)
  59146. */
  59147. get y(): NodeMaterialConnectionPoint;
  59148. /**
  59149. * Gets the z component (output)
  59150. */
  59151. get z(): NodeMaterialConnectionPoint;
  59152. /**
  59153. * Gets the w component (output)
  59154. */
  59155. get w(): NodeMaterialConnectionPoint;
  59156. protected _inputRename(name: string): string;
  59157. protected _outputRename(name: string): string;
  59158. protected _buildBlock(state: NodeMaterialBuildState): this;
  59159. }
  59160. }
  59161. declare module BABYLON {
  59162. /**
  59163. * Block used to lerp between 2 values
  59164. */
  59165. export class LerpBlock extends NodeMaterialBlock {
  59166. /**
  59167. * Creates a new LerpBlock
  59168. * @param name defines the block name
  59169. */
  59170. constructor(name: string);
  59171. /**
  59172. * Gets the current class name
  59173. * @returns the class name
  59174. */
  59175. getClassName(): string;
  59176. /**
  59177. * Gets the left operand input component
  59178. */
  59179. get left(): NodeMaterialConnectionPoint;
  59180. /**
  59181. * Gets the right operand input component
  59182. */
  59183. get right(): NodeMaterialConnectionPoint;
  59184. /**
  59185. * Gets the gradient operand input component
  59186. */
  59187. get gradient(): NodeMaterialConnectionPoint;
  59188. /**
  59189. * Gets the output component
  59190. */
  59191. get output(): NodeMaterialConnectionPoint;
  59192. protected _buildBlock(state: NodeMaterialBuildState): this;
  59193. }
  59194. }
  59195. declare module BABYLON {
  59196. /**
  59197. * Block used to divide 2 vectors
  59198. */
  59199. export class DivideBlock extends NodeMaterialBlock {
  59200. /**
  59201. * Creates a new DivideBlock
  59202. * @param name defines the block name
  59203. */
  59204. constructor(name: string);
  59205. /**
  59206. * Gets the current class name
  59207. * @returns the class name
  59208. */
  59209. getClassName(): string;
  59210. /**
  59211. * Gets the left operand input component
  59212. */
  59213. get left(): NodeMaterialConnectionPoint;
  59214. /**
  59215. * Gets the right operand input component
  59216. */
  59217. get right(): NodeMaterialConnectionPoint;
  59218. /**
  59219. * Gets the output component
  59220. */
  59221. get output(): NodeMaterialConnectionPoint;
  59222. protected _buildBlock(state: NodeMaterialBuildState): this;
  59223. }
  59224. }
  59225. declare module BABYLON {
  59226. /**
  59227. * Block used to subtract 2 vectors
  59228. */
  59229. export class SubtractBlock extends NodeMaterialBlock {
  59230. /**
  59231. * Creates a new SubtractBlock
  59232. * @param name defines the block name
  59233. */
  59234. constructor(name: string);
  59235. /**
  59236. * Gets the current class name
  59237. * @returns the class name
  59238. */
  59239. getClassName(): string;
  59240. /**
  59241. * Gets the left operand input component
  59242. */
  59243. get left(): NodeMaterialConnectionPoint;
  59244. /**
  59245. * Gets the right operand input component
  59246. */
  59247. get right(): NodeMaterialConnectionPoint;
  59248. /**
  59249. * Gets the output component
  59250. */
  59251. get output(): NodeMaterialConnectionPoint;
  59252. protected _buildBlock(state: NodeMaterialBuildState): this;
  59253. }
  59254. }
  59255. declare module BABYLON {
  59256. /**
  59257. * Block used to step a value
  59258. */
  59259. export class StepBlock extends NodeMaterialBlock {
  59260. /**
  59261. * Creates a new StepBlock
  59262. * @param name defines the block name
  59263. */
  59264. constructor(name: string);
  59265. /**
  59266. * Gets the current class name
  59267. * @returns the class name
  59268. */
  59269. getClassName(): string;
  59270. /**
  59271. * Gets the value operand input component
  59272. */
  59273. get value(): NodeMaterialConnectionPoint;
  59274. /**
  59275. * Gets the edge operand input component
  59276. */
  59277. get edge(): NodeMaterialConnectionPoint;
  59278. /**
  59279. * Gets the output component
  59280. */
  59281. get output(): NodeMaterialConnectionPoint;
  59282. protected _buildBlock(state: NodeMaterialBuildState): this;
  59283. }
  59284. }
  59285. declare module BABYLON {
  59286. /**
  59287. * Block used to get the opposite (1 - x) of a value
  59288. */
  59289. export class OneMinusBlock extends NodeMaterialBlock {
  59290. /**
  59291. * Creates a new OneMinusBlock
  59292. * @param name defines the block name
  59293. */
  59294. constructor(name: string);
  59295. /**
  59296. * Gets the current class name
  59297. * @returns the class name
  59298. */
  59299. getClassName(): string;
  59300. /**
  59301. * Gets the input component
  59302. */
  59303. get input(): NodeMaterialConnectionPoint;
  59304. /**
  59305. * Gets the output component
  59306. */
  59307. get output(): NodeMaterialConnectionPoint;
  59308. protected _buildBlock(state: NodeMaterialBuildState): this;
  59309. }
  59310. }
  59311. declare module BABYLON {
  59312. /**
  59313. * Block used to get the view direction
  59314. */
  59315. export class ViewDirectionBlock extends NodeMaterialBlock {
  59316. /**
  59317. * Creates a new ViewDirectionBlock
  59318. * @param name defines the block name
  59319. */
  59320. constructor(name: string);
  59321. /**
  59322. * Gets the current class name
  59323. * @returns the class name
  59324. */
  59325. getClassName(): string;
  59326. /**
  59327. * Gets the world position component
  59328. */
  59329. get worldPosition(): NodeMaterialConnectionPoint;
  59330. /**
  59331. * Gets the camera position component
  59332. */
  59333. get cameraPosition(): NodeMaterialConnectionPoint;
  59334. /**
  59335. * Gets the output component
  59336. */
  59337. get output(): NodeMaterialConnectionPoint;
  59338. autoConfigure(material: NodeMaterial): void;
  59339. protected _buildBlock(state: NodeMaterialBuildState): this;
  59340. }
  59341. }
  59342. declare module BABYLON {
  59343. /**
  59344. * Block used to compute fresnel value
  59345. */
  59346. export class FresnelBlock extends NodeMaterialBlock {
  59347. /**
  59348. * Create a new FresnelBlock
  59349. * @param name defines the block name
  59350. */
  59351. constructor(name: string);
  59352. /**
  59353. * Gets the current class name
  59354. * @returns the class name
  59355. */
  59356. getClassName(): string;
  59357. /**
  59358. * Gets the world normal input component
  59359. */
  59360. get worldNormal(): NodeMaterialConnectionPoint;
  59361. /**
  59362. * Gets the view direction input component
  59363. */
  59364. get viewDirection(): NodeMaterialConnectionPoint;
  59365. /**
  59366. * Gets the bias input component
  59367. */
  59368. get bias(): NodeMaterialConnectionPoint;
  59369. /**
  59370. * Gets the camera (or eye) position component
  59371. */
  59372. get power(): NodeMaterialConnectionPoint;
  59373. /**
  59374. * Gets the fresnel output component
  59375. */
  59376. get fresnel(): NodeMaterialConnectionPoint;
  59377. autoConfigure(material: NodeMaterial): void;
  59378. protected _buildBlock(state: NodeMaterialBuildState): this;
  59379. }
  59380. }
  59381. declare module BABYLON {
  59382. /**
  59383. * Block used to get the max of 2 values
  59384. */
  59385. export class MaxBlock extends NodeMaterialBlock {
  59386. /**
  59387. * Creates a new MaxBlock
  59388. * @param name defines the block name
  59389. */
  59390. constructor(name: string);
  59391. /**
  59392. * Gets the current class name
  59393. * @returns the class name
  59394. */
  59395. getClassName(): string;
  59396. /**
  59397. * Gets the left operand input component
  59398. */
  59399. get left(): NodeMaterialConnectionPoint;
  59400. /**
  59401. * Gets the right operand input component
  59402. */
  59403. get right(): NodeMaterialConnectionPoint;
  59404. /**
  59405. * Gets the output component
  59406. */
  59407. get output(): NodeMaterialConnectionPoint;
  59408. protected _buildBlock(state: NodeMaterialBuildState): this;
  59409. }
  59410. }
  59411. declare module BABYLON {
  59412. /**
  59413. * Block used to get the min of 2 values
  59414. */
  59415. export class MinBlock extends NodeMaterialBlock {
  59416. /**
  59417. * Creates a new MinBlock
  59418. * @param name defines the block name
  59419. */
  59420. constructor(name: string);
  59421. /**
  59422. * Gets the current class name
  59423. * @returns the class name
  59424. */
  59425. getClassName(): string;
  59426. /**
  59427. * Gets the left operand input component
  59428. */
  59429. get left(): NodeMaterialConnectionPoint;
  59430. /**
  59431. * Gets the right operand input component
  59432. */
  59433. get right(): NodeMaterialConnectionPoint;
  59434. /**
  59435. * Gets the output component
  59436. */
  59437. get output(): NodeMaterialConnectionPoint;
  59438. protected _buildBlock(state: NodeMaterialBuildState): this;
  59439. }
  59440. }
  59441. declare module BABYLON {
  59442. /**
  59443. * Block used to get the distance between 2 values
  59444. */
  59445. export class DistanceBlock extends NodeMaterialBlock {
  59446. /**
  59447. * Creates a new DistanceBlock
  59448. * @param name defines the block name
  59449. */
  59450. constructor(name: string);
  59451. /**
  59452. * Gets the current class name
  59453. * @returns the class name
  59454. */
  59455. getClassName(): string;
  59456. /**
  59457. * Gets the left operand input component
  59458. */
  59459. get left(): NodeMaterialConnectionPoint;
  59460. /**
  59461. * Gets the right operand input component
  59462. */
  59463. get right(): NodeMaterialConnectionPoint;
  59464. /**
  59465. * Gets the output component
  59466. */
  59467. get output(): NodeMaterialConnectionPoint;
  59468. protected _buildBlock(state: NodeMaterialBuildState): this;
  59469. }
  59470. }
  59471. declare module BABYLON {
  59472. /**
  59473. * Block used to get the length of a vector
  59474. */
  59475. export class LengthBlock extends NodeMaterialBlock {
  59476. /**
  59477. * Creates a new LengthBlock
  59478. * @param name defines the block name
  59479. */
  59480. constructor(name: string);
  59481. /**
  59482. * Gets the current class name
  59483. * @returns the class name
  59484. */
  59485. getClassName(): string;
  59486. /**
  59487. * Gets the value input component
  59488. */
  59489. get value(): NodeMaterialConnectionPoint;
  59490. /**
  59491. * Gets the output component
  59492. */
  59493. get output(): NodeMaterialConnectionPoint;
  59494. protected _buildBlock(state: NodeMaterialBuildState): this;
  59495. }
  59496. }
  59497. declare module BABYLON {
  59498. /**
  59499. * Block used to get negative version of a value (i.e. x * -1)
  59500. */
  59501. export class NegateBlock extends NodeMaterialBlock {
  59502. /**
  59503. * Creates a new NegateBlock
  59504. * @param name defines the block name
  59505. */
  59506. constructor(name: string);
  59507. /**
  59508. * Gets the current class name
  59509. * @returns the class name
  59510. */
  59511. getClassName(): string;
  59512. /**
  59513. * Gets the value input component
  59514. */
  59515. get value(): NodeMaterialConnectionPoint;
  59516. /**
  59517. * Gets the output component
  59518. */
  59519. get output(): NodeMaterialConnectionPoint;
  59520. protected _buildBlock(state: NodeMaterialBuildState): this;
  59521. }
  59522. }
  59523. declare module BABYLON {
  59524. /**
  59525. * Block used to get the value of the first parameter raised to the power of the second
  59526. */
  59527. export class PowBlock extends NodeMaterialBlock {
  59528. /**
  59529. * Creates a new PowBlock
  59530. * @param name defines the block name
  59531. */
  59532. constructor(name: string);
  59533. /**
  59534. * Gets the current class name
  59535. * @returns the class name
  59536. */
  59537. getClassName(): string;
  59538. /**
  59539. * Gets the value operand input component
  59540. */
  59541. get value(): NodeMaterialConnectionPoint;
  59542. /**
  59543. * Gets the power operand input component
  59544. */
  59545. get power(): NodeMaterialConnectionPoint;
  59546. /**
  59547. * Gets the output component
  59548. */
  59549. get output(): NodeMaterialConnectionPoint;
  59550. protected _buildBlock(state: NodeMaterialBuildState): this;
  59551. }
  59552. }
  59553. declare module BABYLON {
  59554. /**
  59555. * Block used to get a random number
  59556. */
  59557. export class RandomNumberBlock extends NodeMaterialBlock {
  59558. /**
  59559. * Creates a new RandomNumberBlock
  59560. * @param name defines the block name
  59561. */
  59562. constructor(name: string);
  59563. /**
  59564. * Gets the current class name
  59565. * @returns the class name
  59566. */
  59567. getClassName(): string;
  59568. /**
  59569. * Gets the seed input component
  59570. */
  59571. get seed(): NodeMaterialConnectionPoint;
  59572. /**
  59573. * Gets the output component
  59574. */
  59575. get output(): NodeMaterialConnectionPoint;
  59576. protected _buildBlock(state: NodeMaterialBuildState): this;
  59577. }
  59578. }
  59579. declare module BABYLON {
  59580. /**
  59581. * Block used to compute arc tangent of 2 values
  59582. */
  59583. export class ArcTan2Block extends NodeMaterialBlock {
  59584. /**
  59585. * Creates a new ArcTan2Block
  59586. * @param name defines the block name
  59587. */
  59588. constructor(name: string);
  59589. /**
  59590. * Gets the current class name
  59591. * @returns the class name
  59592. */
  59593. getClassName(): string;
  59594. /**
  59595. * Gets the x operand input component
  59596. */
  59597. get x(): NodeMaterialConnectionPoint;
  59598. /**
  59599. * Gets the y operand input component
  59600. */
  59601. get y(): NodeMaterialConnectionPoint;
  59602. /**
  59603. * Gets the output component
  59604. */
  59605. get output(): NodeMaterialConnectionPoint;
  59606. protected _buildBlock(state: NodeMaterialBuildState): this;
  59607. }
  59608. }
  59609. declare module BABYLON {
  59610. /**
  59611. * Block used to smooth step a value
  59612. */
  59613. export class SmoothStepBlock extends NodeMaterialBlock {
  59614. /**
  59615. * Creates a new SmoothStepBlock
  59616. * @param name defines the block name
  59617. */
  59618. constructor(name: string);
  59619. /**
  59620. * Gets the current class name
  59621. * @returns the class name
  59622. */
  59623. getClassName(): string;
  59624. /**
  59625. * Gets the value operand input component
  59626. */
  59627. get value(): NodeMaterialConnectionPoint;
  59628. /**
  59629. * Gets the first edge operand input component
  59630. */
  59631. get edge0(): NodeMaterialConnectionPoint;
  59632. /**
  59633. * Gets the second edge operand input component
  59634. */
  59635. get edge1(): NodeMaterialConnectionPoint;
  59636. /**
  59637. * Gets the output component
  59638. */
  59639. get output(): NodeMaterialConnectionPoint;
  59640. protected _buildBlock(state: NodeMaterialBuildState): this;
  59641. }
  59642. }
  59643. declare module BABYLON {
  59644. /**
  59645. * Block used to get the reciprocal (1 / x) of a value
  59646. */
  59647. export class ReciprocalBlock extends NodeMaterialBlock {
  59648. /**
  59649. * Creates a new ReciprocalBlock
  59650. * @param name defines the block name
  59651. */
  59652. constructor(name: string);
  59653. /**
  59654. * Gets the current class name
  59655. * @returns the class name
  59656. */
  59657. getClassName(): string;
  59658. /**
  59659. * Gets the input component
  59660. */
  59661. get input(): NodeMaterialConnectionPoint;
  59662. /**
  59663. * Gets the output component
  59664. */
  59665. get output(): NodeMaterialConnectionPoint;
  59666. protected _buildBlock(state: NodeMaterialBuildState): this;
  59667. }
  59668. }
  59669. declare module BABYLON {
  59670. /**
  59671. * Block used to replace a color by another one
  59672. */
  59673. export class ReplaceColorBlock extends NodeMaterialBlock {
  59674. /**
  59675. * Creates a new ReplaceColorBlock
  59676. * @param name defines the block name
  59677. */
  59678. constructor(name: string);
  59679. /**
  59680. * Gets the current class name
  59681. * @returns the class name
  59682. */
  59683. getClassName(): string;
  59684. /**
  59685. * Gets the value input component
  59686. */
  59687. get value(): NodeMaterialConnectionPoint;
  59688. /**
  59689. * Gets the reference input component
  59690. */
  59691. get reference(): NodeMaterialConnectionPoint;
  59692. /**
  59693. * Gets the distance input component
  59694. */
  59695. get distance(): NodeMaterialConnectionPoint;
  59696. /**
  59697. * Gets the replacement input component
  59698. */
  59699. get replacement(): NodeMaterialConnectionPoint;
  59700. /**
  59701. * Gets the output component
  59702. */
  59703. get output(): NodeMaterialConnectionPoint;
  59704. protected _buildBlock(state: NodeMaterialBuildState): this;
  59705. }
  59706. }
  59707. declare module BABYLON {
  59708. /**
  59709. * Block used to posterize a value
  59710. * @see https://en.wikipedia.org/wiki/Posterization
  59711. */
  59712. export class PosterizeBlock extends NodeMaterialBlock {
  59713. /**
  59714. * Creates a new PosterizeBlock
  59715. * @param name defines the block name
  59716. */
  59717. constructor(name: string);
  59718. /**
  59719. * Gets the current class name
  59720. * @returns the class name
  59721. */
  59722. getClassName(): string;
  59723. /**
  59724. * Gets the value input component
  59725. */
  59726. get value(): NodeMaterialConnectionPoint;
  59727. /**
  59728. * Gets the steps input component
  59729. */
  59730. get steps(): NodeMaterialConnectionPoint;
  59731. /**
  59732. * Gets the output component
  59733. */
  59734. get output(): NodeMaterialConnectionPoint;
  59735. protected _buildBlock(state: NodeMaterialBuildState): this;
  59736. }
  59737. }
  59738. declare module BABYLON {
  59739. /**
  59740. * Operations supported by the Wave block
  59741. */
  59742. export enum WaveBlockKind {
  59743. /** SawTooth */
  59744. SawTooth = 0,
  59745. /** Square */
  59746. Square = 1,
  59747. /** Triangle */
  59748. Triangle = 2
  59749. }
  59750. /**
  59751. * Block used to apply wave operation to floats
  59752. */
  59753. export class WaveBlock extends NodeMaterialBlock {
  59754. /**
  59755. * Gets or sets the kibnd of wave to be applied by the block
  59756. */
  59757. kind: WaveBlockKind;
  59758. /**
  59759. * Creates a new WaveBlock
  59760. * @param name defines the block name
  59761. */
  59762. constructor(name: string);
  59763. /**
  59764. * Gets the current class name
  59765. * @returns the class name
  59766. */
  59767. getClassName(): string;
  59768. /**
  59769. * Gets the input component
  59770. */
  59771. get input(): NodeMaterialConnectionPoint;
  59772. /**
  59773. * Gets the output component
  59774. */
  59775. get output(): NodeMaterialConnectionPoint;
  59776. protected _buildBlock(state: NodeMaterialBuildState): this;
  59777. serialize(): any;
  59778. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59779. }
  59780. }
  59781. declare module BABYLON {
  59782. /**
  59783. * Class used to store a color step for the GradientBlock
  59784. */
  59785. export class GradientBlockColorStep {
  59786. /**
  59787. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  59788. */
  59789. step: number;
  59790. /**
  59791. * Gets or sets the color associated with this step
  59792. */
  59793. color: Color3;
  59794. /**
  59795. * Creates a new GradientBlockColorStep
  59796. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  59797. * @param color defines the color associated with this step
  59798. */
  59799. constructor(
  59800. /**
  59801. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  59802. */
  59803. step: number,
  59804. /**
  59805. * Gets or sets the color associated with this step
  59806. */
  59807. color: Color3);
  59808. }
  59809. /**
  59810. * Block used to return a color from a gradient based on an input value between 0 and 1
  59811. */
  59812. export class GradientBlock extends NodeMaterialBlock {
  59813. /**
  59814. * Gets or sets the list of color steps
  59815. */
  59816. colorSteps: GradientBlockColorStep[];
  59817. /**
  59818. * Creates a new GradientBlock
  59819. * @param name defines the block name
  59820. */
  59821. constructor(name: string);
  59822. /**
  59823. * Gets the current class name
  59824. * @returns the class name
  59825. */
  59826. getClassName(): string;
  59827. /**
  59828. * Gets the gradient input component
  59829. */
  59830. get gradient(): NodeMaterialConnectionPoint;
  59831. /**
  59832. * Gets the output component
  59833. */
  59834. get output(): NodeMaterialConnectionPoint;
  59835. private _writeColorConstant;
  59836. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  59837. serialize(): any;
  59838. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59839. protected _dumpPropertiesCode(): string;
  59840. }
  59841. }
  59842. declare module BABYLON {
  59843. /**
  59844. * Block used to normalize lerp between 2 values
  59845. */
  59846. export class NLerpBlock extends NodeMaterialBlock {
  59847. /**
  59848. * Creates a new NLerpBlock
  59849. * @param name defines the block name
  59850. */
  59851. constructor(name: string);
  59852. /**
  59853. * Gets the current class name
  59854. * @returns the class name
  59855. */
  59856. getClassName(): string;
  59857. /**
  59858. * Gets the left operand input component
  59859. */
  59860. get left(): NodeMaterialConnectionPoint;
  59861. /**
  59862. * Gets the right operand input component
  59863. */
  59864. get right(): NodeMaterialConnectionPoint;
  59865. /**
  59866. * Gets the gradient operand input component
  59867. */
  59868. get gradient(): NodeMaterialConnectionPoint;
  59869. /**
  59870. * Gets the output component
  59871. */
  59872. get output(): NodeMaterialConnectionPoint;
  59873. protected _buildBlock(state: NodeMaterialBuildState): this;
  59874. }
  59875. }
  59876. declare module BABYLON {
  59877. /**
  59878. * block used to Generate a Worley Noise 3D Noise Pattern
  59879. */
  59880. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  59881. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  59882. manhattanDistance: boolean;
  59883. /**
  59884. * Creates a new WorleyNoise3DBlock
  59885. * @param name defines the block name
  59886. */
  59887. constructor(name: string);
  59888. /**
  59889. * Gets the current class name
  59890. * @returns the class name
  59891. */
  59892. getClassName(): string;
  59893. /**
  59894. * Gets the seed input component
  59895. */
  59896. get seed(): NodeMaterialConnectionPoint;
  59897. /**
  59898. * Gets the jitter input component
  59899. */
  59900. get jitter(): NodeMaterialConnectionPoint;
  59901. /**
  59902. * Gets the output component
  59903. */
  59904. get output(): NodeMaterialConnectionPoint;
  59905. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  59906. /**
  59907. * Exposes the properties to the UI?
  59908. */
  59909. protected _dumpPropertiesCode(): string;
  59910. /**
  59911. * Exposes the properties to the Seralize?
  59912. */
  59913. serialize(): any;
  59914. /**
  59915. * Exposes the properties to the deseralize?
  59916. */
  59917. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59918. }
  59919. }
  59920. declare module BABYLON {
  59921. /**
  59922. * block used to Generate a Simplex Perlin 3d Noise Pattern
  59923. */
  59924. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  59925. /**
  59926. * Creates a new SimplexPerlin3DBlock
  59927. * @param name defines the block name
  59928. */
  59929. constructor(name: string);
  59930. /**
  59931. * Gets the current class name
  59932. * @returns the class name
  59933. */
  59934. getClassName(): string;
  59935. /**
  59936. * Gets the seed operand input component
  59937. */
  59938. get seed(): NodeMaterialConnectionPoint;
  59939. /**
  59940. * Gets the output component
  59941. */
  59942. get output(): NodeMaterialConnectionPoint;
  59943. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  59944. }
  59945. }
  59946. declare module BABYLON {
  59947. /**
  59948. * Block used to blend normals
  59949. */
  59950. export class NormalBlendBlock extends NodeMaterialBlock {
  59951. /**
  59952. * Creates a new NormalBlendBlock
  59953. * @param name defines the block name
  59954. */
  59955. constructor(name: string);
  59956. /**
  59957. * Gets the current class name
  59958. * @returns the class name
  59959. */
  59960. getClassName(): string;
  59961. /**
  59962. * Gets the first input component
  59963. */
  59964. get normalMap0(): NodeMaterialConnectionPoint;
  59965. /**
  59966. * Gets the second input component
  59967. */
  59968. get normalMap1(): NodeMaterialConnectionPoint;
  59969. /**
  59970. * Gets the output component
  59971. */
  59972. get output(): NodeMaterialConnectionPoint;
  59973. protected _buildBlock(state: NodeMaterialBuildState): this;
  59974. }
  59975. }
  59976. declare module BABYLON {
  59977. /**
  59978. * Block used to rotate a 2d vector by a given angle
  59979. */
  59980. export class Rotate2dBlock extends NodeMaterialBlock {
  59981. /**
  59982. * Creates a new Rotate2dBlock
  59983. * @param name defines the block name
  59984. */
  59985. constructor(name: string);
  59986. /**
  59987. * Gets the current class name
  59988. * @returns the class name
  59989. */
  59990. getClassName(): string;
  59991. /**
  59992. * Gets the input vector
  59993. */
  59994. get input(): NodeMaterialConnectionPoint;
  59995. /**
  59996. * Gets the input angle
  59997. */
  59998. get angle(): NodeMaterialConnectionPoint;
  59999. /**
  60000. * Gets the output component
  60001. */
  60002. get output(): NodeMaterialConnectionPoint;
  60003. autoConfigure(material: NodeMaterial): void;
  60004. protected _buildBlock(state: NodeMaterialBuildState): this;
  60005. }
  60006. }
  60007. declare module BABYLON {
  60008. /**
  60009. * Block used to get the reflected vector from a direction and a normal
  60010. */
  60011. export class ReflectBlock extends NodeMaterialBlock {
  60012. /**
  60013. * Creates a new ReflectBlock
  60014. * @param name defines the block name
  60015. */
  60016. constructor(name: string);
  60017. /**
  60018. * Gets the current class name
  60019. * @returns the class name
  60020. */
  60021. getClassName(): string;
  60022. /**
  60023. * Gets the incident component
  60024. */
  60025. get incident(): NodeMaterialConnectionPoint;
  60026. /**
  60027. * Gets the normal component
  60028. */
  60029. get normal(): NodeMaterialConnectionPoint;
  60030. /**
  60031. * Gets the output component
  60032. */
  60033. get output(): NodeMaterialConnectionPoint;
  60034. protected _buildBlock(state: NodeMaterialBuildState): this;
  60035. }
  60036. }
  60037. declare module BABYLON {
  60038. /**
  60039. * Block used to get the refracted vector from a direction and a normal
  60040. */
  60041. export class RefractBlock extends NodeMaterialBlock {
  60042. /**
  60043. * Creates a new RefractBlock
  60044. * @param name defines the block name
  60045. */
  60046. constructor(name: string);
  60047. /**
  60048. * Gets the current class name
  60049. * @returns the class name
  60050. */
  60051. getClassName(): string;
  60052. /**
  60053. * Gets the incident component
  60054. */
  60055. get incident(): NodeMaterialConnectionPoint;
  60056. /**
  60057. * Gets the normal component
  60058. */
  60059. get normal(): NodeMaterialConnectionPoint;
  60060. /**
  60061. * Gets the index of refraction component
  60062. */
  60063. get ior(): NodeMaterialConnectionPoint;
  60064. /**
  60065. * Gets the output component
  60066. */
  60067. get output(): NodeMaterialConnectionPoint;
  60068. protected _buildBlock(state: NodeMaterialBuildState): this;
  60069. }
  60070. }
  60071. declare module BABYLON {
  60072. /**
  60073. * Block used to desaturate a color
  60074. */
  60075. export class DesaturateBlock extends NodeMaterialBlock {
  60076. /**
  60077. * Creates a new DesaturateBlock
  60078. * @param name defines the block name
  60079. */
  60080. constructor(name: string);
  60081. /**
  60082. * Gets the current class name
  60083. * @returns the class name
  60084. */
  60085. getClassName(): string;
  60086. /**
  60087. * Gets the color operand input component
  60088. */
  60089. get color(): NodeMaterialConnectionPoint;
  60090. /**
  60091. * Gets the level operand input component
  60092. */
  60093. get level(): NodeMaterialConnectionPoint;
  60094. /**
  60095. * Gets the output component
  60096. */
  60097. get output(): NodeMaterialConnectionPoint;
  60098. protected _buildBlock(state: NodeMaterialBuildState): this;
  60099. }
  60100. }
  60101. declare module BABYLON {
  60102. /**
  60103. * Effect Render Options
  60104. */
  60105. export interface IEffectRendererOptions {
  60106. /**
  60107. * Defines the vertices positions.
  60108. */
  60109. positions?: number[];
  60110. /**
  60111. * Defines the indices.
  60112. */
  60113. indices?: number[];
  60114. }
  60115. /**
  60116. * Helper class to render one or more effects
  60117. */
  60118. export class EffectRenderer {
  60119. private engine;
  60120. private static _DefaultOptions;
  60121. private _vertexBuffers;
  60122. private _indexBuffer;
  60123. private _ringBufferIndex;
  60124. private _ringScreenBuffer;
  60125. private _fullscreenViewport;
  60126. private _getNextFrameBuffer;
  60127. /**
  60128. * Creates an effect renderer
  60129. * @param engine the engine to use for rendering
  60130. * @param options defines the options of the effect renderer
  60131. */
  60132. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  60133. /**
  60134. * Sets the current viewport in normalized coordinates 0-1
  60135. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  60136. */
  60137. setViewport(viewport?: Viewport): void;
  60138. /**
  60139. * Binds the embedded attributes buffer to the effect.
  60140. * @param effect Defines the effect to bind the attributes for
  60141. */
  60142. bindBuffers(effect: Effect): void;
  60143. /**
  60144. * Sets the current effect wrapper to use during draw.
  60145. * The effect needs to be ready before calling this api.
  60146. * This also sets the default full screen position attribute.
  60147. * @param effectWrapper Defines the effect to draw with
  60148. */
  60149. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  60150. /**
  60151. * Draws a full screen quad.
  60152. */
  60153. draw(): void;
  60154. /**
  60155. * renders one or more effects to a specified texture
  60156. * @param effectWrappers list of effects to renderer
  60157. * @param outputTexture texture to draw to, if null it will render to the screen
  60158. */
  60159. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  60160. /**
  60161. * Disposes of the effect renderer
  60162. */
  60163. dispose(): void;
  60164. }
  60165. /**
  60166. * Options to create an EffectWrapper
  60167. */
  60168. interface EffectWrapperCreationOptions {
  60169. /**
  60170. * Engine to use to create the effect
  60171. */
  60172. engine: ThinEngine;
  60173. /**
  60174. * Fragment shader for the effect
  60175. */
  60176. fragmentShader: string;
  60177. /**
  60178. * Vertex shader for the effect
  60179. */
  60180. vertexShader?: string;
  60181. /**
  60182. * Attributes to use in the shader
  60183. */
  60184. attributeNames?: Array<string>;
  60185. /**
  60186. * Uniforms to use in the shader
  60187. */
  60188. uniformNames?: Array<string>;
  60189. /**
  60190. * Texture sampler names to use in the shader
  60191. */
  60192. samplerNames?: Array<string>;
  60193. /**
  60194. * The friendly name of the effect displayed in Spector.
  60195. */
  60196. name?: string;
  60197. }
  60198. /**
  60199. * Wraps an effect to be used for rendering
  60200. */
  60201. export class EffectWrapper {
  60202. /**
  60203. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  60204. */
  60205. onApplyObservable: Observable<{}>;
  60206. /**
  60207. * The underlying effect
  60208. */
  60209. effect: Effect;
  60210. /**
  60211. * Creates an effect to be renderer
  60212. * @param creationOptions options to create the effect
  60213. */
  60214. constructor(creationOptions: EffectWrapperCreationOptions);
  60215. /**
  60216. * Disposes of the effect wrapper
  60217. */
  60218. dispose(): void;
  60219. }
  60220. }
  60221. declare module BABYLON {
  60222. /**
  60223. * Helper class to push actions to a pool of workers.
  60224. */
  60225. export class WorkerPool implements IDisposable {
  60226. private _workerInfos;
  60227. private _pendingActions;
  60228. /**
  60229. * Constructor
  60230. * @param workers Array of workers to use for actions
  60231. */
  60232. constructor(workers: Array<Worker>);
  60233. /**
  60234. * Terminates all workers and clears any pending actions.
  60235. */
  60236. dispose(): void;
  60237. /**
  60238. * Pushes an action to the worker pool. If all the workers are active, the action will be
  60239. * pended until a worker has completed its action.
  60240. * @param action The action to perform. Call onComplete when the action is complete.
  60241. */
  60242. push(action: (worker: Worker, onComplete: () => void) => void): void;
  60243. private _execute;
  60244. }
  60245. }
  60246. declare module BABYLON {
  60247. /**
  60248. * Configuration for Draco compression
  60249. */
  60250. export interface IDracoCompressionConfiguration {
  60251. /**
  60252. * Configuration for the decoder.
  60253. */
  60254. decoder: {
  60255. /**
  60256. * The url to the WebAssembly module.
  60257. */
  60258. wasmUrl?: string;
  60259. /**
  60260. * The url to the WebAssembly binary.
  60261. */
  60262. wasmBinaryUrl?: string;
  60263. /**
  60264. * The url to the fallback JavaScript module.
  60265. */
  60266. fallbackUrl?: string;
  60267. };
  60268. }
  60269. /**
  60270. * Draco compression (https://google.github.io/draco/)
  60271. *
  60272. * This class wraps the Draco module.
  60273. *
  60274. * **Encoder**
  60275. *
  60276. * The encoder is not currently implemented.
  60277. *
  60278. * **Decoder**
  60279. *
  60280. * 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.
  60281. *
  60282. * To update the configuration, use the following code:
  60283. * ```javascript
  60284. * DracoCompression.Configuration = {
  60285. * decoder: {
  60286. * wasmUrl: "<url to the WebAssembly library>",
  60287. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  60288. * fallbackUrl: "<url to the fallback JavaScript library>",
  60289. * }
  60290. * };
  60291. * ```
  60292. *
  60293. * 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.
  60294. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  60295. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  60296. *
  60297. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  60298. * ```javascript
  60299. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  60300. * ```
  60301. *
  60302. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  60303. */
  60304. export class DracoCompression implements IDisposable {
  60305. private _workerPoolPromise?;
  60306. private _decoderModulePromise?;
  60307. /**
  60308. * The configuration. Defaults to the following urls:
  60309. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  60310. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  60311. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  60312. */
  60313. static Configuration: IDracoCompressionConfiguration;
  60314. /**
  60315. * Returns true if the decoder configuration is available.
  60316. */
  60317. static get DecoderAvailable(): boolean;
  60318. /**
  60319. * Default number of workers to create when creating the draco compression object.
  60320. */
  60321. static DefaultNumWorkers: number;
  60322. private static GetDefaultNumWorkers;
  60323. private static _Default;
  60324. /**
  60325. * Default instance for the draco compression object.
  60326. */
  60327. static get Default(): DracoCompression;
  60328. /**
  60329. * Constructor
  60330. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  60331. */
  60332. constructor(numWorkers?: number);
  60333. /**
  60334. * Stop all async operations and release resources.
  60335. */
  60336. dispose(): void;
  60337. /**
  60338. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  60339. * @returns a promise that resolves when ready
  60340. */
  60341. whenReadyAsync(): Promise<void>;
  60342. /**
  60343. * Decode Draco compressed mesh data to vertex data.
  60344. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  60345. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  60346. * @returns A promise that resolves with the decoded vertex data
  60347. */
  60348. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  60349. [kind: string]: number;
  60350. }): Promise<VertexData>;
  60351. }
  60352. }
  60353. declare module BABYLON {
  60354. /**
  60355. * Class for building Constructive Solid Geometry
  60356. */
  60357. export class CSG {
  60358. private polygons;
  60359. /**
  60360. * The world matrix
  60361. */
  60362. matrix: Matrix;
  60363. /**
  60364. * Stores the position
  60365. */
  60366. position: Vector3;
  60367. /**
  60368. * Stores the rotation
  60369. */
  60370. rotation: Vector3;
  60371. /**
  60372. * Stores the rotation quaternion
  60373. */
  60374. rotationQuaternion: Nullable<Quaternion>;
  60375. /**
  60376. * Stores the scaling vector
  60377. */
  60378. scaling: Vector3;
  60379. /**
  60380. * Convert the Mesh to CSG
  60381. * @param mesh The Mesh to convert to CSG
  60382. * @returns A new CSG from the Mesh
  60383. */
  60384. static FromMesh(mesh: Mesh): CSG;
  60385. /**
  60386. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  60387. * @param polygons Polygons used to construct a CSG solid
  60388. */
  60389. private static FromPolygons;
  60390. /**
  60391. * Clones, or makes a deep copy, of the CSG
  60392. * @returns A new CSG
  60393. */
  60394. clone(): CSG;
  60395. /**
  60396. * Unions this CSG with another CSG
  60397. * @param csg The CSG to union against this CSG
  60398. * @returns The unioned CSG
  60399. */
  60400. union(csg: CSG): CSG;
  60401. /**
  60402. * Unions this CSG with another CSG in place
  60403. * @param csg The CSG to union against this CSG
  60404. */
  60405. unionInPlace(csg: CSG): void;
  60406. /**
  60407. * Subtracts this CSG with another CSG
  60408. * @param csg The CSG to subtract against this CSG
  60409. * @returns A new CSG
  60410. */
  60411. subtract(csg: CSG): CSG;
  60412. /**
  60413. * Subtracts this CSG with another CSG in place
  60414. * @param csg The CSG to subtact against this CSG
  60415. */
  60416. subtractInPlace(csg: CSG): void;
  60417. /**
  60418. * Intersect this CSG with another CSG
  60419. * @param csg The CSG to intersect against this CSG
  60420. * @returns A new CSG
  60421. */
  60422. intersect(csg: CSG): CSG;
  60423. /**
  60424. * Intersects this CSG with another CSG in place
  60425. * @param csg The CSG to intersect against this CSG
  60426. */
  60427. intersectInPlace(csg: CSG): void;
  60428. /**
  60429. * Return a new CSG solid with solid and empty space switched. This solid is
  60430. * not modified.
  60431. * @returns A new CSG solid with solid and empty space switched
  60432. */
  60433. inverse(): CSG;
  60434. /**
  60435. * Inverses the CSG in place
  60436. */
  60437. inverseInPlace(): void;
  60438. /**
  60439. * This is used to keep meshes transformations so they can be restored
  60440. * when we build back a Babylon Mesh
  60441. * NB : All CSG operations are performed in world coordinates
  60442. * @param csg The CSG to copy the transform attributes from
  60443. * @returns This CSG
  60444. */
  60445. copyTransformAttributes(csg: CSG): CSG;
  60446. /**
  60447. * Build Raw mesh from CSG
  60448. * Coordinates here are in world space
  60449. * @param name The name of the mesh geometry
  60450. * @param scene The Scene
  60451. * @param keepSubMeshes Specifies if the submeshes should be kept
  60452. * @returns A new Mesh
  60453. */
  60454. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  60455. /**
  60456. * Build Mesh from CSG taking material and transforms into account
  60457. * @param name The name of the Mesh
  60458. * @param material The material of the Mesh
  60459. * @param scene The Scene
  60460. * @param keepSubMeshes Specifies if submeshes should be kept
  60461. * @returns The new Mesh
  60462. */
  60463. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  60464. }
  60465. }
  60466. declare module BABYLON {
  60467. /**
  60468. * Class used to create a trail following a mesh
  60469. */
  60470. export class TrailMesh extends Mesh {
  60471. private _generator;
  60472. private _autoStart;
  60473. private _running;
  60474. private _diameter;
  60475. private _length;
  60476. private _sectionPolygonPointsCount;
  60477. private _sectionVectors;
  60478. private _sectionNormalVectors;
  60479. private _beforeRenderObserver;
  60480. /**
  60481. * @constructor
  60482. * @param name The value used by scene.getMeshByName() to do a lookup.
  60483. * @param generator The mesh or transform node to generate a trail.
  60484. * @param scene The scene to add this mesh to.
  60485. * @param diameter Diameter of trailing mesh. Default is 1.
  60486. * @param length Length of trailing mesh. Default is 60.
  60487. * @param autoStart Automatically start trailing mesh. Default true.
  60488. */
  60489. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  60490. /**
  60491. * "TrailMesh"
  60492. * @returns "TrailMesh"
  60493. */
  60494. getClassName(): string;
  60495. private _createMesh;
  60496. /**
  60497. * Start trailing mesh.
  60498. */
  60499. start(): void;
  60500. /**
  60501. * Stop trailing mesh.
  60502. */
  60503. stop(): void;
  60504. /**
  60505. * Update trailing mesh geometry.
  60506. */
  60507. update(): void;
  60508. /**
  60509. * Returns a new TrailMesh object.
  60510. * @param name is a string, the name given to the new mesh
  60511. * @param newGenerator use new generator object for cloned trail mesh
  60512. * @returns a new mesh
  60513. */
  60514. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  60515. /**
  60516. * Serializes this trail mesh
  60517. * @param serializationObject object to write serialization to
  60518. */
  60519. serialize(serializationObject: any): void;
  60520. /**
  60521. * Parses a serialized trail mesh
  60522. * @param parsedMesh the serialized mesh
  60523. * @param scene the scene to create the trail mesh in
  60524. * @returns the created trail mesh
  60525. */
  60526. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  60527. }
  60528. }
  60529. declare module BABYLON {
  60530. /**
  60531. * Class containing static functions to help procedurally build meshes
  60532. */
  60533. export class TiledBoxBuilder {
  60534. /**
  60535. * Creates a box mesh
  60536. * 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)
  60537. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  60538. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60539. * * 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
  60540. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60541. * @param name defines the name of the mesh
  60542. * @param options defines the options used to create the mesh
  60543. * @param scene defines the hosting scene
  60544. * @returns the box mesh
  60545. */
  60546. static CreateTiledBox(name: string, options: {
  60547. pattern?: number;
  60548. width?: number;
  60549. height?: number;
  60550. depth?: number;
  60551. tileSize?: number;
  60552. tileWidth?: number;
  60553. tileHeight?: number;
  60554. alignHorizontal?: number;
  60555. alignVertical?: number;
  60556. faceUV?: Vector4[];
  60557. faceColors?: Color4[];
  60558. sideOrientation?: number;
  60559. updatable?: boolean;
  60560. }, scene?: Nullable<Scene>): Mesh;
  60561. }
  60562. }
  60563. declare module BABYLON {
  60564. /**
  60565. * Class containing static functions to help procedurally build meshes
  60566. */
  60567. export class TorusKnotBuilder {
  60568. /**
  60569. * Creates a torus knot mesh
  60570. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  60571. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  60572. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  60573. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  60574. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60575. * * 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
  60576. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  60577. * @param name defines the name of the mesh
  60578. * @param options defines the options used to create the mesh
  60579. * @param scene defines the hosting scene
  60580. * @returns the torus knot mesh
  60581. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  60582. */
  60583. static CreateTorusKnot(name: string, options: {
  60584. radius?: number;
  60585. tube?: number;
  60586. radialSegments?: number;
  60587. tubularSegments?: number;
  60588. p?: number;
  60589. q?: number;
  60590. updatable?: boolean;
  60591. sideOrientation?: number;
  60592. frontUVs?: Vector4;
  60593. backUVs?: Vector4;
  60594. }, scene: any): Mesh;
  60595. }
  60596. }
  60597. declare module BABYLON {
  60598. /**
  60599. * Polygon
  60600. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  60601. */
  60602. export class Polygon {
  60603. /**
  60604. * Creates a rectangle
  60605. * @param xmin bottom X coord
  60606. * @param ymin bottom Y coord
  60607. * @param xmax top X coord
  60608. * @param ymax top Y coord
  60609. * @returns points that make the resulting rectation
  60610. */
  60611. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  60612. /**
  60613. * Creates a circle
  60614. * @param radius radius of circle
  60615. * @param cx scale in x
  60616. * @param cy scale in y
  60617. * @param numberOfSides number of sides that make up the circle
  60618. * @returns points that make the resulting circle
  60619. */
  60620. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  60621. /**
  60622. * Creates a polygon from input string
  60623. * @param input Input polygon data
  60624. * @returns the parsed points
  60625. */
  60626. static Parse(input: string): Vector2[];
  60627. /**
  60628. * Starts building a polygon from x and y coordinates
  60629. * @param x x coordinate
  60630. * @param y y coordinate
  60631. * @returns the started path2
  60632. */
  60633. static StartingAt(x: number, y: number): Path2;
  60634. }
  60635. /**
  60636. * Builds a polygon
  60637. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  60638. */
  60639. export class PolygonMeshBuilder {
  60640. private _points;
  60641. private _outlinepoints;
  60642. private _holes;
  60643. private _name;
  60644. private _scene;
  60645. private _epoints;
  60646. private _eholes;
  60647. private _addToepoint;
  60648. /**
  60649. * Babylon reference to the earcut plugin.
  60650. */
  60651. bjsEarcut: any;
  60652. /**
  60653. * Creates a PolygonMeshBuilder
  60654. * @param name name of the builder
  60655. * @param contours Path of the polygon
  60656. * @param scene scene to add to when creating the mesh
  60657. * @param earcutInjection can be used to inject your own earcut reference
  60658. */
  60659. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  60660. /**
  60661. * Adds a whole within the polygon
  60662. * @param hole Array of points defining the hole
  60663. * @returns this
  60664. */
  60665. addHole(hole: Vector2[]): PolygonMeshBuilder;
  60666. /**
  60667. * Creates the polygon
  60668. * @param updatable If the mesh should be updatable
  60669. * @param depth The depth of the mesh created
  60670. * @returns the created mesh
  60671. */
  60672. build(updatable?: boolean, depth?: number): Mesh;
  60673. /**
  60674. * Creates the polygon
  60675. * @param depth The depth of the mesh created
  60676. * @returns the created VertexData
  60677. */
  60678. buildVertexData(depth?: number): VertexData;
  60679. /**
  60680. * Adds a side to the polygon
  60681. * @param positions points that make the polygon
  60682. * @param normals normals of the polygon
  60683. * @param uvs uvs of the polygon
  60684. * @param indices indices of the polygon
  60685. * @param bounds bounds of the polygon
  60686. * @param points points of the polygon
  60687. * @param depth depth of the polygon
  60688. * @param flip flip of the polygon
  60689. */
  60690. private addSide;
  60691. }
  60692. }
  60693. declare module BABYLON {
  60694. /**
  60695. * Class containing static functions to help procedurally build meshes
  60696. */
  60697. export class PolygonBuilder {
  60698. /**
  60699. * Creates a polygon mesh
  60700. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  60701. * * 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
  60702. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  60703. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60704. * * 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)
  60705. * * Remember you can only change the shape positions, not their number when updating a polygon
  60706. * @param name defines the name of the mesh
  60707. * @param options defines the options used to create the mesh
  60708. * @param scene defines the hosting scene
  60709. * @param earcutInjection can be used to inject your own earcut reference
  60710. * @returns the polygon mesh
  60711. */
  60712. static CreatePolygon(name: string, options: {
  60713. shape: Vector3[];
  60714. holes?: Vector3[][];
  60715. depth?: number;
  60716. faceUV?: Vector4[];
  60717. faceColors?: Color4[];
  60718. updatable?: boolean;
  60719. sideOrientation?: number;
  60720. frontUVs?: Vector4;
  60721. backUVs?: Vector4;
  60722. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  60723. /**
  60724. * Creates an extruded polygon mesh, with depth in the Y direction.
  60725. * * 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)
  60726. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  60727. * @param name defines the name of the mesh
  60728. * @param options defines the options used to create the mesh
  60729. * @param scene defines the hosting scene
  60730. * @param earcutInjection can be used to inject your own earcut reference
  60731. * @returns the polygon mesh
  60732. */
  60733. static ExtrudePolygon(name: string, options: {
  60734. shape: Vector3[];
  60735. holes?: Vector3[][];
  60736. depth?: number;
  60737. faceUV?: Vector4[];
  60738. faceColors?: Color4[];
  60739. updatable?: boolean;
  60740. sideOrientation?: number;
  60741. frontUVs?: Vector4;
  60742. backUVs?: Vector4;
  60743. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  60744. }
  60745. }
  60746. declare module BABYLON {
  60747. /**
  60748. * Class containing static functions to help procedurally build meshes
  60749. */
  60750. export class LatheBuilder {
  60751. /**
  60752. * Creates lathe mesh.
  60753. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  60754. * * 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
  60755. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  60756. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  60757. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  60758. * * 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
  60759. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  60760. * * 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
  60761. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60762. * * 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
  60763. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  60764. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60765. * @param name defines the name of the mesh
  60766. * @param options defines the options used to create the mesh
  60767. * @param scene defines the hosting scene
  60768. * @returns the lathe mesh
  60769. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  60770. */
  60771. static CreateLathe(name: string, options: {
  60772. shape: Vector3[];
  60773. radius?: number;
  60774. tessellation?: number;
  60775. clip?: number;
  60776. arc?: number;
  60777. closed?: boolean;
  60778. updatable?: boolean;
  60779. sideOrientation?: number;
  60780. frontUVs?: Vector4;
  60781. backUVs?: Vector4;
  60782. cap?: number;
  60783. invertUV?: boolean;
  60784. }, scene?: Nullable<Scene>): Mesh;
  60785. }
  60786. }
  60787. declare module BABYLON {
  60788. /**
  60789. * Class containing static functions to help procedurally build meshes
  60790. */
  60791. export class TiledPlaneBuilder {
  60792. /**
  60793. * Creates a tiled plane mesh
  60794. * * The parameter `pattern` will, depending on value, do nothing or
  60795. * * * flip (reflect about central vertical) alternate tiles across and up
  60796. * * * flip every tile on alternate rows
  60797. * * * rotate (180 degs) alternate tiles across and up
  60798. * * * rotate every tile on alternate rows
  60799. * * * flip and rotate alternate tiles across and up
  60800. * * * flip and rotate every tile on alternate rows
  60801. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  60802. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  60803. * * 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
  60804. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  60805. * * 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)
  60806. * * 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)
  60807. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  60808. * @param name defines the name of the mesh
  60809. * @param options defines the options used to create the mesh
  60810. * @param scene defines the hosting scene
  60811. * @returns the box mesh
  60812. */
  60813. static CreateTiledPlane(name: string, options: {
  60814. pattern?: number;
  60815. tileSize?: number;
  60816. tileWidth?: number;
  60817. tileHeight?: number;
  60818. size?: number;
  60819. width?: number;
  60820. height?: number;
  60821. alignHorizontal?: number;
  60822. alignVertical?: number;
  60823. sideOrientation?: number;
  60824. frontUVs?: Vector4;
  60825. backUVs?: Vector4;
  60826. updatable?: boolean;
  60827. }, scene?: Nullable<Scene>): Mesh;
  60828. }
  60829. }
  60830. declare module BABYLON {
  60831. /**
  60832. * Class containing static functions to help procedurally build meshes
  60833. */
  60834. export class TubeBuilder {
  60835. /**
  60836. * Creates a tube mesh.
  60837. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  60838. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  60839. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  60840. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  60841. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  60842. * * 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)
  60843. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  60844. * * 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
  60845. * * 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
  60846. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60847. * * 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
  60848. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  60849. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60850. * @param name defines the name of the mesh
  60851. * @param options defines the options used to create the mesh
  60852. * @param scene defines the hosting scene
  60853. * @returns the tube mesh
  60854. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  60855. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  60856. */
  60857. static CreateTube(name: string, options: {
  60858. path: Vector3[];
  60859. radius?: number;
  60860. tessellation?: number;
  60861. radiusFunction?: {
  60862. (i: number, distance: number): number;
  60863. };
  60864. cap?: number;
  60865. arc?: number;
  60866. updatable?: boolean;
  60867. sideOrientation?: number;
  60868. frontUVs?: Vector4;
  60869. backUVs?: Vector4;
  60870. instance?: Mesh;
  60871. invertUV?: boolean;
  60872. }, scene?: Nullable<Scene>): Mesh;
  60873. }
  60874. }
  60875. declare module BABYLON {
  60876. /**
  60877. * Class containing static functions to help procedurally build meshes
  60878. */
  60879. export class IcoSphereBuilder {
  60880. /**
  60881. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  60882. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  60883. * * 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`)
  60884. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  60885. * * 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
  60886. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60887. * * 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
  60888. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60889. * @param name defines the name of the mesh
  60890. * @param options defines the options used to create the mesh
  60891. * @param scene defines the hosting scene
  60892. * @returns the icosahedron mesh
  60893. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  60894. */
  60895. static CreateIcoSphere(name: string, options: {
  60896. radius?: number;
  60897. radiusX?: number;
  60898. radiusY?: number;
  60899. radiusZ?: number;
  60900. flat?: boolean;
  60901. subdivisions?: number;
  60902. sideOrientation?: number;
  60903. frontUVs?: Vector4;
  60904. backUVs?: Vector4;
  60905. updatable?: boolean;
  60906. }, scene?: Nullable<Scene>): Mesh;
  60907. }
  60908. }
  60909. declare module BABYLON {
  60910. /**
  60911. * Class containing static functions to help procedurally build meshes
  60912. */
  60913. export class DecalBuilder {
  60914. /**
  60915. * Creates a decal mesh.
  60916. * 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
  60917. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  60918. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  60919. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  60920. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  60921. * @param name defines the name of the mesh
  60922. * @param sourceMesh defines the mesh where the decal must be applied
  60923. * @param options defines the options used to create the mesh
  60924. * @param scene defines the hosting scene
  60925. * @returns the decal mesh
  60926. * @see https://doc.babylonjs.com/how_to/decals
  60927. */
  60928. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  60929. position?: Vector3;
  60930. normal?: Vector3;
  60931. size?: Vector3;
  60932. angle?: number;
  60933. }): Mesh;
  60934. }
  60935. }
  60936. declare module BABYLON {
  60937. /**
  60938. * Class containing static functions to help procedurally build meshes
  60939. */
  60940. export class MeshBuilder {
  60941. /**
  60942. * Creates a box mesh
  60943. * * The parameter `size` sets the size (float) of each box side (default 1)
  60944. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  60945. * * 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)
  60946. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  60947. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60948. * * 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
  60949. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60950. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  60951. * @param name defines the name of the mesh
  60952. * @param options defines the options used to create the mesh
  60953. * @param scene defines the hosting scene
  60954. * @returns the box mesh
  60955. */
  60956. static CreateBox(name: string, options: {
  60957. size?: number;
  60958. width?: number;
  60959. height?: number;
  60960. depth?: number;
  60961. faceUV?: Vector4[];
  60962. faceColors?: Color4[];
  60963. sideOrientation?: number;
  60964. frontUVs?: Vector4;
  60965. backUVs?: Vector4;
  60966. updatable?: boolean;
  60967. }, scene?: Nullable<Scene>): Mesh;
  60968. /**
  60969. * Creates a tiled box mesh
  60970. * * faceTiles sets the pattern, tile size and number of tiles for a face
  60971. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60972. * @param name defines the name of the mesh
  60973. * @param options defines the options used to create the mesh
  60974. * @param scene defines the hosting scene
  60975. * @returns the tiled box mesh
  60976. */
  60977. static CreateTiledBox(name: string, options: {
  60978. pattern?: number;
  60979. size?: number;
  60980. width?: number;
  60981. height?: number;
  60982. depth: number;
  60983. tileSize?: number;
  60984. tileWidth?: number;
  60985. tileHeight?: number;
  60986. faceUV?: Vector4[];
  60987. faceColors?: Color4[];
  60988. alignHorizontal?: number;
  60989. alignVertical?: number;
  60990. sideOrientation?: number;
  60991. updatable?: boolean;
  60992. }, scene?: Nullable<Scene>): Mesh;
  60993. /**
  60994. * Creates a sphere mesh
  60995. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  60996. * * 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`)
  60997. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  60998. * * 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
  60999. * * 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)
  61000. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61001. * * 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
  61002. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61003. * @param name defines the name of the mesh
  61004. * @param options defines the options used to create the mesh
  61005. * @param scene defines the hosting scene
  61006. * @returns the sphere mesh
  61007. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  61008. */
  61009. static CreateSphere(name: string, options: {
  61010. segments?: number;
  61011. diameter?: number;
  61012. diameterX?: number;
  61013. diameterY?: number;
  61014. diameterZ?: number;
  61015. arc?: number;
  61016. slice?: number;
  61017. sideOrientation?: number;
  61018. frontUVs?: Vector4;
  61019. backUVs?: Vector4;
  61020. updatable?: boolean;
  61021. }, scene?: Nullable<Scene>): Mesh;
  61022. /**
  61023. * Creates a plane polygonal mesh. By default, this is a disc
  61024. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  61025. * * 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
  61026. * * 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
  61027. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61028. * * 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
  61029. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61030. * @param name defines the name of the mesh
  61031. * @param options defines the options used to create the mesh
  61032. * @param scene defines the hosting scene
  61033. * @returns the plane polygonal mesh
  61034. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  61035. */
  61036. static CreateDisc(name: string, options: {
  61037. radius?: number;
  61038. tessellation?: number;
  61039. arc?: number;
  61040. updatable?: boolean;
  61041. sideOrientation?: number;
  61042. frontUVs?: Vector4;
  61043. backUVs?: Vector4;
  61044. }, scene?: Nullable<Scene>): Mesh;
  61045. /**
  61046. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  61047. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  61048. * * 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`)
  61049. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  61050. * * 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
  61051. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61052. * * 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
  61053. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61054. * @param name defines the name of the mesh
  61055. * @param options defines the options used to create the mesh
  61056. * @param scene defines the hosting scene
  61057. * @returns the icosahedron mesh
  61058. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  61059. */
  61060. static CreateIcoSphere(name: string, options: {
  61061. radius?: number;
  61062. radiusX?: number;
  61063. radiusY?: number;
  61064. radiusZ?: number;
  61065. flat?: boolean;
  61066. subdivisions?: number;
  61067. sideOrientation?: number;
  61068. frontUVs?: Vector4;
  61069. backUVs?: Vector4;
  61070. updatable?: boolean;
  61071. }, scene?: Nullable<Scene>): Mesh;
  61072. /**
  61073. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  61074. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  61075. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  61076. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  61077. * * 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
  61078. * * 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
  61079. * * 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
  61080. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61081. * * 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
  61082. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61083. * * 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
  61084. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  61085. * * 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
  61086. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  61087. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61088. * @param name defines the name of the mesh
  61089. * @param options defines the options used to create the mesh
  61090. * @param scene defines the hosting scene
  61091. * @returns the ribbon mesh
  61092. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  61093. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  61094. */
  61095. static CreateRibbon(name: string, options: {
  61096. pathArray: Vector3[][];
  61097. closeArray?: boolean;
  61098. closePath?: boolean;
  61099. offset?: number;
  61100. updatable?: boolean;
  61101. sideOrientation?: number;
  61102. frontUVs?: Vector4;
  61103. backUVs?: Vector4;
  61104. instance?: Mesh;
  61105. invertUV?: boolean;
  61106. uvs?: Vector2[];
  61107. colors?: Color4[];
  61108. }, scene?: Nullable<Scene>): Mesh;
  61109. /**
  61110. * Creates a cylinder or a cone mesh
  61111. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  61112. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  61113. * * 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.
  61114. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  61115. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  61116. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  61117. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  61118. * * 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).
  61119. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  61120. * * 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).
  61121. * * 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
  61122. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  61123. * * 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
  61124. * * 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.
  61125. * * If `enclose` is false, a ring surface is one element.
  61126. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  61127. * * 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
  61128. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61129. * * 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
  61130. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61131. * @param name defines the name of the mesh
  61132. * @param options defines the options used to create the mesh
  61133. * @param scene defines the hosting scene
  61134. * @returns the cylinder mesh
  61135. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  61136. */
  61137. static CreateCylinder(name: string, options: {
  61138. height?: number;
  61139. diameterTop?: number;
  61140. diameterBottom?: number;
  61141. diameter?: number;
  61142. tessellation?: number;
  61143. subdivisions?: number;
  61144. arc?: number;
  61145. faceColors?: Color4[];
  61146. faceUV?: Vector4[];
  61147. updatable?: boolean;
  61148. hasRings?: boolean;
  61149. enclose?: boolean;
  61150. cap?: number;
  61151. sideOrientation?: number;
  61152. frontUVs?: Vector4;
  61153. backUVs?: Vector4;
  61154. }, scene?: Nullable<Scene>): Mesh;
  61155. /**
  61156. * Creates a torus mesh
  61157. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  61158. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  61159. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  61160. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61161. * * 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
  61162. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61163. * @param name defines the name of the mesh
  61164. * @param options defines the options used to create the mesh
  61165. * @param scene defines the hosting scene
  61166. * @returns the torus mesh
  61167. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  61168. */
  61169. static CreateTorus(name: string, options: {
  61170. diameter?: number;
  61171. thickness?: number;
  61172. tessellation?: number;
  61173. updatable?: boolean;
  61174. sideOrientation?: number;
  61175. frontUVs?: Vector4;
  61176. backUVs?: Vector4;
  61177. }, scene?: Nullable<Scene>): Mesh;
  61178. /**
  61179. * Creates a torus knot mesh
  61180. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  61181. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  61182. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  61183. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  61184. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61185. * * 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
  61186. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61187. * @param name defines the name of the mesh
  61188. * @param options defines the options used to create the mesh
  61189. * @param scene defines the hosting scene
  61190. * @returns the torus knot mesh
  61191. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  61192. */
  61193. static CreateTorusKnot(name: string, options: {
  61194. radius?: number;
  61195. tube?: number;
  61196. radialSegments?: number;
  61197. tubularSegments?: number;
  61198. p?: number;
  61199. q?: number;
  61200. updatable?: boolean;
  61201. sideOrientation?: number;
  61202. frontUVs?: Vector4;
  61203. backUVs?: Vector4;
  61204. }, scene?: Nullable<Scene>): Mesh;
  61205. /**
  61206. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  61207. * * 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
  61208. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  61209. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  61210. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  61211. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  61212. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  61213. * * 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
  61214. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  61215. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61216. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  61217. * @param name defines the name of the new line system
  61218. * @param options defines the options used to create the line system
  61219. * @param scene defines the hosting scene
  61220. * @returns a new line system mesh
  61221. */
  61222. static CreateLineSystem(name: string, options: {
  61223. lines: Vector3[][];
  61224. updatable?: boolean;
  61225. instance?: Nullable<LinesMesh>;
  61226. colors?: Nullable<Color4[][]>;
  61227. useVertexAlpha?: boolean;
  61228. }, scene: Nullable<Scene>): LinesMesh;
  61229. /**
  61230. * Creates a line mesh
  61231. * 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
  61232. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  61233. * * The parameter `points` is an array successive Vector3
  61234. * * 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
  61235. * * The optional parameter `colors` is an array of successive Color4, one per line point
  61236. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  61237. * * When updating an instance, remember that only point positions can change, not the number of points
  61238. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61239. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  61240. * @param name defines the name of the new line system
  61241. * @param options defines the options used to create the line system
  61242. * @param scene defines the hosting scene
  61243. * @returns a new line mesh
  61244. */
  61245. static CreateLines(name: string, options: {
  61246. points: Vector3[];
  61247. updatable?: boolean;
  61248. instance?: Nullable<LinesMesh>;
  61249. colors?: Color4[];
  61250. useVertexAlpha?: boolean;
  61251. }, scene?: Nullable<Scene>): LinesMesh;
  61252. /**
  61253. * Creates a dashed line mesh
  61254. * * 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
  61255. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  61256. * * The parameter `points` is an array successive Vector3
  61257. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  61258. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  61259. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  61260. * * 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
  61261. * * When updating an instance, remember that only point positions can change, not the number of points
  61262. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61263. * @param name defines the name of the mesh
  61264. * @param options defines the options used to create the mesh
  61265. * @param scene defines the hosting scene
  61266. * @returns the dashed line mesh
  61267. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  61268. */
  61269. static CreateDashedLines(name: string, options: {
  61270. points: Vector3[];
  61271. dashSize?: number;
  61272. gapSize?: number;
  61273. dashNb?: number;
  61274. updatable?: boolean;
  61275. instance?: LinesMesh;
  61276. }, scene?: Nullable<Scene>): LinesMesh;
  61277. /**
  61278. * 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.
  61279. * * 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.
  61280. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  61281. * * 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.
  61282. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  61283. * * 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
  61284. * * 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
  61285. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  61286. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61287. * * 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
  61288. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  61289. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61290. * @param name defines the name of the mesh
  61291. * @param options defines the options used to create the mesh
  61292. * @param scene defines the hosting scene
  61293. * @returns the extruded shape mesh
  61294. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  61295. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  61296. */
  61297. static ExtrudeShape(name: string, options: {
  61298. shape: Vector3[];
  61299. path: Vector3[];
  61300. scale?: number;
  61301. rotation?: number;
  61302. cap?: number;
  61303. updatable?: boolean;
  61304. sideOrientation?: number;
  61305. frontUVs?: Vector4;
  61306. backUVs?: Vector4;
  61307. instance?: Mesh;
  61308. invertUV?: boolean;
  61309. }, scene?: Nullable<Scene>): Mesh;
  61310. /**
  61311. * Creates an custom extruded shape mesh.
  61312. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  61313. * * 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.
  61314. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  61315. * * 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
  61316. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  61317. * * 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
  61318. * * It must returns a float value that will be the scale value applied to the shape on each path point
  61319. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  61320. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  61321. * * 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
  61322. * * 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
  61323. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  61324. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61325. * * 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
  61326. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61327. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61328. * @param name defines the name of the mesh
  61329. * @param options defines the options used to create the mesh
  61330. * @param scene defines the hosting scene
  61331. * @returns the custom extruded shape mesh
  61332. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  61333. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  61334. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  61335. */
  61336. static ExtrudeShapeCustom(name: string, options: {
  61337. shape: Vector3[];
  61338. path: Vector3[];
  61339. scaleFunction?: any;
  61340. rotationFunction?: any;
  61341. ribbonCloseArray?: boolean;
  61342. ribbonClosePath?: boolean;
  61343. cap?: number;
  61344. updatable?: boolean;
  61345. sideOrientation?: number;
  61346. frontUVs?: Vector4;
  61347. backUVs?: Vector4;
  61348. instance?: Mesh;
  61349. invertUV?: boolean;
  61350. }, scene?: Nullable<Scene>): Mesh;
  61351. /**
  61352. * Creates lathe mesh.
  61353. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  61354. * * 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
  61355. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  61356. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  61357. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  61358. * * 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
  61359. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  61360. * * 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
  61361. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61362. * * 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
  61363. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61364. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61365. * @param name defines the name of the mesh
  61366. * @param options defines the options used to create the mesh
  61367. * @param scene defines the hosting scene
  61368. * @returns the lathe mesh
  61369. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  61370. */
  61371. static CreateLathe(name: string, options: {
  61372. shape: Vector3[];
  61373. radius?: number;
  61374. tessellation?: number;
  61375. clip?: number;
  61376. arc?: number;
  61377. closed?: boolean;
  61378. updatable?: boolean;
  61379. sideOrientation?: number;
  61380. frontUVs?: Vector4;
  61381. backUVs?: Vector4;
  61382. cap?: number;
  61383. invertUV?: boolean;
  61384. }, scene?: Nullable<Scene>): Mesh;
  61385. /**
  61386. * Creates a tiled plane mesh
  61387. * * You can set a limited pattern arrangement with the tiles
  61388. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61389. * * 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
  61390. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61391. * @param name defines the name of the mesh
  61392. * @param options defines the options used to create the mesh
  61393. * @param scene defines the hosting scene
  61394. * @returns the plane mesh
  61395. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  61396. */
  61397. static CreateTiledPlane(name: string, options: {
  61398. pattern?: number;
  61399. tileSize?: number;
  61400. tileWidth?: number;
  61401. tileHeight?: number;
  61402. size?: number;
  61403. width?: number;
  61404. height?: number;
  61405. alignHorizontal?: number;
  61406. alignVertical?: number;
  61407. sideOrientation?: number;
  61408. frontUVs?: Vector4;
  61409. backUVs?: Vector4;
  61410. updatable?: boolean;
  61411. }, scene?: Nullable<Scene>): Mesh;
  61412. /**
  61413. * Creates a plane mesh
  61414. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  61415. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  61416. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  61417. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61418. * * 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
  61419. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61420. * @param name defines the name of the mesh
  61421. * @param options defines the options used to create the mesh
  61422. * @param scene defines the hosting scene
  61423. * @returns the plane mesh
  61424. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  61425. */
  61426. static CreatePlane(name: string, options: {
  61427. size?: number;
  61428. width?: number;
  61429. height?: number;
  61430. sideOrientation?: number;
  61431. frontUVs?: Vector4;
  61432. backUVs?: Vector4;
  61433. updatable?: boolean;
  61434. sourcePlane?: Plane;
  61435. }, scene?: Nullable<Scene>): Mesh;
  61436. /**
  61437. * Creates a ground mesh
  61438. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  61439. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  61440. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61441. * @param name defines the name of the mesh
  61442. * @param options defines the options used to create the mesh
  61443. * @param scene defines the hosting scene
  61444. * @returns the ground mesh
  61445. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  61446. */
  61447. static CreateGround(name: string, options: {
  61448. width?: number;
  61449. height?: number;
  61450. subdivisions?: number;
  61451. subdivisionsX?: number;
  61452. subdivisionsY?: number;
  61453. updatable?: boolean;
  61454. }, scene?: Nullable<Scene>): Mesh;
  61455. /**
  61456. * Creates a tiled ground mesh
  61457. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  61458. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  61459. * * 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
  61460. * * 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
  61461. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61462. * @param name defines the name of the mesh
  61463. * @param options defines the options used to create the mesh
  61464. * @param scene defines the hosting scene
  61465. * @returns the tiled ground mesh
  61466. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  61467. */
  61468. static CreateTiledGround(name: string, options: {
  61469. xmin: number;
  61470. zmin: number;
  61471. xmax: number;
  61472. zmax: number;
  61473. subdivisions?: {
  61474. w: number;
  61475. h: number;
  61476. };
  61477. precision?: {
  61478. w: number;
  61479. h: number;
  61480. };
  61481. updatable?: boolean;
  61482. }, scene?: Nullable<Scene>): Mesh;
  61483. /**
  61484. * Creates a ground mesh from a height map
  61485. * * The parameter `url` sets the URL of the height map image resource.
  61486. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  61487. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  61488. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  61489. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  61490. * * 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.
  61491. * * 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).
  61492. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  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. * @param name defines the name of the mesh
  61495. * @param url defines the url to the height map
  61496. * @param options defines the options used to create the mesh
  61497. * @param scene defines the hosting scene
  61498. * @returns the ground mesh
  61499. * @see https://doc.babylonjs.com/babylon101/height_map
  61500. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  61501. */
  61502. static CreateGroundFromHeightMap(name: string, url: string, options: {
  61503. width?: number;
  61504. height?: number;
  61505. subdivisions?: number;
  61506. minHeight?: number;
  61507. maxHeight?: number;
  61508. colorFilter?: Color3;
  61509. alphaFilter?: number;
  61510. updatable?: boolean;
  61511. onReady?: (mesh: GroundMesh) => void;
  61512. }, scene?: Nullable<Scene>): GroundMesh;
  61513. /**
  61514. * Creates a polygon mesh
  61515. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  61516. * * 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
  61517. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  61518. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61519. * * 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)
  61520. * * Remember you can only change the shape positions, not their number when updating a polygon
  61521. * @param name defines the name of the mesh
  61522. * @param options defines the options used to create the mesh
  61523. * @param scene defines the hosting scene
  61524. * @param earcutInjection can be used to inject your own earcut reference
  61525. * @returns the polygon mesh
  61526. */
  61527. static CreatePolygon(name: string, options: {
  61528. shape: Vector3[];
  61529. holes?: Vector3[][];
  61530. depth?: number;
  61531. faceUV?: Vector4[];
  61532. faceColors?: Color4[];
  61533. updatable?: boolean;
  61534. sideOrientation?: number;
  61535. frontUVs?: Vector4;
  61536. backUVs?: Vector4;
  61537. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  61538. /**
  61539. * Creates an extruded polygon mesh, with depth in the Y direction.
  61540. * * 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)
  61541. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  61542. * @param name defines the name of the mesh
  61543. * @param options defines the options used to create the mesh
  61544. * @param scene defines the hosting scene
  61545. * @param earcutInjection can be used to inject your own earcut reference
  61546. * @returns the polygon mesh
  61547. */
  61548. static ExtrudePolygon(name: string, options: {
  61549. shape: Vector3[];
  61550. holes?: Vector3[][];
  61551. depth?: number;
  61552. faceUV?: Vector4[];
  61553. faceColors?: Color4[];
  61554. updatable?: boolean;
  61555. sideOrientation?: number;
  61556. frontUVs?: Vector4;
  61557. backUVs?: Vector4;
  61558. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  61559. /**
  61560. * Creates a tube mesh.
  61561. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  61562. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  61563. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  61564. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  61565. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  61566. * * 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)
  61567. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  61568. * * 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
  61569. * * 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
  61570. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61571. * * 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
  61572. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61573. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61574. * @param name defines the name of the mesh
  61575. * @param options defines the options used to create the mesh
  61576. * @param scene defines the hosting scene
  61577. * @returns the tube mesh
  61578. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  61579. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  61580. */
  61581. static CreateTube(name: string, options: {
  61582. path: Vector3[];
  61583. radius?: number;
  61584. tessellation?: number;
  61585. radiusFunction?: {
  61586. (i: number, distance: number): number;
  61587. };
  61588. cap?: number;
  61589. arc?: number;
  61590. updatable?: boolean;
  61591. sideOrientation?: number;
  61592. frontUVs?: Vector4;
  61593. backUVs?: Vector4;
  61594. instance?: Mesh;
  61595. invertUV?: boolean;
  61596. }, scene?: Nullable<Scene>): Mesh;
  61597. /**
  61598. * Creates a polyhedron mesh
  61599. * * 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
  61600. * * The parameter `size` (positive float, default 1) sets the polygon size
  61601. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  61602. * * 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`
  61603. * * 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
  61604. * * 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)`)
  61605. * * 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
  61606. * * 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
  61607. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61608. * * 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
  61609. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61610. * @param name defines the name of the mesh
  61611. * @param options defines the options used to create the mesh
  61612. * @param scene defines the hosting scene
  61613. * @returns the polyhedron mesh
  61614. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  61615. */
  61616. static CreatePolyhedron(name: string, options: {
  61617. type?: number;
  61618. size?: number;
  61619. sizeX?: number;
  61620. sizeY?: number;
  61621. sizeZ?: number;
  61622. custom?: any;
  61623. faceUV?: Vector4[];
  61624. faceColors?: Color4[];
  61625. flat?: boolean;
  61626. updatable?: boolean;
  61627. sideOrientation?: number;
  61628. frontUVs?: Vector4;
  61629. backUVs?: Vector4;
  61630. }, scene?: Nullable<Scene>): Mesh;
  61631. /**
  61632. * Creates a decal mesh.
  61633. * 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
  61634. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  61635. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  61636. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  61637. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  61638. * @param name defines the name of the mesh
  61639. * @param sourceMesh defines the mesh where the decal must be applied
  61640. * @param options defines the options used to create the mesh
  61641. * @param scene defines the hosting scene
  61642. * @returns the decal mesh
  61643. * @see https://doc.babylonjs.com/how_to/decals
  61644. */
  61645. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  61646. position?: Vector3;
  61647. normal?: Vector3;
  61648. size?: Vector3;
  61649. angle?: number;
  61650. }): Mesh;
  61651. }
  61652. }
  61653. declare module BABYLON {
  61654. /**
  61655. * A simplifier interface for future simplification implementations
  61656. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  61657. */
  61658. export interface ISimplifier {
  61659. /**
  61660. * Simplification of a given mesh according to the given settings.
  61661. * Since this requires computation, it is assumed that the function runs async.
  61662. * @param settings The settings of the simplification, including quality and distance
  61663. * @param successCallback A callback that will be called after the mesh was simplified.
  61664. * @param errorCallback in case of an error, this callback will be called. optional.
  61665. */
  61666. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  61667. }
  61668. /**
  61669. * Expected simplification settings.
  61670. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  61671. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  61672. */
  61673. export interface ISimplificationSettings {
  61674. /**
  61675. * Gets or sets the expected quality
  61676. */
  61677. quality: number;
  61678. /**
  61679. * Gets or sets the distance when this optimized version should be used
  61680. */
  61681. distance: number;
  61682. /**
  61683. * Gets an already optimized mesh
  61684. */
  61685. optimizeMesh?: boolean;
  61686. }
  61687. /**
  61688. * Class used to specify simplification options
  61689. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  61690. */
  61691. export class SimplificationSettings implements ISimplificationSettings {
  61692. /** expected quality */
  61693. quality: number;
  61694. /** distance when this optimized version should be used */
  61695. distance: number;
  61696. /** already optimized mesh */
  61697. optimizeMesh?: boolean | undefined;
  61698. /**
  61699. * Creates a SimplificationSettings
  61700. * @param quality expected quality
  61701. * @param distance distance when this optimized version should be used
  61702. * @param optimizeMesh already optimized mesh
  61703. */
  61704. constructor(
  61705. /** expected quality */
  61706. quality: number,
  61707. /** distance when this optimized version should be used */
  61708. distance: number,
  61709. /** already optimized mesh */
  61710. optimizeMesh?: boolean | undefined);
  61711. }
  61712. /**
  61713. * Interface used to define a simplification task
  61714. */
  61715. export interface ISimplificationTask {
  61716. /**
  61717. * Array of settings
  61718. */
  61719. settings: Array<ISimplificationSettings>;
  61720. /**
  61721. * Simplification type
  61722. */
  61723. simplificationType: SimplificationType;
  61724. /**
  61725. * Mesh to simplify
  61726. */
  61727. mesh: Mesh;
  61728. /**
  61729. * Callback called on success
  61730. */
  61731. successCallback?: () => void;
  61732. /**
  61733. * Defines if parallel processing can be used
  61734. */
  61735. parallelProcessing: boolean;
  61736. }
  61737. /**
  61738. * Queue used to order the simplification tasks
  61739. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  61740. */
  61741. export class SimplificationQueue {
  61742. private _simplificationArray;
  61743. /**
  61744. * Gets a boolean indicating that the process is still running
  61745. */
  61746. running: boolean;
  61747. /**
  61748. * Creates a new queue
  61749. */
  61750. constructor();
  61751. /**
  61752. * Adds a new simplification task
  61753. * @param task defines a task to add
  61754. */
  61755. addTask(task: ISimplificationTask): void;
  61756. /**
  61757. * Execute next task
  61758. */
  61759. executeNext(): void;
  61760. /**
  61761. * Execute a simplification task
  61762. * @param task defines the task to run
  61763. */
  61764. runSimplification(task: ISimplificationTask): void;
  61765. private getSimplifier;
  61766. }
  61767. /**
  61768. * The implemented types of simplification
  61769. * At the moment only Quadratic Error Decimation is implemented
  61770. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  61771. */
  61772. export enum SimplificationType {
  61773. /** Quadratic error decimation */
  61774. QUADRATIC = 0
  61775. }
  61776. }
  61777. declare module BABYLON {
  61778. interface Scene {
  61779. /** @hidden (Backing field) */
  61780. _simplificationQueue: SimplificationQueue;
  61781. /**
  61782. * Gets or sets the simplification queue attached to the scene
  61783. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  61784. */
  61785. simplificationQueue: SimplificationQueue;
  61786. }
  61787. interface Mesh {
  61788. /**
  61789. * Simplify the mesh according to the given array of settings.
  61790. * Function will return immediately and will simplify async
  61791. * @param settings a collection of simplification settings
  61792. * @param parallelProcessing should all levels calculate parallel or one after the other
  61793. * @param simplificationType the type of simplification to run
  61794. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  61795. * @returns the current mesh
  61796. */
  61797. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  61798. }
  61799. /**
  61800. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  61801. * created in a scene
  61802. */
  61803. export class SimplicationQueueSceneComponent implements ISceneComponent {
  61804. /**
  61805. * The component name helpfull to identify the component in the list of scene components.
  61806. */
  61807. readonly name: string;
  61808. /**
  61809. * The scene the component belongs to.
  61810. */
  61811. scene: Scene;
  61812. /**
  61813. * Creates a new instance of the component for the given scene
  61814. * @param scene Defines the scene to register the component in
  61815. */
  61816. constructor(scene: Scene);
  61817. /**
  61818. * Registers the component in a given scene
  61819. */
  61820. register(): void;
  61821. /**
  61822. * Rebuilds the elements related to this component in case of
  61823. * context lost for instance.
  61824. */
  61825. rebuild(): void;
  61826. /**
  61827. * Disposes the component and the associated ressources
  61828. */
  61829. dispose(): void;
  61830. private _beforeCameraUpdate;
  61831. }
  61832. }
  61833. declare module BABYLON {
  61834. /**
  61835. * Navigation plugin interface to add navigation constrained by a navigation mesh
  61836. */
  61837. export interface INavigationEnginePlugin {
  61838. /**
  61839. * plugin name
  61840. */
  61841. name: string;
  61842. /**
  61843. * Creates a navigation mesh
  61844. * @param meshes array of all the geometry used to compute the navigatio mesh
  61845. * @param parameters bunch of parameters used to filter geometry
  61846. */
  61847. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  61848. /**
  61849. * Create a navigation mesh debug mesh
  61850. * @param scene is where the mesh will be added
  61851. * @returns debug display mesh
  61852. */
  61853. createDebugNavMesh(scene: Scene): Mesh;
  61854. /**
  61855. * Get a navigation mesh constrained position, closest to the parameter position
  61856. * @param position world position
  61857. * @returns the closest point to position constrained by the navigation mesh
  61858. */
  61859. getClosestPoint(position: Vector3): Vector3;
  61860. /**
  61861. * Get a navigation mesh constrained position, within a particular radius
  61862. * @param position world position
  61863. * @param maxRadius the maximum distance to the constrained world position
  61864. * @returns the closest point to position constrained by the navigation mesh
  61865. */
  61866. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  61867. /**
  61868. * Compute the final position from a segment made of destination-position
  61869. * @param position world position
  61870. * @param destination world position
  61871. * @returns the resulting point along the navmesh
  61872. */
  61873. moveAlong(position: Vector3, destination: Vector3): Vector3;
  61874. /**
  61875. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  61876. * @param start world position
  61877. * @param end world position
  61878. * @returns array containing world position composing the path
  61879. */
  61880. computePath(start: Vector3, end: Vector3): Vector3[];
  61881. /**
  61882. * If this plugin is supported
  61883. * @returns true if plugin is supported
  61884. */
  61885. isSupported(): boolean;
  61886. /**
  61887. * Create a new Crowd so you can add agents
  61888. * @param maxAgents the maximum agent count in the crowd
  61889. * @param maxAgentRadius the maximum radius an agent can have
  61890. * @param scene to attach the crowd to
  61891. * @returns the crowd you can add agents to
  61892. */
  61893. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  61894. /**
  61895. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  61896. * The queries will try to find a solution within those bounds
  61897. * default is (1,1,1)
  61898. * @param extent x,y,z value that define the extent around the queries point of reference
  61899. */
  61900. setDefaultQueryExtent(extent: Vector3): void;
  61901. /**
  61902. * Get the Bounding box extent specified by setDefaultQueryExtent
  61903. * @returns the box extent values
  61904. */
  61905. getDefaultQueryExtent(): Vector3;
  61906. /**
  61907. * Release all resources
  61908. */
  61909. dispose(): void;
  61910. }
  61911. /**
  61912. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  61913. */
  61914. export interface ICrowd {
  61915. /**
  61916. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  61917. * You can attach anything to that node. The node position is updated in the scene update tick.
  61918. * @param pos world position that will be constrained by the navigation mesh
  61919. * @param parameters agent parameters
  61920. * @param transform hooked to the agent that will be update by the scene
  61921. * @returns agent index
  61922. */
  61923. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  61924. /**
  61925. * Returns the agent position in world space
  61926. * @param index agent index returned by addAgent
  61927. * @returns world space position
  61928. */
  61929. getAgentPosition(index: number): Vector3;
  61930. /**
  61931. * Gets the agent velocity in world space
  61932. * @param index agent index returned by addAgent
  61933. * @returns world space velocity
  61934. */
  61935. getAgentVelocity(index: number): Vector3;
  61936. /**
  61937. * remove a particular agent previously created
  61938. * @param index agent index returned by addAgent
  61939. */
  61940. removeAgent(index: number): void;
  61941. /**
  61942. * get the list of all agents attached to this crowd
  61943. * @returns list of agent indices
  61944. */
  61945. getAgents(): number[];
  61946. /**
  61947. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  61948. * @param deltaTime in seconds
  61949. */
  61950. update(deltaTime: number): void;
  61951. /**
  61952. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  61953. * @param index agent index returned by addAgent
  61954. * @param destination targeted world position
  61955. */
  61956. agentGoto(index: number, destination: Vector3): void;
  61957. /**
  61958. * Teleport the agent to a new position
  61959. * @param index agent index returned by addAgent
  61960. * @param destination targeted world position
  61961. */
  61962. agentTeleport(index: number, destination: Vector3): void;
  61963. /**
  61964. * Update agent parameters
  61965. * @param index agent index returned by addAgent
  61966. * @param parameters agent parameters
  61967. */
  61968. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  61969. /**
  61970. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  61971. * The queries will try to find a solution within those bounds
  61972. * default is (1,1,1)
  61973. * @param extent x,y,z value that define the extent around the queries point of reference
  61974. */
  61975. setDefaultQueryExtent(extent: Vector3): void;
  61976. /**
  61977. * Get the Bounding box extent specified by setDefaultQueryExtent
  61978. * @returns the box extent values
  61979. */
  61980. getDefaultQueryExtent(): Vector3;
  61981. /**
  61982. * Release all resources
  61983. */
  61984. dispose(): void;
  61985. }
  61986. /**
  61987. * Configures an agent
  61988. */
  61989. export interface IAgentParameters {
  61990. /**
  61991. * Agent radius. [Limit: >= 0]
  61992. */
  61993. radius: number;
  61994. /**
  61995. * Agent height. [Limit: > 0]
  61996. */
  61997. height: number;
  61998. /**
  61999. * Maximum allowed acceleration. [Limit: >= 0]
  62000. */
  62001. maxAcceleration: number;
  62002. /**
  62003. * Maximum allowed speed. [Limit: >= 0]
  62004. */
  62005. maxSpeed: number;
  62006. /**
  62007. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  62008. */
  62009. collisionQueryRange: number;
  62010. /**
  62011. * The path visibility optimization range. [Limit: > 0]
  62012. */
  62013. pathOptimizationRange: number;
  62014. /**
  62015. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  62016. */
  62017. separationWeight: number;
  62018. }
  62019. /**
  62020. * Configures the navigation mesh creation
  62021. */
  62022. export interface INavMeshParameters {
  62023. /**
  62024. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  62025. */
  62026. cs: number;
  62027. /**
  62028. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  62029. */
  62030. ch: number;
  62031. /**
  62032. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  62033. */
  62034. walkableSlopeAngle: number;
  62035. /**
  62036. * Minimum floor to 'ceiling' height that will still allow the floor area to
  62037. * be considered walkable. [Limit: >= 3] [Units: vx]
  62038. */
  62039. walkableHeight: number;
  62040. /**
  62041. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  62042. */
  62043. walkableClimb: number;
  62044. /**
  62045. * The distance to erode/shrink the walkable area of the heightfield away from
  62046. * obstructions. [Limit: >=0] [Units: vx]
  62047. */
  62048. walkableRadius: number;
  62049. /**
  62050. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  62051. */
  62052. maxEdgeLen: number;
  62053. /**
  62054. * The maximum distance a simplfied contour's border edges should deviate
  62055. * the original raw contour. [Limit: >=0] [Units: vx]
  62056. */
  62057. maxSimplificationError: number;
  62058. /**
  62059. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  62060. */
  62061. minRegionArea: number;
  62062. /**
  62063. * Any regions with a span count smaller than this value will, if possible,
  62064. * be merged with larger regions. [Limit: >=0] [Units: vx]
  62065. */
  62066. mergeRegionArea: number;
  62067. /**
  62068. * The maximum number of vertices allowed for polygons generated during the
  62069. * contour to polygon conversion process. [Limit: >= 3]
  62070. */
  62071. maxVertsPerPoly: number;
  62072. /**
  62073. * Sets the sampling distance to use when generating the detail mesh.
  62074. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  62075. */
  62076. detailSampleDist: number;
  62077. /**
  62078. * The maximum distance the detail mesh surface should deviate from heightfield
  62079. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  62080. */
  62081. detailSampleMaxError: number;
  62082. }
  62083. }
  62084. declare module BABYLON {
  62085. /**
  62086. * RecastJS navigation plugin
  62087. */
  62088. export class RecastJSPlugin implements INavigationEnginePlugin {
  62089. /**
  62090. * Reference to the Recast library
  62091. */
  62092. bjsRECAST: any;
  62093. /**
  62094. * plugin name
  62095. */
  62096. name: string;
  62097. /**
  62098. * the first navmesh created. We might extend this to support multiple navmeshes
  62099. */
  62100. navMesh: any;
  62101. /**
  62102. * Initializes the recastJS plugin
  62103. * @param recastInjection can be used to inject your own recast reference
  62104. */
  62105. constructor(recastInjection?: any);
  62106. /**
  62107. * Creates a navigation mesh
  62108. * @param meshes array of all the geometry used to compute the navigatio mesh
  62109. * @param parameters bunch of parameters used to filter geometry
  62110. */
  62111. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  62112. /**
  62113. * Create a navigation mesh debug mesh
  62114. * @param scene is where the mesh will be added
  62115. * @returns debug display mesh
  62116. */
  62117. createDebugNavMesh(scene: Scene): Mesh;
  62118. /**
  62119. * Get a navigation mesh constrained position, closest to the parameter position
  62120. * @param position world position
  62121. * @returns the closest point to position constrained by the navigation mesh
  62122. */
  62123. getClosestPoint(position: Vector3): Vector3;
  62124. /**
  62125. * Get a navigation mesh constrained position, within a particular radius
  62126. * @param position world position
  62127. * @param maxRadius the maximum distance to the constrained world position
  62128. * @returns the closest point to position constrained by the navigation mesh
  62129. */
  62130. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  62131. /**
  62132. * Compute the final position from a segment made of destination-position
  62133. * @param position world position
  62134. * @param destination world position
  62135. * @returns the resulting point along the navmesh
  62136. */
  62137. moveAlong(position: Vector3, destination: Vector3): Vector3;
  62138. /**
  62139. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  62140. * @param start world position
  62141. * @param end world position
  62142. * @returns array containing world position composing the path
  62143. */
  62144. computePath(start: Vector3, end: Vector3): Vector3[];
  62145. /**
  62146. * Create a new Crowd so you can add agents
  62147. * @param maxAgents the maximum agent count in the crowd
  62148. * @param maxAgentRadius the maximum radius an agent can have
  62149. * @param scene to attach the crowd to
  62150. * @returns the crowd you can add agents to
  62151. */
  62152. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  62153. /**
  62154. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  62155. * The queries will try to find a solution within those bounds
  62156. * default is (1,1,1)
  62157. * @param extent x,y,z value that define the extent around the queries point of reference
  62158. */
  62159. setDefaultQueryExtent(extent: Vector3): void;
  62160. /**
  62161. * Get the Bounding box extent specified by setDefaultQueryExtent
  62162. * @returns the box extent values
  62163. */
  62164. getDefaultQueryExtent(): Vector3;
  62165. /**
  62166. * Disposes
  62167. */
  62168. dispose(): void;
  62169. /**
  62170. * If this plugin is supported
  62171. * @returns true if plugin is supported
  62172. */
  62173. isSupported(): boolean;
  62174. }
  62175. /**
  62176. * Recast detour crowd implementation
  62177. */
  62178. export class RecastJSCrowd implements ICrowd {
  62179. /**
  62180. * Recast/detour plugin
  62181. */
  62182. bjsRECASTPlugin: RecastJSPlugin;
  62183. /**
  62184. * Link to the detour crowd
  62185. */
  62186. recastCrowd: any;
  62187. /**
  62188. * One transform per agent
  62189. */
  62190. transforms: TransformNode[];
  62191. /**
  62192. * All agents created
  62193. */
  62194. agents: number[];
  62195. /**
  62196. * Link to the scene is kept to unregister the crowd from the scene
  62197. */
  62198. private _scene;
  62199. /**
  62200. * Observer for crowd updates
  62201. */
  62202. private _onBeforeAnimationsObserver;
  62203. /**
  62204. * Constructor
  62205. * @param plugin recastJS plugin
  62206. * @param maxAgents the maximum agent count in the crowd
  62207. * @param maxAgentRadius the maximum radius an agent can have
  62208. * @param scene to attach the crowd to
  62209. * @returns the crowd you can add agents to
  62210. */
  62211. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  62212. /**
  62213. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  62214. * You can attach anything to that node. The node position is updated in the scene update tick.
  62215. * @param pos world position that will be constrained by the navigation mesh
  62216. * @param parameters agent parameters
  62217. * @param transform hooked to the agent that will be update by the scene
  62218. * @returns agent index
  62219. */
  62220. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  62221. /**
  62222. * Returns the agent position in world space
  62223. * @param index agent index returned by addAgent
  62224. * @returns world space position
  62225. */
  62226. getAgentPosition(index: number): Vector3;
  62227. /**
  62228. * Returns the agent velocity in world space
  62229. * @param index agent index returned by addAgent
  62230. * @returns world space velocity
  62231. */
  62232. getAgentVelocity(index: number): Vector3;
  62233. /**
  62234. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  62235. * @param index agent index returned by addAgent
  62236. * @param destination targeted world position
  62237. */
  62238. agentGoto(index: number, destination: Vector3): void;
  62239. /**
  62240. * Teleport the agent to a new position
  62241. * @param index agent index returned by addAgent
  62242. * @param destination targeted world position
  62243. */
  62244. agentTeleport(index: number, destination: Vector3): void;
  62245. /**
  62246. * Update agent parameters
  62247. * @param index agent index returned by addAgent
  62248. * @param parameters agent parameters
  62249. */
  62250. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  62251. /**
  62252. * remove a particular agent previously created
  62253. * @param index agent index returned by addAgent
  62254. */
  62255. removeAgent(index: number): void;
  62256. /**
  62257. * get the list of all agents attached to this crowd
  62258. * @returns list of agent indices
  62259. */
  62260. getAgents(): number[];
  62261. /**
  62262. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  62263. * @param deltaTime in seconds
  62264. */
  62265. update(deltaTime: number): void;
  62266. /**
  62267. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  62268. * The queries will try to find a solution within those bounds
  62269. * default is (1,1,1)
  62270. * @param extent x,y,z value that define the extent around the queries point of reference
  62271. */
  62272. setDefaultQueryExtent(extent: Vector3): void;
  62273. /**
  62274. * Get the Bounding box extent specified by setDefaultQueryExtent
  62275. * @returns the box extent values
  62276. */
  62277. getDefaultQueryExtent(): Vector3;
  62278. /**
  62279. * Release all resources
  62280. */
  62281. dispose(): void;
  62282. }
  62283. }
  62284. declare module BABYLON {
  62285. /**
  62286. * Class used to enable access to IndexedDB
  62287. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  62288. */
  62289. export class Database implements IOfflineProvider {
  62290. private _callbackManifestChecked;
  62291. private _currentSceneUrl;
  62292. private _db;
  62293. private _enableSceneOffline;
  62294. private _enableTexturesOffline;
  62295. private _manifestVersionFound;
  62296. private _mustUpdateRessources;
  62297. private _hasReachedQuota;
  62298. private _isSupported;
  62299. private _idbFactory;
  62300. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  62301. private static IsUASupportingBlobStorage;
  62302. /**
  62303. * Gets a boolean indicating if Database storate is enabled (off by default)
  62304. */
  62305. static IDBStorageEnabled: boolean;
  62306. /**
  62307. * Gets a boolean indicating if scene must be saved in the database
  62308. */
  62309. get enableSceneOffline(): boolean;
  62310. /**
  62311. * Gets a boolean indicating if textures must be saved in the database
  62312. */
  62313. get enableTexturesOffline(): boolean;
  62314. /**
  62315. * Creates a new Database
  62316. * @param urlToScene defines the url to load the scene
  62317. * @param callbackManifestChecked defines the callback to use when manifest is checked
  62318. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  62319. */
  62320. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  62321. private static _ParseURL;
  62322. private static _ReturnFullUrlLocation;
  62323. private _checkManifestFile;
  62324. /**
  62325. * Open the database and make it available
  62326. * @param successCallback defines the callback to call on success
  62327. * @param errorCallback defines the callback to call on error
  62328. */
  62329. open(successCallback: () => void, errorCallback: () => void): void;
  62330. /**
  62331. * Loads an image from the database
  62332. * @param url defines the url to load from
  62333. * @param image defines the target DOM image
  62334. */
  62335. loadImage(url: string, image: HTMLImageElement): void;
  62336. private _loadImageFromDBAsync;
  62337. private _saveImageIntoDBAsync;
  62338. private _checkVersionFromDB;
  62339. private _loadVersionFromDBAsync;
  62340. private _saveVersionIntoDBAsync;
  62341. /**
  62342. * Loads a file from database
  62343. * @param url defines the URL to load from
  62344. * @param sceneLoaded defines a callback to call on success
  62345. * @param progressCallBack defines a callback to call when progress changed
  62346. * @param errorCallback defines a callback to call on error
  62347. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  62348. */
  62349. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  62350. private _loadFileAsync;
  62351. private _saveFileAsync;
  62352. /**
  62353. * Validates if xhr data is correct
  62354. * @param xhr defines the request to validate
  62355. * @param dataType defines the expected data type
  62356. * @returns true if data is correct
  62357. */
  62358. private static _ValidateXHRData;
  62359. }
  62360. }
  62361. declare module BABYLON {
  62362. /** @hidden */
  62363. export var gpuUpdateParticlesPixelShader: {
  62364. name: string;
  62365. shader: string;
  62366. };
  62367. }
  62368. declare module BABYLON {
  62369. /** @hidden */
  62370. export var gpuUpdateParticlesVertexShader: {
  62371. name: string;
  62372. shader: string;
  62373. };
  62374. }
  62375. declare module BABYLON {
  62376. /** @hidden */
  62377. export var clipPlaneFragmentDeclaration2: {
  62378. name: string;
  62379. shader: string;
  62380. };
  62381. }
  62382. declare module BABYLON {
  62383. /** @hidden */
  62384. export var gpuRenderParticlesPixelShader: {
  62385. name: string;
  62386. shader: string;
  62387. };
  62388. }
  62389. declare module BABYLON {
  62390. /** @hidden */
  62391. export var clipPlaneVertexDeclaration2: {
  62392. name: string;
  62393. shader: string;
  62394. };
  62395. }
  62396. declare module BABYLON {
  62397. /** @hidden */
  62398. export var gpuRenderParticlesVertexShader: {
  62399. name: string;
  62400. shader: string;
  62401. };
  62402. }
  62403. declare module BABYLON {
  62404. /**
  62405. * This represents a GPU particle system in Babylon
  62406. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  62407. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  62408. */
  62409. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  62410. /**
  62411. * The layer mask we are rendering the particles through.
  62412. */
  62413. layerMask: number;
  62414. private _capacity;
  62415. private _activeCount;
  62416. private _currentActiveCount;
  62417. private _accumulatedCount;
  62418. private _renderEffect;
  62419. private _updateEffect;
  62420. private _buffer0;
  62421. private _buffer1;
  62422. private _spriteBuffer;
  62423. private _updateVAO;
  62424. private _renderVAO;
  62425. private _targetIndex;
  62426. private _sourceBuffer;
  62427. private _targetBuffer;
  62428. private _engine;
  62429. private _currentRenderId;
  62430. private _started;
  62431. private _stopped;
  62432. private _timeDelta;
  62433. private _randomTexture;
  62434. private _randomTexture2;
  62435. private _attributesStrideSize;
  62436. private _updateEffectOptions;
  62437. private _randomTextureSize;
  62438. private _actualFrame;
  62439. private readonly _rawTextureWidth;
  62440. /**
  62441. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  62442. */
  62443. static get IsSupported(): boolean;
  62444. /**
  62445. * An event triggered when the system is disposed.
  62446. */
  62447. onDisposeObservable: Observable<GPUParticleSystem>;
  62448. /**
  62449. * Gets the maximum number of particles active at the same time.
  62450. * @returns The max number of active particles.
  62451. */
  62452. getCapacity(): number;
  62453. /**
  62454. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  62455. * to override the particles.
  62456. */
  62457. forceDepthWrite: boolean;
  62458. /**
  62459. * Gets or set the number of active particles
  62460. */
  62461. get activeParticleCount(): number;
  62462. set activeParticleCount(value: number);
  62463. private _preWarmDone;
  62464. /**
  62465. * Is this system ready to be used/rendered
  62466. * @return true if the system is ready
  62467. */
  62468. isReady(): boolean;
  62469. /**
  62470. * Gets if the system has been started. (Note: this will still be true after stop is called)
  62471. * @returns True if it has been started, otherwise false.
  62472. */
  62473. isStarted(): boolean;
  62474. /**
  62475. * Starts the particle system and begins to emit
  62476. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  62477. */
  62478. start(delay?: number): void;
  62479. /**
  62480. * Stops the particle system.
  62481. */
  62482. stop(): void;
  62483. /**
  62484. * Remove all active particles
  62485. */
  62486. reset(): void;
  62487. /**
  62488. * Returns the string "GPUParticleSystem"
  62489. * @returns a string containing the class name
  62490. */
  62491. getClassName(): string;
  62492. private _colorGradientsTexture;
  62493. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  62494. /**
  62495. * Adds a new color gradient
  62496. * @param gradient defines the gradient to use (between 0 and 1)
  62497. * @param color1 defines the color to affect to the specified gradient
  62498. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  62499. * @returns the current particle system
  62500. */
  62501. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  62502. /**
  62503. * Remove a specific color gradient
  62504. * @param gradient defines the gradient to remove
  62505. * @returns the current particle system
  62506. */
  62507. removeColorGradient(gradient: number): GPUParticleSystem;
  62508. private _angularSpeedGradientsTexture;
  62509. private _sizeGradientsTexture;
  62510. private _velocityGradientsTexture;
  62511. private _limitVelocityGradientsTexture;
  62512. private _dragGradientsTexture;
  62513. private _addFactorGradient;
  62514. /**
  62515. * Adds a new size gradient
  62516. * @param gradient defines the gradient to use (between 0 and 1)
  62517. * @param factor defines the size factor to affect to the specified gradient
  62518. * @returns the current particle system
  62519. */
  62520. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  62521. /**
  62522. * Remove a specific size gradient
  62523. * @param gradient defines the gradient to remove
  62524. * @returns the current particle system
  62525. */
  62526. removeSizeGradient(gradient: number): GPUParticleSystem;
  62527. /**
  62528. * Adds a new angular speed gradient
  62529. * @param gradient defines the gradient to use (between 0 and 1)
  62530. * @param factor defines the angular speed to affect to the specified gradient
  62531. * @returns the current particle system
  62532. */
  62533. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  62534. /**
  62535. * Remove a specific angular speed gradient
  62536. * @param gradient defines the gradient to remove
  62537. * @returns the current particle system
  62538. */
  62539. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  62540. /**
  62541. * Adds a new velocity gradient
  62542. * @param gradient defines the gradient to use (between 0 and 1)
  62543. * @param factor defines the velocity to affect to the specified gradient
  62544. * @returns the current particle system
  62545. */
  62546. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  62547. /**
  62548. * Remove a specific velocity gradient
  62549. * @param gradient defines the gradient to remove
  62550. * @returns the current particle system
  62551. */
  62552. removeVelocityGradient(gradient: number): GPUParticleSystem;
  62553. /**
  62554. * Adds a new limit velocity gradient
  62555. * @param gradient defines the gradient to use (between 0 and 1)
  62556. * @param factor defines the limit velocity value to affect to the specified gradient
  62557. * @returns the current particle system
  62558. */
  62559. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  62560. /**
  62561. * Remove a specific limit velocity gradient
  62562. * @param gradient defines the gradient to remove
  62563. * @returns the current particle system
  62564. */
  62565. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  62566. /**
  62567. * Adds a new drag gradient
  62568. * @param gradient defines the gradient to use (between 0 and 1)
  62569. * @param factor defines the drag value to affect to the specified gradient
  62570. * @returns the current particle system
  62571. */
  62572. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  62573. /**
  62574. * Remove a specific drag gradient
  62575. * @param gradient defines the gradient to remove
  62576. * @returns the current particle system
  62577. */
  62578. removeDragGradient(gradient: number): GPUParticleSystem;
  62579. /**
  62580. * Not supported by GPUParticleSystem
  62581. * @param gradient defines the gradient to use (between 0 and 1)
  62582. * @param factor defines the emit rate value to affect to the specified gradient
  62583. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  62584. * @returns the current particle system
  62585. */
  62586. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  62587. /**
  62588. * Not supported by GPUParticleSystem
  62589. * @param gradient defines the gradient to remove
  62590. * @returns the current particle system
  62591. */
  62592. removeEmitRateGradient(gradient: number): IParticleSystem;
  62593. /**
  62594. * Not supported by GPUParticleSystem
  62595. * @param gradient defines the gradient to use (between 0 and 1)
  62596. * @param factor defines the start size value to affect to the specified gradient
  62597. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  62598. * @returns the current particle system
  62599. */
  62600. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  62601. /**
  62602. * Not supported by GPUParticleSystem
  62603. * @param gradient defines the gradient to remove
  62604. * @returns the current particle system
  62605. */
  62606. removeStartSizeGradient(gradient: number): IParticleSystem;
  62607. /**
  62608. * Not supported by GPUParticleSystem
  62609. * @param gradient defines the gradient to use (between 0 and 1)
  62610. * @param min defines the color remap minimal range
  62611. * @param max defines the color remap maximal range
  62612. * @returns the current particle system
  62613. */
  62614. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  62615. /**
  62616. * Not supported by GPUParticleSystem
  62617. * @param gradient defines the gradient to remove
  62618. * @returns the current particle system
  62619. */
  62620. removeColorRemapGradient(): IParticleSystem;
  62621. /**
  62622. * Not supported by GPUParticleSystem
  62623. * @param gradient defines the gradient to use (between 0 and 1)
  62624. * @param min defines the alpha remap minimal range
  62625. * @param max defines the alpha remap maximal range
  62626. * @returns the current particle system
  62627. */
  62628. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  62629. /**
  62630. * Not supported by GPUParticleSystem
  62631. * @param gradient defines the gradient to remove
  62632. * @returns the current particle system
  62633. */
  62634. removeAlphaRemapGradient(): IParticleSystem;
  62635. /**
  62636. * Not supported by GPUParticleSystem
  62637. * @param gradient defines the gradient to use (between 0 and 1)
  62638. * @param color defines the color to affect to the specified gradient
  62639. * @returns the current particle system
  62640. */
  62641. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  62642. /**
  62643. * Not supported by GPUParticleSystem
  62644. * @param gradient defines the gradient to remove
  62645. * @returns the current particle system
  62646. */
  62647. removeRampGradient(): IParticleSystem;
  62648. /**
  62649. * Not supported by GPUParticleSystem
  62650. * @returns the list of ramp gradients
  62651. */
  62652. getRampGradients(): Nullable<Array<Color3Gradient>>;
  62653. /**
  62654. * Not supported by GPUParticleSystem
  62655. * Gets or sets a boolean indicating that ramp gradients must be used
  62656. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  62657. */
  62658. get useRampGradients(): boolean;
  62659. set useRampGradients(value: boolean);
  62660. /**
  62661. * Not supported by GPUParticleSystem
  62662. * @param gradient defines the gradient to use (between 0 and 1)
  62663. * @param factor defines the life time factor to affect to the specified gradient
  62664. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  62665. * @returns the current particle system
  62666. */
  62667. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  62668. /**
  62669. * Not supported by GPUParticleSystem
  62670. * @param gradient defines the gradient to remove
  62671. * @returns the current particle system
  62672. */
  62673. removeLifeTimeGradient(gradient: number): IParticleSystem;
  62674. /**
  62675. * Instantiates a GPU particle system.
  62676. * 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.
  62677. * @param name The name of the particle system
  62678. * @param options The options used to create the system
  62679. * @param scene The scene the particle system belongs to
  62680. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  62681. */
  62682. constructor(name: string, options: Partial<{
  62683. capacity: number;
  62684. randomTextureSize: number;
  62685. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  62686. protected _reset(): void;
  62687. private _createUpdateVAO;
  62688. private _createRenderVAO;
  62689. private _initialize;
  62690. /** @hidden */
  62691. _recreateUpdateEffect(): void;
  62692. /** @hidden */
  62693. _recreateRenderEffect(): void;
  62694. /**
  62695. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  62696. * @param preWarm defines if we are in the pre-warmimg phase
  62697. */
  62698. animate(preWarm?: boolean): void;
  62699. private _createFactorGradientTexture;
  62700. private _createSizeGradientTexture;
  62701. private _createAngularSpeedGradientTexture;
  62702. private _createVelocityGradientTexture;
  62703. private _createLimitVelocityGradientTexture;
  62704. private _createDragGradientTexture;
  62705. private _createColorGradientTexture;
  62706. /**
  62707. * Renders the particle system in its current state
  62708. * @param preWarm defines if the system should only update the particles but not render them
  62709. * @returns the current number of particles
  62710. */
  62711. render(preWarm?: boolean): number;
  62712. /**
  62713. * Rebuilds the particle system
  62714. */
  62715. rebuild(): void;
  62716. private _releaseBuffers;
  62717. private _releaseVAOs;
  62718. /**
  62719. * Disposes the particle system and free the associated resources
  62720. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  62721. */
  62722. dispose(disposeTexture?: boolean): void;
  62723. /**
  62724. * Clones the particle system.
  62725. * @param name The name of the cloned object
  62726. * @param newEmitter The new emitter to use
  62727. * @returns the cloned particle system
  62728. */
  62729. clone(name: string, newEmitter: any): GPUParticleSystem;
  62730. /**
  62731. * Serializes the particle system to a JSON object.
  62732. * @returns the JSON object
  62733. */
  62734. serialize(): any;
  62735. /**
  62736. * Parses a JSON object to create a GPU particle system.
  62737. * @param parsedParticleSystem The JSON object to parse
  62738. * @param scene The scene to create the particle system in
  62739. * @param rootUrl The root url to use to load external dependencies like texture
  62740. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  62741. * @returns the parsed GPU particle system
  62742. */
  62743. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  62744. }
  62745. }
  62746. declare module BABYLON {
  62747. /**
  62748. * Represents a set of particle systems working together to create a specific effect
  62749. */
  62750. export class ParticleSystemSet implements IDisposable {
  62751. /**
  62752. * Gets or sets base Assets URL
  62753. */
  62754. static BaseAssetsUrl: string;
  62755. private _emitterCreationOptions;
  62756. private _emitterNode;
  62757. /**
  62758. * Gets the particle system list
  62759. */
  62760. systems: IParticleSystem[];
  62761. /**
  62762. * Gets the emitter node used with this set
  62763. */
  62764. get emitterNode(): Nullable<TransformNode>;
  62765. /**
  62766. * Creates a new emitter mesh as a sphere
  62767. * @param options defines the options used to create the sphere
  62768. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  62769. * @param scene defines the hosting scene
  62770. */
  62771. setEmitterAsSphere(options: {
  62772. diameter: number;
  62773. segments: number;
  62774. color: Color3;
  62775. }, renderingGroupId: number, scene: Scene): void;
  62776. /**
  62777. * Starts all particle systems of the set
  62778. * @param emitter defines an optional mesh to use as emitter for the particle systems
  62779. */
  62780. start(emitter?: AbstractMesh): void;
  62781. /**
  62782. * Release all associated resources
  62783. */
  62784. dispose(): void;
  62785. /**
  62786. * Serialize the set into a JSON compatible object
  62787. * @returns a JSON compatible representation of the set
  62788. */
  62789. serialize(): any;
  62790. /**
  62791. * Parse a new ParticleSystemSet from a serialized source
  62792. * @param data defines a JSON compatible representation of the set
  62793. * @param scene defines the hosting scene
  62794. * @param gpu defines if we want GPU particles or CPU particles
  62795. * @returns a new ParticleSystemSet
  62796. */
  62797. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  62798. }
  62799. }
  62800. declare module BABYLON {
  62801. /**
  62802. * This class is made for on one-liner static method to help creating particle system set.
  62803. */
  62804. export class ParticleHelper {
  62805. /**
  62806. * Gets or sets base Assets URL
  62807. */
  62808. static BaseAssetsUrl: string;
  62809. /**
  62810. * Create a default particle system that you can tweak
  62811. * @param emitter defines the emitter to use
  62812. * @param capacity defines the system capacity (default is 500 particles)
  62813. * @param scene defines the hosting scene
  62814. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  62815. * @returns the new Particle system
  62816. */
  62817. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  62818. /**
  62819. * This is the main static method (one-liner) of this helper to create different particle systems
  62820. * @param type This string represents the type to the particle system to create
  62821. * @param scene The scene where the particle system should live
  62822. * @param gpu If the system will use gpu
  62823. * @returns the ParticleSystemSet created
  62824. */
  62825. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  62826. /**
  62827. * Static function used to export a particle system to a ParticleSystemSet variable.
  62828. * Please note that the emitter shape is not exported
  62829. * @param systems defines the particle systems to export
  62830. * @returns the created particle system set
  62831. */
  62832. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  62833. }
  62834. }
  62835. declare module BABYLON {
  62836. interface Engine {
  62837. /**
  62838. * Create an effect to use with particle systems.
  62839. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  62840. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  62841. * @param uniformsNames defines a list of attribute names
  62842. * @param samplers defines an array of string used to represent textures
  62843. * @param defines defines the string containing the defines to use to compile the shaders
  62844. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  62845. * @param onCompiled defines a function to call when the effect creation is successful
  62846. * @param onError defines a function to call when the effect creation has failed
  62847. * @returns the new Effect
  62848. */
  62849. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  62850. }
  62851. interface Mesh {
  62852. /**
  62853. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  62854. * @returns an array of IParticleSystem
  62855. */
  62856. getEmittedParticleSystems(): IParticleSystem[];
  62857. /**
  62858. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  62859. * @returns an array of IParticleSystem
  62860. */
  62861. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  62862. }
  62863. /**
  62864. * @hidden
  62865. */
  62866. export var _IDoNeedToBeInTheBuild: number;
  62867. }
  62868. declare module BABYLON {
  62869. /** Defines the 4 color options */
  62870. export enum PointColor {
  62871. /** color value */
  62872. Color = 2,
  62873. /** uv value */
  62874. UV = 1,
  62875. /** random value */
  62876. Random = 0,
  62877. /** stated value */
  62878. Stated = 3
  62879. }
  62880. /**
  62881. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  62882. * 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.
  62883. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  62884. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  62885. *
  62886. * Full documentation here : TO BE ENTERED
  62887. */
  62888. export class PointsCloudSystem implements IDisposable {
  62889. /**
  62890. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  62891. * Example : var p = SPS.particles[i];
  62892. */
  62893. particles: CloudPoint[];
  62894. /**
  62895. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  62896. */
  62897. nbParticles: number;
  62898. /**
  62899. * This a counter for your own usage. It's not set by any SPS functions.
  62900. */
  62901. counter: number;
  62902. /**
  62903. * The PCS name. This name is also given to the underlying mesh.
  62904. */
  62905. name: string;
  62906. /**
  62907. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  62908. */
  62909. mesh: Mesh;
  62910. /**
  62911. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  62912. * Please read :
  62913. */
  62914. vars: any;
  62915. /**
  62916. * @hidden
  62917. */
  62918. _size: number;
  62919. private _scene;
  62920. private _promises;
  62921. private _positions;
  62922. private _indices;
  62923. private _normals;
  62924. private _colors;
  62925. private _uvs;
  62926. private _indices32;
  62927. private _positions32;
  62928. private _colors32;
  62929. private _uvs32;
  62930. private _updatable;
  62931. private _isVisibilityBoxLocked;
  62932. private _alwaysVisible;
  62933. private _groups;
  62934. private _groupCounter;
  62935. private _computeParticleColor;
  62936. private _computeParticleTexture;
  62937. private _computeParticleRotation;
  62938. private _computeBoundingBox;
  62939. private _isReady;
  62940. /**
  62941. * Creates a PCS (Points Cloud System) object
  62942. * @param name (String) is the PCS name, this will be the underlying mesh name
  62943. * @param pointSize (number) is the size for each point
  62944. * @param scene (Scene) is the scene in which the PCS is added
  62945. * @param options defines the options of the PCS e.g.
  62946. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  62947. */
  62948. constructor(name: string, pointSize: number, scene: Scene, options?: {
  62949. updatable?: boolean;
  62950. });
  62951. /**
  62952. * Builds the PCS underlying mesh. Returns a standard Mesh.
  62953. * If no points were added to the PCS, the returned mesh is just a single point.
  62954. * @returns a promise for the created mesh
  62955. */
  62956. buildMeshAsync(): Promise<Mesh>;
  62957. /**
  62958. * @hidden
  62959. */
  62960. private _buildMesh;
  62961. private _addParticle;
  62962. private _randomUnitVector;
  62963. private _getColorIndicesForCoord;
  62964. private _setPointsColorOrUV;
  62965. private _colorFromTexture;
  62966. private _calculateDensity;
  62967. /**
  62968. * Adds points to the PCS in random positions within a unit sphere
  62969. * @param nb (positive integer) the number of particles to be created from this model
  62970. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  62971. * @returns the number of groups in the system
  62972. */
  62973. addPoints(nb: number, pointFunction?: any): number;
  62974. /**
  62975. * Adds points to the PCS from the surface of the model shape
  62976. * @param mesh is any Mesh object that will be used as a surface model for the points
  62977. * @param nb (positive integer) the number of particles to be created from this model
  62978. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  62979. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  62980. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  62981. * @returns the number of groups in the system
  62982. */
  62983. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  62984. /**
  62985. * Adds points to the PCS inside the model shape
  62986. * @param mesh is any Mesh object that will be used as a surface model for the points
  62987. * @param nb (positive integer) the number of particles to be created from this model
  62988. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  62989. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  62990. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  62991. * @returns the number of groups in the system
  62992. */
  62993. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  62994. /**
  62995. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  62996. * This method calls `updateParticle()` for each particle of the SPS.
  62997. * For an animated SPS, it is usually called within the render loop.
  62998. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  62999. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  63000. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  63001. * @returns the PCS.
  63002. */
  63003. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  63004. /**
  63005. * Disposes the PCS.
  63006. */
  63007. dispose(): void;
  63008. /**
  63009. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  63010. * doc :
  63011. * @returns the PCS.
  63012. */
  63013. refreshVisibleSize(): PointsCloudSystem;
  63014. /**
  63015. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  63016. * @param size the size (float) of the visibility box
  63017. * note : this doesn't lock the PCS mesh bounding box.
  63018. * doc :
  63019. */
  63020. setVisibilityBox(size: number): void;
  63021. /**
  63022. * Gets whether the PCS is always visible or not
  63023. * doc :
  63024. */
  63025. get isAlwaysVisible(): boolean;
  63026. /**
  63027. * Sets the PCS as always visible or not
  63028. * doc :
  63029. */
  63030. set isAlwaysVisible(val: boolean);
  63031. /**
  63032. * Tells to `setParticles()` to compute the particle rotations or not
  63033. * Default value : false. The PCS is faster when it's set to false
  63034. * Note : particle rotations are only applied to parent particles
  63035. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  63036. */
  63037. set computeParticleRotation(val: boolean);
  63038. /**
  63039. * Tells to `setParticles()` to compute the particle colors or not.
  63040. * Default value : true. The PCS is faster when it's set to false.
  63041. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  63042. */
  63043. set computeParticleColor(val: boolean);
  63044. set computeParticleTexture(val: boolean);
  63045. /**
  63046. * Gets if `setParticles()` computes the particle colors or not.
  63047. * Default value : false. The PCS is faster when it's set to false.
  63048. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  63049. */
  63050. get computeParticleColor(): boolean;
  63051. /**
  63052. * Gets if `setParticles()` computes the particle textures or not.
  63053. * Default value : false. The PCS is faster when it's set to false.
  63054. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  63055. */
  63056. get computeParticleTexture(): boolean;
  63057. /**
  63058. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  63059. */
  63060. set computeBoundingBox(val: boolean);
  63061. /**
  63062. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  63063. */
  63064. get computeBoundingBox(): boolean;
  63065. /**
  63066. * This function does nothing. It may be overwritten to set all the particle first values.
  63067. * The PCS doesn't call this function, you may have to call it by your own.
  63068. * doc :
  63069. */
  63070. initParticles(): void;
  63071. /**
  63072. * This function does nothing. It may be overwritten to recycle a particle
  63073. * The PCS doesn't call this function, you can to call it
  63074. * doc :
  63075. * @param particle The particle to recycle
  63076. * @returns the recycled particle
  63077. */
  63078. recycleParticle(particle: CloudPoint): CloudPoint;
  63079. /**
  63080. * Updates a particle : this function should be overwritten by the user.
  63081. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  63082. * doc :
  63083. * @example : just set a particle position or velocity and recycle conditions
  63084. * @param particle The particle to update
  63085. * @returns the updated particle
  63086. */
  63087. updateParticle(particle: CloudPoint): CloudPoint;
  63088. /**
  63089. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  63090. * This does nothing and may be overwritten by the user.
  63091. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  63092. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  63093. * @param update the boolean update value actually passed to setParticles()
  63094. */
  63095. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  63096. /**
  63097. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  63098. * This will be passed three parameters.
  63099. * This does nothing and may be overwritten by the user.
  63100. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  63101. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  63102. * @param update the boolean update value actually passed to setParticles()
  63103. */
  63104. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  63105. }
  63106. }
  63107. declare module BABYLON {
  63108. /**
  63109. * Represents one particle of a points cloud system.
  63110. */
  63111. export class CloudPoint {
  63112. /**
  63113. * particle global index
  63114. */
  63115. idx: number;
  63116. /**
  63117. * The color of the particle
  63118. */
  63119. color: Nullable<Color4>;
  63120. /**
  63121. * The world space position of the particle.
  63122. */
  63123. position: Vector3;
  63124. /**
  63125. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  63126. */
  63127. rotation: Vector3;
  63128. /**
  63129. * The world space rotation quaternion of the particle.
  63130. */
  63131. rotationQuaternion: Nullable<Quaternion>;
  63132. /**
  63133. * The uv of the particle.
  63134. */
  63135. uv: Nullable<Vector2>;
  63136. /**
  63137. * The current speed of the particle.
  63138. */
  63139. velocity: Vector3;
  63140. /**
  63141. * The pivot point in the particle local space.
  63142. */
  63143. pivot: Vector3;
  63144. /**
  63145. * Must the particle be translated from its pivot point in its local space ?
  63146. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  63147. * Default : false
  63148. */
  63149. translateFromPivot: boolean;
  63150. /**
  63151. * Index of this particle in the global "positions" array (Internal use)
  63152. * @hidden
  63153. */
  63154. _pos: number;
  63155. /**
  63156. * @hidden Index of this particle in the global "indices" array (Internal use)
  63157. */
  63158. _ind: number;
  63159. /**
  63160. * Group this particle belongs to
  63161. */
  63162. _group: PointsGroup;
  63163. /**
  63164. * Group id of this particle
  63165. */
  63166. groupId: number;
  63167. /**
  63168. * Index of the particle in its group id (Internal use)
  63169. */
  63170. idxInGroup: number;
  63171. /**
  63172. * @hidden Particle BoundingInfo object (Internal use)
  63173. */
  63174. _boundingInfo: BoundingInfo;
  63175. /**
  63176. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  63177. */
  63178. _pcs: PointsCloudSystem;
  63179. /**
  63180. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  63181. */
  63182. _stillInvisible: boolean;
  63183. /**
  63184. * @hidden Last computed particle rotation matrix
  63185. */
  63186. _rotationMatrix: number[];
  63187. /**
  63188. * Parent particle Id, if any.
  63189. * Default null.
  63190. */
  63191. parentId: Nullable<number>;
  63192. /**
  63193. * @hidden Internal global position in the PCS.
  63194. */
  63195. _globalPosition: Vector3;
  63196. /**
  63197. * Creates a Point Cloud object.
  63198. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  63199. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  63200. * @param group (PointsGroup) is the group the particle belongs to
  63201. * @param groupId (integer) is the group identifier in the PCS.
  63202. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  63203. * @param pcs defines the PCS it is associated to
  63204. */
  63205. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  63206. /**
  63207. * get point size
  63208. */
  63209. get size(): Vector3;
  63210. /**
  63211. * Set point size
  63212. */
  63213. set size(scale: Vector3);
  63214. /**
  63215. * Legacy support, changed quaternion to rotationQuaternion
  63216. */
  63217. get quaternion(): Nullable<Quaternion>;
  63218. /**
  63219. * Legacy support, changed quaternion to rotationQuaternion
  63220. */
  63221. set quaternion(q: Nullable<Quaternion>);
  63222. /**
  63223. * Returns a boolean. True if the particle intersects a mesh, else false
  63224. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  63225. * @param target is the object (point or mesh) what the intersection is computed against
  63226. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  63227. * @returns true if it intersects
  63228. */
  63229. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  63230. /**
  63231. * get the rotation matrix of the particle
  63232. * @hidden
  63233. */
  63234. getRotationMatrix(m: Matrix): void;
  63235. }
  63236. /**
  63237. * Represents a group of points in a points cloud system
  63238. * * PCS internal tool, don't use it manually.
  63239. */
  63240. export class PointsGroup {
  63241. /**
  63242. * The group id
  63243. * @hidden
  63244. */
  63245. groupID: number;
  63246. /**
  63247. * image data for group (internal use)
  63248. * @hidden
  63249. */
  63250. _groupImageData: Nullable<ArrayBufferView>;
  63251. /**
  63252. * Image Width (internal use)
  63253. * @hidden
  63254. */
  63255. _groupImgWidth: number;
  63256. /**
  63257. * Image Height (internal use)
  63258. * @hidden
  63259. */
  63260. _groupImgHeight: number;
  63261. /**
  63262. * Custom position function (internal use)
  63263. * @hidden
  63264. */
  63265. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  63266. /**
  63267. * density per facet for surface points
  63268. * @hidden
  63269. */
  63270. _groupDensity: number[];
  63271. /**
  63272. * Only when points are colored by texture carries pointer to texture list array
  63273. * @hidden
  63274. */
  63275. _textureNb: number;
  63276. /**
  63277. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  63278. * PCS internal tool, don't use it manually.
  63279. * @hidden
  63280. */
  63281. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  63282. }
  63283. }
  63284. declare module BABYLON {
  63285. interface Scene {
  63286. /** @hidden (Backing field) */
  63287. _physicsEngine: Nullable<IPhysicsEngine>;
  63288. /** @hidden */
  63289. _physicsTimeAccumulator: number;
  63290. /**
  63291. * Gets the current physics engine
  63292. * @returns a IPhysicsEngine or null if none attached
  63293. */
  63294. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  63295. /**
  63296. * Enables physics to the current scene
  63297. * @param gravity defines the scene's gravity for the physics engine
  63298. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  63299. * @return a boolean indicating if the physics engine was initialized
  63300. */
  63301. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  63302. /**
  63303. * Disables and disposes the physics engine associated with the scene
  63304. */
  63305. disablePhysicsEngine(): void;
  63306. /**
  63307. * Gets a boolean indicating if there is an active physics engine
  63308. * @returns a boolean indicating if there is an active physics engine
  63309. */
  63310. isPhysicsEnabled(): boolean;
  63311. /**
  63312. * Deletes a physics compound impostor
  63313. * @param compound defines the compound to delete
  63314. */
  63315. deleteCompoundImpostor(compound: any): void;
  63316. /**
  63317. * An event triggered when physic simulation is about to be run
  63318. */
  63319. onBeforePhysicsObservable: Observable<Scene>;
  63320. /**
  63321. * An event triggered when physic simulation has been done
  63322. */
  63323. onAfterPhysicsObservable: Observable<Scene>;
  63324. }
  63325. interface AbstractMesh {
  63326. /** @hidden */
  63327. _physicsImpostor: Nullable<PhysicsImpostor>;
  63328. /**
  63329. * Gets or sets impostor used for physic simulation
  63330. * @see http://doc.babylonjs.com/features/physics_engine
  63331. */
  63332. physicsImpostor: Nullable<PhysicsImpostor>;
  63333. /**
  63334. * Gets the current physics impostor
  63335. * @see http://doc.babylonjs.com/features/physics_engine
  63336. * @returns a physics impostor or null
  63337. */
  63338. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  63339. /** Apply a physic impulse to the mesh
  63340. * @param force defines the force to apply
  63341. * @param contactPoint defines where to apply the force
  63342. * @returns the current mesh
  63343. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  63344. */
  63345. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  63346. /**
  63347. * Creates a physic joint between two meshes
  63348. * @param otherMesh defines the other mesh to use
  63349. * @param pivot1 defines the pivot to use on this mesh
  63350. * @param pivot2 defines the pivot to use on the other mesh
  63351. * @param options defines additional options (can be plugin dependent)
  63352. * @returns the current mesh
  63353. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  63354. */
  63355. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  63356. /** @hidden */
  63357. _disposePhysicsObserver: Nullable<Observer<Node>>;
  63358. }
  63359. /**
  63360. * Defines the physics engine scene component responsible to manage a physics engine
  63361. */
  63362. export class PhysicsEngineSceneComponent implements ISceneComponent {
  63363. /**
  63364. * The component name helpful to identify the component in the list of scene components.
  63365. */
  63366. readonly name: string;
  63367. /**
  63368. * The scene the component belongs to.
  63369. */
  63370. scene: Scene;
  63371. /**
  63372. * Creates a new instance of the component for the given scene
  63373. * @param scene Defines the scene to register the component in
  63374. */
  63375. constructor(scene: Scene);
  63376. /**
  63377. * Registers the component in a given scene
  63378. */
  63379. register(): void;
  63380. /**
  63381. * Rebuilds the elements related to this component in case of
  63382. * context lost for instance.
  63383. */
  63384. rebuild(): void;
  63385. /**
  63386. * Disposes the component and the associated ressources
  63387. */
  63388. dispose(): void;
  63389. }
  63390. }
  63391. declare module BABYLON {
  63392. /**
  63393. * A helper for physics simulations
  63394. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63395. */
  63396. export class PhysicsHelper {
  63397. private _scene;
  63398. private _physicsEngine;
  63399. /**
  63400. * Initializes the Physics helper
  63401. * @param scene Babylon.js scene
  63402. */
  63403. constructor(scene: Scene);
  63404. /**
  63405. * Applies a radial explosion impulse
  63406. * @param origin the origin of the explosion
  63407. * @param radiusOrEventOptions the radius or the options of radial explosion
  63408. * @param strength the explosion strength
  63409. * @param falloff possible options: Constant & Linear. Defaults to Constant
  63410. * @returns A physics radial explosion event, or null
  63411. */
  63412. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  63413. /**
  63414. * Applies a radial explosion force
  63415. * @param origin the origin of the explosion
  63416. * @param radiusOrEventOptions the radius or the options of radial explosion
  63417. * @param strength the explosion strength
  63418. * @param falloff possible options: Constant & Linear. Defaults to Constant
  63419. * @returns A physics radial explosion event, or null
  63420. */
  63421. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  63422. /**
  63423. * Creates a gravitational field
  63424. * @param origin the origin of the explosion
  63425. * @param radiusOrEventOptions the radius or the options of radial explosion
  63426. * @param strength the explosion strength
  63427. * @param falloff possible options: Constant & Linear. Defaults to Constant
  63428. * @returns A physics gravitational field event, or null
  63429. */
  63430. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  63431. /**
  63432. * Creates a physics updraft event
  63433. * @param origin the origin of the updraft
  63434. * @param radiusOrEventOptions the radius or the options of the updraft
  63435. * @param strength the strength of the updraft
  63436. * @param height the height of the updraft
  63437. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  63438. * @returns A physics updraft event, or null
  63439. */
  63440. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  63441. /**
  63442. * Creates a physics vortex event
  63443. * @param origin the of the vortex
  63444. * @param radiusOrEventOptions the radius or the options of the vortex
  63445. * @param strength the strength of the vortex
  63446. * @param height the height of the vortex
  63447. * @returns a Physics vortex event, or null
  63448. * A physics vortex event or null
  63449. */
  63450. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  63451. }
  63452. /**
  63453. * Represents a physics radial explosion event
  63454. */
  63455. class PhysicsRadialExplosionEvent {
  63456. private _scene;
  63457. private _options;
  63458. private _sphere;
  63459. private _dataFetched;
  63460. /**
  63461. * Initializes a radial explosioin event
  63462. * @param _scene BabylonJS scene
  63463. * @param _options The options for the vortex event
  63464. */
  63465. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  63466. /**
  63467. * Returns the data related to the radial explosion event (sphere).
  63468. * @returns The radial explosion event data
  63469. */
  63470. getData(): PhysicsRadialExplosionEventData;
  63471. /**
  63472. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  63473. * @param impostor A physics imposter
  63474. * @param origin the origin of the explosion
  63475. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  63476. */
  63477. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  63478. /**
  63479. * Triggers affecterd impostors callbacks
  63480. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  63481. */
  63482. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  63483. /**
  63484. * Disposes the sphere.
  63485. * @param force Specifies if the sphere should be disposed by force
  63486. */
  63487. dispose(force?: boolean): void;
  63488. /*** Helpers ***/
  63489. private _prepareSphere;
  63490. private _intersectsWithSphere;
  63491. }
  63492. /**
  63493. * Represents a gravitational field event
  63494. */
  63495. class PhysicsGravitationalFieldEvent {
  63496. private _physicsHelper;
  63497. private _scene;
  63498. private _origin;
  63499. private _options;
  63500. private _tickCallback;
  63501. private _sphere;
  63502. private _dataFetched;
  63503. /**
  63504. * Initializes the physics gravitational field event
  63505. * @param _physicsHelper A physics helper
  63506. * @param _scene BabylonJS scene
  63507. * @param _origin The origin position of the gravitational field event
  63508. * @param _options The options for the vortex event
  63509. */
  63510. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  63511. /**
  63512. * Returns the data related to the gravitational field event (sphere).
  63513. * @returns A gravitational field event
  63514. */
  63515. getData(): PhysicsGravitationalFieldEventData;
  63516. /**
  63517. * Enables the gravitational field.
  63518. */
  63519. enable(): void;
  63520. /**
  63521. * Disables the gravitational field.
  63522. */
  63523. disable(): void;
  63524. /**
  63525. * Disposes the sphere.
  63526. * @param force The force to dispose from the gravitational field event
  63527. */
  63528. dispose(force?: boolean): void;
  63529. private _tick;
  63530. }
  63531. /**
  63532. * Represents a physics updraft event
  63533. */
  63534. class PhysicsUpdraftEvent {
  63535. private _scene;
  63536. private _origin;
  63537. private _options;
  63538. private _physicsEngine;
  63539. private _originTop;
  63540. private _originDirection;
  63541. private _tickCallback;
  63542. private _cylinder;
  63543. private _cylinderPosition;
  63544. private _dataFetched;
  63545. /**
  63546. * Initializes the physics updraft event
  63547. * @param _scene BabylonJS scene
  63548. * @param _origin The origin position of the updraft
  63549. * @param _options The options for the updraft event
  63550. */
  63551. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  63552. /**
  63553. * Returns the data related to the updraft event (cylinder).
  63554. * @returns A physics updraft event
  63555. */
  63556. getData(): PhysicsUpdraftEventData;
  63557. /**
  63558. * Enables the updraft.
  63559. */
  63560. enable(): void;
  63561. /**
  63562. * Disables the updraft.
  63563. */
  63564. disable(): void;
  63565. /**
  63566. * Disposes the cylinder.
  63567. * @param force Specifies if the updraft should be disposed by force
  63568. */
  63569. dispose(force?: boolean): void;
  63570. private getImpostorHitData;
  63571. private _tick;
  63572. /*** Helpers ***/
  63573. private _prepareCylinder;
  63574. private _intersectsWithCylinder;
  63575. }
  63576. /**
  63577. * Represents a physics vortex event
  63578. */
  63579. class PhysicsVortexEvent {
  63580. private _scene;
  63581. private _origin;
  63582. private _options;
  63583. private _physicsEngine;
  63584. private _originTop;
  63585. private _tickCallback;
  63586. private _cylinder;
  63587. private _cylinderPosition;
  63588. private _dataFetched;
  63589. /**
  63590. * Initializes the physics vortex event
  63591. * @param _scene The BabylonJS scene
  63592. * @param _origin The origin position of the vortex
  63593. * @param _options The options for the vortex event
  63594. */
  63595. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  63596. /**
  63597. * Returns the data related to the vortex event (cylinder).
  63598. * @returns The physics vortex event data
  63599. */
  63600. getData(): PhysicsVortexEventData;
  63601. /**
  63602. * Enables the vortex.
  63603. */
  63604. enable(): void;
  63605. /**
  63606. * Disables the cortex.
  63607. */
  63608. disable(): void;
  63609. /**
  63610. * Disposes the sphere.
  63611. * @param force
  63612. */
  63613. dispose(force?: boolean): void;
  63614. private getImpostorHitData;
  63615. private _tick;
  63616. /*** Helpers ***/
  63617. private _prepareCylinder;
  63618. private _intersectsWithCylinder;
  63619. }
  63620. /**
  63621. * Options fot the radial explosion event
  63622. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63623. */
  63624. export class PhysicsRadialExplosionEventOptions {
  63625. /**
  63626. * The radius of the sphere for the radial explosion.
  63627. */
  63628. radius: number;
  63629. /**
  63630. * The strenth of the explosion.
  63631. */
  63632. strength: number;
  63633. /**
  63634. * The strenght of the force in correspondence to the distance of the affected object
  63635. */
  63636. falloff: PhysicsRadialImpulseFalloff;
  63637. /**
  63638. * Sphere options for the radial explosion.
  63639. */
  63640. sphere: {
  63641. segments: number;
  63642. diameter: number;
  63643. };
  63644. /**
  63645. * Sphere options for the radial explosion.
  63646. */
  63647. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  63648. }
  63649. /**
  63650. * Options fot the updraft event
  63651. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63652. */
  63653. export class PhysicsUpdraftEventOptions {
  63654. /**
  63655. * The radius of the cylinder for the vortex
  63656. */
  63657. radius: number;
  63658. /**
  63659. * The strenth of the updraft.
  63660. */
  63661. strength: number;
  63662. /**
  63663. * The height of the cylinder for the updraft.
  63664. */
  63665. height: number;
  63666. /**
  63667. * The mode for the the updraft.
  63668. */
  63669. updraftMode: PhysicsUpdraftMode;
  63670. }
  63671. /**
  63672. * Options fot the vortex event
  63673. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63674. */
  63675. export class PhysicsVortexEventOptions {
  63676. /**
  63677. * The radius of the cylinder for the vortex
  63678. */
  63679. radius: number;
  63680. /**
  63681. * The strenth of the vortex.
  63682. */
  63683. strength: number;
  63684. /**
  63685. * The height of the cylinder for the vortex.
  63686. */
  63687. height: number;
  63688. /**
  63689. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  63690. */
  63691. centripetalForceThreshold: number;
  63692. /**
  63693. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  63694. */
  63695. centripetalForceMultiplier: number;
  63696. /**
  63697. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  63698. */
  63699. centrifugalForceMultiplier: number;
  63700. /**
  63701. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  63702. */
  63703. updraftForceMultiplier: number;
  63704. }
  63705. /**
  63706. * The strenght of the force in correspondence to the distance of the affected object
  63707. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63708. */
  63709. export enum PhysicsRadialImpulseFalloff {
  63710. /** Defines that impulse is constant in strength across it's whole radius */
  63711. Constant = 0,
  63712. /** Defines that impulse gets weaker if it's further from the origin */
  63713. Linear = 1
  63714. }
  63715. /**
  63716. * The strength of the force in correspondence to the distance of the affected object
  63717. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63718. */
  63719. export enum PhysicsUpdraftMode {
  63720. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  63721. Center = 0,
  63722. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  63723. Perpendicular = 1
  63724. }
  63725. /**
  63726. * Interface for a physics hit data
  63727. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63728. */
  63729. export interface PhysicsHitData {
  63730. /**
  63731. * The force applied at the contact point
  63732. */
  63733. force: Vector3;
  63734. /**
  63735. * The contact point
  63736. */
  63737. contactPoint: Vector3;
  63738. /**
  63739. * The distance from the origin to the contact point
  63740. */
  63741. distanceFromOrigin: number;
  63742. }
  63743. /**
  63744. * Interface for radial explosion event data
  63745. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63746. */
  63747. export interface PhysicsRadialExplosionEventData {
  63748. /**
  63749. * A sphere used for the radial explosion event
  63750. */
  63751. sphere: Mesh;
  63752. }
  63753. /**
  63754. * Interface for gravitational field event data
  63755. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63756. */
  63757. export interface PhysicsGravitationalFieldEventData {
  63758. /**
  63759. * A sphere mesh used for the gravitational field event
  63760. */
  63761. sphere: Mesh;
  63762. }
  63763. /**
  63764. * Interface for updraft event data
  63765. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63766. */
  63767. export interface PhysicsUpdraftEventData {
  63768. /**
  63769. * A cylinder used for the updraft event
  63770. */
  63771. cylinder: Mesh;
  63772. }
  63773. /**
  63774. * Interface for vortex event data
  63775. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63776. */
  63777. export interface PhysicsVortexEventData {
  63778. /**
  63779. * A cylinder used for the vortex event
  63780. */
  63781. cylinder: Mesh;
  63782. }
  63783. /**
  63784. * Interface for an affected physics impostor
  63785. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63786. */
  63787. export interface PhysicsAffectedImpostorWithData {
  63788. /**
  63789. * The impostor affected by the effect
  63790. */
  63791. impostor: PhysicsImpostor;
  63792. /**
  63793. * The data about the hit/horce from the explosion
  63794. */
  63795. hitData: PhysicsHitData;
  63796. }
  63797. }
  63798. declare module BABYLON {
  63799. /** @hidden */
  63800. export var blackAndWhitePixelShader: {
  63801. name: string;
  63802. shader: string;
  63803. };
  63804. }
  63805. declare module BABYLON {
  63806. /**
  63807. * Post process used to render in black and white
  63808. */
  63809. export class BlackAndWhitePostProcess extends PostProcess {
  63810. /**
  63811. * Linear about to convert he result to black and white (default: 1)
  63812. */
  63813. degree: number;
  63814. /**
  63815. * Creates a black and white post process
  63816. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  63817. * @param name The name of the effect.
  63818. * @param options The required width/height ratio to downsize to before computing the render pass.
  63819. * @param camera The camera to apply the render pass to.
  63820. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63821. * @param engine The engine which the post process will be applied. (default: current engine)
  63822. * @param reusable If the post process can be reused on the same frame. (default: false)
  63823. */
  63824. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  63825. }
  63826. }
  63827. declare module BABYLON {
  63828. /**
  63829. * This represents a set of one or more post processes in Babylon.
  63830. * A post process can be used to apply a shader to a texture after it is rendered.
  63831. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  63832. */
  63833. export class PostProcessRenderEffect {
  63834. private _postProcesses;
  63835. private _getPostProcesses;
  63836. private _singleInstance;
  63837. private _cameras;
  63838. private _indicesForCamera;
  63839. /**
  63840. * Name of the effect
  63841. * @hidden
  63842. */
  63843. _name: string;
  63844. /**
  63845. * Instantiates a post process render effect.
  63846. * A post process can be used to apply a shader to a texture after it is rendered.
  63847. * @param engine The engine the effect is tied to
  63848. * @param name The name of the effect
  63849. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  63850. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  63851. */
  63852. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  63853. /**
  63854. * Checks if all the post processes in the effect are supported.
  63855. */
  63856. get isSupported(): boolean;
  63857. /**
  63858. * Updates the current state of the effect
  63859. * @hidden
  63860. */
  63861. _update(): void;
  63862. /**
  63863. * Attaches the effect on cameras
  63864. * @param cameras The camera to attach to.
  63865. * @hidden
  63866. */
  63867. _attachCameras(cameras: Camera): void;
  63868. /**
  63869. * Attaches the effect on cameras
  63870. * @param cameras The camera to attach to.
  63871. * @hidden
  63872. */
  63873. _attachCameras(cameras: Camera[]): void;
  63874. /**
  63875. * Detaches the effect on cameras
  63876. * @param cameras The camera to detatch from.
  63877. * @hidden
  63878. */
  63879. _detachCameras(cameras: Camera): void;
  63880. /**
  63881. * Detatches the effect on cameras
  63882. * @param cameras The camera to detatch from.
  63883. * @hidden
  63884. */
  63885. _detachCameras(cameras: Camera[]): void;
  63886. /**
  63887. * Enables the effect on given cameras
  63888. * @param cameras The camera to enable.
  63889. * @hidden
  63890. */
  63891. _enable(cameras: Camera): void;
  63892. /**
  63893. * Enables the effect on given cameras
  63894. * @param cameras The camera to enable.
  63895. * @hidden
  63896. */
  63897. _enable(cameras: Nullable<Camera[]>): void;
  63898. /**
  63899. * Disables the effect on the given cameras
  63900. * @param cameras The camera to disable.
  63901. * @hidden
  63902. */
  63903. _disable(cameras: Camera): void;
  63904. /**
  63905. * Disables the effect on the given cameras
  63906. * @param cameras The camera to disable.
  63907. * @hidden
  63908. */
  63909. _disable(cameras: Nullable<Camera[]>): void;
  63910. /**
  63911. * Gets a list of the post processes contained in the effect.
  63912. * @param camera The camera to get the post processes on.
  63913. * @returns The list of the post processes in the effect.
  63914. */
  63915. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  63916. }
  63917. }
  63918. declare module BABYLON {
  63919. /** @hidden */
  63920. export var extractHighlightsPixelShader: {
  63921. name: string;
  63922. shader: string;
  63923. };
  63924. }
  63925. declare module BABYLON {
  63926. /**
  63927. * 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.
  63928. */
  63929. export class ExtractHighlightsPostProcess extends PostProcess {
  63930. /**
  63931. * The luminance threshold, pixels below this value will be set to black.
  63932. */
  63933. threshold: number;
  63934. /** @hidden */
  63935. _exposure: number;
  63936. /**
  63937. * Post process which has the input texture to be used when performing highlight extraction
  63938. * @hidden
  63939. */
  63940. _inputPostProcess: Nullable<PostProcess>;
  63941. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  63942. }
  63943. }
  63944. declare module BABYLON {
  63945. /** @hidden */
  63946. export var bloomMergePixelShader: {
  63947. name: string;
  63948. shader: string;
  63949. };
  63950. }
  63951. declare module BABYLON {
  63952. /**
  63953. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  63954. */
  63955. export class BloomMergePostProcess extends PostProcess {
  63956. /** Weight of the bloom to be added to the original input. */
  63957. weight: number;
  63958. /**
  63959. * Creates a new instance of @see BloomMergePostProcess
  63960. * @param name The name of the effect.
  63961. * @param originalFromInput Post process which's input will be used for the merge.
  63962. * @param blurred Blurred highlights post process which's output will be used.
  63963. * @param weight Weight of the bloom to be added to the original input.
  63964. * @param options The required width/height ratio to downsize to before computing the render pass.
  63965. * @param camera The camera to apply the render pass to.
  63966. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63967. * @param engine The engine which the post process will be applied. (default: current engine)
  63968. * @param reusable If the post process can be reused on the same frame. (default: false)
  63969. * @param textureType Type of textures used when performing the post process. (default: 0)
  63970. * @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)
  63971. */
  63972. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  63973. /** Weight of the bloom to be added to the original input. */
  63974. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  63975. }
  63976. }
  63977. declare module BABYLON {
  63978. /**
  63979. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  63980. */
  63981. export class BloomEffect extends PostProcessRenderEffect {
  63982. private bloomScale;
  63983. /**
  63984. * @hidden Internal
  63985. */
  63986. _effects: Array<PostProcess>;
  63987. /**
  63988. * @hidden Internal
  63989. */
  63990. _downscale: ExtractHighlightsPostProcess;
  63991. private _blurX;
  63992. private _blurY;
  63993. private _merge;
  63994. /**
  63995. * The luminance threshold to find bright areas of the image to bloom.
  63996. */
  63997. get threshold(): number;
  63998. set threshold(value: number);
  63999. /**
  64000. * The strength of the bloom.
  64001. */
  64002. get weight(): number;
  64003. set weight(value: number);
  64004. /**
  64005. * Specifies the size of the bloom blur kernel, relative to the final output size
  64006. */
  64007. get kernel(): number;
  64008. set kernel(value: number);
  64009. /**
  64010. * Creates a new instance of @see BloomEffect
  64011. * @param scene The scene the effect belongs to.
  64012. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  64013. * @param bloomKernel The size of the kernel to be used when applying the blur.
  64014. * @param bloomWeight The the strength of bloom.
  64015. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  64016. * @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)
  64017. */
  64018. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  64019. /**
  64020. * Disposes each of the internal effects for a given camera.
  64021. * @param camera The camera to dispose the effect on.
  64022. */
  64023. disposeEffects(camera: Camera): void;
  64024. /**
  64025. * @hidden Internal
  64026. */
  64027. _updateEffects(): void;
  64028. /**
  64029. * Internal
  64030. * @returns if all the contained post processes are ready.
  64031. * @hidden
  64032. */
  64033. _isReady(): boolean;
  64034. }
  64035. }
  64036. declare module BABYLON {
  64037. /** @hidden */
  64038. export var chromaticAberrationPixelShader: {
  64039. name: string;
  64040. shader: string;
  64041. };
  64042. }
  64043. declare module BABYLON {
  64044. /**
  64045. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  64046. */
  64047. export class ChromaticAberrationPostProcess extends PostProcess {
  64048. /**
  64049. * The amount of seperation of rgb channels (default: 30)
  64050. */
  64051. aberrationAmount: number;
  64052. /**
  64053. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  64054. */
  64055. radialIntensity: number;
  64056. /**
  64057. * 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))
  64058. */
  64059. direction: Vector2;
  64060. /**
  64061. * 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))
  64062. */
  64063. centerPosition: Vector2;
  64064. /**
  64065. * Creates a new instance ChromaticAberrationPostProcess
  64066. * @param name The name of the effect.
  64067. * @param screenWidth The width of the screen to apply the effect on.
  64068. * @param screenHeight The height of the screen to apply the effect on.
  64069. * @param options The required width/height ratio to downsize to before computing the render pass.
  64070. * @param camera The camera to apply the render pass to.
  64071. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64072. * @param engine The engine which the post process will be applied. (default: current engine)
  64073. * @param reusable If the post process can be reused on the same frame. (default: false)
  64074. * @param textureType Type of textures used when performing the post process. (default: 0)
  64075. * @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)
  64076. */
  64077. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64078. }
  64079. }
  64080. declare module BABYLON {
  64081. /** @hidden */
  64082. export var circleOfConfusionPixelShader: {
  64083. name: string;
  64084. shader: string;
  64085. };
  64086. }
  64087. declare module BABYLON {
  64088. /**
  64089. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  64090. */
  64091. export class CircleOfConfusionPostProcess extends PostProcess {
  64092. /**
  64093. * 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.
  64094. */
  64095. lensSize: number;
  64096. /**
  64097. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  64098. */
  64099. fStop: number;
  64100. /**
  64101. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  64102. */
  64103. focusDistance: number;
  64104. /**
  64105. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  64106. */
  64107. focalLength: number;
  64108. private _depthTexture;
  64109. /**
  64110. * Creates a new instance CircleOfConfusionPostProcess
  64111. * @param name The name of the effect.
  64112. * @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.
  64113. * @param options The required width/height ratio to downsize to before computing the render pass.
  64114. * @param camera The camera to apply the render pass to.
  64115. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64116. * @param engine The engine which the post process will be applied. (default: current engine)
  64117. * @param reusable If the post process can be reused on the same frame. (default: false)
  64118. * @param textureType Type of textures used when performing the post process. (default: 0)
  64119. * @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)
  64120. */
  64121. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64122. /**
  64123. * 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.
  64124. */
  64125. set depthTexture(value: RenderTargetTexture);
  64126. }
  64127. }
  64128. declare module BABYLON {
  64129. /** @hidden */
  64130. export var colorCorrectionPixelShader: {
  64131. name: string;
  64132. shader: string;
  64133. };
  64134. }
  64135. declare module BABYLON {
  64136. /**
  64137. *
  64138. * This post-process allows the modification of rendered colors by using
  64139. * a 'look-up table' (LUT). This effect is also called Color Grading.
  64140. *
  64141. * The object needs to be provided an url to a texture containing the color
  64142. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  64143. * Use an image editing software to tweak the LUT to match your needs.
  64144. *
  64145. * For an example of a color LUT, see here:
  64146. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  64147. * For explanations on color grading, see here:
  64148. * @see http://udn.epicgames.com/Three/ColorGrading.html
  64149. *
  64150. */
  64151. export class ColorCorrectionPostProcess extends PostProcess {
  64152. private _colorTableTexture;
  64153. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  64154. }
  64155. }
  64156. declare module BABYLON {
  64157. /** @hidden */
  64158. export var convolutionPixelShader: {
  64159. name: string;
  64160. shader: string;
  64161. };
  64162. }
  64163. declare module BABYLON {
  64164. /**
  64165. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  64166. * input texture to perform effects such as edge detection or sharpening
  64167. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  64168. */
  64169. export class ConvolutionPostProcess extends PostProcess {
  64170. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  64171. kernel: number[];
  64172. /**
  64173. * Creates a new instance ConvolutionPostProcess
  64174. * @param name The name of the effect.
  64175. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  64176. * @param options The required width/height ratio to downsize to before computing the render pass.
  64177. * @param camera The camera to apply the render pass to.
  64178. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64179. * @param engine The engine which the post process will be applied. (default: current engine)
  64180. * @param reusable If the post process can be reused on the same frame. (default: false)
  64181. * @param textureType Type of textures used when performing the post process. (default: 0)
  64182. */
  64183. constructor(name: string,
  64184. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  64185. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  64186. /**
  64187. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64188. */
  64189. static EdgeDetect0Kernel: number[];
  64190. /**
  64191. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64192. */
  64193. static EdgeDetect1Kernel: number[];
  64194. /**
  64195. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64196. */
  64197. static EdgeDetect2Kernel: number[];
  64198. /**
  64199. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64200. */
  64201. static SharpenKernel: number[];
  64202. /**
  64203. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64204. */
  64205. static EmbossKernel: number[];
  64206. /**
  64207. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64208. */
  64209. static GaussianKernel: number[];
  64210. }
  64211. }
  64212. declare module BABYLON {
  64213. /**
  64214. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  64215. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  64216. * based on samples that have a large difference in distance than the center pixel.
  64217. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  64218. */
  64219. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  64220. direction: Vector2;
  64221. /**
  64222. * Creates a new instance CircleOfConfusionPostProcess
  64223. * @param name The name of the effect.
  64224. * @param scene The scene the effect belongs to.
  64225. * @param direction The direction the blur should be applied.
  64226. * @param kernel The size of the kernel used to blur.
  64227. * @param options The required width/height ratio to downsize to before computing the render pass.
  64228. * @param camera The camera to apply the render pass to.
  64229. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  64230. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  64231. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64232. * @param engine The engine which the post process will be applied. (default: current engine)
  64233. * @param reusable If the post process can be reused on the same frame. (default: false)
  64234. * @param textureType Type of textures used when performing the post process. (default: 0)
  64235. * @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)
  64236. */
  64237. 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);
  64238. }
  64239. }
  64240. declare module BABYLON {
  64241. /** @hidden */
  64242. export var depthOfFieldMergePixelShader: {
  64243. name: string;
  64244. shader: string;
  64245. };
  64246. }
  64247. declare module BABYLON {
  64248. /**
  64249. * Options to be set when merging outputs from the default pipeline.
  64250. */
  64251. export class DepthOfFieldMergePostProcessOptions {
  64252. /**
  64253. * The original image to merge on top of
  64254. */
  64255. originalFromInput: PostProcess;
  64256. /**
  64257. * Parameters to perform the merge of the depth of field effect
  64258. */
  64259. depthOfField?: {
  64260. circleOfConfusion: PostProcess;
  64261. blurSteps: Array<PostProcess>;
  64262. };
  64263. /**
  64264. * Parameters to perform the merge of bloom effect
  64265. */
  64266. bloom?: {
  64267. blurred: PostProcess;
  64268. weight: number;
  64269. };
  64270. }
  64271. /**
  64272. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  64273. */
  64274. export class DepthOfFieldMergePostProcess extends PostProcess {
  64275. private blurSteps;
  64276. /**
  64277. * Creates a new instance of DepthOfFieldMergePostProcess
  64278. * @param name The name of the effect.
  64279. * @param originalFromInput Post process which's input will be used for the merge.
  64280. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  64281. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  64282. * @param options The required width/height ratio to downsize to before computing the render pass.
  64283. * @param camera The camera to apply the render pass to.
  64284. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64285. * @param engine The engine which the post process will be applied. (default: current engine)
  64286. * @param reusable If the post process can be reused on the same frame. (default: false)
  64287. * @param textureType Type of textures used when performing the post process. (default: 0)
  64288. * @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)
  64289. */
  64290. 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);
  64291. /**
  64292. * Updates the effect with the current post process compile time values and recompiles the shader.
  64293. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  64294. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  64295. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  64296. * @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
  64297. * @param onCompiled Called when the shader has been compiled.
  64298. * @param onError Called if there is an error when compiling a shader.
  64299. */
  64300. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  64301. }
  64302. }
  64303. declare module BABYLON {
  64304. /**
  64305. * Specifies the level of max blur that should be applied when using the depth of field effect
  64306. */
  64307. export enum DepthOfFieldEffectBlurLevel {
  64308. /**
  64309. * Subtle blur
  64310. */
  64311. Low = 0,
  64312. /**
  64313. * Medium blur
  64314. */
  64315. Medium = 1,
  64316. /**
  64317. * Large blur
  64318. */
  64319. High = 2
  64320. }
  64321. /**
  64322. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  64323. */
  64324. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  64325. private _circleOfConfusion;
  64326. /**
  64327. * @hidden Internal, blurs from high to low
  64328. */
  64329. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  64330. private _depthOfFieldBlurY;
  64331. private _dofMerge;
  64332. /**
  64333. * @hidden Internal post processes in depth of field effect
  64334. */
  64335. _effects: Array<PostProcess>;
  64336. /**
  64337. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  64338. */
  64339. set focalLength(value: number);
  64340. get focalLength(): number;
  64341. /**
  64342. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  64343. */
  64344. set fStop(value: number);
  64345. get fStop(): number;
  64346. /**
  64347. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  64348. */
  64349. set focusDistance(value: number);
  64350. get focusDistance(): number;
  64351. /**
  64352. * 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.
  64353. */
  64354. set lensSize(value: number);
  64355. get lensSize(): number;
  64356. /**
  64357. * Creates a new instance DepthOfFieldEffect
  64358. * @param scene The scene the effect belongs to.
  64359. * @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.
  64360. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  64361. * @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)
  64362. */
  64363. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  64364. /**
  64365. * Get the current class name of the current effet
  64366. * @returns "DepthOfFieldEffect"
  64367. */
  64368. getClassName(): string;
  64369. /**
  64370. * 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.
  64371. */
  64372. set depthTexture(value: RenderTargetTexture);
  64373. /**
  64374. * Disposes each of the internal effects for a given camera.
  64375. * @param camera The camera to dispose the effect on.
  64376. */
  64377. disposeEffects(camera: Camera): void;
  64378. /**
  64379. * @hidden Internal
  64380. */
  64381. _updateEffects(): void;
  64382. /**
  64383. * Internal
  64384. * @returns if all the contained post processes are ready.
  64385. * @hidden
  64386. */
  64387. _isReady(): boolean;
  64388. }
  64389. }
  64390. declare module BABYLON {
  64391. /** @hidden */
  64392. export var displayPassPixelShader: {
  64393. name: string;
  64394. shader: string;
  64395. };
  64396. }
  64397. declare module BABYLON {
  64398. /**
  64399. * DisplayPassPostProcess which produces an output the same as it's input
  64400. */
  64401. export class DisplayPassPostProcess extends PostProcess {
  64402. /**
  64403. * Creates the DisplayPassPostProcess
  64404. * @param name The name of the effect.
  64405. * @param options The required width/height ratio to downsize to before computing the render pass.
  64406. * @param camera The camera to apply the render pass to.
  64407. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64408. * @param engine The engine which the post process will be applied. (default: current engine)
  64409. * @param reusable If the post process can be reused on the same frame. (default: false)
  64410. */
  64411. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  64412. }
  64413. }
  64414. declare module BABYLON {
  64415. /** @hidden */
  64416. export var filterPixelShader: {
  64417. name: string;
  64418. shader: string;
  64419. };
  64420. }
  64421. declare module BABYLON {
  64422. /**
  64423. * Applies a kernel filter to the image
  64424. */
  64425. export class FilterPostProcess extends PostProcess {
  64426. /** The matrix to be applied to the image */
  64427. kernelMatrix: Matrix;
  64428. /**
  64429. *
  64430. * @param name The name of the effect.
  64431. * @param kernelMatrix The matrix to be applied to the image
  64432. * @param options The required width/height ratio to downsize to before computing the render pass.
  64433. * @param camera The camera to apply the render pass to.
  64434. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64435. * @param engine The engine which the post process will be applied. (default: current engine)
  64436. * @param reusable If the post process can be reused on the same frame. (default: false)
  64437. */
  64438. constructor(name: string,
  64439. /** The matrix to be applied to the image */
  64440. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  64441. }
  64442. }
  64443. declare module BABYLON {
  64444. /** @hidden */
  64445. export var fxaaPixelShader: {
  64446. name: string;
  64447. shader: string;
  64448. };
  64449. }
  64450. declare module BABYLON {
  64451. /** @hidden */
  64452. export var fxaaVertexShader: {
  64453. name: string;
  64454. shader: string;
  64455. };
  64456. }
  64457. declare module BABYLON {
  64458. /**
  64459. * Fxaa post process
  64460. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  64461. */
  64462. export class FxaaPostProcess extends PostProcess {
  64463. /** @hidden */
  64464. texelWidth: number;
  64465. /** @hidden */
  64466. texelHeight: number;
  64467. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  64468. private _getDefines;
  64469. }
  64470. }
  64471. declare module BABYLON {
  64472. /** @hidden */
  64473. export var grainPixelShader: {
  64474. name: string;
  64475. shader: string;
  64476. };
  64477. }
  64478. declare module BABYLON {
  64479. /**
  64480. * The GrainPostProcess adds noise to the image at mid luminance levels
  64481. */
  64482. export class GrainPostProcess extends PostProcess {
  64483. /**
  64484. * The intensity of the grain added (default: 30)
  64485. */
  64486. intensity: number;
  64487. /**
  64488. * If the grain should be randomized on every frame
  64489. */
  64490. animated: boolean;
  64491. /**
  64492. * Creates a new instance of @see GrainPostProcess
  64493. * @param name The name of the effect.
  64494. * @param options The required width/height ratio to downsize to before computing the render pass.
  64495. * @param camera The camera to apply the render pass to.
  64496. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64497. * @param engine The engine which the post process will be applied. (default: current engine)
  64498. * @param reusable If the post process can be reused on the same frame. (default: false)
  64499. * @param textureType Type of textures used when performing the post process. (default: 0)
  64500. * @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)
  64501. */
  64502. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64503. }
  64504. }
  64505. declare module BABYLON {
  64506. /** @hidden */
  64507. export var highlightsPixelShader: {
  64508. name: string;
  64509. shader: string;
  64510. };
  64511. }
  64512. declare module BABYLON {
  64513. /**
  64514. * Extracts highlights from the image
  64515. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  64516. */
  64517. export class HighlightsPostProcess extends PostProcess {
  64518. /**
  64519. * Extracts highlights from the image
  64520. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  64521. * @param name The name of the effect.
  64522. * @param options The required width/height ratio to downsize to before computing the render pass.
  64523. * @param camera The camera to apply the render pass to.
  64524. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64525. * @param engine The engine which the post process will be applied. (default: current engine)
  64526. * @param reusable If the post process can be reused on the same frame. (default: false)
  64527. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  64528. */
  64529. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  64530. }
  64531. }
  64532. declare module BABYLON {
  64533. /** @hidden */
  64534. export var mrtFragmentDeclaration: {
  64535. name: string;
  64536. shader: string;
  64537. };
  64538. }
  64539. declare module BABYLON {
  64540. /** @hidden */
  64541. export var geometryPixelShader: {
  64542. name: string;
  64543. shader: string;
  64544. };
  64545. }
  64546. declare module BABYLON {
  64547. /** @hidden */
  64548. export var geometryVertexShader: {
  64549. name: string;
  64550. shader: string;
  64551. };
  64552. }
  64553. declare module BABYLON {
  64554. /** @hidden */
  64555. interface ISavedTransformationMatrix {
  64556. world: Matrix;
  64557. viewProjection: Matrix;
  64558. }
  64559. /**
  64560. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  64561. */
  64562. export class GeometryBufferRenderer {
  64563. /**
  64564. * Constant used to retrieve the position texture index in the G-Buffer textures array
  64565. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  64566. */
  64567. static readonly POSITION_TEXTURE_TYPE: number;
  64568. /**
  64569. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  64570. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  64571. */
  64572. static readonly VELOCITY_TEXTURE_TYPE: number;
  64573. /**
  64574. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  64575. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  64576. */
  64577. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  64578. /**
  64579. * Dictionary used to store the previous transformation matrices of each rendered mesh
  64580. * in order to compute objects velocities when enableVelocity is set to "true"
  64581. * @hidden
  64582. */
  64583. _previousTransformationMatrices: {
  64584. [index: number]: ISavedTransformationMatrix;
  64585. };
  64586. /**
  64587. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  64588. * in order to compute objects velocities when enableVelocity is set to "true"
  64589. * @hidden
  64590. */
  64591. _previousBonesTransformationMatrices: {
  64592. [index: number]: Float32Array;
  64593. };
  64594. /**
  64595. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  64596. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  64597. */
  64598. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  64599. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  64600. renderTransparentMeshes: boolean;
  64601. private _scene;
  64602. private _multiRenderTarget;
  64603. private _ratio;
  64604. private _enablePosition;
  64605. private _enableVelocity;
  64606. private _enableReflectivity;
  64607. private _positionIndex;
  64608. private _velocityIndex;
  64609. private _reflectivityIndex;
  64610. protected _effect: Effect;
  64611. protected _cachedDefines: string;
  64612. /**
  64613. * Set the render list (meshes to be rendered) used in the G buffer.
  64614. */
  64615. set renderList(meshes: Mesh[]);
  64616. /**
  64617. * Gets wether or not G buffer are supported by the running hardware.
  64618. * This requires draw buffer supports
  64619. */
  64620. get isSupported(): boolean;
  64621. /**
  64622. * Returns the index of the given texture type in the G-Buffer textures array
  64623. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  64624. * @returns the index of the given texture type in the G-Buffer textures array
  64625. */
  64626. getTextureIndex(textureType: number): number;
  64627. /**
  64628. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  64629. */
  64630. get enablePosition(): boolean;
  64631. /**
  64632. * Sets whether or not objects positions are enabled for the G buffer.
  64633. */
  64634. set enablePosition(enable: boolean);
  64635. /**
  64636. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  64637. */
  64638. get enableVelocity(): boolean;
  64639. /**
  64640. * Sets wether or not objects velocities are enabled for the G buffer.
  64641. */
  64642. set enableVelocity(enable: boolean);
  64643. /**
  64644. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  64645. */
  64646. get enableReflectivity(): boolean;
  64647. /**
  64648. * Sets wether or not objects roughness are enabled for the G buffer.
  64649. */
  64650. set enableReflectivity(enable: boolean);
  64651. /**
  64652. * Gets the scene associated with the buffer.
  64653. */
  64654. get scene(): Scene;
  64655. /**
  64656. * Gets the ratio used by the buffer during its creation.
  64657. * How big is the buffer related to the main canvas.
  64658. */
  64659. get ratio(): number;
  64660. /** @hidden */
  64661. static _SceneComponentInitialization: (scene: Scene) => void;
  64662. /**
  64663. * Creates a new G Buffer for the scene
  64664. * @param scene The scene the buffer belongs to
  64665. * @param ratio How big is the buffer related to the main canvas.
  64666. */
  64667. constructor(scene: Scene, ratio?: number);
  64668. /**
  64669. * Checks wether everything is ready to render a submesh to the G buffer.
  64670. * @param subMesh the submesh to check readiness for
  64671. * @param useInstances is the mesh drawn using instance or not
  64672. * @returns true if ready otherwise false
  64673. */
  64674. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  64675. /**
  64676. * Gets the current underlying G Buffer.
  64677. * @returns the buffer
  64678. */
  64679. getGBuffer(): MultiRenderTarget;
  64680. /**
  64681. * Gets the number of samples used to render the buffer (anti aliasing).
  64682. */
  64683. get samples(): number;
  64684. /**
  64685. * Sets the number of samples used to render the buffer (anti aliasing).
  64686. */
  64687. set samples(value: number);
  64688. /**
  64689. * Disposes the renderer and frees up associated resources.
  64690. */
  64691. dispose(): void;
  64692. protected _createRenderTargets(): void;
  64693. private _copyBonesTransformationMatrices;
  64694. }
  64695. }
  64696. declare module BABYLON {
  64697. interface Scene {
  64698. /** @hidden (Backing field) */
  64699. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  64700. /**
  64701. * Gets or Sets the current geometry buffer associated to the scene.
  64702. */
  64703. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  64704. /**
  64705. * Enables a GeometryBufferRender and associates it with the scene
  64706. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  64707. * @returns the GeometryBufferRenderer
  64708. */
  64709. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  64710. /**
  64711. * Disables the GeometryBufferRender associated with the scene
  64712. */
  64713. disableGeometryBufferRenderer(): void;
  64714. }
  64715. /**
  64716. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  64717. * in several rendering techniques.
  64718. */
  64719. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  64720. /**
  64721. * The component name helpful to identify the component in the list of scene components.
  64722. */
  64723. readonly name: string;
  64724. /**
  64725. * The scene the component belongs to.
  64726. */
  64727. scene: Scene;
  64728. /**
  64729. * Creates a new instance of the component for the given scene
  64730. * @param scene Defines the scene to register the component in
  64731. */
  64732. constructor(scene: Scene);
  64733. /**
  64734. * Registers the component in a given scene
  64735. */
  64736. register(): void;
  64737. /**
  64738. * Rebuilds the elements related to this component in case of
  64739. * context lost for instance.
  64740. */
  64741. rebuild(): void;
  64742. /**
  64743. * Disposes the component and the associated ressources
  64744. */
  64745. dispose(): void;
  64746. private _gatherRenderTargets;
  64747. }
  64748. }
  64749. declare module BABYLON {
  64750. /** @hidden */
  64751. export var motionBlurPixelShader: {
  64752. name: string;
  64753. shader: string;
  64754. };
  64755. }
  64756. declare module BABYLON {
  64757. /**
  64758. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  64759. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  64760. * As an example, all you have to do is to create the post-process:
  64761. * var mb = new BABYLON.MotionBlurPostProcess(
  64762. * 'mb', // The name of the effect.
  64763. * scene, // The scene containing the objects to blur according to their velocity.
  64764. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  64765. * camera // The camera to apply the render pass to.
  64766. * );
  64767. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  64768. */
  64769. export class MotionBlurPostProcess extends PostProcess {
  64770. /**
  64771. * Defines how much the image is blurred by the movement. Default value is equal to 1
  64772. */
  64773. motionStrength: number;
  64774. /**
  64775. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  64776. */
  64777. get motionBlurSamples(): number;
  64778. /**
  64779. * Sets the number of iterations to be used for motion blur quality
  64780. */
  64781. set motionBlurSamples(samples: number);
  64782. private _motionBlurSamples;
  64783. private _geometryBufferRenderer;
  64784. /**
  64785. * Creates a new instance MotionBlurPostProcess
  64786. * @param name The name of the effect.
  64787. * @param scene The scene containing the objects to blur according to their velocity.
  64788. * @param options The required width/height ratio to downsize to before computing the render pass.
  64789. * @param camera The camera to apply the render pass to.
  64790. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64791. * @param engine The engine which the post process will be applied. (default: current engine)
  64792. * @param reusable If the post process can be reused on the same frame. (default: false)
  64793. * @param textureType Type of textures used when performing the post process. (default: 0)
  64794. * @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)
  64795. */
  64796. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64797. /**
  64798. * Excludes the given skinned mesh from computing bones velocities.
  64799. * 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.
  64800. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  64801. */
  64802. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  64803. /**
  64804. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  64805. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  64806. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  64807. */
  64808. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  64809. /**
  64810. * Disposes the post process.
  64811. * @param camera The camera to dispose the post process on.
  64812. */
  64813. dispose(camera?: Camera): void;
  64814. }
  64815. }
  64816. declare module BABYLON {
  64817. /** @hidden */
  64818. export var refractionPixelShader: {
  64819. name: string;
  64820. shader: string;
  64821. };
  64822. }
  64823. declare module BABYLON {
  64824. /**
  64825. * Post process which applies a refractin texture
  64826. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  64827. */
  64828. export class RefractionPostProcess extends PostProcess {
  64829. /** the base color of the refraction (used to taint the rendering) */
  64830. color: Color3;
  64831. /** simulated refraction depth */
  64832. depth: number;
  64833. /** the coefficient of the base color (0 to remove base color tainting) */
  64834. colorLevel: number;
  64835. private _refTexture;
  64836. private _ownRefractionTexture;
  64837. /**
  64838. * Gets or sets the refraction texture
  64839. * Please note that you are responsible for disposing the texture if you set it manually
  64840. */
  64841. get refractionTexture(): Texture;
  64842. set refractionTexture(value: Texture);
  64843. /**
  64844. * Initializes the RefractionPostProcess
  64845. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  64846. * @param name The name of the effect.
  64847. * @param refractionTextureUrl Url of the refraction texture to use
  64848. * @param color the base color of the refraction (used to taint the rendering)
  64849. * @param depth simulated refraction depth
  64850. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  64851. * @param camera The camera to apply the render pass to.
  64852. * @param options The required width/height ratio to downsize to before computing the render pass.
  64853. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64854. * @param engine The engine which the post process will be applied. (default: current engine)
  64855. * @param reusable If the post process can be reused on the same frame. (default: false)
  64856. */
  64857. constructor(name: string, refractionTextureUrl: string,
  64858. /** the base color of the refraction (used to taint the rendering) */
  64859. color: Color3,
  64860. /** simulated refraction depth */
  64861. depth: number,
  64862. /** the coefficient of the base color (0 to remove base color tainting) */
  64863. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  64864. /**
  64865. * Disposes of the post process
  64866. * @param camera Camera to dispose post process on
  64867. */
  64868. dispose(camera: Camera): void;
  64869. }
  64870. }
  64871. declare module BABYLON {
  64872. /** @hidden */
  64873. export var sharpenPixelShader: {
  64874. name: string;
  64875. shader: string;
  64876. };
  64877. }
  64878. declare module BABYLON {
  64879. /**
  64880. * The SharpenPostProcess applies a sharpen kernel to every pixel
  64881. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  64882. */
  64883. export class SharpenPostProcess extends PostProcess {
  64884. /**
  64885. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  64886. */
  64887. colorAmount: number;
  64888. /**
  64889. * How much sharpness should be applied (default: 0.3)
  64890. */
  64891. edgeAmount: number;
  64892. /**
  64893. * Creates a new instance ConvolutionPostProcess
  64894. * @param name The name of the effect.
  64895. * @param options The required width/height ratio to downsize to before computing the render pass.
  64896. * @param camera The camera to apply the render pass to.
  64897. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64898. * @param engine The engine which the post process will be applied. (default: current engine)
  64899. * @param reusable If the post process can be reused on the same frame. (default: false)
  64900. * @param textureType Type of textures used when performing the post process. (default: 0)
  64901. * @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)
  64902. */
  64903. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64904. }
  64905. }
  64906. declare module BABYLON {
  64907. /**
  64908. * PostProcessRenderPipeline
  64909. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  64910. */
  64911. export class PostProcessRenderPipeline {
  64912. private engine;
  64913. private _renderEffects;
  64914. private _renderEffectsForIsolatedPass;
  64915. /**
  64916. * List of inspectable custom properties (used by the Inspector)
  64917. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  64918. */
  64919. inspectableCustomProperties: IInspectable[];
  64920. /**
  64921. * @hidden
  64922. */
  64923. protected _cameras: Camera[];
  64924. /** @hidden */
  64925. _name: string;
  64926. /**
  64927. * Gets pipeline name
  64928. */
  64929. get name(): string;
  64930. /** Gets the list of attached cameras */
  64931. get cameras(): Camera[];
  64932. /**
  64933. * Initializes a PostProcessRenderPipeline
  64934. * @param engine engine to add the pipeline to
  64935. * @param name name of the pipeline
  64936. */
  64937. constructor(engine: Engine, name: string);
  64938. /**
  64939. * Gets the class name
  64940. * @returns "PostProcessRenderPipeline"
  64941. */
  64942. getClassName(): string;
  64943. /**
  64944. * If all the render effects in the pipeline are supported
  64945. */
  64946. get isSupported(): boolean;
  64947. /**
  64948. * Adds an effect to the pipeline
  64949. * @param renderEffect the effect to add
  64950. */
  64951. addEffect(renderEffect: PostProcessRenderEffect): void;
  64952. /** @hidden */
  64953. _rebuild(): void;
  64954. /** @hidden */
  64955. _enableEffect(renderEffectName: string, cameras: Camera): void;
  64956. /** @hidden */
  64957. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  64958. /** @hidden */
  64959. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  64960. /** @hidden */
  64961. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  64962. /** @hidden */
  64963. _attachCameras(cameras: Camera, unique: boolean): void;
  64964. /** @hidden */
  64965. _attachCameras(cameras: Camera[], unique: boolean): void;
  64966. /** @hidden */
  64967. _detachCameras(cameras: Camera): void;
  64968. /** @hidden */
  64969. _detachCameras(cameras: Nullable<Camera[]>): void;
  64970. /** @hidden */
  64971. _update(): void;
  64972. /** @hidden */
  64973. _reset(): void;
  64974. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  64975. /**
  64976. * Disposes of the pipeline
  64977. */
  64978. dispose(): void;
  64979. }
  64980. }
  64981. declare module BABYLON {
  64982. /**
  64983. * PostProcessRenderPipelineManager class
  64984. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  64985. */
  64986. export class PostProcessRenderPipelineManager {
  64987. private _renderPipelines;
  64988. /**
  64989. * Initializes a PostProcessRenderPipelineManager
  64990. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  64991. */
  64992. constructor();
  64993. /**
  64994. * Gets the list of supported render pipelines
  64995. */
  64996. get supportedPipelines(): PostProcessRenderPipeline[];
  64997. /**
  64998. * Adds a pipeline to the manager
  64999. * @param renderPipeline The pipeline to add
  65000. */
  65001. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  65002. /**
  65003. * Attaches a camera to the pipeline
  65004. * @param renderPipelineName The name of the pipeline to attach to
  65005. * @param cameras the camera to attach
  65006. * @param unique if the camera can be attached multiple times to the pipeline
  65007. */
  65008. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  65009. /**
  65010. * Detaches a camera from the pipeline
  65011. * @param renderPipelineName The name of the pipeline to detach from
  65012. * @param cameras the camera to detach
  65013. */
  65014. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  65015. /**
  65016. * Enables an effect by name on a pipeline
  65017. * @param renderPipelineName the name of the pipeline to enable the effect in
  65018. * @param renderEffectName the name of the effect to enable
  65019. * @param cameras the cameras that the effect should be enabled on
  65020. */
  65021. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  65022. /**
  65023. * Disables an effect by name on a pipeline
  65024. * @param renderPipelineName the name of the pipeline to disable the effect in
  65025. * @param renderEffectName the name of the effect to disable
  65026. * @param cameras the cameras that the effect should be disabled on
  65027. */
  65028. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  65029. /**
  65030. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  65031. */
  65032. update(): void;
  65033. /** @hidden */
  65034. _rebuild(): void;
  65035. /**
  65036. * Disposes of the manager and pipelines
  65037. */
  65038. dispose(): void;
  65039. }
  65040. }
  65041. declare module BABYLON {
  65042. interface Scene {
  65043. /** @hidden (Backing field) */
  65044. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  65045. /**
  65046. * Gets the postprocess render pipeline manager
  65047. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  65048. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  65049. */
  65050. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  65051. }
  65052. /**
  65053. * Defines the Render Pipeline scene component responsible to rendering pipelines
  65054. */
  65055. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  65056. /**
  65057. * The component name helpfull to identify the component in the list of scene components.
  65058. */
  65059. readonly name: string;
  65060. /**
  65061. * The scene the component belongs to.
  65062. */
  65063. scene: Scene;
  65064. /**
  65065. * Creates a new instance of the component for the given scene
  65066. * @param scene Defines the scene to register the component in
  65067. */
  65068. constructor(scene: Scene);
  65069. /**
  65070. * Registers the component in a given scene
  65071. */
  65072. register(): void;
  65073. /**
  65074. * Rebuilds the elements related to this component in case of
  65075. * context lost for instance.
  65076. */
  65077. rebuild(): void;
  65078. /**
  65079. * Disposes the component and the associated ressources
  65080. */
  65081. dispose(): void;
  65082. private _gatherRenderTargets;
  65083. }
  65084. }
  65085. declare module BABYLON {
  65086. /**
  65087. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  65088. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  65089. */
  65090. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  65091. private _scene;
  65092. private _camerasToBeAttached;
  65093. /**
  65094. * ID of the sharpen post process,
  65095. */
  65096. private readonly SharpenPostProcessId;
  65097. /**
  65098. * @ignore
  65099. * ID of the image processing post process;
  65100. */
  65101. readonly ImageProcessingPostProcessId: string;
  65102. /**
  65103. * @ignore
  65104. * ID of the Fast Approximate Anti-Aliasing post process;
  65105. */
  65106. readonly FxaaPostProcessId: string;
  65107. /**
  65108. * ID of the chromatic aberration post process,
  65109. */
  65110. private readonly ChromaticAberrationPostProcessId;
  65111. /**
  65112. * ID of the grain post process
  65113. */
  65114. private readonly GrainPostProcessId;
  65115. /**
  65116. * Sharpen post process which will apply a sharpen convolution to enhance edges
  65117. */
  65118. sharpen: SharpenPostProcess;
  65119. private _sharpenEffect;
  65120. private bloom;
  65121. /**
  65122. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  65123. */
  65124. depthOfField: DepthOfFieldEffect;
  65125. /**
  65126. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  65127. */
  65128. fxaa: FxaaPostProcess;
  65129. /**
  65130. * Image post processing pass used to perform operations such as tone mapping or color grading.
  65131. */
  65132. imageProcessing: ImageProcessingPostProcess;
  65133. /**
  65134. * Chromatic aberration post process which will shift rgb colors in the image
  65135. */
  65136. chromaticAberration: ChromaticAberrationPostProcess;
  65137. private _chromaticAberrationEffect;
  65138. /**
  65139. * Grain post process which add noise to the image
  65140. */
  65141. grain: GrainPostProcess;
  65142. private _grainEffect;
  65143. /**
  65144. * Glow post process which adds a glow to emissive areas of the image
  65145. */
  65146. private _glowLayer;
  65147. /**
  65148. * Animations which can be used to tweak settings over a period of time
  65149. */
  65150. animations: Animation[];
  65151. private _imageProcessingConfigurationObserver;
  65152. private _sharpenEnabled;
  65153. private _bloomEnabled;
  65154. private _depthOfFieldEnabled;
  65155. private _depthOfFieldBlurLevel;
  65156. private _fxaaEnabled;
  65157. private _imageProcessingEnabled;
  65158. private _defaultPipelineTextureType;
  65159. private _bloomScale;
  65160. private _chromaticAberrationEnabled;
  65161. private _grainEnabled;
  65162. private _buildAllowed;
  65163. /**
  65164. * Gets active scene
  65165. */
  65166. get scene(): Scene;
  65167. /**
  65168. * Enable or disable the sharpen process from the pipeline
  65169. */
  65170. set sharpenEnabled(enabled: boolean);
  65171. get sharpenEnabled(): boolean;
  65172. private _resizeObserver;
  65173. private _hardwareScaleLevel;
  65174. private _bloomKernel;
  65175. /**
  65176. * Specifies the size of the bloom blur kernel, relative to the final output size
  65177. */
  65178. get bloomKernel(): number;
  65179. set bloomKernel(value: number);
  65180. /**
  65181. * Specifies the weight of the bloom in the final rendering
  65182. */
  65183. private _bloomWeight;
  65184. /**
  65185. * Specifies the luma threshold for the area that will be blurred by the bloom
  65186. */
  65187. private _bloomThreshold;
  65188. private _hdr;
  65189. /**
  65190. * The strength of the bloom.
  65191. */
  65192. set bloomWeight(value: number);
  65193. get bloomWeight(): number;
  65194. /**
  65195. * The strength of the bloom.
  65196. */
  65197. set bloomThreshold(value: number);
  65198. get bloomThreshold(): number;
  65199. /**
  65200. * The scale of the bloom, lower value will provide better performance.
  65201. */
  65202. set bloomScale(value: number);
  65203. get bloomScale(): number;
  65204. /**
  65205. * Enable or disable the bloom from the pipeline
  65206. */
  65207. set bloomEnabled(enabled: boolean);
  65208. get bloomEnabled(): boolean;
  65209. private _rebuildBloom;
  65210. /**
  65211. * If the depth of field is enabled.
  65212. */
  65213. get depthOfFieldEnabled(): boolean;
  65214. set depthOfFieldEnabled(enabled: boolean);
  65215. /**
  65216. * Blur level of the depth of field effect. (Higher blur will effect performance)
  65217. */
  65218. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  65219. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  65220. /**
  65221. * If the anti aliasing is enabled.
  65222. */
  65223. set fxaaEnabled(enabled: boolean);
  65224. get fxaaEnabled(): boolean;
  65225. private _samples;
  65226. /**
  65227. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  65228. */
  65229. set samples(sampleCount: number);
  65230. get samples(): number;
  65231. /**
  65232. * If image processing is enabled.
  65233. */
  65234. set imageProcessingEnabled(enabled: boolean);
  65235. get imageProcessingEnabled(): boolean;
  65236. /**
  65237. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  65238. */
  65239. set glowLayerEnabled(enabled: boolean);
  65240. get glowLayerEnabled(): boolean;
  65241. /**
  65242. * Gets the glow layer (or null if not defined)
  65243. */
  65244. get glowLayer(): Nullable<GlowLayer>;
  65245. /**
  65246. * Enable or disable the chromaticAberration process from the pipeline
  65247. */
  65248. set chromaticAberrationEnabled(enabled: boolean);
  65249. get chromaticAberrationEnabled(): boolean;
  65250. /**
  65251. * Enable or disable the grain process from the pipeline
  65252. */
  65253. set grainEnabled(enabled: boolean);
  65254. get grainEnabled(): boolean;
  65255. /**
  65256. * @constructor
  65257. * @param name - The rendering pipeline name (default: "")
  65258. * @param hdr - If high dynamic range textures should be used (default: true)
  65259. * @param scene - The scene linked to this pipeline (default: the last created scene)
  65260. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  65261. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  65262. */
  65263. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  65264. /**
  65265. * Get the class name
  65266. * @returns "DefaultRenderingPipeline"
  65267. */
  65268. getClassName(): string;
  65269. /**
  65270. * Force the compilation of the entire pipeline.
  65271. */
  65272. prepare(): void;
  65273. private _hasCleared;
  65274. private _prevPostProcess;
  65275. private _prevPrevPostProcess;
  65276. private _setAutoClearAndTextureSharing;
  65277. private _depthOfFieldSceneObserver;
  65278. private _buildPipeline;
  65279. private _disposePostProcesses;
  65280. /**
  65281. * Adds a camera to the pipeline
  65282. * @param camera the camera to be added
  65283. */
  65284. addCamera(camera: Camera): void;
  65285. /**
  65286. * Removes a camera from the pipeline
  65287. * @param camera the camera to remove
  65288. */
  65289. removeCamera(camera: Camera): void;
  65290. /**
  65291. * Dispose of the pipeline and stop all post processes
  65292. */
  65293. dispose(): void;
  65294. /**
  65295. * Serialize the rendering pipeline (Used when exporting)
  65296. * @returns the serialized object
  65297. */
  65298. serialize(): any;
  65299. /**
  65300. * Parse the serialized pipeline
  65301. * @param source Source pipeline.
  65302. * @param scene The scene to load the pipeline to.
  65303. * @param rootUrl The URL of the serialized pipeline.
  65304. * @returns An instantiated pipeline from the serialized object.
  65305. */
  65306. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  65307. }
  65308. }
  65309. declare module BABYLON {
  65310. /** @hidden */
  65311. export var lensHighlightsPixelShader: {
  65312. name: string;
  65313. shader: string;
  65314. };
  65315. }
  65316. declare module BABYLON {
  65317. /** @hidden */
  65318. export var depthOfFieldPixelShader: {
  65319. name: string;
  65320. shader: string;
  65321. };
  65322. }
  65323. declare module BABYLON {
  65324. /**
  65325. * BABYLON.JS Chromatic Aberration GLSL Shader
  65326. * Author: Olivier Guyot
  65327. * Separates very slightly R, G and B colors on the edges of the screen
  65328. * Inspired by Francois Tarlier & Martins Upitis
  65329. */
  65330. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  65331. /**
  65332. * @ignore
  65333. * The chromatic aberration PostProcess id in the pipeline
  65334. */
  65335. LensChromaticAberrationEffect: string;
  65336. /**
  65337. * @ignore
  65338. * The highlights enhancing PostProcess id in the pipeline
  65339. */
  65340. HighlightsEnhancingEffect: string;
  65341. /**
  65342. * @ignore
  65343. * The depth-of-field PostProcess id in the pipeline
  65344. */
  65345. LensDepthOfFieldEffect: string;
  65346. private _scene;
  65347. private _depthTexture;
  65348. private _grainTexture;
  65349. private _chromaticAberrationPostProcess;
  65350. private _highlightsPostProcess;
  65351. private _depthOfFieldPostProcess;
  65352. private _edgeBlur;
  65353. private _grainAmount;
  65354. private _chromaticAberration;
  65355. private _distortion;
  65356. private _highlightsGain;
  65357. private _highlightsThreshold;
  65358. private _dofDistance;
  65359. private _dofAperture;
  65360. private _dofDarken;
  65361. private _dofPentagon;
  65362. private _blurNoise;
  65363. /**
  65364. * @constructor
  65365. *
  65366. * Effect parameters are as follow:
  65367. * {
  65368. * chromatic_aberration: number; // from 0 to x (1 for realism)
  65369. * edge_blur: number; // from 0 to x (1 for realism)
  65370. * distortion: number; // from 0 to x (1 for realism)
  65371. * grain_amount: number; // from 0 to 1
  65372. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  65373. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  65374. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  65375. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  65376. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  65377. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  65378. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  65379. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  65380. * }
  65381. * Note: if an effect parameter is unset, effect is disabled
  65382. *
  65383. * @param name The rendering pipeline name
  65384. * @param parameters - An object containing all parameters (see above)
  65385. * @param scene The scene linked to this pipeline
  65386. * @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)
  65387. * @param cameras The array of cameras that the rendering pipeline will be attached to
  65388. */
  65389. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  65390. /**
  65391. * Get the class name
  65392. * @returns "LensRenderingPipeline"
  65393. */
  65394. getClassName(): string;
  65395. /**
  65396. * Gets associated scene
  65397. */
  65398. get scene(): Scene;
  65399. /**
  65400. * Gets or sets the edge blur
  65401. */
  65402. get edgeBlur(): number;
  65403. set edgeBlur(value: number);
  65404. /**
  65405. * Gets or sets the grain amount
  65406. */
  65407. get grainAmount(): number;
  65408. set grainAmount(value: number);
  65409. /**
  65410. * Gets or sets the chromatic aberration amount
  65411. */
  65412. get chromaticAberration(): number;
  65413. set chromaticAberration(value: number);
  65414. /**
  65415. * Gets or sets the depth of field aperture
  65416. */
  65417. get dofAperture(): number;
  65418. set dofAperture(value: number);
  65419. /**
  65420. * Gets or sets the edge distortion
  65421. */
  65422. get edgeDistortion(): number;
  65423. set edgeDistortion(value: number);
  65424. /**
  65425. * Gets or sets the depth of field distortion
  65426. */
  65427. get dofDistortion(): number;
  65428. set dofDistortion(value: number);
  65429. /**
  65430. * Gets or sets the darken out of focus amount
  65431. */
  65432. get darkenOutOfFocus(): number;
  65433. set darkenOutOfFocus(value: number);
  65434. /**
  65435. * Gets or sets a boolean indicating if blur noise is enabled
  65436. */
  65437. get blurNoise(): boolean;
  65438. set blurNoise(value: boolean);
  65439. /**
  65440. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  65441. */
  65442. get pentagonBokeh(): boolean;
  65443. set pentagonBokeh(value: boolean);
  65444. /**
  65445. * Gets or sets the highlight grain amount
  65446. */
  65447. get highlightsGain(): number;
  65448. set highlightsGain(value: number);
  65449. /**
  65450. * Gets or sets the highlight threshold
  65451. */
  65452. get highlightsThreshold(): number;
  65453. set highlightsThreshold(value: number);
  65454. /**
  65455. * Sets the amount of blur at the edges
  65456. * @param amount blur amount
  65457. */
  65458. setEdgeBlur(amount: number): void;
  65459. /**
  65460. * Sets edge blur to 0
  65461. */
  65462. disableEdgeBlur(): void;
  65463. /**
  65464. * Sets the amout of grain
  65465. * @param amount Amount of grain
  65466. */
  65467. setGrainAmount(amount: number): void;
  65468. /**
  65469. * Set grain amount to 0
  65470. */
  65471. disableGrain(): void;
  65472. /**
  65473. * Sets the chromatic aberration amount
  65474. * @param amount amount of chromatic aberration
  65475. */
  65476. setChromaticAberration(amount: number): void;
  65477. /**
  65478. * Sets chromatic aberration amount to 0
  65479. */
  65480. disableChromaticAberration(): void;
  65481. /**
  65482. * Sets the EdgeDistortion amount
  65483. * @param amount amount of EdgeDistortion
  65484. */
  65485. setEdgeDistortion(amount: number): void;
  65486. /**
  65487. * Sets edge distortion to 0
  65488. */
  65489. disableEdgeDistortion(): void;
  65490. /**
  65491. * Sets the FocusDistance amount
  65492. * @param amount amount of FocusDistance
  65493. */
  65494. setFocusDistance(amount: number): void;
  65495. /**
  65496. * Disables depth of field
  65497. */
  65498. disableDepthOfField(): void;
  65499. /**
  65500. * Sets the Aperture amount
  65501. * @param amount amount of Aperture
  65502. */
  65503. setAperture(amount: number): void;
  65504. /**
  65505. * Sets the DarkenOutOfFocus amount
  65506. * @param amount amount of DarkenOutOfFocus
  65507. */
  65508. setDarkenOutOfFocus(amount: number): void;
  65509. private _pentagonBokehIsEnabled;
  65510. /**
  65511. * Creates a pentagon bokeh effect
  65512. */
  65513. enablePentagonBokeh(): void;
  65514. /**
  65515. * Disables the pentagon bokeh effect
  65516. */
  65517. disablePentagonBokeh(): void;
  65518. /**
  65519. * Enables noise blur
  65520. */
  65521. enableNoiseBlur(): void;
  65522. /**
  65523. * Disables noise blur
  65524. */
  65525. disableNoiseBlur(): void;
  65526. /**
  65527. * Sets the HighlightsGain amount
  65528. * @param amount amount of HighlightsGain
  65529. */
  65530. setHighlightsGain(amount: number): void;
  65531. /**
  65532. * Sets the HighlightsThreshold amount
  65533. * @param amount amount of HighlightsThreshold
  65534. */
  65535. setHighlightsThreshold(amount: number): void;
  65536. /**
  65537. * Disables highlights
  65538. */
  65539. disableHighlights(): void;
  65540. /**
  65541. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  65542. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  65543. */
  65544. dispose(disableDepthRender?: boolean): void;
  65545. private _createChromaticAberrationPostProcess;
  65546. private _createHighlightsPostProcess;
  65547. private _createDepthOfFieldPostProcess;
  65548. private _createGrainTexture;
  65549. }
  65550. }
  65551. declare module BABYLON {
  65552. /** @hidden */
  65553. export var ssao2PixelShader: {
  65554. name: string;
  65555. shader: string;
  65556. };
  65557. }
  65558. declare module BABYLON {
  65559. /** @hidden */
  65560. export var ssaoCombinePixelShader: {
  65561. name: string;
  65562. shader: string;
  65563. };
  65564. }
  65565. declare module BABYLON {
  65566. /**
  65567. * Render pipeline to produce ssao effect
  65568. */
  65569. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  65570. /**
  65571. * @ignore
  65572. * The PassPostProcess id in the pipeline that contains the original scene color
  65573. */
  65574. SSAOOriginalSceneColorEffect: string;
  65575. /**
  65576. * @ignore
  65577. * The SSAO PostProcess id in the pipeline
  65578. */
  65579. SSAORenderEffect: string;
  65580. /**
  65581. * @ignore
  65582. * The horizontal blur PostProcess id in the pipeline
  65583. */
  65584. SSAOBlurHRenderEffect: string;
  65585. /**
  65586. * @ignore
  65587. * The vertical blur PostProcess id in the pipeline
  65588. */
  65589. SSAOBlurVRenderEffect: string;
  65590. /**
  65591. * @ignore
  65592. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  65593. */
  65594. SSAOCombineRenderEffect: string;
  65595. /**
  65596. * The output strength of the SSAO post-process. Default value is 1.0.
  65597. */
  65598. totalStrength: number;
  65599. /**
  65600. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  65601. */
  65602. maxZ: number;
  65603. /**
  65604. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  65605. */
  65606. minZAspect: number;
  65607. private _samples;
  65608. /**
  65609. * Number of samples used for the SSAO calculations. Default value is 8
  65610. */
  65611. set samples(n: number);
  65612. get samples(): number;
  65613. private _textureSamples;
  65614. /**
  65615. * Number of samples to use for antialiasing
  65616. */
  65617. set textureSamples(n: number);
  65618. get textureSamples(): number;
  65619. /**
  65620. * Ratio object used for SSAO ratio and blur ratio
  65621. */
  65622. private _ratio;
  65623. /**
  65624. * Dynamically generated sphere sampler.
  65625. */
  65626. private _sampleSphere;
  65627. /**
  65628. * Blur filter offsets
  65629. */
  65630. private _samplerOffsets;
  65631. private _expensiveBlur;
  65632. /**
  65633. * If bilateral blur should be used
  65634. */
  65635. set expensiveBlur(b: boolean);
  65636. get expensiveBlur(): boolean;
  65637. /**
  65638. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  65639. */
  65640. radius: number;
  65641. /**
  65642. * The base color of the SSAO post-process
  65643. * The final result is "base + ssao" between [0, 1]
  65644. */
  65645. base: number;
  65646. /**
  65647. * Support test.
  65648. */
  65649. static get IsSupported(): boolean;
  65650. private _scene;
  65651. private _depthTexture;
  65652. private _normalTexture;
  65653. private _randomTexture;
  65654. private _originalColorPostProcess;
  65655. private _ssaoPostProcess;
  65656. private _blurHPostProcess;
  65657. private _blurVPostProcess;
  65658. private _ssaoCombinePostProcess;
  65659. /**
  65660. * Gets active scene
  65661. */
  65662. get scene(): Scene;
  65663. /**
  65664. * @constructor
  65665. * @param name The rendering pipeline name
  65666. * @param scene The scene linked to this pipeline
  65667. * @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 }
  65668. * @param cameras The array of cameras that the rendering pipeline will be attached to
  65669. */
  65670. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  65671. /**
  65672. * Get the class name
  65673. * @returns "SSAO2RenderingPipeline"
  65674. */
  65675. getClassName(): string;
  65676. /**
  65677. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  65678. */
  65679. dispose(disableGeometryBufferRenderer?: boolean): void;
  65680. private _createBlurPostProcess;
  65681. /** @hidden */
  65682. _rebuild(): void;
  65683. private _bits;
  65684. private _radicalInverse_VdC;
  65685. private _hammersley;
  65686. private _hemisphereSample_uniform;
  65687. private _generateHemisphere;
  65688. private _createSSAOPostProcess;
  65689. private _createSSAOCombinePostProcess;
  65690. private _createRandomTexture;
  65691. /**
  65692. * Serialize the rendering pipeline (Used when exporting)
  65693. * @returns the serialized object
  65694. */
  65695. serialize(): any;
  65696. /**
  65697. * Parse the serialized pipeline
  65698. * @param source Source pipeline.
  65699. * @param scene The scene to load the pipeline to.
  65700. * @param rootUrl The URL of the serialized pipeline.
  65701. * @returns An instantiated pipeline from the serialized object.
  65702. */
  65703. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  65704. }
  65705. }
  65706. declare module BABYLON {
  65707. /** @hidden */
  65708. export var ssaoPixelShader: {
  65709. name: string;
  65710. shader: string;
  65711. };
  65712. }
  65713. declare module BABYLON {
  65714. /**
  65715. * Render pipeline to produce ssao effect
  65716. */
  65717. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  65718. /**
  65719. * @ignore
  65720. * The PassPostProcess id in the pipeline that contains the original scene color
  65721. */
  65722. SSAOOriginalSceneColorEffect: string;
  65723. /**
  65724. * @ignore
  65725. * The SSAO PostProcess id in the pipeline
  65726. */
  65727. SSAORenderEffect: string;
  65728. /**
  65729. * @ignore
  65730. * The horizontal blur PostProcess id in the pipeline
  65731. */
  65732. SSAOBlurHRenderEffect: string;
  65733. /**
  65734. * @ignore
  65735. * The vertical blur PostProcess id in the pipeline
  65736. */
  65737. SSAOBlurVRenderEffect: string;
  65738. /**
  65739. * @ignore
  65740. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  65741. */
  65742. SSAOCombineRenderEffect: string;
  65743. /**
  65744. * The output strength of the SSAO post-process. Default value is 1.0.
  65745. */
  65746. totalStrength: number;
  65747. /**
  65748. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  65749. */
  65750. radius: number;
  65751. /**
  65752. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  65753. * Must not be equal to fallOff and superior to fallOff.
  65754. * Default value is 0.0075
  65755. */
  65756. area: number;
  65757. /**
  65758. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  65759. * Must not be equal to area and inferior to area.
  65760. * Default value is 0.000001
  65761. */
  65762. fallOff: number;
  65763. /**
  65764. * The base color of the SSAO post-process
  65765. * The final result is "base + ssao" between [0, 1]
  65766. */
  65767. base: number;
  65768. private _scene;
  65769. private _depthTexture;
  65770. private _randomTexture;
  65771. private _originalColorPostProcess;
  65772. private _ssaoPostProcess;
  65773. private _blurHPostProcess;
  65774. private _blurVPostProcess;
  65775. private _ssaoCombinePostProcess;
  65776. private _firstUpdate;
  65777. /**
  65778. * Gets active scene
  65779. */
  65780. get scene(): Scene;
  65781. /**
  65782. * @constructor
  65783. * @param name - The rendering pipeline name
  65784. * @param scene - The scene linked to this pipeline
  65785. * @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 }
  65786. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  65787. */
  65788. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  65789. /**
  65790. * Get the class name
  65791. * @returns "SSAORenderingPipeline"
  65792. */
  65793. getClassName(): string;
  65794. /**
  65795. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  65796. */
  65797. dispose(disableDepthRender?: boolean): void;
  65798. private _createBlurPostProcess;
  65799. /** @hidden */
  65800. _rebuild(): void;
  65801. private _createSSAOPostProcess;
  65802. private _createSSAOCombinePostProcess;
  65803. private _createRandomTexture;
  65804. }
  65805. }
  65806. declare module BABYLON {
  65807. /** @hidden */
  65808. export var screenSpaceReflectionPixelShader: {
  65809. name: string;
  65810. shader: string;
  65811. };
  65812. }
  65813. declare module BABYLON {
  65814. /**
  65815. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  65816. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  65817. */
  65818. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  65819. /**
  65820. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  65821. */
  65822. threshold: number;
  65823. /**
  65824. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  65825. */
  65826. strength: number;
  65827. /**
  65828. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  65829. */
  65830. reflectionSpecularFalloffExponent: number;
  65831. /**
  65832. * 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]
  65833. */
  65834. step: number;
  65835. /**
  65836. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  65837. */
  65838. roughnessFactor: number;
  65839. private _geometryBufferRenderer;
  65840. private _enableSmoothReflections;
  65841. private _reflectionSamples;
  65842. private _smoothSteps;
  65843. /**
  65844. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  65845. * @param name The name of the effect.
  65846. * @param scene The scene containing the objects to calculate reflections.
  65847. * @param options The required width/height ratio to downsize to before computing the render pass.
  65848. * @param camera The camera to apply the render pass to.
  65849. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65850. * @param engine The engine which the post process will be applied. (default: current engine)
  65851. * @param reusable If the post process can be reused on the same frame. (default: false)
  65852. * @param textureType Type of textures used when performing the post process. (default: 0)
  65853. * @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)
  65854. */
  65855. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  65856. /**
  65857. * Gets wether or not smoothing reflections is enabled.
  65858. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  65859. */
  65860. get enableSmoothReflections(): boolean;
  65861. /**
  65862. * Sets wether or not smoothing reflections is enabled.
  65863. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  65864. */
  65865. set enableSmoothReflections(enabled: boolean);
  65866. /**
  65867. * Gets the number of samples taken while computing reflections. More samples count is high,
  65868. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  65869. */
  65870. get reflectionSamples(): number;
  65871. /**
  65872. * Sets the number of samples taken while computing reflections. More samples count is high,
  65873. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  65874. */
  65875. set reflectionSamples(samples: number);
  65876. /**
  65877. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  65878. * more the post-process will require GPU power and can generate a drop in FPS.
  65879. * Default value (5.0) work pretty well in all cases but can be adjusted.
  65880. */
  65881. get smoothSteps(): number;
  65882. set smoothSteps(steps: number);
  65883. private _updateEffectDefines;
  65884. }
  65885. }
  65886. declare module BABYLON {
  65887. /** @hidden */
  65888. export var standardPixelShader: {
  65889. name: string;
  65890. shader: string;
  65891. };
  65892. }
  65893. declare module BABYLON {
  65894. /**
  65895. * Standard rendering pipeline
  65896. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  65897. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  65898. */
  65899. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  65900. /**
  65901. * Public members
  65902. */
  65903. /**
  65904. * Post-process which contains the original scene color before the pipeline applies all the effects
  65905. */
  65906. originalPostProcess: Nullable<PostProcess>;
  65907. /**
  65908. * Post-process used to down scale an image x4
  65909. */
  65910. downSampleX4PostProcess: Nullable<PostProcess>;
  65911. /**
  65912. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  65913. */
  65914. brightPassPostProcess: Nullable<PostProcess>;
  65915. /**
  65916. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  65917. */
  65918. blurHPostProcesses: PostProcess[];
  65919. /**
  65920. * Post-process array storing all the vertical blur post-processes used by the pipeline
  65921. */
  65922. blurVPostProcesses: PostProcess[];
  65923. /**
  65924. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  65925. */
  65926. textureAdderPostProcess: Nullable<PostProcess>;
  65927. /**
  65928. * Post-process used to create volumetric lighting effect
  65929. */
  65930. volumetricLightPostProcess: Nullable<PostProcess>;
  65931. /**
  65932. * Post-process used to smooth the previous volumetric light post-process on the X axis
  65933. */
  65934. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  65935. /**
  65936. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  65937. */
  65938. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  65939. /**
  65940. * Post-process used to merge the volumetric light effect and the real scene color
  65941. */
  65942. volumetricLightMergePostProces: Nullable<PostProcess>;
  65943. /**
  65944. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  65945. */
  65946. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  65947. /**
  65948. * Base post-process used to calculate the average luminance of the final image for HDR
  65949. */
  65950. luminancePostProcess: Nullable<PostProcess>;
  65951. /**
  65952. * Post-processes used to create down sample post-processes in order to get
  65953. * the average luminance of the final image for HDR
  65954. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  65955. */
  65956. luminanceDownSamplePostProcesses: PostProcess[];
  65957. /**
  65958. * Post-process used to create a HDR effect (light adaptation)
  65959. */
  65960. hdrPostProcess: Nullable<PostProcess>;
  65961. /**
  65962. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  65963. */
  65964. textureAdderFinalPostProcess: Nullable<PostProcess>;
  65965. /**
  65966. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  65967. */
  65968. lensFlareFinalPostProcess: Nullable<PostProcess>;
  65969. /**
  65970. * Post-process used to merge the final HDR post-process and the real scene color
  65971. */
  65972. hdrFinalPostProcess: Nullable<PostProcess>;
  65973. /**
  65974. * Post-process used to create a lens flare effect
  65975. */
  65976. lensFlarePostProcess: Nullable<PostProcess>;
  65977. /**
  65978. * Post-process that merges the result of the lens flare post-process and the real scene color
  65979. */
  65980. lensFlareComposePostProcess: Nullable<PostProcess>;
  65981. /**
  65982. * Post-process used to create a motion blur effect
  65983. */
  65984. motionBlurPostProcess: Nullable<PostProcess>;
  65985. /**
  65986. * Post-process used to create a depth of field effect
  65987. */
  65988. depthOfFieldPostProcess: Nullable<PostProcess>;
  65989. /**
  65990. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  65991. */
  65992. fxaaPostProcess: Nullable<FxaaPostProcess>;
  65993. /**
  65994. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  65995. */
  65996. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  65997. /**
  65998. * Represents the brightness threshold in order to configure the illuminated surfaces
  65999. */
  66000. brightThreshold: number;
  66001. /**
  66002. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  66003. */
  66004. blurWidth: number;
  66005. /**
  66006. * Sets if the blur for highlighted surfaces must be only horizontal
  66007. */
  66008. horizontalBlur: boolean;
  66009. /**
  66010. * Gets the overall exposure used by the pipeline
  66011. */
  66012. get exposure(): number;
  66013. /**
  66014. * Sets the overall exposure used by the pipeline
  66015. */
  66016. set exposure(value: number);
  66017. /**
  66018. * Texture used typically to simulate "dirty" on camera lens
  66019. */
  66020. lensTexture: Nullable<Texture>;
  66021. /**
  66022. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  66023. */
  66024. volumetricLightCoefficient: number;
  66025. /**
  66026. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  66027. */
  66028. volumetricLightPower: number;
  66029. /**
  66030. * Used the set the blur intensity to smooth the volumetric lights
  66031. */
  66032. volumetricLightBlurScale: number;
  66033. /**
  66034. * Light (spot or directional) used to generate the volumetric lights rays
  66035. * The source light must have a shadow generate so the pipeline can get its
  66036. * depth map
  66037. */
  66038. sourceLight: Nullable<SpotLight | DirectionalLight>;
  66039. /**
  66040. * For eye adaptation, represents the minimum luminance the eye can see
  66041. */
  66042. hdrMinimumLuminance: number;
  66043. /**
  66044. * For eye adaptation, represents the decrease luminance speed
  66045. */
  66046. hdrDecreaseRate: number;
  66047. /**
  66048. * For eye adaptation, represents the increase luminance speed
  66049. */
  66050. hdrIncreaseRate: number;
  66051. /**
  66052. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  66053. */
  66054. get hdrAutoExposure(): boolean;
  66055. /**
  66056. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  66057. */
  66058. set hdrAutoExposure(value: boolean);
  66059. /**
  66060. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  66061. */
  66062. lensColorTexture: Nullable<Texture>;
  66063. /**
  66064. * The overall strengh for the lens flare effect
  66065. */
  66066. lensFlareStrength: number;
  66067. /**
  66068. * Dispersion coefficient for lens flare ghosts
  66069. */
  66070. lensFlareGhostDispersal: number;
  66071. /**
  66072. * Main lens flare halo width
  66073. */
  66074. lensFlareHaloWidth: number;
  66075. /**
  66076. * Based on the lens distortion effect, defines how much the lens flare result
  66077. * is distorted
  66078. */
  66079. lensFlareDistortionStrength: number;
  66080. /**
  66081. * Configures the blur intensity used for for lens flare (halo)
  66082. */
  66083. lensFlareBlurWidth: number;
  66084. /**
  66085. * Lens star texture must be used to simulate rays on the flares and is available
  66086. * in the documentation
  66087. */
  66088. lensStarTexture: Nullable<Texture>;
  66089. /**
  66090. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  66091. * flare effect by taking account of the dirt texture
  66092. */
  66093. lensFlareDirtTexture: Nullable<Texture>;
  66094. /**
  66095. * Represents the focal length for the depth of field effect
  66096. */
  66097. depthOfFieldDistance: number;
  66098. /**
  66099. * Represents the blur intensity for the blurred part of the depth of field effect
  66100. */
  66101. depthOfFieldBlurWidth: number;
  66102. /**
  66103. * Gets how much the image is blurred by the movement while using the motion blur post-process
  66104. */
  66105. get motionStrength(): number;
  66106. /**
  66107. * Sets how much the image is blurred by the movement while using the motion blur post-process
  66108. */
  66109. set motionStrength(strength: number);
  66110. /**
  66111. * Gets wether or not the motion blur post-process is object based or screen based.
  66112. */
  66113. get objectBasedMotionBlur(): boolean;
  66114. /**
  66115. * Sets wether or not the motion blur post-process should be object based or screen based
  66116. */
  66117. set objectBasedMotionBlur(value: boolean);
  66118. /**
  66119. * List of animations for the pipeline (IAnimatable implementation)
  66120. */
  66121. animations: Animation[];
  66122. /**
  66123. * Private members
  66124. */
  66125. private _scene;
  66126. private _currentDepthOfFieldSource;
  66127. private _basePostProcess;
  66128. private _fixedExposure;
  66129. private _currentExposure;
  66130. private _hdrAutoExposure;
  66131. private _hdrCurrentLuminance;
  66132. private _motionStrength;
  66133. private _isObjectBasedMotionBlur;
  66134. private _floatTextureType;
  66135. private _camerasToBeAttached;
  66136. private _ratio;
  66137. private _bloomEnabled;
  66138. private _depthOfFieldEnabled;
  66139. private _vlsEnabled;
  66140. private _lensFlareEnabled;
  66141. private _hdrEnabled;
  66142. private _motionBlurEnabled;
  66143. private _fxaaEnabled;
  66144. private _screenSpaceReflectionsEnabled;
  66145. private _motionBlurSamples;
  66146. private _volumetricLightStepsCount;
  66147. private _samples;
  66148. /**
  66149. * @ignore
  66150. * Specifies if the bloom pipeline is enabled
  66151. */
  66152. get BloomEnabled(): boolean;
  66153. set BloomEnabled(enabled: boolean);
  66154. /**
  66155. * @ignore
  66156. * Specifies if the depth of field pipeline is enabed
  66157. */
  66158. get DepthOfFieldEnabled(): boolean;
  66159. set DepthOfFieldEnabled(enabled: boolean);
  66160. /**
  66161. * @ignore
  66162. * Specifies if the lens flare pipeline is enabed
  66163. */
  66164. get LensFlareEnabled(): boolean;
  66165. set LensFlareEnabled(enabled: boolean);
  66166. /**
  66167. * @ignore
  66168. * Specifies if the HDR pipeline is enabled
  66169. */
  66170. get HDREnabled(): boolean;
  66171. set HDREnabled(enabled: boolean);
  66172. /**
  66173. * @ignore
  66174. * Specifies if the volumetric lights scattering effect is enabled
  66175. */
  66176. get VLSEnabled(): boolean;
  66177. set VLSEnabled(enabled: boolean);
  66178. /**
  66179. * @ignore
  66180. * Specifies if the motion blur effect is enabled
  66181. */
  66182. get MotionBlurEnabled(): boolean;
  66183. set MotionBlurEnabled(enabled: boolean);
  66184. /**
  66185. * Specifies if anti-aliasing is enabled
  66186. */
  66187. get fxaaEnabled(): boolean;
  66188. set fxaaEnabled(enabled: boolean);
  66189. /**
  66190. * Specifies if screen space reflections are enabled.
  66191. */
  66192. get screenSpaceReflectionsEnabled(): boolean;
  66193. set screenSpaceReflectionsEnabled(enabled: boolean);
  66194. /**
  66195. * Specifies the number of steps used to calculate the volumetric lights
  66196. * Typically in interval [50, 200]
  66197. */
  66198. get volumetricLightStepsCount(): number;
  66199. set volumetricLightStepsCount(count: number);
  66200. /**
  66201. * Specifies the number of samples used for the motion blur effect
  66202. * Typically in interval [16, 64]
  66203. */
  66204. get motionBlurSamples(): number;
  66205. set motionBlurSamples(samples: number);
  66206. /**
  66207. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  66208. */
  66209. get samples(): number;
  66210. set samples(sampleCount: number);
  66211. /**
  66212. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  66213. * @constructor
  66214. * @param name The rendering pipeline name
  66215. * @param scene The scene linked to this pipeline
  66216. * @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)
  66217. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  66218. * @param cameras The array of cameras that the rendering pipeline will be attached to
  66219. */
  66220. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  66221. private _buildPipeline;
  66222. private _createDownSampleX4PostProcess;
  66223. private _createBrightPassPostProcess;
  66224. private _createBlurPostProcesses;
  66225. private _createTextureAdderPostProcess;
  66226. private _createVolumetricLightPostProcess;
  66227. private _createLuminancePostProcesses;
  66228. private _createHdrPostProcess;
  66229. private _createLensFlarePostProcess;
  66230. private _createDepthOfFieldPostProcess;
  66231. private _createMotionBlurPostProcess;
  66232. private _getDepthTexture;
  66233. private _disposePostProcesses;
  66234. /**
  66235. * Dispose of the pipeline and stop all post processes
  66236. */
  66237. dispose(): void;
  66238. /**
  66239. * Serialize the rendering pipeline (Used when exporting)
  66240. * @returns the serialized object
  66241. */
  66242. serialize(): any;
  66243. /**
  66244. * Parse the serialized pipeline
  66245. * @param source Source pipeline.
  66246. * @param scene The scene to load the pipeline to.
  66247. * @param rootUrl The URL of the serialized pipeline.
  66248. * @returns An instantiated pipeline from the serialized object.
  66249. */
  66250. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  66251. /**
  66252. * Luminance steps
  66253. */
  66254. static LuminanceSteps: number;
  66255. }
  66256. }
  66257. declare module BABYLON {
  66258. /** @hidden */
  66259. export var tonemapPixelShader: {
  66260. name: string;
  66261. shader: string;
  66262. };
  66263. }
  66264. declare module BABYLON {
  66265. /** Defines operator used for tonemapping */
  66266. export enum TonemappingOperator {
  66267. /** Hable */
  66268. Hable = 0,
  66269. /** Reinhard */
  66270. Reinhard = 1,
  66271. /** HejiDawson */
  66272. HejiDawson = 2,
  66273. /** Photographic */
  66274. Photographic = 3
  66275. }
  66276. /**
  66277. * Defines a post process to apply tone mapping
  66278. */
  66279. export class TonemapPostProcess extends PostProcess {
  66280. private _operator;
  66281. /** Defines the required exposure adjustement */
  66282. exposureAdjustment: number;
  66283. /**
  66284. * Creates a new TonemapPostProcess
  66285. * @param name defines the name of the postprocess
  66286. * @param _operator defines the operator to use
  66287. * @param exposureAdjustment defines the required exposure adjustement
  66288. * @param camera defines the camera to use (can be null)
  66289. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  66290. * @param engine defines the hosting engine (can be ignore if camera is set)
  66291. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  66292. */
  66293. constructor(name: string, _operator: TonemappingOperator,
  66294. /** Defines the required exposure adjustement */
  66295. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  66296. }
  66297. }
  66298. declare module BABYLON {
  66299. /** @hidden */
  66300. export var volumetricLightScatteringPixelShader: {
  66301. name: string;
  66302. shader: string;
  66303. };
  66304. }
  66305. declare module BABYLON {
  66306. /** @hidden */
  66307. export var volumetricLightScatteringPassVertexShader: {
  66308. name: string;
  66309. shader: string;
  66310. };
  66311. }
  66312. declare module BABYLON {
  66313. /** @hidden */
  66314. export var volumetricLightScatteringPassPixelShader: {
  66315. name: string;
  66316. shader: string;
  66317. };
  66318. }
  66319. declare module BABYLON {
  66320. /**
  66321. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  66322. */
  66323. export class VolumetricLightScatteringPostProcess extends PostProcess {
  66324. private _volumetricLightScatteringPass;
  66325. private _volumetricLightScatteringRTT;
  66326. private _viewPort;
  66327. private _screenCoordinates;
  66328. private _cachedDefines;
  66329. /**
  66330. * If not undefined, the mesh position is computed from the attached node position
  66331. */
  66332. attachedNode: {
  66333. position: Vector3;
  66334. };
  66335. /**
  66336. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  66337. */
  66338. customMeshPosition: Vector3;
  66339. /**
  66340. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  66341. */
  66342. useCustomMeshPosition: boolean;
  66343. /**
  66344. * If the post-process should inverse the light scattering direction
  66345. */
  66346. invert: boolean;
  66347. /**
  66348. * The internal mesh used by the post-process
  66349. */
  66350. mesh: Mesh;
  66351. /**
  66352. * @hidden
  66353. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  66354. */
  66355. get useDiffuseColor(): boolean;
  66356. set useDiffuseColor(useDiffuseColor: boolean);
  66357. /**
  66358. * Array containing the excluded meshes not rendered in the internal pass
  66359. */
  66360. excludedMeshes: AbstractMesh[];
  66361. /**
  66362. * Controls the overall intensity of the post-process
  66363. */
  66364. exposure: number;
  66365. /**
  66366. * Dissipates each sample's contribution in range [0, 1]
  66367. */
  66368. decay: number;
  66369. /**
  66370. * Controls the overall intensity of each sample
  66371. */
  66372. weight: number;
  66373. /**
  66374. * Controls the density of each sample
  66375. */
  66376. density: number;
  66377. /**
  66378. * @constructor
  66379. * @param name The post-process name
  66380. * @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)
  66381. * @param camera The camera that the post-process will be attached to
  66382. * @param mesh The mesh used to create the light scattering
  66383. * @param samples The post-process quality, default 100
  66384. * @param samplingModeThe post-process filtering mode
  66385. * @param engine The babylon engine
  66386. * @param reusable If the post-process is reusable
  66387. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  66388. */
  66389. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  66390. /**
  66391. * Returns the string "VolumetricLightScatteringPostProcess"
  66392. * @returns "VolumetricLightScatteringPostProcess"
  66393. */
  66394. getClassName(): string;
  66395. private _isReady;
  66396. /**
  66397. * Sets the new light position for light scattering effect
  66398. * @param position The new custom light position
  66399. */
  66400. setCustomMeshPosition(position: Vector3): void;
  66401. /**
  66402. * Returns the light position for light scattering effect
  66403. * @return Vector3 The custom light position
  66404. */
  66405. getCustomMeshPosition(): Vector3;
  66406. /**
  66407. * Disposes the internal assets and detaches the post-process from the camera
  66408. */
  66409. dispose(camera: Camera): void;
  66410. /**
  66411. * Returns the render target texture used by the post-process
  66412. * @return the render target texture used by the post-process
  66413. */
  66414. getPass(): RenderTargetTexture;
  66415. private _meshExcluded;
  66416. private _createPass;
  66417. private _updateMeshScreenCoordinates;
  66418. /**
  66419. * Creates a default mesh for the Volumeric Light Scattering post-process
  66420. * @param name The mesh name
  66421. * @param scene The scene where to create the mesh
  66422. * @return the default mesh
  66423. */
  66424. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  66425. }
  66426. }
  66427. declare module BABYLON {
  66428. interface Scene {
  66429. /** @hidden (Backing field) */
  66430. _boundingBoxRenderer: BoundingBoxRenderer;
  66431. /** @hidden (Backing field) */
  66432. _forceShowBoundingBoxes: boolean;
  66433. /**
  66434. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  66435. */
  66436. forceShowBoundingBoxes: boolean;
  66437. /**
  66438. * Gets the bounding box renderer associated with the scene
  66439. * @returns a BoundingBoxRenderer
  66440. */
  66441. getBoundingBoxRenderer(): BoundingBoxRenderer;
  66442. }
  66443. interface AbstractMesh {
  66444. /** @hidden (Backing field) */
  66445. _showBoundingBox: boolean;
  66446. /**
  66447. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  66448. */
  66449. showBoundingBox: boolean;
  66450. }
  66451. /**
  66452. * Component responsible of rendering the bounding box of the meshes in a scene.
  66453. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  66454. */
  66455. export class BoundingBoxRenderer implements ISceneComponent {
  66456. /**
  66457. * The component name helpfull to identify the component in the list of scene components.
  66458. */
  66459. readonly name: string;
  66460. /**
  66461. * The scene the component belongs to.
  66462. */
  66463. scene: Scene;
  66464. /**
  66465. * Color of the bounding box lines placed in front of an object
  66466. */
  66467. frontColor: Color3;
  66468. /**
  66469. * Color of the bounding box lines placed behind an object
  66470. */
  66471. backColor: Color3;
  66472. /**
  66473. * Defines if the renderer should show the back lines or not
  66474. */
  66475. showBackLines: boolean;
  66476. /**
  66477. * @hidden
  66478. */
  66479. renderList: SmartArray<BoundingBox>;
  66480. private _colorShader;
  66481. private _vertexBuffers;
  66482. private _indexBuffer;
  66483. private _fillIndexBuffer;
  66484. private _fillIndexData;
  66485. /**
  66486. * Instantiates a new bounding box renderer in a scene.
  66487. * @param scene the scene the renderer renders in
  66488. */
  66489. constructor(scene: Scene);
  66490. /**
  66491. * Registers the component in a given scene
  66492. */
  66493. register(): void;
  66494. private _evaluateSubMesh;
  66495. private _activeMesh;
  66496. private _prepareRessources;
  66497. private _createIndexBuffer;
  66498. /**
  66499. * Rebuilds the elements related to this component in case of
  66500. * context lost for instance.
  66501. */
  66502. rebuild(): void;
  66503. /**
  66504. * @hidden
  66505. */
  66506. reset(): void;
  66507. /**
  66508. * Render the bounding boxes of a specific rendering group
  66509. * @param renderingGroupId defines the rendering group to render
  66510. */
  66511. render(renderingGroupId: number): void;
  66512. /**
  66513. * In case of occlusion queries, we can render the occlusion bounding box through this method
  66514. * @param mesh Define the mesh to render the occlusion bounding box for
  66515. */
  66516. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  66517. /**
  66518. * Dispose and release the resources attached to this renderer.
  66519. */
  66520. dispose(): void;
  66521. }
  66522. }
  66523. declare module BABYLON {
  66524. interface Scene {
  66525. /** @hidden (Backing field) */
  66526. _depthRenderer: {
  66527. [id: string]: DepthRenderer;
  66528. };
  66529. /**
  66530. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  66531. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  66532. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  66533. * @returns the created depth renderer
  66534. */
  66535. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  66536. /**
  66537. * Disables a depth renderer for a given camera
  66538. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  66539. */
  66540. disableDepthRenderer(camera?: Nullable<Camera>): void;
  66541. }
  66542. /**
  66543. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  66544. * in several rendering techniques.
  66545. */
  66546. export class DepthRendererSceneComponent implements ISceneComponent {
  66547. /**
  66548. * The component name helpfull to identify the component in the list of scene components.
  66549. */
  66550. readonly name: string;
  66551. /**
  66552. * The scene the component belongs to.
  66553. */
  66554. scene: Scene;
  66555. /**
  66556. * Creates a new instance of the component for the given scene
  66557. * @param scene Defines the scene to register the component in
  66558. */
  66559. constructor(scene: Scene);
  66560. /**
  66561. * Registers the component in a given scene
  66562. */
  66563. register(): void;
  66564. /**
  66565. * Rebuilds the elements related to this component in case of
  66566. * context lost for instance.
  66567. */
  66568. rebuild(): void;
  66569. /**
  66570. * Disposes the component and the associated ressources
  66571. */
  66572. dispose(): void;
  66573. private _gatherRenderTargets;
  66574. private _gatherActiveCameraRenderTargets;
  66575. }
  66576. }
  66577. declare module BABYLON {
  66578. /** @hidden */
  66579. export var outlinePixelShader: {
  66580. name: string;
  66581. shader: string;
  66582. };
  66583. }
  66584. declare module BABYLON {
  66585. /** @hidden */
  66586. export var outlineVertexShader: {
  66587. name: string;
  66588. shader: string;
  66589. };
  66590. }
  66591. declare module BABYLON {
  66592. interface Scene {
  66593. /** @hidden */
  66594. _outlineRenderer: OutlineRenderer;
  66595. /**
  66596. * Gets the outline renderer associated with the scene
  66597. * @returns a OutlineRenderer
  66598. */
  66599. getOutlineRenderer(): OutlineRenderer;
  66600. }
  66601. interface AbstractMesh {
  66602. /** @hidden (Backing field) */
  66603. _renderOutline: boolean;
  66604. /**
  66605. * Gets or sets a boolean indicating if the outline must be rendered as well
  66606. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  66607. */
  66608. renderOutline: boolean;
  66609. /** @hidden (Backing field) */
  66610. _renderOverlay: boolean;
  66611. /**
  66612. * Gets or sets a boolean indicating if the overlay must be rendered as well
  66613. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  66614. */
  66615. renderOverlay: boolean;
  66616. }
  66617. /**
  66618. * This class is responsible to draw bothe outline/overlay of meshes.
  66619. * It should not be used directly but through the available method on mesh.
  66620. */
  66621. export class OutlineRenderer implements ISceneComponent {
  66622. /**
  66623. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  66624. */
  66625. private static _StencilReference;
  66626. /**
  66627. * The name of the component. Each component must have a unique name.
  66628. */
  66629. name: string;
  66630. /**
  66631. * The scene the component belongs to.
  66632. */
  66633. scene: Scene;
  66634. /**
  66635. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  66636. */
  66637. zOffset: number;
  66638. private _engine;
  66639. private _effect;
  66640. private _cachedDefines;
  66641. private _savedDepthWrite;
  66642. /**
  66643. * Instantiates a new outline renderer. (There could be only one per scene).
  66644. * @param scene Defines the scene it belongs to
  66645. */
  66646. constructor(scene: Scene);
  66647. /**
  66648. * Register the component to one instance of a scene.
  66649. */
  66650. register(): void;
  66651. /**
  66652. * Rebuilds the elements related to this component in case of
  66653. * context lost for instance.
  66654. */
  66655. rebuild(): void;
  66656. /**
  66657. * Disposes the component and the associated ressources.
  66658. */
  66659. dispose(): void;
  66660. /**
  66661. * Renders the outline in the canvas.
  66662. * @param subMesh Defines the sumesh to render
  66663. * @param batch Defines the batch of meshes in case of instances
  66664. * @param useOverlay Defines if the rendering is for the overlay or the outline
  66665. */
  66666. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  66667. /**
  66668. * Returns whether or not the outline renderer is ready for a given submesh.
  66669. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  66670. * @param subMesh Defines the submesh to check readyness for
  66671. * @param useInstances Defines wheter wee are trying to render instances or not
  66672. * @returns true if ready otherwise false
  66673. */
  66674. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  66675. private _beforeRenderingMesh;
  66676. private _afterRenderingMesh;
  66677. }
  66678. }
  66679. declare module BABYLON {
  66680. /**
  66681. * Defines the basic options interface of a Sprite Frame Source Size.
  66682. */
  66683. export interface ISpriteJSONSpriteSourceSize {
  66684. /**
  66685. * number of the original width of the Frame
  66686. */
  66687. w: number;
  66688. /**
  66689. * number of the original height of the Frame
  66690. */
  66691. h: number;
  66692. }
  66693. /**
  66694. * Defines the basic options interface of a Sprite Frame Data.
  66695. */
  66696. export interface ISpriteJSONSpriteFrameData {
  66697. /**
  66698. * number of the x offset of the Frame
  66699. */
  66700. x: number;
  66701. /**
  66702. * number of the y offset of the Frame
  66703. */
  66704. y: number;
  66705. /**
  66706. * number of the width of the Frame
  66707. */
  66708. w: number;
  66709. /**
  66710. * number of the height of the Frame
  66711. */
  66712. h: number;
  66713. }
  66714. /**
  66715. * Defines the basic options interface of a JSON Sprite.
  66716. */
  66717. export interface ISpriteJSONSprite {
  66718. /**
  66719. * string name of the Frame
  66720. */
  66721. filename: string;
  66722. /**
  66723. * ISpriteJSONSpriteFrame basic object of the frame data
  66724. */
  66725. frame: ISpriteJSONSpriteFrameData;
  66726. /**
  66727. * boolean to flag is the frame was rotated.
  66728. */
  66729. rotated: boolean;
  66730. /**
  66731. * boolean to flag is the frame was trimmed.
  66732. */
  66733. trimmed: boolean;
  66734. /**
  66735. * ISpriteJSONSpriteFrame basic object of the source data
  66736. */
  66737. spriteSourceSize: ISpriteJSONSpriteFrameData;
  66738. /**
  66739. * ISpriteJSONSpriteFrame basic object of the source data
  66740. */
  66741. sourceSize: ISpriteJSONSpriteSourceSize;
  66742. }
  66743. /**
  66744. * Defines the basic options interface of a JSON atlas.
  66745. */
  66746. export interface ISpriteJSONAtlas {
  66747. /**
  66748. * Array of objects that contain the frame data.
  66749. */
  66750. frames: Array<ISpriteJSONSprite>;
  66751. /**
  66752. * object basic object containing the sprite meta data.
  66753. */
  66754. meta?: object;
  66755. }
  66756. }
  66757. declare module BABYLON {
  66758. /** @hidden */
  66759. export var spriteMapPixelShader: {
  66760. name: string;
  66761. shader: string;
  66762. };
  66763. }
  66764. declare module BABYLON {
  66765. /** @hidden */
  66766. export var spriteMapVertexShader: {
  66767. name: string;
  66768. shader: string;
  66769. };
  66770. }
  66771. declare module BABYLON {
  66772. /**
  66773. * Defines the basic options interface of a SpriteMap
  66774. */
  66775. export interface ISpriteMapOptions {
  66776. /**
  66777. * Vector2 of the number of cells in the grid.
  66778. */
  66779. stageSize?: Vector2;
  66780. /**
  66781. * Vector2 of the size of the output plane in World Units.
  66782. */
  66783. outputSize?: Vector2;
  66784. /**
  66785. * Vector3 of the position of the output plane in World Units.
  66786. */
  66787. outputPosition?: Vector3;
  66788. /**
  66789. * Vector3 of the rotation of the output plane.
  66790. */
  66791. outputRotation?: Vector3;
  66792. /**
  66793. * number of layers that the system will reserve in resources.
  66794. */
  66795. layerCount?: number;
  66796. /**
  66797. * number of max animation frames a single cell will reserve in resources.
  66798. */
  66799. maxAnimationFrames?: number;
  66800. /**
  66801. * number cell index of the base tile when the system compiles.
  66802. */
  66803. baseTile?: number;
  66804. /**
  66805. * boolean flip the sprite after its been repositioned by the framing data.
  66806. */
  66807. flipU?: boolean;
  66808. /**
  66809. * Vector3 scalar of the global RGB values of the SpriteMap.
  66810. */
  66811. colorMultiply?: Vector3;
  66812. }
  66813. /**
  66814. * Defines the IDisposable interface in order to be cleanable from resources.
  66815. */
  66816. export interface ISpriteMap extends IDisposable {
  66817. /**
  66818. * String name of the SpriteMap.
  66819. */
  66820. name: string;
  66821. /**
  66822. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  66823. */
  66824. atlasJSON: ISpriteJSONAtlas;
  66825. /**
  66826. * Texture of the SpriteMap.
  66827. */
  66828. spriteSheet: Texture;
  66829. /**
  66830. * The parameters to initialize the SpriteMap with.
  66831. */
  66832. options: ISpriteMapOptions;
  66833. }
  66834. /**
  66835. * Class used to manage a grid restricted sprite deployment on an Output plane.
  66836. */
  66837. export class SpriteMap implements ISpriteMap {
  66838. /** The Name of the spriteMap */
  66839. name: string;
  66840. /** The JSON file with the frame and meta data */
  66841. atlasJSON: ISpriteJSONAtlas;
  66842. /** The systems Sprite Sheet Texture */
  66843. spriteSheet: Texture;
  66844. /** Arguments passed with the Constructor */
  66845. options: ISpriteMapOptions;
  66846. /** Public Sprite Storage array, parsed from atlasJSON */
  66847. sprites: Array<ISpriteJSONSprite>;
  66848. /** Returns the Number of Sprites in the System */
  66849. get spriteCount(): number;
  66850. /** Returns the Position of Output Plane*/
  66851. get position(): Vector3;
  66852. /** Returns the Position of Output Plane*/
  66853. set position(v: Vector3);
  66854. /** Returns the Rotation of Output Plane*/
  66855. get rotation(): Vector3;
  66856. /** Returns the Rotation of Output Plane*/
  66857. set rotation(v: Vector3);
  66858. /** Sets the AnimationMap*/
  66859. get animationMap(): RawTexture;
  66860. /** Sets the AnimationMap*/
  66861. set animationMap(v: RawTexture);
  66862. /** Scene that the SpriteMap was created in */
  66863. private _scene;
  66864. /** Texture Buffer of Float32 that holds tile frame data*/
  66865. private _frameMap;
  66866. /** Texture Buffers of Float32 that holds tileMap data*/
  66867. private _tileMaps;
  66868. /** Texture Buffer of Float32 that holds Animation Data*/
  66869. private _animationMap;
  66870. /** Custom ShaderMaterial Central to the System*/
  66871. private _material;
  66872. /** Custom ShaderMaterial Central to the System*/
  66873. private _output;
  66874. /** Systems Time Ticker*/
  66875. private _time;
  66876. /**
  66877. * Creates a new SpriteMap
  66878. * @param name defines the SpriteMaps Name
  66879. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  66880. * @param spriteSheet is the Texture that the Sprites are on.
  66881. * @param options a basic deployment configuration
  66882. * @param scene The Scene that the map is deployed on
  66883. */
  66884. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  66885. /**
  66886. * Returns tileID location
  66887. * @returns Vector2 the cell position ID
  66888. */
  66889. getTileID(): Vector2;
  66890. /**
  66891. * Gets the UV location of the mouse over the SpriteMap.
  66892. * @returns Vector2 the UV position of the mouse interaction
  66893. */
  66894. getMousePosition(): Vector2;
  66895. /**
  66896. * Creates the "frame" texture Buffer
  66897. * -------------------------------------
  66898. * Structure of frames
  66899. * "filename": "Falling-Water-2.png",
  66900. * "frame": {"x":69,"y":103,"w":24,"h":32},
  66901. * "rotated": true,
  66902. * "trimmed": true,
  66903. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  66904. * "sourceSize": {"w":32,"h":32}
  66905. * @returns RawTexture of the frameMap
  66906. */
  66907. private _createFrameBuffer;
  66908. /**
  66909. * Creates the tileMap texture Buffer
  66910. * @param buffer normally and array of numbers, or a false to generate from scratch
  66911. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  66912. * @returns RawTexture of the tileMap
  66913. */
  66914. private _createTileBuffer;
  66915. /**
  66916. * Modifies the data of the tileMaps
  66917. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  66918. * @param pos is the iVector2 Coordinates of the Tile
  66919. * @param tile The SpriteIndex of the new Tile
  66920. */
  66921. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  66922. /**
  66923. * Creates the animationMap texture Buffer
  66924. * @param buffer normally and array of numbers, or a false to generate from scratch
  66925. * @returns RawTexture of the animationMap
  66926. */
  66927. private _createTileAnimationBuffer;
  66928. /**
  66929. * Modifies the data of the animationMap
  66930. * @param cellID is the Index of the Sprite
  66931. * @param _frame is the target Animation frame
  66932. * @param toCell is the Target Index of the next frame of the animation
  66933. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  66934. * @param speed is a global scalar of the time variable on the map.
  66935. */
  66936. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  66937. /**
  66938. * Exports the .tilemaps file
  66939. */
  66940. saveTileMaps(): void;
  66941. /**
  66942. * Imports the .tilemaps file
  66943. * @param url of the .tilemaps file
  66944. */
  66945. loadTileMaps(url: string): void;
  66946. /**
  66947. * Release associated resources
  66948. */
  66949. dispose(): void;
  66950. }
  66951. }
  66952. declare module BABYLON {
  66953. /**
  66954. * Class used to manage multiple sprites of different sizes on the same spritesheet
  66955. * @see http://doc.babylonjs.com/babylon101/sprites
  66956. */
  66957. export class SpritePackedManager extends SpriteManager {
  66958. /** defines the packed manager's name */
  66959. name: string;
  66960. /**
  66961. * Creates a new sprite manager from a packed sprite sheet
  66962. * @param name defines the manager's name
  66963. * @param imgUrl defines the sprite sheet url
  66964. * @param capacity defines the maximum allowed number of sprites
  66965. * @param scene defines the hosting scene
  66966. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  66967. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  66968. * @param samplingMode defines the smapling mode to use with spritesheet
  66969. * @param fromPacked set to true; do not alter
  66970. */
  66971. constructor(
  66972. /** defines the packed manager's name */
  66973. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  66974. }
  66975. }
  66976. declare module BABYLON {
  66977. /**
  66978. * Defines the list of states available for a task inside a AssetsManager
  66979. */
  66980. export enum AssetTaskState {
  66981. /**
  66982. * Initialization
  66983. */
  66984. INIT = 0,
  66985. /**
  66986. * Running
  66987. */
  66988. RUNNING = 1,
  66989. /**
  66990. * Done
  66991. */
  66992. DONE = 2,
  66993. /**
  66994. * Error
  66995. */
  66996. ERROR = 3
  66997. }
  66998. /**
  66999. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  67000. */
  67001. export abstract class AbstractAssetTask {
  67002. /**
  67003. * Task name
  67004. */ name: string;
  67005. /**
  67006. * Callback called when the task is successful
  67007. */
  67008. onSuccess: (task: any) => void;
  67009. /**
  67010. * Callback called when the task is not successful
  67011. */
  67012. onError: (task: any, message?: string, exception?: any) => void;
  67013. /**
  67014. * Creates a new AssetsManager
  67015. * @param name defines the name of the task
  67016. */
  67017. constructor(
  67018. /**
  67019. * Task name
  67020. */ name: string);
  67021. private _isCompleted;
  67022. private _taskState;
  67023. private _errorObject;
  67024. /**
  67025. * Get if the task is completed
  67026. */
  67027. get isCompleted(): boolean;
  67028. /**
  67029. * Gets the current state of the task
  67030. */
  67031. get taskState(): AssetTaskState;
  67032. /**
  67033. * Gets the current error object (if task is in error)
  67034. */
  67035. get errorObject(): {
  67036. message?: string;
  67037. exception?: any;
  67038. };
  67039. /**
  67040. * Internal only
  67041. * @hidden
  67042. */
  67043. _setErrorObject(message?: string, exception?: any): void;
  67044. /**
  67045. * Execute the current task
  67046. * @param scene defines the scene where you want your assets to be loaded
  67047. * @param onSuccess is a callback called when the task is successfully executed
  67048. * @param onError is a callback called if an error occurs
  67049. */
  67050. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67051. /**
  67052. * Execute the current task
  67053. * @param scene defines the scene where you want your assets to be loaded
  67054. * @param onSuccess is a callback called when the task is successfully executed
  67055. * @param onError is a callback called if an error occurs
  67056. */
  67057. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67058. /**
  67059. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  67060. * This can be used with failed tasks that have the reason for failure fixed.
  67061. */
  67062. reset(): void;
  67063. private onErrorCallback;
  67064. private onDoneCallback;
  67065. }
  67066. /**
  67067. * Define the interface used by progress events raised during assets loading
  67068. */
  67069. export interface IAssetsProgressEvent {
  67070. /**
  67071. * Defines the number of remaining tasks to process
  67072. */
  67073. remainingCount: number;
  67074. /**
  67075. * Defines the total number of tasks
  67076. */
  67077. totalCount: number;
  67078. /**
  67079. * Defines the task that was just processed
  67080. */
  67081. task: AbstractAssetTask;
  67082. }
  67083. /**
  67084. * Class used to share progress information about assets loading
  67085. */
  67086. export class AssetsProgressEvent implements IAssetsProgressEvent {
  67087. /**
  67088. * Defines the number of remaining tasks to process
  67089. */
  67090. remainingCount: number;
  67091. /**
  67092. * Defines the total number of tasks
  67093. */
  67094. totalCount: number;
  67095. /**
  67096. * Defines the task that was just processed
  67097. */
  67098. task: AbstractAssetTask;
  67099. /**
  67100. * Creates a AssetsProgressEvent
  67101. * @param remainingCount defines the number of remaining tasks to process
  67102. * @param totalCount defines the total number of tasks
  67103. * @param task defines the task that was just processed
  67104. */
  67105. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  67106. }
  67107. /**
  67108. * Define a task used by AssetsManager to load meshes
  67109. */
  67110. export class MeshAssetTask extends AbstractAssetTask {
  67111. /**
  67112. * Defines the name of the task
  67113. */
  67114. name: string;
  67115. /**
  67116. * Defines the list of mesh's names you want to load
  67117. */
  67118. meshesNames: any;
  67119. /**
  67120. * Defines the root url to use as a base to load your meshes and associated resources
  67121. */
  67122. rootUrl: string;
  67123. /**
  67124. * Defines the filename of the scene to load from
  67125. */
  67126. sceneFilename: string;
  67127. /**
  67128. * Gets the list of loaded meshes
  67129. */
  67130. loadedMeshes: Array<AbstractMesh>;
  67131. /**
  67132. * Gets the list of loaded particle systems
  67133. */
  67134. loadedParticleSystems: Array<IParticleSystem>;
  67135. /**
  67136. * Gets the list of loaded skeletons
  67137. */
  67138. loadedSkeletons: Array<Skeleton>;
  67139. /**
  67140. * Gets the list of loaded animation groups
  67141. */
  67142. loadedAnimationGroups: Array<AnimationGroup>;
  67143. /**
  67144. * Callback called when the task is successful
  67145. */
  67146. onSuccess: (task: MeshAssetTask) => void;
  67147. /**
  67148. * Callback called when the task is successful
  67149. */
  67150. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  67151. /**
  67152. * Creates a new MeshAssetTask
  67153. * @param name defines the name of the task
  67154. * @param meshesNames defines the list of mesh's names you want to load
  67155. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  67156. * @param sceneFilename defines the filename of the scene to load from
  67157. */
  67158. constructor(
  67159. /**
  67160. * Defines the name of the task
  67161. */
  67162. name: string,
  67163. /**
  67164. * Defines the list of mesh's names you want to load
  67165. */
  67166. meshesNames: any,
  67167. /**
  67168. * Defines the root url to use as a base to load your meshes and associated resources
  67169. */
  67170. rootUrl: string,
  67171. /**
  67172. * Defines the filename of the scene to load from
  67173. */
  67174. sceneFilename: string);
  67175. /**
  67176. * Execute the current task
  67177. * @param scene defines the scene where you want your assets to be loaded
  67178. * @param onSuccess is a callback called when the task is successfully executed
  67179. * @param onError is a callback called if an error occurs
  67180. */
  67181. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67182. }
  67183. /**
  67184. * Define a task used by AssetsManager to load text content
  67185. */
  67186. export class TextFileAssetTask extends AbstractAssetTask {
  67187. /**
  67188. * Defines the name of the task
  67189. */
  67190. name: string;
  67191. /**
  67192. * Defines the location of the file to load
  67193. */
  67194. url: string;
  67195. /**
  67196. * Gets the loaded text string
  67197. */
  67198. text: string;
  67199. /**
  67200. * Callback called when the task is successful
  67201. */
  67202. onSuccess: (task: TextFileAssetTask) => void;
  67203. /**
  67204. * Callback called when the task is successful
  67205. */
  67206. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  67207. /**
  67208. * Creates a new TextFileAssetTask object
  67209. * @param name defines the name of the task
  67210. * @param url defines the location of the file to load
  67211. */
  67212. constructor(
  67213. /**
  67214. * Defines the name of the task
  67215. */
  67216. name: string,
  67217. /**
  67218. * Defines the location of the file to load
  67219. */
  67220. url: string);
  67221. /**
  67222. * Execute the current task
  67223. * @param scene defines the scene where you want your assets to be loaded
  67224. * @param onSuccess is a callback called when the task is successfully executed
  67225. * @param onError is a callback called if an error occurs
  67226. */
  67227. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67228. }
  67229. /**
  67230. * Define a task used by AssetsManager to load binary data
  67231. */
  67232. export class BinaryFileAssetTask extends AbstractAssetTask {
  67233. /**
  67234. * Defines the name of the task
  67235. */
  67236. name: string;
  67237. /**
  67238. * Defines the location of the file to load
  67239. */
  67240. url: string;
  67241. /**
  67242. * Gets the lodaded data (as an array buffer)
  67243. */
  67244. data: ArrayBuffer;
  67245. /**
  67246. * Callback called when the task is successful
  67247. */
  67248. onSuccess: (task: BinaryFileAssetTask) => void;
  67249. /**
  67250. * Callback called when the task is successful
  67251. */
  67252. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  67253. /**
  67254. * Creates a new BinaryFileAssetTask object
  67255. * @param name defines the name of the new task
  67256. * @param url defines the location of the file to load
  67257. */
  67258. constructor(
  67259. /**
  67260. * Defines the name of the task
  67261. */
  67262. name: string,
  67263. /**
  67264. * Defines the location of the file to load
  67265. */
  67266. url: string);
  67267. /**
  67268. * Execute the current task
  67269. * @param scene defines the scene where you want your assets to be loaded
  67270. * @param onSuccess is a callback called when the task is successfully executed
  67271. * @param onError is a callback called if an error occurs
  67272. */
  67273. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67274. }
  67275. /**
  67276. * Define a task used by AssetsManager to load images
  67277. */
  67278. export class ImageAssetTask extends AbstractAssetTask {
  67279. /**
  67280. * Defines the name of the task
  67281. */
  67282. name: string;
  67283. /**
  67284. * Defines the location of the image to load
  67285. */
  67286. url: string;
  67287. /**
  67288. * Gets the loaded images
  67289. */
  67290. image: HTMLImageElement;
  67291. /**
  67292. * Callback called when the task is successful
  67293. */
  67294. onSuccess: (task: ImageAssetTask) => void;
  67295. /**
  67296. * Callback called when the task is successful
  67297. */
  67298. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  67299. /**
  67300. * Creates a new ImageAssetTask
  67301. * @param name defines the name of the task
  67302. * @param url defines the location of the image to load
  67303. */
  67304. constructor(
  67305. /**
  67306. * Defines the name of the task
  67307. */
  67308. name: string,
  67309. /**
  67310. * Defines the location of the image to load
  67311. */
  67312. url: string);
  67313. /**
  67314. * Execute the current task
  67315. * @param scene defines the scene where you want your assets to be loaded
  67316. * @param onSuccess is a callback called when the task is successfully executed
  67317. * @param onError is a callback called if an error occurs
  67318. */
  67319. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67320. }
  67321. /**
  67322. * Defines the interface used by texture loading tasks
  67323. */
  67324. export interface ITextureAssetTask<TEX extends BaseTexture> {
  67325. /**
  67326. * Gets the loaded texture
  67327. */
  67328. texture: TEX;
  67329. }
  67330. /**
  67331. * Define a task used by AssetsManager to load 2D textures
  67332. */
  67333. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  67334. /**
  67335. * Defines the name of the task
  67336. */
  67337. name: string;
  67338. /**
  67339. * Defines the location of the file to load
  67340. */
  67341. url: string;
  67342. /**
  67343. * Defines if mipmap should not be generated (default is false)
  67344. */
  67345. noMipmap?: boolean | undefined;
  67346. /**
  67347. * Defines if texture must be inverted on Y axis (default is false)
  67348. */
  67349. invertY?: boolean | undefined;
  67350. /**
  67351. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  67352. */
  67353. samplingMode: number;
  67354. /**
  67355. * Gets the loaded texture
  67356. */
  67357. texture: Texture;
  67358. /**
  67359. * Callback called when the task is successful
  67360. */
  67361. onSuccess: (task: TextureAssetTask) => void;
  67362. /**
  67363. * Callback called when the task is successful
  67364. */
  67365. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  67366. /**
  67367. * Creates a new TextureAssetTask object
  67368. * @param name defines the name of the task
  67369. * @param url defines the location of the file to load
  67370. * @param noMipmap defines if mipmap should not be generated (default is false)
  67371. * @param invertY defines if texture must be inverted on Y axis (default is false)
  67372. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  67373. */
  67374. constructor(
  67375. /**
  67376. * Defines the name of the task
  67377. */
  67378. name: string,
  67379. /**
  67380. * Defines the location of the file to load
  67381. */
  67382. url: string,
  67383. /**
  67384. * Defines if mipmap should not be generated (default is false)
  67385. */
  67386. noMipmap?: boolean | undefined,
  67387. /**
  67388. * Defines if texture must be inverted on Y axis (default is false)
  67389. */
  67390. invertY?: boolean | undefined,
  67391. /**
  67392. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  67393. */
  67394. samplingMode?: number);
  67395. /**
  67396. * Execute the current task
  67397. * @param scene defines the scene where you want your assets to be loaded
  67398. * @param onSuccess is a callback called when the task is successfully executed
  67399. * @param onError is a callback called if an error occurs
  67400. */
  67401. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67402. }
  67403. /**
  67404. * Define a task used by AssetsManager to load cube textures
  67405. */
  67406. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  67407. /**
  67408. * Defines the name of the task
  67409. */
  67410. name: string;
  67411. /**
  67412. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  67413. */
  67414. url: string;
  67415. /**
  67416. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  67417. */
  67418. extensions?: string[] | undefined;
  67419. /**
  67420. * Defines if mipmaps should not be generated (default is false)
  67421. */
  67422. noMipmap?: boolean | undefined;
  67423. /**
  67424. * Defines the explicit list of files (undefined by default)
  67425. */
  67426. files?: string[] | undefined;
  67427. /**
  67428. * Gets the loaded texture
  67429. */
  67430. texture: CubeTexture;
  67431. /**
  67432. * Callback called when the task is successful
  67433. */
  67434. onSuccess: (task: CubeTextureAssetTask) => void;
  67435. /**
  67436. * Callback called when the task is successful
  67437. */
  67438. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  67439. /**
  67440. * Creates a new CubeTextureAssetTask
  67441. * @param name defines the name of the task
  67442. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  67443. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  67444. * @param noMipmap defines if mipmaps should not be generated (default is false)
  67445. * @param files defines the explicit list of files (undefined by default)
  67446. */
  67447. constructor(
  67448. /**
  67449. * Defines the name of the task
  67450. */
  67451. name: string,
  67452. /**
  67453. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  67454. */
  67455. url: string,
  67456. /**
  67457. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  67458. */
  67459. extensions?: string[] | undefined,
  67460. /**
  67461. * Defines if mipmaps should not be generated (default is false)
  67462. */
  67463. noMipmap?: boolean | undefined,
  67464. /**
  67465. * Defines the explicit list of files (undefined by default)
  67466. */
  67467. files?: string[] | undefined);
  67468. /**
  67469. * Execute the current task
  67470. * @param scene defines the scene where you want your assets to be loaded
  67471. * @param onSuccess is a callback called when the task is successfully executed
  67472. * @param onError is a callback called if an error occurs
  67473. */
  67474. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67475. }
  67476. /**
  67477. * Define a task used by AssetsManager to load HDR cube textures
  67478. */
  67479. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  67480. /**
  67481. * Defines the name of the task
  67482. */
  67483. name: string;
  67484. /**
  67485. * Defines the location of the file to load
  67486. */
  67487. url: string;
  67488. /**
  67489. * Defines the desired size (the more it increases the longer the generation will be)
  67490. */
  67491. size: number;
  67492. /**
  67493. * Defines if mipmaps should not be generated (default is false)
  67494. */
  67495. noMipmap: boolean;
  67496. /**
  67497. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  67498. */
  67499. generateHarmonics: boolean;
  67500. /**
  67501. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space) (default is false)
  67502. */
  67503. gammaSpace: boolean;
  67504. /**
  67505. * Internal Use Only
  67506. */
  67507. reserved: boolean;
  67508. /**
  67509. * Gets the loaded texture
  67510. */
  67511. texture: HDRCubeTexture;
  67512. /**
  67513. * Callback called when the task is successful
  67514. */
  67515. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  67516. /**
  67517. * Callback called when the task is successful
  67518. */
  67519. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  67520. /**
  67521. * Creates a new HDRCubeTextureAssetTask object
  67522. * @param name defines the name of the task
  67523. * @param url defines the location of the file to load
  67524. * @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.
  67525. * @param noMipmap defines if mipmaps should not be generated (default is false)
  67526. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  67527. * @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)
  67528. * @param reserved Internal use only
  67529. */
  67530. constructor(
  67531. /**
  67532. * Defines the name of the task
  67533. */
  67534. name: string,
  67535. /**
  67536. * Defines the location of the file to load
  67537. */
  67538. url: string,
  67539. /**
  67540. * Defines the desired size (the more it increases the longer the generation will be)
  67541. */
  67542. size: number,
  67543. /**
  67544. * Defines if mipmaps should not be generated (default is false)
  67545. */
  67546. noMipmap?: boolean,
  67547. /**
  67548. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  67549. */
  67550. generateHarmonics?: boolean,
  67551. /**
  67552. * 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)
  67553. */
  67554. gammaSpace?: boolean,
  67555. /**
  67556. * Internal Use Only
  67557. */
  67558. reserved?: boolean);
  67559. /**
  67560. * Execute the current task
  67561. * @param scene defines the scene where you want your assets to be loaded
  67562. * @param onSuccess is a callback called when the task is successfully executed
  67563. * @param onError is a callback called if an error occurs
  67564. */
  67565. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67566. }
  67567. /**
  67568. * Define a task used by AssetsManager to load Equirectangular cube textures
  67569. */
  67570. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  67571. /**
  67572. * Defines the name of the task
  67573. */
  67574. name: string;
  67575. /**
  67576. * Defines the location of the file to load
  67577. */
  67578. url: string;
  67579. /**
  67580. * Defines the desired size (the more it increases the longer the generation will be)
  67581. */
  67582. size: number;
  67583. /**
  67584. * Defines if mipmaps should not be generated (default is false)
  67585. */
  67586. noMipmap: boolean;
  67587. /**
  67588. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  67589. * but the standard material would require them in Gamma space) (default is true)
  67590. */
  67591. gammaSpace: boolean;
  67592. /**
  67593. * Gets the loaded texture
  67594. */
  67595. texture: EquiRectangularCubeTexture;
  67596. /**
  67597. * Callback called when the task is successful
  67598. */
  67599. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  67600. /**
  67601. * Callback called when the task is successful
  67602. */
  67603. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  67604. /**
  67605. * Creates a new EquiRectangularCubeTextureAssetTask object
  67606. * @param name defines the name of the task
  67607. * @param url defines the location of the file to load
  67608. * @param size defines the desired size (the more it increases the longer the generation will be)
  67609. * If the size is omitted this implies you are using a preprocessed cubemap.
  67610. * @param noMipmap defines if mipmaps should not be generated (default is false)
  67611. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  67612. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  67613. * (default is true)
  67614. */
  67615. constructor(
  67616. /**
  67617. * Defines the name of the task
  67618. */
  67619. name: string,
  67620. /**
  67621. * Defines the location of the file to load
  67622. */
  67623. url: string,
  67624. /**
  67625. * Defines the desired size (the more it increases the longer the generation will be)
  67626. */
  67627. size: number,
  67628. /**
  67629. * Defines if mipmaps should not be generated (default is false)
  67630. */
  67631. noMipmap?: boolean,
  67632. /**
  67633. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  67634. * but the standard material would require them in Gamma space) (default is true)
  67635. */
  67636. gammaSpace?: boolean);
  67637. /**
  67638. * Execute the current task
  67639. * @param scene defines the scene where you want your assets to be loaded
  67640. * @param onSuccess is a callback called when the task is successfully executed
  67641. * @param onError is a callback called if an error occurs
  67642. */
  67643. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67644. }
  67645. /**
  67646. * This class can be used to easily import assets into a scene
  67647. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  67648. */
  67649. export class AssetsManager {
  67650. private _scene;
  67651. private _isLoading;
  67652. protected _tasks: AbstractAssetTask[];
  67653. protected _waitingTasksCount: number;
  67654. protected _totalTasksCount: number;
  67655. /**
  67656. * Callback called when all tasks are processed
  67657. */
  67658. onFinish: (tasks: AbstractAssetTask[]) => void;
  67659. /**
  67660. * Callback called when a task is successful
  67661. */
  67662. onTaskSuccess: (task: AbstractAssetTask) => void;
  67663. /**
  67664. * Callback called when a task had an error
  67665. */
  67666. onTaskError: (task: AbstractAssetTask) => void;
  67667. /**
  67668. * Callback called when a task is done (whatever the result is)
  67669. */
  67670. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  67671. /**
  67672. * Observable called when all tasks are processed
  67673. */
  67674. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  67675. /**
  67676. * Observable called when a task had an error
  67677. */
  67678. onTaskErrorObservable: Observable<AbstractAssetTask>;
  67679. /**
  67680. * Observable called when all tasks were executed
  67681. */
  67682. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  67683. /**
  67684. * Observable called when a task is done (whatever the result is)
  67685. */
  67686. onProgressObservable: Observable<IAssetsProgressEvent>;
  67687. /**
  67688. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  67689. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  67690. */
  67691. useDefaultLoadingScreen: boolean;
  67692. /**
  67693. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  67694. * when all assets have been downloaded.
  67695. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  67696. */
  67697. autoHideLoadingUI: boolean;
  67698. /**
  67699. * Creates a new AssetsManager
  67700. * @param scene defines the scene to work on
  67701. */
  67702. constructor(scene: Scene);
  67703. /**
  67704. * Add a MeshAssetTask to the list of active tasks
  67705. * @param taskName defines the name of the new task
  67706. * @param meshesNames defines the name of meshes to load
  67707. * @param rootUrl defines the root url to use to locate files
  67708. * @param sceneFilename defines the filename of the scene file
  67709. * @returns a new MeshAssetTask object
  67710. */
  67711. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  67712. /**
  67713. * Add a TextFileAssetTask to the list of active tasks
  67714. * @param taskName defines the name of the new task
  67715. * @param url defines the url of the file to load
  67716. * @returns a new TextFileAssetTask object
  67717. */
  67718. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  67719. /**
  67720. * Add a BinaryFileAssetTask to the list of active tasks
  67721. * @param taskName defines the name of the new task
  67722. * @param url defines the url of the file to load
  67723. * @returns a new BinaryFileAssetTask object
  67724. */
  67725. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  67726. /**
  67727. * Add a ImageAssetTask to the list of active tasks
  67728. * @param taskName defines the name of the new task
  67729. * @param url defines the url of the file to load
  67730. * @returns a new ImageAssetTask object
  67731. */
  67732. addImageTask(taskName: string, url: string): ImageAssetTask;
  67733. /**
  67734. * Add a TextureAssetTask to the list of active tasks
  67735. * @param taskName defines the name of the new task
  67736. * @param url defines the url of the file to load
  67737. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  67738. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  67739. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  67740. * @returns a new TextureAssetTask object
  67741. */
  67742. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  67743. /**
  67744. * Add a CubeTextureAssetTask to the list of active tasks
  67745. * @param taskName defines the name of the new task
  67746. * @param url defines the url of the file to load
  67747. * @param extensions defines the extension to use to load the cube map (can be null)
  67748. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  67749. * @param files defines the list of files to load (can be null)
  67750. * @returns a new CubeTextureAssetTask object
  67751. */
  67752. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  67753. /**
  67754. *
  67755. * Add a HDRCubeTextureAssetTask to the list of active tasks
  67756. * @param taskName defines the name of the new task
  67757. * @param url defines the url of the file to load
  67758. * @param size defines the size you want for the cubemap (can be null)
  67759. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  67760. * @param generateHarmonics defines if you want to automatically generate (true by default)
  67761. * @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)
  67762. * @param reserved Internal use only
  67763. * @returns a new HDRCubeTextureAssetTask object
  67764. */
  67765. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  67766. /**
  67767. *
  67768. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  67769. * @param taskName defines the name of the new task
  67770. * @param url defines the url of the file to load
  67771. * @param size defines the size you want for the cubemap (can be null)
  67772. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  67773. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  67774. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  67775. * @returns a new EquiRectangularCubeTextureAssetTask object
  67776. */
  67777. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  67778. /**
  67779. * Remove a task from the assets manager.
  67780. * @param task the task to remove
  67781. */
  67782. removeTask(task: AbstractAssetTask): void;
  67783. private _decreaseWaitingTasksCount;
  67784. private _runTask;
  67785. /**
  67786. * Reset the AssetsManager and remove all tasks
  67787. * @return the current instance of the AssetsManager
  67788. */
  67789. reset(): AssetsManager;
  67790. /**
  67791. * Start the loading process
  67792. * @return the current instance of the AssetsManager
  67793. */
  67794. load(): AssetsManager;
  67795. /**
  67796. * Start the loading process as an async operation
  67797. * @return a promise returning the list of failed tasks
  67798. */
  67799. loadAsync(): Promise<void>;
  67800. }
  67801. }
  67802. declare module BABYLON {
  67803. /**
  67804. * Wrapper class for promise with external resolve and reject.
  67805. */
  67806. export class Deferred<T> {
  67807. /**
  67808. * The promise associated with this deferred object.
  67809. */
  67810. readonly promise: Promise<T>;
  67811. private _resolve;
  67812. private _reject;
  67813. /**
  67814. * The resolve method of the promise associated with this deferred object.
  67815. */
  67816. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  67817. /**
  67818. * The reject method of the promise associated with this deferred object.
  67819. */
  67820. get reject(): (reason?: any) => void;
  67821. /**
  67822. * Constructor for this deferred object.
  67823. */
  67824. constructor();
  67825. }
  67826. }
  67827. declare module BABYLON {
  67828. /**
  67829. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  67830. */
  67831. export class MeshExploder {
  67832. private _centerMesh;
  67833. private _meshes;
  67834. private _meshesOrigins;
  67835. private _toCenterVectors;
  67836. private _scaledDirection;
  67837. private _newPosition;
  67838. private _centerPosition;
  67839. /**
  67840. * Explodes meshes from a center mesh.
  67841. * @param meshes The meshes to explode.
  67842. * @param centerMesh The mesh to be center of explosion.
  67843. */
  67844. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  67845. private _setCenterMesh;
  67846. /**
  67847. * Get class name
  67848. * @returns "MeshExploder"
  67849. */
  67850. getClassName(): string;
  67851. /**
  67852. * "Exploded meshes"
  67853. * @returns Array of meshes with the centerMesh at index 0.
  67854. */
  67855. getMeshes(): Array<Mesh>;
  67856. /**
  67857. * Explodes meshes giving a specific direction
  67858. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  67859. */
  67860. explode(direction?: number): void;
  67861. }
  67862. }
  67863. declare module BABYLON {
  67864. /**
  67865. * Class used to help managing file picking and drag'n'drop
  67866. */
  67867. export class FilesInput {
  67868. /**
  67869. * List of files ready to be loaded
  67870. */
  67871. static get FilesToLoad(): {
  67872. [key: string]: File;
  67873. };
  67874. /**
  67875. * Callback called when a file is processed
  67876. */
  67877. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  67878. private _engine;
  67879. private _currentScene;
  67880. private _sceneLoadedCallback;
  67881. private _progressCallback;
  67882. private _additionalRenderLoopLogicCallback;
  67883. private _textureLoadingCallback;
  67884. private _startingProcessingFilesCallback;
  67885. private _onReloadCallback;
  67886. private _errorCallback;
  67887. private _elementToMonitor;
  67888. private _sceneFileToLoad;
  67889. private _filesToLoad;
  67890. /**
  67891. * Creates a new FilesInput
  67892. * @param engine defines the rendering engine
  67893. * @param scene defines the hosting scene
  67894. * @param sceneLoadedCallback callback called when scene is loaded
  67895. * @param progressCallback callback called to track progress
  67896. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  67897. * @param textureLoadingCallback callback called when a texture is loading
  67898. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  67899. * @param onReloadCallback callback called when a reload is requested
  67900. * @param errorCallback callback call if an error occurs
  67901. */
  67902. 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);
  67903. private _dragEnterHandler;
  67904. private _dragOverHandler;
  67905. private _dropHandler;
  67906. /**
  67907. * Calls this function to listen to drag'n'drop events on a specific DOM element
  67908. * @param elementToMonitor defines the DOM element to track
  67909. */
  67910. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  67911. /**
  67912. * Release all associated resources
  67913. */
  67914. dispose(): void;
  67915. private renderFunction;
  67916. private drag;
  67917. private drop;
  67918. private _traverseFolder;
  67919. private _processFiles;
  67920. /**
  67921. * Load files from a drop event
  67922. * @param event defines the drop event to use as source
  67923. */
  67924. loadFiles(event: any): void;
  67925. private _processReload;
  67926. /**
  67927. * Reload the current scene from the loaded files
  67928. */
  67929. reload(): void;
  67930. }
  67931. }
  67932. declare module BABYLON {
  67933. /**
  67934. * Defines the root class used to create scene optimization to use with SceneOptimizer
  67935. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  67936. */
  67937. export class SceneOptimization {
  67938. /**
  67939. * Defines the priority of this optimization (0 by default which means first in the list)
  67940. */
  67941. priority: number;
  67942. /**
  67943. * Gets a string describing the action executed by the current optimization
  67944. * @returns description string
  67945. */
  67946. getDescription(): string;
  67947. /**
  67948. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  67949. * @param scene defines the current scene where to apply this optimization
  67950. * @param optimizer defines the current optimizer
  67951. * @returns true if everything that can be done was applied
  67952. */
  67953. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  67954. /**
  67955. * Creates the SceneOptimization object
  67956. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  67957. * @param desc defines the description associated with the optimization
  67958. */
  67959. constructor(
  67960. /**
  67961. * Defines the priority of this optimization (0 by default which means first in the list)
  67962. */
  67963. priority?: number);
  67964. }
  67965. /**
  67966. * Defines an optimization used to reduce the size of render target textures
  67967. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  67968. */
  67969. export class TextureOptimization extends SceneOptimization {
  67970. /**
  67971. * Defines the priority of this optimization (0 by default which means first in the list)
  67972. */
  67973. priority: number;
  67974. /**
  67975. * 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
  67976. */
  67977. maximumSize: number;
  67978. /**
  67979. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  67980. */
  67981. step: number;
  67982. /**
  67983. * Gets a string describing the action executed by the current optimization
  67984. * @returns description string
  67985. */
  67986. getDescription(): string;
  67987. /**
  67988. * Creates the TextureOptimization object
  67989. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  67990. * @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
  67991. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  67992. */
  67993. constructor(
  67994. /**
  67995. * Defines the priority of this optimization (0 by default which means first in the list)
  67996. */
  67997. priority?: number,
  67998. /**
  67999. * Defines the maximum 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
  68000. */
  68001. maximumSize?: number,
  68002. /**
  68003. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  68004. */
  68005. step?: number);
  68006. /**
  68007. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68008. * @param scene defines the current scene where to apply this optimization
  68009. * @param optimizer defines the current optimizer
  68010. * @returns true if everything that can be done was applied
  68011. */
  68012. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68013. }
  68014. /**
  68015. * Defines an optimization used to increase or decrease the rendering resolution
  68016. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68017. */
  68018. export class HardwareScalingOptimization extends SceneOptimization {
  68019. /**
  68020. * Defines the priority of this optimization (0 by default which means first in the list)
  68021. */
  68022. priority: number;
  68023. /**
  68024. * Defines the maximum scale to use (2 by default)
  68025. */
  68026. maximumScale: number;
  68027. /**
  68028. * Defines the step to use between two passes (0.5 by default)
  68029. */
  68030. step: number;
  68031. private _currentScale;
  68032. private _directionOffset;
  68033. /**
  68034. * Gets a string describing the action executed by the current optimization
  68035. * @return description string
  68036. */
  68037. getDescription(): string;
  68038. /**
  68039. * Creates the HardwareScalingOptimization object
  68040. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  68041. * @param maximumScale defines the maximum scale to use (2 by default)
  68042. * @param step defines the step to use between two passes (0.5 by default)
  68043. */
  68044. constructor(
  68045. /**
  68046. * Defines the priority of this optimization (0 by default which means first in the list)
  68047. */
  68048. priority?: number,
  68049. /**
  68050. * Defines the maximum scale to use (2 by default)
  68051. */
  68052. maximumScale?: number,
  68053. /**
  68054. * Defines the step to use between two passes (0.5 by default)
  68055. */
  68056. step?: number);
  68057. /**
  68058. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68059. * @param scene defines the current scene where to apply this optimization
  68060. * @param optimizer defines the current optimizer
  68061. * @returns true if everything that can be done was applied
  68062. */
  68063. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68064. }
  68065. /**
  68066. * Defines an optimization used to remove shadows
  68067. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68068. */
  68069. export class ShadowsOptimization extends SceneOptimization {
  68070. /**
  68071. * Gets a string describing the action executed by the current optimization
  68072. * @return description string
  68073. */
  68074. getDescription(): string;
  68075. /**
  68076. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68077. * @param scene defines the current scene where to apply this optimization
  68078. * @param optimizer defines the current optimizer
  68079. * @returns true if everything that can be done was applied
  68080. */
  68081. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68082. }
  68083. /**
  68084. * Defines an optimization used to turn post-processes off
  68085. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68086. */
  68087. export class PostProcessesOptimization extends SceneOptimization {
  68088. /**
  68089. * Gets a string describing the action executed by the current optimization
  68090. * @return description string
  68091. */
  68092. getDescription(): string;
  68093. /**
  68094. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68095. * @param scene defines the current scene where to apply this optimization
  68096. * @param optimizer defines the current optimizer
  68097. * @returns true if everything that can be done was applied
  68098. */
  68099. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68100. }
  68101. /**
  68102. * Defines an optimization used to turn lens flares off
  68103. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68104. */
  68105. export class LensFlaresOptimization extends SceneOptimization {
  68106. /**
  68107. * Gets a string describing the action executed by the current optimization
  68108. * @return description string
  68109. */
  68110. getDescription(): string;
  68111. /**
  68112. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68113. * @param scene defines the current scene where to apply this optimization
  68114. * @param optimizer defines the current optimizer
  68115. * @returns true if everything that can be done was applied
  68116. */
  68117. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68118. }
  68119. /**
  68120. * Defines an optimization based on user defined callback.
  68121. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68122. */
  68123. export class CustomOptimization extends SceneOptimization {
  68124. /**
  68125. * Callback called to apply the custom optimization.
  68126. */
  68127. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  68128. /**
  68129. * Callback called to get custom description
  68130. */
  68131. onGetDescription: () => string;
  68132. /**
  68133. * Gets a string describing the action executed by the current optimization
  68134. * @returns description string
  68135. */
  68136. getDescription(): string;
  68137. /**
  68138. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68139. * @param scene defines the current scene where to apply this optimization
  68140. * @param optimizer defines the current optimizer
  68141. * @returns true if everything that can be done was applied
  68142. */
  68143. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68144. }
  68145. /**
  68146. * Defines an optimization used to turn particles off
  68147. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68148. */
  68149. export class ParticlesOptimization extends SceneOptimization {
  68150. /**
  68151. * Gets a string describing the action executed by the current optimization
  68152. * @return description string
  68153. */
  68154. getDescription(): string;
  68155. /**
  68156. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68157. * @param scene defines the current scene where to apply this optimization
  68158. * @param optimizer defines the current optimizer
  68159. * @returns true if everything that can be done was applied
  68160. */
  68161. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68162. }
  68163. /**
  68164. * Defines an optimization used to turn render targets off
  68165. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68166. */
  68167. export class RenderTargetsOptimization extends SceneOptimization {
  68168. /**
  68169. * Gets a string describing the action executed by the current optimization
  68170. * @return description string
  68171. */
  68172. getDescription(): string;
  68173. /**
  68174. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68175. * @param scene defines the current scene where to apply this optimization
  68176. * @param optimizer defines the current optimizer
  68177. * @returns true if everything that can be done was applied
  68178. */
  68179. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68180. }
  68181. /**
  68182. * Defines an optimization used to merge meshes with compatible materials
  68183. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68184. */
  68185. export class MergeMeshesOptimization extends SceneOptimization {
  68186. private static _UpdateSelectionTree;
  68187. /**
  68188. * Gets or sets a boolean which defines if optimization octree has to be updated
  68189. */
  68190. static get UpdateSelectionTree(): boolean;
  68191. /**
  68192. * Gets or sets a boolean which defines if optimization octree has to be updated
  68193. */
  68194. static set UpdateSelectionTree(value: boolean);
  68195. /**
  68196. * Gets a string describing the action executed by the current optimization
  68197. * @return description string
  68198. */
  68199. getDescription(): string;
  68200. private _canBeMerged;
  68201. /**
  68202. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68203. * @param scene defines the current scene where to apply this optimization
  68204. * @param optimizer defines the current optimizer
  68205. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  68206. * @returns true if everything that can be done was applied
  68207. */
  68208. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  68209. }
  68210. /**
  68211. * Defines a list of options used by SceneOptimizer
  68212. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68213. */
  68214. export class SceneOptimizerOptions {
  68215. /**
  68216. * Defines the target frame rate to reach (60 by default)
  68217. */
  68218. targetFrameRate: number;
  68219. /**
  68220. * Defines the interval between two checkes (2000ms by default)
  68221. */
  68222. trackerDuration: number;
  68223. /**
  68224. * Gets the list of optimizations to apply
  68225. */
  68226. optimizations: SceneOptimization[];
  68227. /**
  68228. * Creates a new list of options used by SceneOptimizer
  68229. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  68230. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  68231. */
  68232. constructor(
  68233. /**
  68234. * Defines the target frame rate to reach (60 by default)
  68235. */
  68236. targetFrameRate?: number,
  68237. /**
  68238. * Defines the interval between two checkes (2000ms by default)
  68239. */
  68240. trackerDuration?: number);
  68241. /**
  68242. * Add a new optimization
  68243. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  68244. * @returns the current SceneOptimizerOptions
  68245. */
  68246. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  68247. /**
  68248. * Add a new custom optimization
  68249. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  68250. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  68251. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  68252. * @returns the current SceneOptimizerOptions
  68253. */
  68254. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  68255. /**
  68256. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  68257. * @param targetFrameRate defines the target frame rate (60 by default)
  68258. * @returns a SceneOptimizerOptions object
  68259. */
  68260. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  68261. /**
  68262. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  68263. * @param targetFrameRate defines the target frame rate (60 by default)
  68264. * @returns a SceneOptimizerOptions object
  68265. */
  68266. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  68267. /**
  68268. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  68269. * @param targetFrameRate defines the target frame rate (60 by default)
  68270. * @returns a SceneOptimizerOptions object
  68271. */
  68272. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  68273. }
  68274. /**
  68275. * Class used to run optimizations in order to reach a target frame rate
  68276. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68277. */
  68278. export class SceneOptimizer implements IDisposable {
  68279. private _isRunning;
  68280. private _options;
  68281. private _scene;
  68282. private _currentPriorityLevel;
  68283. private _targetFrameRate;
  68284. private _trackerDuration;
  68285. private _currentFrameRate;
  68286. private _sceneDisposeObserver;
  68287. private _improvementMode;
  68288. /**
  68289. * Defines an observable called when the optimizer reaches the target frame rate
  68290. */
  68291. onSuccessObservable: Observable<SceneOptimizer>;
  68292. /**
  68293. * Defines an observable called when the optimizer enables an optimization
  68294. */
  68295. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  68296. /**
  68297. * Defines an observable called when the optimizer is not able to reach the target frame rate
  68298. */
  68299. onFailureObservable: Observable<SceneOptimizer>;
  68300. /**
  68301. * Gets a boolean indicating if the optimizer is in improvement mode
  68302. */
  68303. get isInImprovementMode(): boolean;
  68304. /**
  68305. * Gets the current priority level (0 at start)
  68306. */
  68307. get currentPriorityLevel(): number;
  68308. /**
  68309. * Gets the current frame rate checked by the SceneOptimizer
  68310. */
  68311. get currentFrameRate(): number;
  68312. /**
  68313. * Gets or sets the current target frame rate (60 by default)
  68314. */
  68315. get targetFrameRate(): number;
  68316. /**
  68317. * Gets or sets the current target frame rate (60 by default)
  68318. */
  68319. set targetFrameRate(value: number);
  68320. /**
  68321. * Gets or sets the current interval between two checks (every 2000ms by default)
  68322. */
  68323. get trackerDuration(): number;
  68324. /**
  68325. * Gets or sets the current interval between two checks (every 2000ms by default)
  68326. */
  68327. set trackerDuration(value: number);
  68328. /**
  68329. * Gets the list of active optimizations
  68330. */
  68331. get optimizations(): SceneOptimization[];
  68332. /**
  68333. * Creates a new SceneOptimizer
  68334. * @param scene defines the scene to work on
  68335. * @param options defines the options to use with the SceneOptimizer
  68336. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  68337. * @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)
  68338. */
  68339. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  68340. /**
  68341. * Stops the current optimizer
  68342. */
  68343. stop(): void;
  68344. /**
  68345. * Reset the optimizer to initial step (current priority level = 0)
  68346. */
  68347. reset(): void;
  68348. /**
  68349. * Start the optimizer. By default it will try to reach a specific framerate
  68350. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  68351. */
  68352. start(): void;
  68353. private _checkCurrentState;
  68354. /**
  68355. * Release all resources
  68356. */
  68357. dispose(): void;
  68358. /**
  68359. * Helper function to create a SceneOptimizer with one single line of code
  68360. * @param scene defines the scene to work on
  68361. * @param options defines the options to use with the SceneOptimizer
  68362. * @param onSuccess defines a callback to call on success
  68363. * @param onFailure defines a callback to call on failure
  68364. * @returns the new SceneOptimizer object
  68365. */
  68366. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  68367. }
  68368. }
  68369. declare module BABYLON {
  68370. /**
  68371. * Class used to serialize a scene into a string
  68372. */
  68373. export class SceneSerializer {
  68374. /**
  68375. * Clear cache used by a previous serialization
  68376. */
  68377. static ClearCache(): void;
  68378. /**
  68379. * Serialize a scene into a JSON compatible object
  68380. * @param scene defines the scene to serialize
  68381. * @returns a JSON compatible object
  68382. */
  68383. static Serialize(scene: Scene): any;
  68384. /**
  68385. * Serialize a mesh into a JSON compatible object
  68386. * @param toSerialize defines the mesh to serialize
  68387. * @param withParents defines if parents must be serialized as well
  68388. * @param withChildren defines if children must be serialized as well
  68389. * @returns a JSON compatible object
  68390. */
  68391. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  68392. }
  68393. }
  68394. declare module BABYLON {
  68395. /**
  68396. * Class used to host texture specific utilities
  68397. */
  68398. export class TextureTools {
  68399. /**
  68400. * Uses the GPU to create a copy texture rescaled at a given size
  68401. * @param texture Texture to copy from
  68402. * @param width defines the desired width
  68403. * @param height defines the desired height
  68404. * @param useBilinearMode defines if bilinear mode has to be used
  68405. * @return the generated texture
  68406. */
  68407. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  68408. }
  68409. }
  68410. declare module BABYLON {
  68411. /**
  68412. * This represents the different options available for the video capture.
  68413. */
  68414. export interface VideoRecorderOptions {
  68415. /** Defines the mime type of the video. */
  68416. mimeType: string;
  68417. /** Defines the FPS the video should be recorded at. */
  68418. fps: number;
  68419. /** Defines the chunk size for the recording data. */
  68420. recordChunckSize: number;
  68421. /** The audio tracks to attach to the recording. */
  68422. audioTracks?: MediaStreamTrack[];
  68423. }
  68424. /**
  68425. * This can help with recording videos from BabylonJS.
  68426. * This is based on the available WebRTC functionalities of the browser.
  68427. *
  68428. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  68429. */
  68430. export class VideoRecorder {
  68431. private static readonly _defaultOptions;
  68432. /**
  68433. * Returns whether or not the VideoRecorder is available in your browser.
  68434. * @param engine Defines the Babylon Engine.
  68435. * @returns true if supported otherwise false.
  68436. */
  68437. static IsSupported(engine: Engine): boolean;
  68438. private readonly _options;
  68439. private _canvas;
  68440. private _mediaRecorder;
  68441. private _recordedChunks;
  68442. private _fileName;
  68443. private _resolve;
  68444. private _reject;
  68445. /**
  68446. * True when a recording is already in progress.
  68447. */
  68448. get isRecording(): boolean;
  68449. /**
  68450. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  68451. * @param engine Defines the BabylonJS Engine you wish to record.
  68452. * @param options Defines options that can be used to customize the capture.
  68453. */
  68454. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  68455. /**
  68456. * Stops the current recording before the default capture timeout passed in the startRecording function.
  68457. */
  68458. stopRecording(): void;
  68459. /**
  68460. * Starts recording the canvas for a max duration specified in parameters.
  68461. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  68462. * If null no automatic download will start and you can rely on the promise to get the data back.
  68463. * @param maxDuration Defines the maximum recording time in seconds.
  68464. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  68465. * @return A promise callback at the end of the recording with the video data in Blob.
  68466. */
  68467. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  68468. /**
  68469. * Releases internal resources used during the recording.
  68470. */
  68471. dispose(): void;
  68472. private _handleDataAvailable;
  68473. private _handleError;
  68474. private _handleStop;
  68475. }
  68476. }
  68477. declare module BABYLON {
  68478. /**
  68479. * Class containing a set of static utilities functions for screenshots
  68480. */
  68481. export class ScreenshotTools {
  68482. /**
  68483. * Captures a screenshot of the current rendering
  68484. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  68485. * @param engine defines the rendering engine
  68486. * @param camera defines the source camera
  68487. * @param size This parameter can be set to a single number or to an object with the
  68488. * following (optional) properties: precision, width, height. If a single number is passed,
  68489. * it will be used for both width and height. If an object is passed, the screenshot size
  68490. * will be derived from the parameters. The precision property is a multiplier allowing
  68491. * rendering at a higher or lower resolution
  68492. * @param successCallback defines the callback receives a single parameter which contains the
  68493. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  68494. * src parameter of an <img> to display it
  68495. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  68496. * Check your browser for supported MIME types
  68497. */
  68498. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  68499. /**
  68500. * Captures a screenshot of the current rendering
  68501. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  68502. * @param engine defines the rendering engine
  68503. * @param camera defines the source camera
  68504. * @param size This parameter can be set to a single number or to an object with the
  68505. * following (optional) properties: precision, width, height. If a single number is passed,
  68506. * it will be used for both width and height. If an object is passed, the screenshot size
  68507. * will be derived from the parameters. The precision property is a multiplier allowing
  68508. * rendering at a higher or lower resolution
  68509. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  68510. * Check your browser for supported MIME types
  68511. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  68512. * to the src parameter of an <img> to display it
  68513. */
  68514. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  68515. /**
  68516. * Generates an image screenshot from the specified camera.
  68517. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  68518. * @param engine The engine to use for rendering
  68519. * @param camera The camera to use for rendering
  68520. * @param size This parameter can be set to a single number or to an object with the
  68521. * following (optional) properties: precision, width, height. If a single number is passed,
  68522. * it will be used for both width and height. If an object is passed, the screenshot size
  68523. * will be derived from the parameters. The precision property is a multiplier allowing
  68524. * rendering at a higher or lower resolution
  68525. * @param successCallback The callback receives a single parameter which contains the
  68526. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  68527. * src parameter of an <img> to display it
  68528. * @param mimeType The MIME type of the screenshot image (default: image/png).
  68529. * Check your browser for supported MIME types
  68530. * @param samples Texture samples (default: 1)
  68531. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  68532. * @param fileName A name for for the downloaded file.
  68533. */
  68534. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  68535. /**
  68536. * Generates an image screenshot from the specified camera.
  68537. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  68538. * @param engine The engine to use for rendering
  68539. * @param camera The camera to use for rendering
  68540. * @param size This parameter can be set to a single number or to an object with the
  68541. * following (optional) properties: precision, width, height. If a single number is passed,
  68542. * it will be used for both width and height. If an object is passed, the screenshot size
  68543. * will be derived from the parameters. The precision property is a multiplier allowing
  68544. * rendering at a higher or lower resolution
  68545. * @param mimeType The MIME type of the screenshot image (default: image/png).
  68546. * Check your browser for supported MIME types
  68547. * @param samples Texture samples (default: 1)
  68548. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  68549. * @param fileName A name for for the downloaded file.
  68550. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  68551. * to the src parameter of an <img> to display it
  68552. */
  68553. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  68554. /**
  68555. * Gets height and width for screenshot size
  68556. * @private
  68557. */
  68558. private static _getScreenshotSize;
  68559. }
  68560. }
  68561. declare module BABYLON {
  68562. /**
  68563. * Interface for a data buffer
  68564. */
  68565. export interface IDataBuffer {
  68566. /**
  68567. * Reads bytes from the data buffer.
  68568. * @param byteOffset The byte offset to read
  68569. * @param byteLength The byte length to read
  68570. * @returns A promise that resolves when the bytes are read
  68571. */
  68572. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  68573. /**
  68574. * The byte length of the buffer.
  68575. */
  68576. readonly byteLength: number;
  68577. }
  68578. /**
  68579. * Utility class for reading from a data buffer
  68580. */
  68581. export class DataReader {
  68582. /**
  68583. * The data buffer associated with this data reader.
  68584. */
  68585. readonly buffer: IDataBuffer;
  68586. /**
  68587. * The current byte offset from the beginning of the data buffer.
  68588. */
  68589. byteOffset: number;
  68590. private _dataView;
  68591. private _dataByteOffset;
  68592. /**
  68593. * Constructor
  68594. * @param buffer The buffer to read
  68595. */
  68596. constructor(buffer: IDataBuffer);
  68597. /**
  68598. * Loads the given byte length.
  68599. * @param byteLength The byte length to load
  68600. * @returns A promise that resolves when the load is complete
  68601. */
  68602. loadAsync(byteLength: number): Promise<void>;
  68603. /**
  68604. * Read a unsigned 32-bit integer from the currently loaded data range.
  68605. * @returns The 32-bit integer read
  68606. */
  68607. readUint32(): number;
  68608. /**
  68609. * Read a byte array from the currently loaded data range.
  68610. * @param byteLength The byte length to read
  68611. * @returns The byte array read
  68612. */
  68613. readUint8Array(byteLength: number): Uint8Array;
  68614. /**
  68615. * Read a string from the currently loaded data range.
  68616. * @param byteLength The byte length to read
  68617. * @returns The string read
  68618. */
  68619. readString(byteLength: number): string;
  68620. /**
  68621. * Skips the given byte length the currently loaded data range.
  68622. * @param byteLength The byte length to skip
  68623. */
  68624. skipBytes(byteLength: number): void;
  68625. }
  68626. }
  68627. declare module BABYLON {
  68628. /**
  68629. * Options used for hit testing
  68630. */
  68631. export interface IWebXRHitTestOptions {
  68632. /**
  68633. * Only test when user interacted with the scene. Default - hit test every frame
  68634. */
  68635. testOnPointerDownOnly?: boolean;
  68636. /**
  68637. * The node to use to transform the local results to world coordinates
  68638. */
  68639. worldParentNode?: TransformNode;
  68640. }
  68641. /**
  68642. * Interface defining the babylon result of raycasting/hit-test
  68643. */
  68644. export interface IWebXRHitResult {
  68645. /**
  68646. * The native hit test result
  68647. */
  68648. xrHitResult: XRHitResult;
  68649. /**
  68650. * Transformation matrix that can be applied to a node that will put it in the hit point location
  68651. */
  68652. transformationMatrix: Matrix;
  68653. }
  68654. /**
  68655. * The currently-working hit-test module.
  68656. * Hit test (or raycasting) is used to interact with the real world.
  68657. * For further information read here - https://github.com/immersive-web/hit-test
  68658. */
  68659. export class WebXRHitTestLegacy extends WebXRAbstractFeature {
  68660. /**
  68661. * options to use when constructing this feature
  68662. */
  68663. readonly options: IWebXRHitTestOptions;
  68664. /**
  68665. * The module's name
  68666. */
  68667. static readonly Name: string;
  68668. /**
  68669. * The (Babylon) version of this module.
  68670. * This is an integer representing the implementation version.
  68671. * This number does not correspond to the webxr specs version
  68672. */
  68673. static readonly Version: number;
  68674. /**
  68675. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  68676. * @param event the (select) event to use to select with
  68677. * @param referenceSpace the reference space to use for this hit test
  68678. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  68679. */
  68680. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  68681. /**
  68682. * execute a hit test with an XR Ray
  68683. *
  68684. * @param xrSession a native xrSession that will execute this hit test
  68685. * @param xrRay the ray (position and direction) to use for raycasting
  68686. * @param referenceSpace native XR reference space to use for the hit-test
  68687. * @param filter filter function that will filter the results
  68688. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  68689. */
  68690. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  68691. /**
  68692. * Triggered when new babylon (transformed) hit test results are available
  68693. */
  68694. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  68695. private _onSelectEnabled;
  68696. /**
  68697. * Creates a new instance of the (legacy version) hit test feature
  68698. * @param _xrSessionManager an instance of WebXRSessionManager
  68699. * @param options options to use when constructing this feature
  68700. */
  68701. constructor(_xrSessionManager: WebXRSessionManager,
  68702. /**
  68703. * options to use when constructing this feature
  68704. */
  68705. options?: IWebXRHitTestOptions);
  68706. /**
  68707. * Populated with the last native XR Hit Results
  68708. */
  68709. lastNativeXRHitResults: XRHitResult[];
  68710. /**
  68711. * attach this feature
  68712. * Will usually be called by the features manager
  68713. *
  68714. * @returns true if successful.
  68715. */
  68716. attach(): boolean;
  68717. /**
  68718. * detach this feature.
  68719. * Will usually be called by the features manager
  68720. *
  68721. * @returns true if successful.
  68722. */
  68723. detach(): boolean;
  68724. private _onHitTestResults;
  68725. private _origin;
  68726. private _direction;
  68727. private _mat;
  68728. protected _onXRFrame(frame: XRFrame): void;
  68729. private _onSelect;
  68730. /**
  68731. * Dispose this feature and all of the resources attached
  68732. */
  68733. dispose(): void;
  68734. }
  68735. }
  68736. declare module BABYLON {
  68737. /**
  68738. * Options used in the plane detector module
  68739. */
  68740. export interface IWebXRPlaneDetectorOptions {
  68741. /**
  68742. * The node to use to transform the local results to world coordinates
  68743. */
  68744. worldParentNode?: TransformNode;
  68745. }
  68746. /**
  68747. * A babylon interface for a webxr plane.
  68748. * A Plane is actually a polygon, built from N points in space
  68749. *
  68750. * Supported in chrome 79, not supported in canary 81 ATM
  68751. */
  68752. export interface IWebXRPlane {
  68753. /**
  68754. * a babylon-assigned ID for this polygon
  68755. */
  68756. id: number;
  68757. /**
  68758. * the native xr-plane object
  68759. */
  68760. xrPlane: XRPlane;
  68761. /**
  68762. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  68763. */
  68764. polygonDefinition: Array<Vector3>;
  68765. /**
  68766. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  68767. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  68768. */
  68769. transformationMatrix: Matrix;
  68770. }
  68771. /**
  68772. * The plane detector is used to detect planes in the real world when in AR
  68773. * For more information see https://github.com/immersive-web/real-world-geometry/
  68774. */
  68775. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  68776. private _options;
  68777. /**
  68778. * The module's name
  68779. */
  68780. static readonly Name: string;
  68781. /**
  68782. * The (Babylon) version of this module.
  68783. * This is an integer representing the implementation version.
  68784. * This number does not correspond to the webxr specs version
  68785. */
  68786. static readonly Version: number;
  68787. /**
  68788. * Observers registered here will be executed when a new plane was added to the session
  68789. */
  68790. onPlaneAddedObservable: Observable<IWebXRPlane>;
  68791. /**
  68792. * Observers registered here will be executed when a plane is no longer detected in the session
  68793. */
  68794. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  68795. /**
  68796. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  68797. * This can execute N times every frame
  68798. */
  68799. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  68800. private _enabled;
  68801. private _detectedPlanes;
  68802. private _lastFrameDetected;
  68803. /**
  68804. * construct a new Plane Detector
  68805. * @param _xrSessionManager an instance of xr Session manager
  68806. * @param _options configuration to use when constructing this feature
  68807. */
  68808. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  68809. private _init;
  68810. protected _onXRFrame(frame: XRFrame): void;
  68811. /**
  68812. * Dispose this feature and all of the resources attached
  68813. */
  68814. dispose(): void;
  68815. private _updatePlaneWithXRPlane;
  68816. /**
  68817. * avoiding using Array.find for global support.
  68818. * @param xrPlane the plane to find in the array
  68819. */
  68820. private findIndexInPlaneArray;
  68821. }
  68822. }
  68823. declare module BABYLON {
  68824. /**
  68825. * Configuration options of the anchor system
  68826. */
  68827. export interface IWebXRAnchorSystemOptions {
  68828. /**
  68829. * a node that will be used to convert local to world coordinates
  68830. */
  68831. worldParentNode?: TransformNode;
  68832. /**
  68833. * should the anchor system use plane detection.
  68834. * If set to true, the plane-detection feature should be set using setPlaneDetector
  68835. */
  68836. usePlaneDetection?: boolean;
  68837. /**
  68838. * Should a new anchor be added every time a select event is triggered
  68839. */
  68840. addAnchorOnSelect?: boolean;
  68841. }
  68842. /**
  68843. * A babylon container for an XR Anchor
  68844. */
  68845. export interface IWebXRAnchor {
  68846. /**
  68847. * A babylon-assigned ID for this anchor
  68848. */
  68849. id: number;
  68850. /**
  68851. * The native anchor object
  68852. */
  68853. xrAnchor: XRAnchor;
  68854. /**
  68855. * Transformation matrix to apply to an object attached to this anchor
  68856. */
  68857. transformationMatrix: Matrix;
  68858. }
  68859. /**
  68860. * An implementation of the anchor system of WebXR.
  68861. * Note that the current documented implementation is not available in any browser. Future implementations
  68862. * will use the frame to create an anchor and not the session or a detected plane
  68863. * For further information see https://github.com/immersive-web/anchors/
  68864. */
  68865. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  68866. private _options;
  68867. /**
  68868. * The module's name
  68869. */
  68870. static readonly Name: string;
  68871. /**
  68872. * The (Babylon) version of this module.
  68873. * This is an integer representing the implementation version.
  68874. * This number does not correspond to the webxr specs version
  68875. */
  68876. static readonly Version: number;
  68877. /**
  68878. * Observers registered here will be executed when a new anchor was added to the session
  68879. */
  68880. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  68881. /**
  68882. * Observers registered here will be executed when an existing anchor updates
  68883. * This can execute N times every frame
  68884. */
  68885. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  68886. /**
  68887. * Observers registered here will be executed when an anchor was removed from the session
  68888. */
  68889. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  68890. private _planeDetector;
  68891. private _hitTestModule;
  68892. private _enabled;
  68893. private _trackedAnchors;
  68894. private _lastFrameDetected;
  68895. /**
  68896. * constructs a new anchor system
  68897. * @param _xrSessionManager an instance of WebXRSessionManager
  68898. * @param _options configuration object for this feature
  68899. */
  68900. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  68901. /**
  68902. * set the plane detector to use in order to create anchors from frames
  68903. * @param planeDetector the plane-detector module to use
  68904. * @param enable enable plane-anchors. default is true
  68905. */
  68906. setPlaneDetector(planeDetector: WebXRPlaneDetector, enable?: boolean): void;
  68907. /**
  68908. * If set, it will improve performance by using the current hit-test results instead of executing a new hit-test
  68909. * @param hitTestModule the hit-test module to use.
  68910. */
  68911. setHitTestModule(hitTestModule: WebXRHitTestLegacy): void;
  68912. /**
  68913. * attach this feature
  68914. * Will usually be called by the features manager
  68915. *
  68916. * @returns true if successful.
  68917. */
  68918. attach(): boolean;
  68919. /**
  68920. * detach this feature.
  68921. * Will usually be called by the features manager
  68922. *
  68923. * @returns true if successful.
  68924. */
  68925. detach(): boolean;
  68926. /**
  68927. * Dispose this feature and all of the resources attached
  68928. */
  68929. dispose(): void;
  68930. protected _onXRFrame(frame: XRFrame): void;
  68931. private _onSelect;
  68932. /**
  68933. * Add anchor at a specific XR point.
  68934. *
  68935. * @param xrRigidTransformation xr-coordinates where a new anchor should be added
  68936. * @param anchorCreator the object o use to create an anchor with. either a session or a plane
  68937. * @returns a promise the fulfills when the anchor was created
  68938. */
  68939. addAnchorAtRigidTransformation(xrRigidTransformation: XRRigidTransform, anchorCreator?: XRAnchorCreator): Promise<XRAnchor>;
  68940. private _updateAnchorWithXRFrame;
  68941. /**
  68942. * avoiding using Array.find for global support.
  68943. * @param xrAnchor the plane to find in the array
  68944. */
  68945. private _findIndexInAnchorArray;
  68946. }
  68947. }
  68948. declare module BABYLON {
  68949. /**
  68950. * Options interface for the background remover plugin
  68951. */
  68952. export interface IWebXRBackgroundRemoverOptions {
  68953. /**
  68954. * don't disable the environment helper
  68955. */
  68956. ignoreEnvironmentHelper?: boolean;
  68957. /**
  68958. * flags to configure the removal of the environment helper.
  68959. * If not set, the entire background will be removed. If set, flags should be set as well.
  68960. */
  68961. environmentHelperRemovalFlags?: {
  68962. /**
  68963. * Should the skybox be removed (default false)
  68964. */
  68965. skyBox?: boolean;
  68966. /**
  68967. * Should the ground be removed (default false)
  68968. */
  68969. ground?: boolean;
  68970. };
  68971. /**
  68972. * Further background meshes to disable when entering AR
  68973. */
  68974. backgroundMeshes?: AbstractMesh[];
  68975. }
  68976. /**
  68977. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  68978. */
  68979. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  68980. /**
  68981. * read-only options to be used in this module
  68982. */
  68983. readonly options: IWebXRBackgroundRemoverOptions;
  68984. /**
  68985. * The module's name
  68986. */
  68987. static readonly Name: string;
  68988. /**
  68989. * The (Babylon) version of this module.
  68990. * This is an integer representing the implementation version.
  68991. * This number does not correspond to the webxr specs version
  68992. */
  68993. static readonly Version: number;
  68994. /**
  68995. * registered observers will be triggered when the background state changes
  68996. */
  68997. onBackgroundStateChangedObservable: Observable<boolean>;
  68998. /**
  68999. * constructs a new background remover module
  69000. * @param _xrSessionManager the session manager for this module
  69001. * @param options read-only options to be used in this module
  69002. */
  69003. constructor(_xrSessionManager: WebXRSessionManager,
  69004. /**
  69005. * read-only options to be used in this module
  69006. */
  69007. options?: IWebXRBackgroundRemoverOptions);
  69008. /**
  69009. * attach this feature
  69010. * Will usually be called by the features manager
  69011. *
  69012. * @returns true if successful.
  69013. */
  69014. attach(): boolean;
  69015. /**
  69016. * detach this feature.
  69017. * Will usually be called by the features manager
  69018. *
  69019. * @returns true if successful.
  69020. */
  69021. detach(): boolean;
  69022. private _setBackgroundState;
  69023. /**
  69024. * Dispose this feature and all of the resources attached
  69025. */
  69026. dispose(): void;
  69027. protected _onXRFrame(_xrFrame: XRFrame): void;
  69028. }
  69029. }
  69030. declare module BABYLON {
  69031. /**
  69032. * Options for the controller physics feature
  69033. */
  69034. export class IWebXRControllerPhysicsOptions {
  69035. /**
  69036. * the xr input to use with this pointer selection
  69037. */
  69038. xrInput: WebXRInput;
  69039. /**
  69040. * The physics properties of the future impostors
  69041. */
  69042. physicsProperties?: {
  69043. /**
  69044. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  69045. * Note that this requires a physics engine that supports mesh impostors!
  69046. */
  69047. useControllerMesh?: boolean;
  69048. /**
  69049. * The type of impostor to create. Default is sphere
  69050. */
  69051. impostorType?: number;
  69052. /**
  69053. * the size of the impostor. Defaults to 10cm
  69054. */
  69055. impostorSize?: number | {
  69056. width: number;
  69057. height: number;
  69058. depth: number;
  69059. };
  69060. /**
  69061. * Friction definitions
  69062. */
  69063. friction?: number;
  69064. /**
  69065. * Restitution
  69066. */
  69067. restitution?: number;
  69068. };
  69069. /**
  69070. * Should the headset get its own impostor
  69071. */
  69072. enableHeadsetImpostor?: boolean;
  69073. /**
  69074. * Optional parameters for the headset impostor
  69075. */
  69076. headsetImpostorParams?: {
  69077. /**
  69078. * The type of impostor to create. Default is sphere
  69079. */
  69080. impostorType: number;
  69081. /**
  69082. * the size of the impostor. Defaults to 10cm
  69083. */
  69084. impostorSize?: number | {
  69085. width: number;
  69086. height: number;
  69087. depth: number;
  69088. };
  69089. /**
  69090. * Friction definitions
  69091. */
  69092. friction?: number;
  69093. /**
  69094. * Restitution
  69095. */
  69096. restitution?: number;
  69097. };
  69098. }
  69099. /**
  69100. * Add physics impostor to your webxr controllers,
  69101. * including naive calculation of their linear and angular velocity
  69102. */
  69103. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  69104. private readonly _options;
  69105. /**
  69106. * The module's name
  69107. */
  69108. static readonly Name: string;
  69109. /**
  69110. * The (Babylon) version of this module.
  69111. * This is an integer representing the implementation version.
  69112. * This number does not correspond to the webxr specs version
  69113. */
  69114. static readonly Version: number;
  69115. private _lastTimestamp;
  69116. private _delta;
  69117. private _controllers;
  69118. private _headsetImpostor?;
  69119. private _headsetMesh?;
  69120. private _tmpVector;
  69121. private _tmpQuaternion;
  69122. /**
  69123. * Construct a new Controller Physics Feature
  69124. * @param _xrSessionManager the corresponding xr session manager
  69125. * @param _options options to create this feature with
  69126. */
  69127. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  69128. /**
  69129. * Update the physics properties provided in the constructor
  69130. * @param newProperties the new properties object
  69131. */
  69132. setPhysicsProperties(newProperties: {
  69133. impostorType?: number;
  69134. impostorSize?: number | {
  69135. width: number;
  69136. height: number;
  69137. depth: number;
  69138. };
  69139. friction?: number;
  69140. restitution?: number;
  69141. }): void;
  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. */
  69147. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  69148. /**
  69149. * Get the headset impostor, if enabled
  69150. */
  69151. getHeadsetImpostor(): PhysicsImpostor | undefined;
  69152. /**
  69153. * attach this feature
  69154. * Will usually be called by the features manager
  69155. *
  69156. * @returns true if successful.
  69157. */
  69158. attach(): boolean;
  69159. /**
  69160. * detach this feature.
  69161. * Will usually be called by the features manager
  69162. *
  69163. * @returns true if successful.
  69164. */
  69165. detach(): boolean;
  69166. /**
  69167. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  69168. * @param xrController the controller to add
  69169. */
  69170. addController(xrController: WebXRInputSource): void;
  69171. private _debugMode;
  69172. /**
  69173. * @hidden
  69174. * enable debugging - will show console outputs and the impostor mesh
  69175. */
  69176. _enablePhysicsDebug(): void;
  69177. private _attachController;
  69178. private _detachController;
  69179. protected _onXRFrame(_xrFrame: any): void;
  69180. }
  69181. }
  69182. declare module BABYLON {
  69183. /**
  69184. * The motion controller class for all microsoft mixed reality controllers
  69185. */
  69186. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  69187. /**
  69188. * The base url used to load the left and right controller models
  69189. */
  69190. static MODEL_BASE_URL: string;
  69191. /**
  69192. * The name of the left controller model file
  69193. */
  69194. static MODEL_LEFT_FILENAME: string;
  69195. /**
  69196. * The name of the right controller model file
  69197. */
  69198. static MODEL_RIGHT_FILENAME: string;
  69199. profileId: string;
  69200. protected readonly _mapping: {
  69201. defaultButton: {
  69202. "valueNodeName": string;
  69203. "unpressedNodeName": string;
  69204. "pressedNodeName": string;
  69205. };
  69206. defaultAxis: {
  69207. "valueNodeName": string;
  69208. "minNodeName": string;
  69209. "maxNodeName": string;
  69210. };
  69211. buttons: {
  69212. "xr-standard-trigger": {
  69213. "rootNodeName": string;
  69214. "componentProperty": string;
  69215. "states": string[];
  69216. };
  69217. "xr-standard-squeeze": {
  69218. "rootNodeName": string;
  69219. "componentProperty": string;
  69220. "states": string[];
  69221. };
  69222. "xr-standard-touchpad": {
  69223. "rootNodeName": string;
  69224. "labelAnchorNodeName": string;
  69225. "touchPointNodeName": string;
  69226. };
  69227. "xr-standard-thumbstick": {
  69228. "rootNodeName": string;
  69229. "componentProperty": string;
  69230. "states": string[];
  69231. };
  69232. };
  69233. axes: {
  69234. "xr-standard-touchpad": {
  69235. "x-axis": {
  69236. "rootNodeName": string;
  69237. };
  69238. "y-axis": {
  69239. "rootNodeName": string;
  69240. };
  69241. };
  69242. "xr-standard-thumbstick": {
  69243. "x-axis": {
  69244. "rootNodeName": string;
  69245. };
  69246. "y-axis": {
  69247. "rootNodeName": string;
  69248. };
  69249. };
  69250. };
  69251. };
  69252. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  69253. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  69254. protected _getFilenameAndPath(): {
  69255. filename: string;
  69256. path: string;
  69257. };
  69258. protected _updateModel(): void;
  69259. protected _getModelLoadingConstraints(): boolean;
  69260. protected _setRootMesh(meshes: AbstractMesh[]): void;
  69261. }
  69262. }
  69263. declare module BABYLON {
  69264. /**
  69265. * The motion controller class for oculus touch (quest, rift).
  69266. * This class supports legacy mapping as well the standard xr mapping
  69267. */
  69268. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  69269. private _forceLegacyControllers;
  69270. /**
  69271. * The base url used to load the left and right controller models
  69272. */
  69273. static MODEL_BASE_URL: string;
  69274. /**
  69275. * The name of the left controller model file
  69276. */
  69277. static MODEL_LEFT_FILENAME: string;
  69278. /**
  69279. * The name of the right controller model file
  69280. */
  69281. static MODEL_RIGHT_FILENAME: string;
  69282. /**
  69283. * Base Url for the Quest controller model.
  69284. */
  69285. static QUEST_MODEL_BASE_URL: string;
  69286. profileId: string;
  69287. private _modelRootNode;
  69288. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  69289. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  69290. protected _getFilenameAndPath(): {
  69291. filename: string;
  69292. path: string;
  69293. };
  69294. /**
  69295. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  69296. * between the touch and touch 2.
  69297. */
  69298. private _isQuest;
  69299. protected _updateModel(): void;
  69300. protected _getModelLoadingConstraints(): boolean;
  69301. protected _setRootMesh(meshes: AbstractMesh[]): void;
  69302. }
  69303. }
  69304. declare module BABYLON {
  69305. /**
  69306. * The motion controller class for the standard HTC-Vive controllers
  69307. */
  69308. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  69309. /**
  69310. * The base url used to load the left and right controller models
  69311. */
  69312. static MODEL_BASE_URL: string;
  69313. /**
  69314. * File name for the controller model.
  69315. */
  69316. static MODEL_FILENAME: string;
  69317. profileId: string;
  69318. private _modelRootNode;
  69319. /**
  69320. * Create a new Vive motion controller object
  69321. * @param scene the scene to use to create this controller
  69322. * @param gamepadObject the corresponding gamepad object
  69323. * @param handness the handness of the controller
  69324. */
  69325. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  69326. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  69327. protected _getFilenameAndPath(): {
  69328. filename: string;
  69329. path: string;
  69330. };
  69331. protected _updateModel(): void;
  69332. protected _getModelLoadingConstraints(): boolean;
  69333. protected _setRootMesh(meshes: AbstractMesh[]): void;
  69334. }
  69335. }
  69336. declare module BABYLON {
  69337. /**
  69338. * A cursor which tracks a point on a path
  69339. */
  69340. export class PathCursor {
  69341. private path;
  69342. /**
  69343. * Stores path cursor callbacks for when an onchange event is triggered
  69344. */
  69345. private _onchange;
  69346. /**
  69347. * The value of the path cursor
  69348. */
  69349. value: number;
  69350. /**
  69351. * The animation array of the path cursor
  69352. */
  69353. animations: Animation[];
  69354. /**
  69355. * Initializes the path cursor
  69356. * @param path The path to track
  69357. */
  69358. constructor(path: Path2);
  69359. /**
  69360. * Gets the cursor point on the path
  69361. * @returns A point on the path cursor at the cursor location
  69362. */
  69363. getPoint(): Vector3;
  69364. /**
  69365. * Moves the cursor ahead by the step amount
  69366. * @param step The amount to move the cursor forward
  69367. * @returns This path cursor
  69368. */
  69369. moveAhead(step?: number): PathCursor;
  69370. /**
  69371. * Moves the cursor behind by the step amount
  69372. * @param step The amount to move the cursor back
  69373. * @returns This path cursor
  69374. */
  69375. moveBack(step?: number): PathCursor;
  69376. /**
  69377. * Moves the cursor by the step amount
  69378. * If the step amount is greater than one, an exception is thrown
  69379. * @param step The amount to move the cursor
  69380. * @returns This path cursor
  69381. */
  69382. move(step: number): PathCursor;
  69383. /**
  69384. * Ensures that the value is limited between zero and one
  69385. * @returns This path cursor
  69386. */
  69387. private ensureLimits;
  69388. /**
  69389. * Runs onchange callbacks on change (used by the animation engine)
  69390. * @returns This path cursor
  69391. */
  69392. private raiseOnChange;
  69393. /**
  69394. * Executes a function on change
  69395. * @param f A path cursor onchange callback
  69396. * @returns This path cursor
  69397. */
  69398. onchange(f: (cursor: PathCursor) => void): PathCursor;
  69399. }
  69400. }
  69401. declare module BABYLON {
  69402. /** @hidden */
  69403. export var blurPixelShader: {
  69404. name: string;
  69405. shader: string;
  69406. };
  69407. }
  69408. declare module BABYLON {
  69409. /** @hidden */
  69410. export var pointCloudVertexDeclaration: {
  69411. name: string;
  69412. shader: string;
  69413. };
  69414. }
  69415. // Mixins
  69416. interface Window {
  69417. mozIndexedDB: IDBFactory;
  69418. webkitIndexedDB: IDBFactory;
  69419. msIndexedDB: IDBFactory;
  69420. webkitURL: typeof URL;
  69421. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  69422. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  69423. WebGLRenderingContext: WebGLRenderingContext;
  69424. MSGesture: MSGesture;
  69425. CANNON: any;
  69426. AudioContext: AudioContext;
  69427. webkitAudioContext: AudioContext;
  69428. PointerEvent: any;
  69429. Math: Math;
  69430. Uint8Array: Uint8ArrayConstructor;
  69431. Float32Array: Float32ArrayConstructor;
  69432. mozURL: typeof URL;
  69433. msURL: typeof URL;
  69434. VRFrameData: any; // WebVR, from specs 1.1
  69435. DracoDecoderModule: any;
  69436. setImmediate(handler: (...args: any[]) => void): number;
  69437. }
  69438. interface HTMLCanvasElement {
  69439. requestPointerLock(): void;
  69440. msRequestPointerLock?(): void;
  69441. mozRequestPointerLock?(): void;
  69442. webkitRequestPointerLock?(): void;
  69443. /** Track wether a record is in progress */
  69444. isRecording: boolean;
  69445. /** Capture Stream method defined by some browsers */
  69446. captureStream(fps?: number): MediaStream;
  69447. }
  69448. interface CanvasRenderingContext2D {
  69449. msImageSmoothingEnabled: boolean;
  69450. }
  69451. interface MouseEvent {
  69452. mozMovementX: number;
  69453. mozMovementY: number;
  69454. webkitMovementX: number;
  69455. webkitMovementY: number;
  69456. msMovementX: number;
  69457. msMovementY: number;
  69458. }
  69459. interface Navigator {
  69460. mozGetVRDevices: (any: any) => any;
  69461. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  69462. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  69463. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  69464. webkitGetGamepads(): Gamepad[];
  69465. msGetGamepads(): Gamepad[];
  69466. webkitGamepads(): Gamepad[];
  69467. }
  69468. interface HTMLVideoElement {
  69469. mozSrcObject: any;
  69470. }
  69471. interface Math {
  69472. fround(x: number): number;
  69473. imul(a: number, b: number): number;
  69474. }
  69475. interface WebGLRenderingContext {
  69476. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  69477. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  69478. vertexAttribDivisor(index: number, divisor: number): void;
  69479. createVertexArray(): any;
  69480. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  69481. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  69482. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  69483. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  69484. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  69485. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  69486. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  69487. // Queries
  69488. createQuery(): WebGLQuery;
  69489. deleteQuery(query: WebGLQuery): void;
  69490. beginQuery(target: number, query: WebGLQuery): void;
  69491. endQuery(target: number): void;
  69492. getQueryParameter(query: WebGLQuery, pname: number): any;
  69493. getQuery(target: number, pname: number): any;
  69494. MAX_SAMPLES: number;
  69495. RGBA8: number;
  69496. READ_FRAMEBUFFER: number;
  69497. DRAW_FRAMEBUFFER: number;
  69498. UNIFORM_BUFFER: number;
  69499. HALF_FLOAT_OES: number;
  69500. RGBA16F: number;
  69501. RGBA32F: number;
  69502. R32F: number;
  69503. RG32F: number;
  69504. RGB32F: number;
  69505. R16F: number;
  69506. RG16F: number;
  69507. RGB16F: number;
  69508. RED: number;
  69509. RG: number;
  69510. R8: number;
  69511. RG8: number;
  69512. UNSIGNED_INT_24_8: number;
  69513. DEPTH24_STENCIL8: number;
  69514. MIN: number;
  69515. MAX: number;
  69516. /* Multiple Render Targets */
  69517. drawBuffers(buffers: number[]): void;
  69518. readBuffer(src: number): void;
  69519. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  69520. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  69521. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  69522. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  69523. // Occlusion Query
  69524. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  69525. ANY_SAMPLES_PASSED: number;
  69526. QUERY_RESULT_AVAILABLE: number;
  69527. QUERY_RESULT: number;
  69528. }
  69529. interface WebGLProgram {
  69530. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  69531. }
  69532. interface EXT_disjoint_timer_query {
  69533. QUERY_COUNTER_BITS_EXT: number;
  69534. TIME_ELAPSED_EXT: number;
  69535. TIMESTAMP_EXT: number;
  69536. GPU_DISJOINT_EXT: number;
  69537. QUERY_RESULT_EXT: number;
  69538. QUERY_RESULT_AVAILABLE_EXT: number;
  69539. queryCounterEXT(query: WebGLQuery, target: number): void;
  69540. createQueryEXT(): WebGLQuery;
  69541. beginQueryEXT(target: number, query: WebGLQuery): void;
  69542. endQueryEXT(target: number): void;
  69543. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  69544. deleteQueryEXT(query: WebGLQuery): void;
  69545. }
  69546. interface WebGLUniformLocation {
  69547. _currentState: any;
  69548. }
  69549. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  69550. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  69551. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  69552. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  69553. interface WebGLRenderingContext {
  69554. readonly RASTERIZER_DISCARD: number;
  69555. readonly DEPTH_COMPONENT24: number;
  69556. readonly TEXTURE_3D: number;
  69557. readonly TEXTURE_2D_ARRAY: number;
  69558. readonly TEXTURE_COMPARE_FUNC: number;
  69559. readonly TEXTURE_COMPARE_MODE: number;
  69560. readonly COMPARE_REF_TO_TEXTURE: number;
  69561. readonly TEXTURE_WRAP_R: number;
  69562. readonly HALF_FLOAT: number;
  69563. readonly RGB8: number;
  69564. readonly RED_INTEGER: number;
  69565. readonly RG_INTEGER: number;
  69566. readonly RGB_INTEGER: number;
  69567. readonly RGBA_INTEGER: number;
  69568. readonly R8_SNORM: number;
  69569. readonly RG8_SNORM: number;
  69570. readonly RGB8_SNORM: number;
  69571. readonly RGBA8_SNORM: number;
  69572. readonly R8I: number;
  69573. readonly RG8I: number;
  69574. readonly RGB8I: number;
  69575. readonly RGBA8I: number;
  69576. readonly R8UI: number;
  69577. readonly RG8UI: number;
  69578. readonly RGB8UI: number;
  69579. readonly RGBA8UI: number;
  69580. readonly R16I: number;
  69581. readonly RG16I: number;
  69582. readonly RGB16I: number;
  69583. readonly RGBA16I: number;
  69584. readonly R16UI: number;
  69585. readonly RG16UI: number;
  69586. readonly RGB16UI: number;
  69587. readonly RGBA16UI: number;
  69588. readonly R32I: number;
  69589. readonly RG32I: number;
  69590. readonly RGB32I: number;
  69591. readonly RGBA32I: number;
  69592. readonly R32UI: number;
  69593. readonly RG32UI: number;
  69594. readonly RGB32UI: number;
  69595. readonly RGBA32UI: number;
  69596. readonly RGB10_A2UI: number;
  69597. readonly R11F_G11F_B10F: number;
  69598. readonly RGB9_E5: number;
  69599. readonly RGB10_A2: number;
  69600. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  69601. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  69602. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  69603. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  69604. readonly DEPTH_COMPONENT32F: number;
  69605. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  69606. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  69607. 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;
  69608. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  69609. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  69610. readonly TRANSFORM_FEEDBACK: number;
  69611. readonly INTERLEAVED_ATTRIBS: number;
  69612. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  69613. createTransformFeedback(): WebGLTransformFeedback;
  69614. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  69615. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  69616. beginTransformFeedback(primitiveMode: number): void;
  69617. endTransformFeedback(): void;
  69618. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  69619. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  69620. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  69621. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  69622. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  69623. }
  69624. interface ImageBitmap {
  69625. readonly width: number;
  69626. readonly height: number;
  69627. close(): void;
  69628. }
  69629. interface WebGLQuery extends WebGLObject {
  69630. }
  69631. declare var WebGLQuery: {
  69632. prototype: WebGLQuery;
  69633. new(): WebGLQuery;
  69634. };
  69635. interface WebGLSampler extends WebGLObject {
  69636. }
  69637. declare var WebGLSampler: {
  69638. prototype: WebGLSampler;
  69639. new(): WebGLSampler;
  69640. };
  69641. interface WebGLSync extends WebGLObject {
  69642. }
  69643. declare var WebGLSync: {
  69644. prototype: WebGLSync;
  69645. new(): WebGLSync;
  69646. };
  69647. interface WebGLTransformFeedback extends WebGLObject {
  69648. }
  69649. declare var WebGLTransformFeedback: {
  69650. prototype: WebGLTransformFeedback;
  69651. new(): WebGLTransformFeedback;
  69652. };
  69653. interface WebGLVertexArrayObject extends WebGLObject {
  69654. }
  69655. declare var WebGLVertexArrayObject: {
  69656. prototype: WebGLVertexArrayObject;
  69657. new(): WebGLVertexArrayObject;
  69658. };
  69659. // Type definitions for WebVR API
  69660. // Project: https://w3c.github.io/webvr/
  69661. // Definitions by: six a <https://github.com/lostfictions>
  69662. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  69663. interface VRDisplay extends EventTarget {
  69664. /**
  69665. * Dictionary of capabilities describing the VRDisplay.
  69666. */
  69667. readonly capabilities: VRDisplayCapabilities;
  69668. /**
  69669. * z-depth defining the far plane of the eye view frustum
  69670. * enables mapping of values in the render target depth
  69671. * attachment to scene coordinates. Initially set to 10000.0.
  69672. */
  69673. depthFar: number;
  69674. /**
  69675. * z-depth defining the near plane of the eye view frustum
  69676. * enables mapping of values in the render target depth
  69677. * attachment to scene coordinates. Initially set to 0.01.
  69678. */
  69679. depthNear: number;
  69680. /**
  69681. * An identifier for this distinct VRDisplay. Used as an
  69682. * association point in the Gamepad API.
  69683. */
  69684. readonly displayId: number;
  69685. /**
  69686. * A display name, a user-readable name identifying it.
  69687. */
  69688. readonly displayName: string;
  69689. readonly isConnected: boolean;
  69690. readonly isPresenting: boolean;
  69691. /**
  69692. * If this VRDisplay supports room-scale experiences, the optional
  69693. * stage attribute contains details on the room-scale parameters.
  69694. */
  69695. readonly stageParameters: VRStageParameters | null;
  69696. /**
  69697. * Passing the value returned by `requestAnimationFrame` to
  69698. * `cancelAnimationFrame` will unregister the callback.
  69699. * @param handle Define the hanle of the request to cancel
  69700. */
  69701. cancelAnimationFrame(handle: number): void;
  69702. /**
  69703. * Stops presenting to the VRDisplay.
  69704. * @returns a promise to know when it stopped
  69705. */
  69706. exitPresent(): Promise<void>;
  69707. /**
  69708. * Return the current VREyeParameters for the given eye.
  69709. * @param whichEye Define the eye we want the parameter for
  69710. * @returns the eye parameters
  69711. */
  69712. getEyeParameters(whichEye: string): VREyeParameters;
  69713. /**
  69714. * Populates the passed VRFrameData with the information required to render
  69715. * the current frame.
  69716. * @param frameData Define the data structure to populate
  69717. * @returns true if ok otherwise false
  69718. */
  69719. getFrameData(frameData: VRFrameData): boolean;
  69720. /**
  69721. * Get the layers currently being presented.
  69722. * @returns the list of VR layers
  69723. */
  69724. getLayers(): VRLayer[];
  69725. /**
  69726. * Return a VRPose containing the future predicted pose of the VRDisplay
  69727. * when the current frame will be presented. The value returned will not
  69728. * change until JavaScript has returned control to the browser.
  69729. *
  69730. * The VRPose will contain the position, orientation, velocity,
  69731. * and acceleration of each of these properties.
  69732. * @returns the pose object
  69733. */
  69734. getPose(): VRPose;
  69735. /**
  69736. * Return the current instantaneous pose of the VRDisplay, with no
  69737. * prediction applied.
  69738. * @returns the current instantaneous pose
  69739. */
  69740. getImmediatePose(): VRPose;
  69741. /**
  69742. * The callback passed to `requestAnimationFrame` will be called
  69743. * any time a new frame should be rendered. When the VRDisplay is
  69744. * presenting the callback will be called at the native refresh
  69745. * rate of the HMD. When not presenting this function acts
  69746. * identically to how window.requestAnimationFrame acts. Content should
  69747. * make no assumptions of frame rate or vsync behavior as the HMD runs
  69748. * asynchronously from other displays and at differing refresh rates.
  69749. * @param callback Define the eaction to run next frame
  69750. * @returns the request handle it
  69751. */
  69752. requestAnimationFrame(callback: FrameRequestCallback): number;
  69753. /**
  69754. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  69755. * Repeat calls while already presenting will update the VRLayers being displayed.
  69756. * @param layers Define the list of layer to present
  69757. * @returns a promise to know when the request has been fulfilled
  69758. */
  69759. requestPresent(layers: VRLayer[]): Promise<void>;
  69760. /**
  69761. * Reset the pose for this display, treating its current position and
  69762. * orientation as the "origin/zero" values. VRPose.position,
  69763. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  69764. * updated when calling resetPose(). This should be called in only
  69765. * sitting-space experiences.
  69766. */
  69767. resetPose(): void;
  69768. /**
  69769. * The VRLayer provided to the VRDisplay will be captured and presented
  69770. * in the HMD. Calling this function has the same effect on the source
  69771. * canvas as any other operation that uses its source image, and canvases
  69772. * created without preserveDrawingBuffer set to true will be cleared.
  69773. * @param pose Define the pose to submit
  69774. */
  69775. submitFrame(pose?: VRPose): void;
  69776. }
  69777. declare var VRDisplay: {
  69778. prototype: VRDisplay;
  69779. new(): VRDisplay;
  69780. };
  69781. interface VRLayer {
  69782. leftBounds?: number[] | Float32Array | null;
  69783. rightBounds?: number[] | Float32Array | null;
  69784. source?: HTMLCanvasElement | null;
  69785. }
  69786. interface VRDisplayCapabilities {
  69787. readonly canPresent: boolean;
  69788. readonly hasExternalDisplay: boolean;
  69789. readonly hasOrientation: boolean;
  69790. readonly hasPosition: boolean;
  69791. readonly maxLayers: number;
  69792. }
  69793. interface VREyeParameters {
  69794. /** @deprecated */
  69795. readonly fieldOfView: VRFieldOfView;
  69796. readonly offset: Float32Array;
  69797. readonly renderHeight: number;
  69798. readonly renderWidth: number;
  69799. }
  69800. interface VRFieldOfView {
  69801. readonly downDegrees: number;
  69802. readonly leftDegrees: number;
  69803. readonly rightDegrees: number;
  69804. readonly upDegrees: number;
  69805. }
  69806. interface VRFrameData {
  69807. readonly leftProjectionMatrix: Float32Array;
  69808. readonly leftViewMatrix: Float32Array;
  69809. readonly pose: VRPose;
  69810. readonly rightProjectionMatrix: Float32Array;
  69811. readonly rightViewMatrix: Float32Array;
  69812. readonly timestamp: number;
  69813. }
  69814. interface VRPose {
  69815. readonly angularAcceleration: Float32Array | null;
  69816. readonly angularVelocity: Float32Array | null;
  69817. readonly linearAcceleration: Float32Array | null;
  69818. readonly linearVelocity: Float32Array | null;
  69819. readonly orientation: Float32Array | null;
  69820. readonly position: Float32Array | null;
  69821. readonly timestamp: number;
  69822. }
  69823. interface VRStageParameters {
  69824. sittingToStandingTransform?: Float32Array;
  69825. sizeX?: number;
  69826. sizeY?: number;
  69827. }
  69828. interface Navigator {
  69829. getVRDisplays(): Promise<VRDisplay[]>;
  69830. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  69831. }
  69832. interface Window {
  69833. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  69834. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  69835. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  69836. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  69837. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  69838. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  69839. }
  69840. interface Gamepad {
  69841. readonly displayId: number;
  69842. }
  69843. type XRSessionMode =
  69844. | "inline"
  69845. | "immersive-vr"
  69846. | "immersive-ar";
  69847. type XRReferenceSpaceType =
  69848. | "viewer"
  69849. | "local"
  69850. | "local-floor"
  69851. | "bounded-floor"
  69852. | "unbounded";
  69853. type XREnvironmentBlendMode =
  69854. | "opaque"
  69855. | "additive"
  69856. | "alpha-blend";
  69857. type XRVisibilityState =
  69858. | "visible"
  69859. | "visible-blurred"
  69860. | "hidden";
  69861. type XRHandedness =
  69862. | "none"
  69863. | "left"
  69864. | "right";
  69865. type XRTargetRayMode =
  69866. | "gaze"
  69867. | "tracked-pointer"
  69868. | "screen";
  69869. type XREye =
  69870. | "none"
  69871. | "left"
  69872. | "right";
  69873. interface XRSpace extends EventTarget {
  69874. }
  69875. interface XRRenderState {
  69876. depthNear?: number;
  69877. depthFar?: number;
  69878. inlineVerticalFieldOfView?: number;
  69879. baseLayer?: XRWebGLLayer;
  69880. }
  69881. interface XRInputSource {
  69882. handedness: XRHandedness;
  69883. targetRayMode: XRTargetRayMode;
  69884. targetRaySpace: XRSpace;
  69885. gripSpace: XRSpace | undefined;
  69886. gamepad: Gamepad | undefined;
  69887. profiles: Array<string>;
  69888. }
  69889. interface XRSessionInit {
  69890. optionalFeatures?: XRReferenceSpaceType[];
  69891. requiredFeatures?: XRReferenceSpaceType[];
  69892. }
  69893. interface XRSession extends XRAnchorCreator {
  69894. addEventListener: Function;
  69895. removeEventListener: Function;
  69896. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  69897. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  69898. requestAnimationFrame: Function;
  69899. end(): Promise<void>;
  69900. renderState: XRRenderState;
  69901. inputSources: Array<XRInputSource>;
  69902. // AR hit test
  69903. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  69904. updateWorldTrackingState(options: {
  69905. planeDetectionState?: { enabled: boolean; }
  69906. }): void;
  69907. }
  69908. interface XRReferenceSpace extends XRSpace {
  69909. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  69910. onreset: any;
  69911. }
  69912. type XRPlaneSet = Set<XRPlane>;
  69913. type XRAnchorSet = Set<XRAnchor>;
  69914. interface XRFrame {
  69915. session: XRSession;
  69916. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  69917. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  69918. // Anchors
  69919. trackedAnchors?: XRAnchorSet;
  69920. // Planes
  69921. worldInformation: {
  69922. detectedPlanes?: XRPlaneSet;
  69923. };
  69924. }
  69925. interface XRViewerPose extends XRPose {
  69926. views: Array<XRView>;
  69927. }
  69928. interface XRPose {
  69929. transform: XRRigidTransform;
  69930. emulatedPosition: boolean;
  69931. }
  69932. interface XRWebGLLayerOptions {
  69933. antialias?: boolean;
  69934. depth?: boolean;
  69935. stencil?: boolean;
  69936. alpha?: boolean;
  69937. multiview?: boolean;
  69938. framebufferScaleFactor?: number;
  69939. }
  69940. declare var XRWebGLLayer: {
  69941. prototype: XRWebGLLayer;
  69942. new(session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  69943. };
  69944. interface XRWebGLLayer {
  69945. framebuffer: WebGLFramebuffer;
  69946. framebufferWidth: number;
  69947. framebufferHeight: number;
  69948. getViewport: Function;
  69949. }
  69950. declare class XRRigidTransform {
  69951. constructor(matrix: Float32Array | DOMPointInit, direction?: DOMPointInit);
  69952. position: DOMPointReadOnly;
  69953. orientation: DOMPointReadOnly;
  69954. matrix: Float32Array;
  69955. inverse: XRRigidTransform;
  69956. }
  69957. interface XRView {
  69958. eye: XREye;
  69959. projectionMatrix: Float32Array;
  69960. transform: XRRigidTransform;
  69961. }
  69962. interface XRInputSourceChangeEvent {
  69963. session: XRSession;
  69964. removed: Array<XRInputSource>;
  69965. added: Array<XRInputSource>;
  69966. }
  69967. interface XRInputSourceEvent extends Event {
  69968. readonly frame: XRFrame;
  69969. readonly inputSource: XRInputSource;
  69970. }
  69971. // Experimental(er) features
  69972. declare class XRRay {
  69973. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  69974. origin: DOMPointReadOnly;
  69975. direction: DOMPointReadOnly;
  69976. matrix: Float32Array;
  69977. }
  69978. interface XRHitResult {
  69979. hitMatrix: Float32Array;
  69980. }
  69981. interface XRAnchor {
  69982. // remove?
  69983. id?: string;
  69984. anchorSpace: XRSpace;
  69985. lastChangedTime: number;
  69986. detach(): void;
  69987. }
  69988. interface XRPlane extends XRAnchorCreator {
  69989. orientation: "Horizontal" | "Vertical";
  69990. planeSpace: XRSpace;
  69991. polygon: Array<DOMPointReadOnly>;
  69992. lastChangedTime: number;
  69993. }
  69994. interface XRAnchorCreator {
  69995. // AR Anchors
  69996. createAnchor(pose: XRPose | XRRigidTransform, referenceSpace: XRReferenceSpace): Promise<XRAnchor>;
  69997. }
  69998. /**
  69999. * @ignore
  70000. */
  70001. declare module BABYLON.GLTF2.Exporter {
  70002. }
  70003. /**
  70004. * @ignore
  70005. */
  70006. declare module BABYLON.GLTF1 {
  70007. }
  70008. declare module BABYLON.GUI {
  70009. /**
  70010. * Class used to specific a value and its associated unit
  70011. */
  70012. export class ValueAndUnit {
  70013. /** defines the unit to store */
  70014. unit: number;
  70015. /** defines a boolean indicating if the value can be negative */
  70016. negativeValueAllowed: boolean;
  70017. private _value;
  70018. private _originalUnit;
  70019. /**
  70020. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  70021. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  70022. */
  70023. ignoreAdaptiveScaling: boolean;
  70024. /**
  70025. * Creates a new ValueAndUnit
  70026. * @param value defines the value to store
  70027. * @param unit defines the unit to store
  70028. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  70029. */
  70030. constructor(value: number,
  70031. /** defines the unit to store */
  70032. unit?: number,
  70033. /** defines a boolean indicating if the value can be negative */
  70034. negativeValueAllowed?: boolean);
  70035. /** Gets a boolean indicating if the value is a percentage */
  70036. get isPercentage(): boolean;
  70037. /** Gets a boolean indicating if the value is store as pixel */
  70038. get isPixel(): boolean;
  70039. /** Gets direct internal value */
  70040. get internalValue(): number;
  70041. /**
  70042. * Gets value as pixel
  70043. * @param host defines the root host
  70044. * @param refValue defines the reference value for percentages
  70045. * @returns the value as pixel
  70046. */
  70047. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  70048. /**
  70049. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  70050. * @param value defines the value to store
  70051. * @param unit defines the unit to store
  70052. * @returns the current ValueAndUnit
  70053. */
  70054. updateInPlace(value: number, unit?: number): ValueAndUnit;
  70055. /**
  70056. * Gets the value accordingly to its unit
  70057. * @param host defines the root host
  70058. * @returns the value
  70059. */
  70060. getValue(host: AdvancedDynamicTexture): number;
  70061. /**
  70062. * Gets a string representation of the value
  70063. * @param host defines the root host
  70064. * @param decimals defines an optional number of decimals to display
  70065. * @returns a string
  70066. */
  70067. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  70068. /**
  70069. * Store a value parsed from a string
  70070. * @param source defines the source string
  70071. * @returns true if the value was successfully parsed
  70072. */
  70073. fromString(source: string | number): boolean;
  70074. private static _Regex;
  70075. private static _UNITMODE_PERCENTAGE;
  70076. private static _UNITMODE_PIXEL;
  70077. /** UNITMODE_PERCENTAGE */
  70078. static get UNITMODE_PERCENTAGE(): number;
  70079. /** UNITMODE_PIXEL */
  70080. static get UNITMODE_PIXEL(): number;
  70081. }
  70082. }
  70083. declare module BABYLON.GUI {
  70084. /**
  70085. * Define a style used by control to automatically setup properties based on a template.
  70086. * Only support font related properties so far
  70087. */
  70088. export class Style implements BABYLON.IDisposable {
  70089. private _fontFamily;
  70090. private _fontStyle;
  70091. private _fontWeight;
  70092. /** @hidden */
  70093. _host: AdvancedDynamicTexture;
  70094. /** @hidden */
  70095. _fontSize: ValueAndUnit;
  70096. /**
  70097. * BABYLON.Observable raised when the style values are changed
  70098. */
  70099. onChangedObservable: BABYLON.Observable<Style>;
  70100. /**
  70101. * Creates a new style object
  70102. * @param host defines the AdvancedDynamicTexture which hosts this style
  70103. */
  70104. constructor(host: AdvancedDynamicTexture);
  70105. /**
  70106. * Gets or sets the font size
  70107. */
  70108. get fontSize(): string | number;
  70109. set fontSize(value: string | number);
  70110. /**
  70111. * Gets or sets the font family
  70112. */
  70113. get fontFamily(): string;
  70114. set fontFamily(value: string);
  70115. /**
  70116. * Gets or sets the font style
  70117. */
  70118. get fontStyle(): string;
  70119. set fontStyle(value: string);
  70120. /** Gets or sets font weight */
  70121. get fontWeight(): string;
  70122. set fontWeight(value: string);
  70123. /** Dispose all associated resources */
  70124. dispose(): void;
  70125. }
  70126. }
  70127. declare module BABYLON.GUI {
  70128. /**
  70129. * Class used to transport BABYLON.Vector2 information for pointer events
  70130. */
  70131. export class Vector2WithInfo extends BABYLON.Vector2 {
  70132. /** defines the current mouse button index */
  70133. buttonIndex: number;
  70134. /**
  70135. * Creates a new Vector2WithInfo
  70136. * @param source defines the vector2 data to transport
  70137. * @param buttonIndex defines the current mouse button index
  70138. */
  70139. constructor(source: BABYLON.Vector2,
  70140. /** defines the current mouse button index */
  70141. buttonIndex?: number);
  70142. }
  70143. /** Class used to provide 2D matrix features */
  70144. export class Matrix2D {
  70145. /** Gets the internal array of 6 floats used to store matrix data */
  70146. m: Float32Array;
  70147. /**
  70148. * Creates a new matrix
  70149. * @param m00 defines value for (0, 0)
  70150. * @param m01 defines value for (0, 1)
  70151. * @param m10 defines value for (1, 0)
  70152. * @param m11 defines value for (1, 1)
  70153. * @param m20 defines value for (2, 0)
  70154. * @param m21 defines value for (2, 1)
  70155. */
  70156. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  70157. /**
  70158. * Fills the matrix from direct values
  70159. * @param m00 defines value for (0, 0)
  70160. * @param m01 defines value for (0, 1)
  70161. * @param m10 defines value for (1, 0)
  70162. * @param m11 defines value for (1, 1)
  70163. * @param m20 defines value for (2, 0)
  70164. * @param m21 defines value for (2, 1)
  70165. * @returns the current modified matrix
  70166. */
  70167. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  70168. /**
  70169. * Gets matrix determinant
  70170. * @returns the determinant
  70171. */
  70172. determinant(): number;
  70173. /**
  70174. * Inverses the matrix and stores it in a target matrix
  70175. * @param result defines the target matrix
  70176. * @returns the current matrix
  70177. */
  70178. invertToRef(result: Matrix2D): Matrix2D;
  70179. /**
  70180. * Multiplies the current matrix with another one
  70181. * @param other defines the second operand
  70182. * @param result defines the target matrix
  70183. * @returns the current matrix
  70184. */
  70185. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  70186. /**
  70187. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  70188. * @param x defines the x coordinate to transform
  70189. * @param y defines the x coordinate to transform
  70190. * @param result defines the target vector2
  70191. * @returns the current matrix
  70192. */
  70193. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  70194. /**
  70195. * Creates an identity matrix
  70196. * @returns a new matrix
  70197. */
  70198. static Identity(): Matrix2D;
  70199. /**
  70200. * Creates a translation matrix and stores it in a target matrix
  70201. * @param x defines the x coordinate of the translation
  70202. * @param y defines the y coordinate of the translation
  70203. * @param result defines the target matrix
  70204. */
  70205. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  70206. /**
  70207. * Creates a scaling matrix and stores it in a target matrix
  70208. * @param x defines the x coordinate of the scaling
  70209. * @param y defines the y coordinate of the scaling
  70210. * @param result defines the target matrix
  70211. */
  70212. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  70213. /**
  70214. * Creates a rotation matrix and stores it in a target matrix
  70215. * @param angle defines the rotation angle
  70216. * @param result defines the target matrix
  70217. */
  70218. static RotationToRef(angle: number, result: Matrix2D): void;
  70219. private static _TempPreTranslationMatrix;
  70220. private static _TempPostTranslationMatrix;
  70221. private static _TempRotationMatrix;
  70222. private static _TempScalingMatrix;
  70223. private static _TempCompose0;
  70224. private static _TempCompose1;
  70225. private static _TempCompose2;
  70226. /**
  70227. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  70228. * @param tx defines the x coordinate of the translation
  70229. * @param ty defines the y coordinate of the translation
  70230. * @param angle defines the rotation angle
  70231. * @param scaleX defines the x coordinate of the scaling
  70232. * @param scaleY defines the y coordinate of the scaling
  70233. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  70234. * @param result defines the target matrix
  70235. */
  70236. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  70237. }
  70238. }
  70239. declare module BABYLON.GUI {
  70240. /**
  70241. * Class used to store 2D control sizes
  70242. */
  70243. export class Measure {
  70244. /** defines left coordinate */
  70245. left: number;
  70246. /** defines top coordinate */
  70247. top: number;
  70248. /** defines width dimension */
  70249. width: number;
  70250. /** defines height dimension */
  70251. height: number;
  70252. /**
  70253. * Creates a new measure
  70254. * @param left defines left coordinate
  70255. * @param top defines top coordinate
  70256. * @param width defines width dimension
  70257. * @param height defines height dimension
  70258. */
  70259. constructor(
  70260. /** defines left coordinate */
  70261. left: number,
  70262. /** defines top coordinate */
  70263. top: number,
  70264. /** defines width dimension */
  70265. width: number,
  70266. /** defines height dimension */
  70267. height: number);
  70268. /**
  70269. * Copy from another measure
  70270. * @param other defines the other measure to copy from
  70271. */
  70272. copyFrom(other: Measure): void;
  70273. /**
  70274. * Copy from a group of 4 floats
  70275. * @param left defines left coordinate
  70276. * @param top defines top coordinate
  70277. * @param width defines width dimension
  70278. * @param height defines height dimension
  70279. */
  70280. copyFromFloats(left: number, top: number, width: number, height: number): void;
  70281. /**
  70282. * Computes the axis aligned bounding box measure for two given measures
  70283. * @param a Input measure
  70284. * @param b Input measure
  70285. * @param result the resulting bounding measure
  70286. */
  70287. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  70288. /**
  70289. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  70290. * @param transform the matrix to transform the measure before computing the AABB
  70291. * @param result the resulting AABB
  70292. */
  70293. transformToRef(transform: Matrix2D, result: Measure): void;
  70294. /**
  70295. * Check equality between this measure and another one
  70296. * @param other defines the other measures
  70297. * @returns true if both measures are equals
  70298. */
  70299. isEqualsTo(other: Measure): boolean;
  70300. /**
  70301. * Creates an empty measure
  70302. * @returns a new measure
  70303. */
  70304. static Empty(): Measure;
  70305. }
  70306. }
  70307. declare module BABYLON.GUI {
  70308. /**
  70309. * Interface used to define a control that can receive focus
  70310. */
  70311. export interface IFocusableControl {
  70312. /**
  70313. * Function called when the control receives the focus
  70314. */
  70315. onFocus(): void;
  70316. /**
  70317. * Function called when the control loses the focus
  70318. */
  70319. onBlur(): void;
  70320. /**
  70321. * Function called to let the control handle keyboard events
  70322. * @param evt defines the current keyboard event
  70323. */
  70324. processKeyboard(evt: KeyboardEvent): void;
  70325. /**
  70326. * Function called to get the list of controls that should not steal the focus from this control
  70327. * @returns an array of controls
  70328. */
  70329. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  70330. }
  70331. /**
  70332. * Class used to create texture to support 2D GUI elements
  70333. * @see http://doc.babylonjs.com/how_to/gui
  70334. */
  70335. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  70336. private _isDirty;
  70337. private _renderObserver;
  70338. private _resizeObserver;
  70339. private _preKeyboardObserver;
  70340. private _pointerMoveObserver;
  70341. private _pointerObserver;
  70342. private _canvasPointerOutObserver;
  70343. private _background;
  70344. /** @hidden */
  70345. _rootContainer: Container;
  70346. /** @hidden */
  70347. _lastPickedControl: Control;
  70348. /** @hidden */
  70349. _lastControlOver: {
  70350. [pointerId: number]: Control;
  70351. };
  70352. /** @hidden */
  70353. _lastControlDown: {
  70354. [pointerId: number]: Control;
  70355. };
  70356. /** @hidden */
  70357. _capturingControl: {
  70358. [pointerId: number]: Control;
  70359. };
  70360. /** @hidden */
  70361. _shouldBlockPointer: boolean;
  70362. /** @hidden */
  70363. _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  70364. /** @hidden */
  70365. _linkedControls: Control[];
  70366. private _isFullscreen;
  70367. private _fullscreenViewport;
  70368. private _idealWidth;
  70369. private _idealHeight;
  70370. private _useSmallestIdeal;
  70371. private _renderAtIdealSize;
  70372. private _focusedControl;
  70373. private _blockNextFocusCheck;
  70374. private _renderScale;
  70375. private _rootElement;
  70376. private _cursorChanged;
  70377. /** @hidden */
  70378. _numLayoutCalls: number;
  70379. /** Gets the number of layout calls made the last time the ADT has been rendered */
  70380. get numLayoutCalls(): number;
  70381. /** @hidden */
  70382. _numRenderCalls: number;
  70383. /** Gets the number of render calls made the last time the ADT has been rendered */
  70384. get numRenderCalls(): number;
  70385. /**
  70386. * Define type to string to ensure compatibility across browsers
  70387. * Safari doesn't support DataTransfer constructor
  70388. */
  70389. private _clipboardData;
  70390. /**
  70391. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  70392. */
  70393. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  70394. /**
  70395. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  70396. */
  70397. onControlPickedObservable: BABYLON.Observable<Control>;
  70398. /**
  70399. * BABYLON.Observable event triggered before layout is evaluated
  70400. */
  70401. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  70402. /**
  70403. * BABYLON.Observable event triggered after the layout was evaluated
  70404. */
  70405. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  70406. /**
  70407. * BABYLON.Observable event triggered before the texture is rendered
  70408. */
  70409. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  70410. /**
  70411. * BABYLON.Observable event triggered after the texture was rendered
  70412. */
  70413. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  70414. /**
  70415. * Gets or sets a boolean defining if alpha is stored as premultiplied
  70416. */
  70417. premulAlpha: boolean;
  70418. /**
  70419. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  70420. * Useful when you want more antialiasing
  70421. */
  70422. get renderScale(): number;
  70423. set renderScale(value: number);
  70424. /** Gets or sets the background color */
  70425. get background(): string;
  70426. set background(value: string);
  70427. /**
  70428. * Gets or sets the ideal width used to design controls.
  70429. * The GUI will then rescale everything accordingly
  70430. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  70431. */
  70432. get idealWidth(): number;
  70433. set idealWidth(value: number);
  70434. /**
  70435. * Gets or sets the ideal height used to design controls.
  70436. * The GUI will then rescale everything accordingly
  70437. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  70438. */
  70439. get idealHeight(): number;
  70440. set idealHeight(value: number);
  70441. /**
  70442. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  70443. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  70444. */
  70445. get useSmallestIdeal(): boolean;
  70446. set useSmallestIdeal(value: boolean);
  70447. /**
  70448. * Gets or sets a boolean indicating if adaptive scaling must be used
  70449. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  70450. */
  70451. get renderAtIdealSize(): boolean;
  70452. set renderAtIdealSize(value: boolean);
  70453. /**
  70454. * Gets the ratio used when in "ideal mode"
  70455. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  70456. * */
  70457. get idealRatio(): number;
  70458. /**
  70459. * Gets the underlying layer used to render the texture when in fullscreen mode
  70460. */
  70461. get layer(): BABYLON.Nullable<BABYLON.Layer>;
  70462. /**
  70463. * Gets the root container control
  70464. */
  70465. get rootContainer(): Container;
  70466. /**
  70467. * Returns an array containing the root container.
  70468. * This is mostly used to let the Inspector introspects the ADT
  70469. * @returns an array containing the rootContainer
  70470. */
  70471. getChildren(): Array<Container>;
  70472. /**
  70473. * Will return all controls that are inside this texture
  70474. * @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
  70475. * @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
  70476. * @return all child controls
  70477. */
  70478. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  70479. /**
  70480. * Gets or sets the current focused control
  70481. */
  70482. get focusedControl(): BABYLON.Nullable<IFocusableControl>;
  70483. set focusedControl(control: BABYLON.Nullable<IFocusableControl>);
  70484. /**
  70485. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  70486. */
  70487. get isForeground(): boolean;
  70488. set isForeground(value: boolean);
  70489. /**
  70490. * Gets or set information about clipboardData
  70491. */
  70492. get clipboardData(): string;
  70493. set clipboardData(value: string);
  70494. /**
  70495. * Creates a new AdvancedDynamicTexture
  70496. * @param name defines the name of the texture
  70497. * @param width defines the width of the texture
  70498. * @param height defines the height of the texture
  70499. * @param scene defines the hosting scene
  70500. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  70501. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  70502. */
  70503. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number);
  70504. /**
  70505. * Get the current class name of the texture useful for serialization or dynamic coding.
  70506. * @returns "AdvancedDynamicTexture"
  70507. */
  70508. getClassName(): string;
  70509. /**
  70510. * Function used to execute a function on all controls
  70511. * @param func defines the function to execute
  70512. * @param container defines the container where controls belong. If null the root container will be used
  70513. */
  70514. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  70515. private _useInvalidateRectOptimization;
  70516. /**
  70517. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  70518. */
  70519. get useInvalidateRectOptimization(): boolean;
  70520. set useInvalidateRectOptimization(value: boolean);
  70521. private _invalidatedRectangle;
  70522. /**
  70523. * Invalidates a rectangle area on the gui texture
  70524. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  70525. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  70526. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  70527. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  70528. */
  70529. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  70530. /**
  70531. * Marks the texture as dirty forcing a complete update
  70532. */
  70533. markAsDirty(): void;
  70534. /**
  70535. * Helper function used to create a new style
  70536. * @returns a new style
  70537. * @see http://doc.babylonjs.com/how_to/gui#styles
  70538. */
  70539. createStyle(): Style;
  70540. /**
  70541. * Adds a new control to the root container
  70542. * @param control defines the control to add
  70543. * @returns the current texture
  70544. */
  70545. addControl(control: Control): AdvancedDynamicTexture;
  70546. /**
  70547. * Removes a control from the root container
  70548. * @param control defines the control to remove
  70549. * @returns the current texture
  70550. */
  70551. removeControl(control: Control): AdvancedDynamicTexture;
  70552. /**
  70553. * Release all resources
  70554. */
  70555. dispose(): void;
  70556. private _onResize;
  70557. /** @hidden */
  70558. _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  70559. /**
  70560. * Get screen coordinates for a vector3
  70561. * @param position defines the position to project
  70562. * @param worldMatrix defines the world matrix to use
  70563. * @returns the projected position
  70564. */
  70565. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  70566. private _checkUpdate;
  70567. private _clearMeasure;
  70568. private _render;
  70569. /** @hidden */
  70570. _changeCursor(cursor: string): void;
  70571. /** @hidden */
  70572. _registerLastControlDown(control: Control, pointerId: number): void;
  70573. private _doPicking;
  70574. /** @hidden */
  70575. _cleanControlAfterRemovalFromList(list: {
  70576. [pointerId: number]: Control;
  70577. }, control: Control): void;
  70578. /** @hidden */
  70579. _cleanControlAfterRemoval(control: Control): void;
  70580. /** Attach to all scene events required to support pointer events */
  70581. attach(): void;
  70582. /** @hidden */
  70583. private onClipboardCopy;
  70584. /** @hidden */
  70585. private onClipboardCut;
  70586. /** @hidden */
  70587. private onClipboardPaste;
  70588. /**
  70589. * Register the clipboard Events onto the canvas
  70590. */
  70591. registerClipboardEvents(): void;
  70592. /**
  70593. * Unregister the clipboard Events from the canvas
  70594. */
  70595. unRegisterClipboardEvents(): void;
  70596. /**
  70597. * Connect the texture to a hosting mesh to enable interactions
  70598. * @param mesh defines the mesh to attach to
  70599. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  70600. */
  70601. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  70602. /**
  70603. * Move the focus to a specific control
  70604. * @param control defines the control which will receive the focus
  70605. */
  70606. moveFocusToControl(control: IFocusableControl): void;
  70607. private _manageFocus;
  70608. private _attachToOnPointerOut;
  70609. /**
  70610. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  70611. * @param mesh defines the mesh which will receive the texture
  70612. * @param width defines the texture width (1024 by default)
  70613. * @param height defines the texture height (1024 by default)
  70614. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  70615. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  70616. * @returns a new AdvancedDynamicTexture
  70617. */
  70618. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean): AdvancedDynamicTexture;
  70619. /**
  70620. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  70621. * In this mode the texture will rely on a layer for its rendering.
  70622. * This allows it to be treated like any other layer.
  70623. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  70624. * LayerMask is set through advancedTexture.layer.layerMask
  70625. * @param name defines name for the texture
  70626. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  70627. * @param scene defines the hsoting scene
  70628. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  70629. * @returns a new AdvancedDynamicTexture
  70630. */
  70631. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  70632. }
  70633. }
  70634. declare module BABYLON.GUI {
  70635. /**
  70636. * Root class used for all 2D controls
  70637. * @see http://doc.babylonjs.com/how_to/gui#controls
  70638. */
  70639. export class Control {
  70640. /** defines the name of the control */
  70641. name?: string | undefined;
  70642. /**
  70643. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  70644. */
  70645. static AllowAlphaInheritance: boolean;
  70646. private _alpha;
  70647. private _alphaSet;
  70648. private _zIndex;
  70649. /** @hidden */
  70650. _host: AdvancedDynamicTexture;
  70651. /** Gets or sets the control parent */
  70652. parent: BABYLON.Nullable<Container>;
  70653. /** @hidden */
  70654. _currentMeasure: Measure;
  70655. private _fontFamily;
  70656. private _fontStyle;
  70657. private _fontWeight;
  70658. private _fontSize;
  70659. private _font;
  70660. /** @hidden */
  70661. _width: ValueAndUnit;
  70662. /** @hidden */
  70663. _height: ValueAndUnit;
  70664. /** @hidden */
  70665. protected _fontOffset: {
  70666. ascent: number;
  70667. height: number;
  70668. descent: number;
  70669. };
  70670. private _color;
  70671. private _style;
  70672. private _styleObserver;
  70673. /** @hidden */
  70674. protected _horizontalAlignment: number;
  70675. /** @hidden */
  70676. protected _verticalAlignment: number;
  70677. /** @hidden */
  70678. protected _isDirty: boolean;
  70679. /** @hidden */
  70680. protected _wasDirty: boolean;
  70681. /** @hidden */
  70682. _tempParentMeasure: Measure;
  70683. /** @hidden */
  70684. _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  70685. /** @hidden */
  70686. protected _cachedParentMeasure: Measure;
  70687. private _paddingLeft;
  70688. private _paddingRight;
  70689. private _paddingTop;
  70690. private _paddingBottom;
  70691. /** @hidden */
  70692. _left: ValueAndUnit;
  70693. /** @hidden */
  70694. _top: ValueAndUnit;
  70695. private _scaleX;
  70696. private _scaleY;
  70697. private _rotation;
  70698. private _transformCenterX;
  70699. private _transformCenterY;
  70700. /** @hidden */
  70701. _transformMatrix: Matrix2D;
  70702. /** @hidden */
  70703. protected _invertTransformMatrix: Matrix2D;
  70704. /** @hidden */
  70705. protected _transformedPosition: BABYLON.Vector2;
  70706. private _isMatrixDirty;
  70707. private _cachedOffsetX;
  70708. private _cachedOffsetY;
  70709. private _isVisible;
  70710. private _isHighlighted;
  70711. /** @hidden */
  70712. _linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  70713. private _fontSet;
  70714. private _dummyVector2;
  70715. private _downCount;
  70716. private _enterCount;
  70717. private _doNotRender;
  70718. private _downPointerIds;
  70719. protected _isEnabled: boolean;
  70720. protected _disabledColor: string;
  70721. /** @hidden */
  70722. protected _rebuildLayout: boolean;
  70723. /** @hidden */
  70724. _customData: any;
  70725. /** @hidden */
  70726. _isClipped: boolean;
  70727. /** @hidden */
  70728. _automaticSize: boolean;
  70729. /** @hidden */
  70730. _tag: any;
  70731. /**
  70732. * 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
  70733. */
  70734. uniqueId: number;
  70735. /**
  70736. * Gets or sets an object used to store user defined information for the node
  70737. */
  70738. metadata: any;
  70739. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  70740. isHitTestVisible: boolean;
  70741. /** Gets or sets a boolean indicating if the control can block pointer events */
  70742. isPointerBlocker: boolean;
  70743. /** Gets or sets a boolean indicating if the control can be focusable */
  70744. isFocusInvisible: boolean;
  70745. /**
  70746. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  70747. * 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
  70748. */
  70749. clipChildren: boolean;
  70750. /**
  70751. * Gets or sets a boolean indicating that control content must be clipped
  70752. * 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
  70753. */
  70754. clipContent: boolean;
  70755. /**
  70756. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  70757. */
  70758. useBitmapCache: boolean;
  70759. private _cacheData;
  70760. private _shadowOffsetX;
  70761. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  70762. get shadowOffsetX(): number;
  70763. set shadowOffsetX(value: number);
  70764. private _shadowOffsetY;
  70765. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  70766. get shadowOffsetY(): number;
  70767. set shadowOffsetY(value: number);
  70768. private _shadowBlur;
  70769. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  70770. get shadowBlur(): number;
  70771. set shadowBlur(value: number);
  70772. private _shadowColor;
  70773. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  70774. get shadowColor(): string;
  70775. set shadowColor(value: string);
  70776. /** Gets or sets the cursor to use when the control is hovered */
  70777. hoverCursor: string;
  70778. /** @hidden */
  70779. protected _linkOffsetX: ValueAndUnit;
  70780. /** @hidden */
  70781. protected _linkOffsetY: ValueAndUnit;
  70782. /** Gets the control type name */
  70783. get typeName(): string;
  70784. /**
  70785. * Get the current class name of the control.
  70786. * @returns current class name
  70787. */
  70788. getClassName(): string;
  70789. /**
  70790. * An event triggered when the pointer move over the control.
  70791. */
  70792. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  70793. /**
  70794. * An event triggered when the pointer move out of the control.
  70795. */
  70796. onPointerOutObservable: BABYLON.Observable<Control>;
  70797. /**
  70798. * An event triggered when the pointer taps the control
  70799. */
  70800. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  70801. /**
  70802. * An event triggered when pointer up
  70803. */
  70804. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  70805. /**
  70806. * An event triggered when a control is clicked on
  70807. */
  70808. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  70809. /**
  70810. * An event triggered when pointer enters the control
  70811. */
  70812. onPointerEnterObservable: BABYLON.Observable<Control>;
  70813. /**
  70814. * An event triggered when the control is marked as dirty
  70815. */
  70816. onDirtyObservable: BABYLON.Observable<Control>;
  70817. /**
  70818. * An event triggered before drawing the control
  70819. */
  70820. onBeforeDrawObservable: BABYLON.Observable<Control>;
  70821. /**
  70822. * An event triggered after the control was drawn
  70823. */
  70824. onAfterDrawObservable: BABYLON.Observable<Control>;
  70825. /**
  70826. * Get the hosting AdvancedDynamicTexture
  70827. */
  70828. get host(): AdvancedDynamicTexture;
  70829. /** Gets or set information about font offsets (used to render and align text) */
  70830. get fontOffset(): {
  70831. ascent: number;
  70832. height: number;
  70833. descent: number;
  70834. };
  70835. set fontOffset(offset: {
  70836. ascent: number;
  70837. height: number;
  70838. descent: number;
  70839. });
  70840. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  70841. get alpha(): number;
  70842. set alpha(value: number);
  70843. /**
  70844. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  70845. */
  70846. get isHighlighted(): boolean;
  70847. set isHighlighted(value: boolean);
  70848. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  70849. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  70850. */
  70851. get scaleX(): number;
  70852. set scaleX(value: number);
  70853. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  70854. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  70855. */
  70856. get scaleY(): number;
  70857. set scaleY(value: number);
  70858. /** Gets or sets the rotation angle (0 by default)
  70859. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  70860. */
  70861. get rotation(): number;
  70862. set rotation(value: number);
  70863. /** Gets or sets the transformation center on Y axis (0 by default)
  70864. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  70865. */
  70866. get transformCenterY(): number;
  70867. set transformCenterY(value: number);
  70868. /** Gets or sets the transformation center on X axis (0 by default)
  70869. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  70870. */
  70871. get transformCenterX(): number;
  70872. set transformCenterX(value: number);
  70873. /**
  70874. * Gets or sets the horizontal alignment
  70875. * @see http://doc.babylonjs.com/how_to/gui#alignments
  70876. */
  70877. get horizontalAlignment(): number;
  70878. set horizontalAlignment(value: number);
  70879. /**
  70880. * Gets or sets the vertical alignment
  70881. * @see http://doc.babylonjs.com/how_to/gui#alignments
  70882. */
  70883. get verticalAlignment(): number;
  70884. set verticalAlignment(value: number);
  70885. /**
  70886. * Gets or sets control width
  70887. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  70888. */
  70889. get width(): string | number;
  70890. set width(value: string | number);
  70891. /**
  70892. * Gets or sets the control width in pixel
  70893. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  70894. */
  70895. get widthInPixels(): number;
  70896. set widthInPixels(value: number);
  70897. /**
  70898. * Gets or sets control height
  70899. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  70900. */
  70901. get height(): string | number;
  70902. set height(value: string | number);
  70903. /**
  70904. * Gets or sets control height in pixel
  70905. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  70906. */
  70907. get heightInPixels(): number;
  70908. set heightInPixels(value: number);
  70909. /** Gets or set font family */
  70910. get fontFamily(): string;
  70911. set fontFamily(value: string);
  70912. /** Gets or sets font style */
  70913. get fontStyle(): string;
  70914. set fontStyle(value: string);
  70915. /** Gets or sets font weight */
  70916. get fontWeight(): string;
  70917. set fontWeight(value: string);
  70918. /**
  70919. * Gets or sets style
  70920. * @see http://doc.babylonjs.com/how_to/gui#styles
  70921. */
  70922. get style(): BABYLON.Nullable<Style>;
  70923. set style(value: BABYLON.Nullable<Style>);
  70924. /** @hidden */
  70925. get _isFontSizeInPercentage(): boolean;
  70926. /** Gets or sets font size in pixels */
  70927. get fontSizeInPixels(): number;
  70928. set fontSizeInPixels(value: number);
  70929. /** Gets or sets font size */
  70930. get fontSize(): string | number;
  70931. set fontSize(value: string | number);
  70932. /** Gets or sets foreground color */
  70933. get color(): string;
  70934. set color(value: string);
  70935. /** Gets or sets z index which is used to reorder controls on the z axis */
  70936. get zIndex(): number;
  70937. set zIndex(value: number);
  70938. /** Gets or sets a boolean indicating if the control can be rendered */
  70939. get notRenderable(): boolean;
  70940. set notRenderable(value: boolean);
  70941. /** Gets or sets a boolean indicating if the control is visible */
  70942. get isVisible(): boolean;
  70943. set isVisible(value: boolean);
  70944. /** Gets a boolean indicating that the control needs to update its rendering */
  70945. get isDirty(): boolean;
  70946. /**
  70947. * Gets the current linked mesh (or null if none)
  70948. */
  70949. get linkedMesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  70950. /**
  70951. * Gets or sets a value indicating the padding to use on the left of the control
  70952. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  70953. */
  70954. get paddingLeft(): string | number;
  70955. set paddingLeft(value: string | number);
  70956. /**
  70957. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  70958. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  70959. */
  70960. get paddingLeftInPixels(): number;
  70961. set paddingLeftInPixels(value: number);
  70962. /**
  70963. * Gets or sets a value indicating the padding to use on the right of the control
  70964. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  70965. */
  70966. get paddingRight(): string | number;
  70967. set paddingRight(value: string | number);
  70968. /**
  70969. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  70970. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  70971. */
  70972. get paddingRightInPixels(): number;
  70973. set paddingRightInPixels(value: number);
  70974. /**
  70975. * Gets or sets a value indicating the padding to use on the top of the control
  70976. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  70977. */
  70978. get paddingTop(): string | number;
  70979. set paddingTop(value: string | number);
  70980. /**
  70981. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  70982. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  70983. */
  70984. get paddingTopInPixels(): number;
  70985. set paddingTopInPixels(value: number);
  70986. /**
  70987. * Gets or sets a value indicating the padding to use on the bottom of the control
  70988. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  70989. */
  70990. get paddingBottom(): string | number;
  70991. set paddingBottom(value: string | number);
  70992. /**
  70993. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  70994. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  70995. */
  70996. get paddingBottomInPixels(): number;
  70997. set paddingBottomInPixels(value: number);
  70998. /**
  70999. * Gets or sets a value indicating the left coordinate of the control
  71000. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71001. */
  71002. get left(): string | number;
  71003. set left(value: string | number);
  71004. /**
  71005. * Gets or sets a value indicating the left coordinate in pixels of the control
  71006. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71007. */
  71008. get leftInPixels(): number;
  71009. set leftInPixels(value: number);
  71010. /**
  71011. * Gets or sets a value indicating the top coordinate of the control
  71012. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71013. */
  71014. get top(): string | number;
  71015. set top(value: string | number);
  71016. /**
  71017. * Gets or sets a value indicating the top coordinate in pixels of the control
  71018. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71019. */
  71020. get topInPixels(): number;
  71021. set topInPixels(value: number);
  71022. /**
  71023. * Gets or sets a value indicating the offset on X axis to the linked mesh
  71024. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  71025. */
  71026. get linkOffsetX(): string | number;
  71027. set linkOffsetX(value: string | number);
  71028. /**
  71029. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  71030. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  71031. */
  71032. get linkOffsetXInPixels(): number;
  71033. set linkOffsetXInPixels(value: number);
  71034. /**
  71035. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  71036. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  71037. */
  71038. get linkOffsetY(): string | number;
  71039. set linkOffsetY(value: string | number);
  71040. /**
  71041. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  71042. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  71043. */
  71044. get linkOffsetYInPixels(): number;
  71045. set linkOffsetYInPixels(value: number);
  71046. /** Gets the center coordinate on X axis */
  71047. get centerX(): number;
  71048. /** Gets the center coordinate on Y axis */
  71049. get centerY(): number;
  71050. /** Gets or sets if control is Enabled*/
  71051. get isEnabled(): boolean;
  71052. set isEnabled(value: boolean);
  71053. /** Gets or sets background color of control if it's disabled*/
  71054. get disabledColor(): string;
  71055. set disabledColor(value: string);
  71056. /**
  71057. * Creates a new control
  71058. * @param name defines the name of the control
  71059. */
  71060. constructor(
  71061. /** defines the name of the control */
  71062. name?: string | undefined);
  71063. /** @hidden */
  71064. protected _getTypeName(): string;
  71065. /**
  71066. * Gets the first ascendant in the hierarchy of the given type
  71067. * @param className defines the required type
  71068. * @returns the ascendant or null if not found
  71069. */
  71070. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  71071. /** @hidden */
  71072. _resetFontCache(): void;
  71073. /**
  71074. * Determines if a container is an ascendant of the current control
  71075. * @param container defines the container to look for
  71076. * @returns true if the container is one of the ascendant of the control
  71077. */
  71078. isAscendant(container: Control): boolean;
  71079. /**
  71080. * Gets coordinates in local control space
  71081. * @param globalCoordinates defines the coordinates to transform
  71082. * @returns the new coordinates in local space
  71083. */
  71084. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  71085. /**
  71086. * Gets coordinates in local control space
  71087. * @param globalCoordinates defines the coordinates to transform
  71088. * @param result defines the target vector2 where to store the result
  71089. * @returns the current control
  71090. */
  71091. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  71092. /**
  71093. * Gets coordinates in parent local control space
  71094. * @param globalCoordinates defines the coordinates to transform
  71095. * @returns the new coordinates in parent local space
  71096. */
  71097. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  71098. /**
  71099. * Move the current control to a vector3 position projected onto the screen.
  71100. * @param position defines the target position
  71101. * @param scene defines the hosting scene
  71102. */
  71103. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  71104. /**
  71105. * Will store all controls that have this control as ascendant in a given array
  71106. * @param results defines the array where to store the descendants
  71107. * @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
  71108. * @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
  71109. */
  71110. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  71111. /**
  71112. * Will return all controls that have this control as ascendant
  71113. * @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
  71114. * @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
  71115. * @return all child controls
  71116. */
  71117. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  71118. /**
  71119. * Link current control with a target mesh
  71120. * @param mesh defines the mesh to link with
  71121. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  71122. */
  71123. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.AbstractMesh>): void;
  71124. /** @hidden */
  71125. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  71126. /** @hidden */
  71127. _offsetLeft(offset: number): void;
  71128. /** @hidden */
  71129. _offsetTop(offset: number): void;
  71130. /** @hidden */
  71131. _markMatrixAsDirty(): void;
  71132. /** @hidden */
  71133. _flagDescendantsAsMatrixDirty(): void;
  71134. /** @hidden */
  71135. _intersectsRect(rect: Measure): boolean;
  71136. /** @hidden */
  71137. protected invalidateRect(): void;
  71138. /** @hidden */
  71139. _markAsDirty(force?: boolean): void;
  71140. /** @hidden */
  71141. _markAllAsDirty(): void;
  71142. /** @hidden */
  71143. _link(host: AdvancedDynamicTexture): void;
  71144. /** @hidden */
  71145. protected _transform(context?: CanvasRenderingContext2D): void;
  71146. /** @hidden */
  71147. _renderHighlight(context: CanvasRenderingContext2D): void;
  71148. /** @hidden */
  71149. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  71150. /** @hidden */
  71151. protected _applyStates(context: CanvasRenderingContext2D): void;
  71152. /** @hidden */
  71153. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  71154. /** @hidden */
  71155. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  71156. protected _evaluateClippingState(parentMeasure: Measure): void;
  71157. /** @hidden */
  71158. _measure(): void;
  71159. /** @hidden */
  71160. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  71161. /** @hidden */
  71162. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  71163. /** @hidden */
  71164. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  71165. /** @hidden */
  71166. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  71167. private static _ClipMeasure;
  71168. private _tmpMeasureA;
  71169. private _clip;
  71170. /** @hidden */
  71171. _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  71172. /** @hidden */
  71173. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  71174. /**
  71175. * Tests if a given coordinates belong to the current control
  71176. * @param x defines x coordinate to test
  71177. * @param y defines y coordinate to test
  71178. * @returns true if the coordinates are inside the control
  71179. */
  71180. contains(x: number, y: number): boolean;
  71181. /** @hidden */
  71182. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  71183. /** @hidden */
  71184. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  71185. /** @hidden */
  71186. _onPointerEnter(target: Control): boolean;
  71187. /** @hidden */
  71188. _onPointerOut(target: Control, force?: boolean): void;
  71189. /** @hidden */
  71190. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  71191. /** @hidden */
  71192. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  71193. /** @hidden */
  71194. _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  71195. /** @hidden */
  71196. _processObservables(type: number, x: number, y: number, pointerId: number, buttonIndex: number): boolean;
  71197. private _prepareFont;
  71198. /** Releases associated resources */
  71199. dispose(): void;
  71200. private static _HORIZONTAL_ALIGNMENT_LEFT;
  71201. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  71202. private static _HORIZONTAL_ALIGNMENT_CENTER;
  71203. private static _VERTICAL_ALIGNMENT_TOP;
  71204. private static _VERTICAL_ALIGNMENT_BOTTOM;
  71205. private static _VERTICAL_ALIGNMENT_CENTER;
  71206. /** HORIZONTAL_ALIGNMENT_LEFT */
  71207. static get HORIZONTAL_ALIGNMENT_LEFT(): number;
  71208. /** HORIZONTAL_ALIGNMENT_RIGHT */
  71209. static get HORIZONTAL_ALIGNMENT_RIGHT(): number;
  71210. /** HORIZONTAL_ALIGNMENT_CENTER */
  71211. static get HORIZONTAL_ALIGNMENT_CENTER(): number;
  71212. /** VERTICAL_ALIGNMENT_TOP */
  71213. static get VERTICAL_ALIGNMENT_TOP(): number;
  71214. /** VERTICAL_ALIGNMENT_BOTTOM */
  71215. static get VERTICAL_ALIGNMENT_BOTTOM(): number;
  71216. /** VERTICAL_ALIGNMENT_CENTER */
  71217. static get VERTICAL_ALIGNMENT_CENTER(): number;
  71218. private static _FontHeightSizes;
  71219. /** @hidden */
  71220. static _GetFontOffset(font: string): {
  71221. ascent: number;
  71222. height: number;
  71223. descent: number;
  71224. };
  71225. /**
  71226. * Creates a stack panel that can be used to render headers
  71227. * @param control defines the control to associate with the header
  71228. * @param text defines the text of the header
  71229. * @param size defines the size of the header
  71230. * @param options defines options used to configure the header
  71231. * @returns a new StackPanel
  71232. * @ignore
  71233. * @hidden
  71234. */
  71235. static AddHeader: (control: Control, text: string, size: string | number, options: {
  71236. isHorizontal: boolean;
  71237. controlFirst: boolean;
  71238. }) => any;
  71239. /** @hidden */
  71240. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  71241. }
  71242. }
  71243. declare module BABYLON.GUI {
  71244. /**
  71245. * Root class for 2D containers
  71246. * @see http://doc.babylonjs.com/how_to/gui#containers
  71247. */
  71248. export class Container extends Control {
  71249. name?: string | undefined;
  71250. /** @hidden */
  71251. _children: Control[];
  71252. /** @hidden */
  71253. protected _measureForChildren: Measure;
  71254. /** @hidden */
  71255. protected _background: string;
  71256. /** @hidden */
  71257. protected _adaptWidthToChildren: boolean;
  71258. /** @hidden */
  71259. protected _adaptHeightToChildren: boolean;
  71260. /**
  71261. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  71262. */
  71263. logLayoutCycleErrors: boolean;
  71264. /**
  71265. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  71266. */
  71267. maxLayoutCycle: number;
  71268. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  71269. get adaptHeightToChildren(): boolean;
  71270. set adaptHeightToChildren(value: boolean);
  71271. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  71272. get adaptWidthToChildren(): boolean;
  71273. set adaptWidthToChildren(value: boolean);
  71274. /** Gets or sets background color */
  71275. get background(): string;
  71276. set background(value: string);
  71277. /** Gets the list of children */
  71278. get children(): Control[];
  71279. /**
  71280. * Creates a new Container
  71281. * @param name defines the name of the container
  71282. */
  71283. constructor(name?: string | undefined);
  71284. protected _getTypeName(): string;
  71285. _flagDescendantsAsMatrixDirty(): void;
  71286. /**
  71287. * Gets a child using its name
  71288. * @param name defines the child name to look for
  71289. * @returns the child control if found
  71290. */
  71291. getChildByName(name: string): BABYLON.Nullable<Control>;
  71292. /**
  71293. * Gets a child using its type and its name
  71294. * @param name defines the child name to look for
  71295. * @param type defines the child type to look for
  71296. * @returns the child control if found
  71297. */
  71298. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  71299. /**
  71300. * Search for a specific control in children
  71301. * @param control defines the control to look for
  71302. * @returns true if the control is in child list
  71303. */
  71304. containsControl(control: Control): boolean;
  71305. /**
  71306. * Adds a new control to the current container
  71307. * @param control defines the control to add
  71308. * @returns the current container
  71309. */
  71310. addControl(control: BABYLON.Nullable<Control>): Container;
  71311. /**
  71312. * Removes all controls from the current container
  71313. * @returns the current container
  71314. */
  71315. clearControls(): Container;
  71316. /**
  71317. * Removes a control from the current container
  71318. * @param control defines the control to remove
  71319. * @returns the current container
  71320. */
  71321. removeControl(control: Control): Container;
  71322. /** @hidden */
  71323. _reOrderControl(control: Control): void;
  71324. /** @hidden */
  71325. _offsetLeft(offset: number): void;
  71326. /** @hidden */
  71327. _offsetTop(offset: number): void;
  71328. /** @hidden */
  71329. _markAllAsDirty(): void;
  71330. /** @hidden */
  71331. protected _localDraw(context: CanvasRenderingContext2D): void;
  71332. /** @hidden */
  71333. _link(host: AdvancedDynamicTexture): void;
  71334. /** @hidden */
  71335. protected _beforeLayout(): void;
  71336. /** @hidden */
  71337. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  71338. /** @hidden */
  71339. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  71340. protected _postMeasure(): void;
  71341. /** @hidden */
  71342. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  71343. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  71344. /** @hidden */
  71345. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  71346. /** @hidden */
  71347. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  71348. /** Releases associated resources */
  71349. dispose(): void;
  71350. }
  71351. }
  71352. declare module BABYLON.GUI {
  71353. /** Class used to create rectangle container */
  71354. export class Rectangle extends Container {
  71355. name?: string | undefined;
  71356. private _thickness;
  71357. private _cornerRadius;
  71358. /** Gets or sets border thickness */
  71359. get thickness(): number;
  71360. set thickness(value: number);
  71361. /** Gets or sets the corner radius angle */
  71362. get cornerRadius(): number;
  71363. set cornerRadius(value: number);
  71364. /**
  71365. * Creates a new Rectangle
  71366. * @param name defines the control name
  71367. */
  71368. constructor(name?: string | undefined);
  71369. protected _getTypeName(): string;
  71370. protected _localDraw(context: CanvasRenderingContext2D): void;
  71371. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  71372. private _drawRoundedRect;
  71373. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  71374. }
  71375. }
  71376. declare module BABYLON.GUI {
  71377. /**
  71378. * Enum that determines the text-wrapping mode to use.
  71379. */
  71380. export enum TextWrapping {
  71381. /**
  71382. * Clip the text when it's larger than Control.width; this is the default mode.
  71383. */
  71384. Clip = 0,
  71385. /**
  71386. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  71387. */
  71388. WordWrap = 1,
  71389. /**
  71390. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  71391. */
  71392. Ellipsis = 2
  71393. }
  71394. /**
  71395. * Class used to create text block control
  71396. */
  71397. export class TextBlock extends Control {
  71398. /**
  71399. * Defines the name of the control
  71400. */
  71401. name?: string | undefined;
  71402. private _text;
  71403. private _textWrapping;
  71404. private _textHorizontalAlignment;
  71405. private _textVerticalAlignment;
  71406. private _lines;
  71407. private _resizeToFit;
  71408. private _lineSpacing;
  71409. private _outlineWidth;
  71410. private _outlineColor;
  71411. /**
  71412. * An event triggered after the text is changed
  71413. */
  71414. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  71415. /**
  71416. * An event triggered after the text was broken up into lines
  71417. */
  71418. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  71419. /**
  71420. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  71421. */
  71422. get lines(): any[];
  71423. /**
  71424. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  71425. */
  71426. get resizeToFit(): boolean;
  71427. /**
  71428. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  71429. */
  71430. set resizeToFit(value: boolean);
  71431. /**
  71432. * Gets or sets a boolean indicating if text must be wrapped
  71433. */
  71434. get textWrapping(): TextWrapping | boolean;
  71435. /**
  71436. * Gets or sets a boolean indicating if text must be wrapped
  71437. */
  71438. set textWrapping(value: TextWrapping | boolean);
  71439. /**
  71440. * Gets or sets text to display
  71441. */
  71442. get text(): string;
  71443. /**
  71444. * Gets or sets text to display
  71445. */
  71446. set text(value: string);
  71447. /**
  71448. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  71449. */
  71450. get textHorizontalAlignment(): number;
  71451. /**
  71452. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  71453. */
  71454. set textHorizontalAlignment(value: number);
  71455. /**
  71456. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  71457. */
  71458. get textVerticalAlignment(): number;
  71459. /**
  71460. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  71461. */
  71462. set textVerticalAlignment(value: number);
  71463. /**
  71464. * Gets or sets line spacing value
  71465. */
  71466. set lineSpacing(value: string | number);
  71467. /**
  71468. * Gets or sets line spacing value
  71469. */
  71470. get lineSpacing(): string | number;
  71471. /**
  71472. * Gets or sets outlineWidth of the text to display
  71473. */
  71474. get outlineWidth(): number;
  71475. /**
  71476. * Gets or sets outlineWidth of the text to display
  71477. */
  71478. set outlineWidth(value: number);
  71479. /**
  71480. * Gets or sets outlineColor of the text to display
  71481. */
  71482. get outlineColor(): string;
  71483. /**
  71484. * Gets or sets outlineColor of the text to display
  71485. */
  71486. set outlineColor(value: string);
  71487. /**
  71488. * Creates a new TextBlock object
  71489. * @param name defines the name of the control
  71490. * @param text defines the text to display (emptry string by default)
  71491. */
  71492. constructor(
  71493. /**
  71494. * Defines the name of the control
  71495. */
  71496. name?: string | undefined, text?: string);
  71497. protected _getTypeName(): string;
  71498. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  71499. private _drawText;
  71500. /** @hidden */
  71501. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  71502. protected _applyStates(context: CanvasRenderingContext2D): void;
  71503. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  71504. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  71505. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  71506. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  71507. protected _renderLines(context: CanvasRenderingContext2D): void;
  71508. /**
  71509. * Given a width constraint applied on the text block, find the expected height
  71510. * @returns expected height
  71511. */
  71512. computeExpectedHeight(): number;
  71513. dispose(): void;
  71514. }
  71515. }
  71516. declare module BABYLON.GUI {
  71517. /**
  71518. * Class used to create 2D images
  71519. */
  71520. export class Image extends Control {
  71521. name?: string | undefined;
  71522. private _workingCanvas;
  71523. private _domImage;
  71524. private _imageWidth;
  71525. private _imageHeight;
  71526. private _loaded;
  71527. private _stretch;
  71528. private _source;
  71529. private _autoScale;
  71530. private _sourceLeft;
  71531. private _sourceTop;
  71532. private _sourceWidth;
  71533. private _sourceHeight;
  71534. private _svgAttributesComputationCompleted;
  71535. private _isSVG;
  71536. private _cellWidth;
  71537. private _cellHeight;
  71538. private _cellId;
  71539. private _populateNinePatchSlicesFromImage;
  71540. private _sliceLeft;
  71541. private _sliceRight;
  71542. private _sliceTop;
  71543. private _sliceBottom;
  71544. private _detectPointerOnOpaqueOnly;
  71545. /**
  71546. * BABYLON.Observable notified when the content is loaded
  71547. */
  71548. onImageLoadedObservable: BABYLON.Observable<Image>;
  71549. /**
  71550. * BABYLON.Observable notified when _sourceLeft, _sourceTop, _sourceWidth and _sourceHeight are computed
  71551. */
  71552. onSVGAttributesComputedObservable: BABYLON.Observable<Image>;
  71553. /**
  71554. * Gets a boolean indicating that the content is loaded
  71555. */
  71556. get isLoaded(): boolean;
  71557. /**
  71558. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  71559. */
  71560. get populateNinePatchSlicesFromImage(): boolean;
  71561. set populateNinePatchSlicesFromImage(value: boolean);
  71562. /**
  71563. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  71564. * Beware using this as this will comsume more memory as the image has to be stored twice
  71565. */
  71566. get detectPointerOnOpaqueOnly(): boolean;
  71567. set detectPointerOnOpaqueOnly(value: boolean);
  71568. /**
  71569. * Gets or sets the left value for slicing (9-patch)
  71570. */
  71571. get sliceLeft(): number;
  71572. set sliceLeft(value: number);
  71573. /**
  71574. * Gets or sets the right value for slicing (9-patch)
  71575. */
  71576. get sliceRight(): number;
  71577. set sliceRight(value: number);
  71578. /**
  71579. * Gets or sets the top value for slicing (9-patch)
  71580. */
  71581. get sliceTop(): number;
  71582. set sliceTop(value: number);
  71583. /**
  71584. * Gets or sets the bottom value for slicing (9-patch)
  71585. */
  71586. get sliceBottom(): number;
  71587. set sliceBottom(value: number);
  71588. /**
  71589. * Gets or sets the left coordinate in the source image
  71590. */
  71591. get sourceLeft(): number;
  71592. set sourceLeft(value: number);
  71593. /**
  71594. * Gets or sets the top coordinate in the source image
  71595. */
  71596. get sourceTop(): number;
  71597. set sourceTop(value: number);
  71598. /**
  71599. * Gets or sets the width to capture in the source image
  71600. */
  71601. get sourceWidth(): number;
  71602. set sourceWidth(value: number);
  71603. /**
  71604. * Gets or sets the height to capture in the source image
  71605. */
  71606. get sourceHeight(): number;
  71607. set sourceHeight(value: number);
  71608. /** Indicates if the format of the image is SVG */
  71609. get isSVG(): boolean;
  71610. /** Gets the status of the SVG attributes computation (sourceLeft, sourceTop, sourceWidth, sourceHeight) */
  71611. get svgAttributesComputationCompleted(): boolean;
  71612. /**
  71613. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  71614. * @see http://doc.babylonjs.com/how_to/gui#image
  71615. */
  71616. get autoScale(): boolean;
  71617. set autoScale(value: boolean);
  71618. /** Gets or sets the streching mode used by the image */
  71619. get stretch(): number;
  71620. set stretch(value: number);
  71621. /** @hidden */
  71622. _rotate90(n: number, preserveProperties?: boolean): Image;
  71623. private _handleRotationForSVGImage;
  71624. private _rotate90SourceProperties;
  71625. /**
  71626. * Gets or sets the internal DOM image used to render the control
  71627. */
  71628. set domImage(value: HTMLImageElement);
  71629. get domImage(): HTMLImageElement;
  71630. private _onImageLoaded;
  71631. private _extractNinePatchSliceDataFromImage;
  71632. /**
  71633. * Gets or sets image source url
  71634. */
  71635. set source(value: BABYLON.Nullable<string>);
  71636. /**
  71637. * Checks for svg document with icon id present
  71638. */
  71639. private _svgCheck;
  71640. /**
  71641. * Sets sourceLeft, sourceTop, sourceWidth, sourceHeight automatically
  71642. * given external svg file and icon id
  71643. */
  71644. private _getSVGAttribs;
  71645. /**
  71646. * Gets or sets the cell width to use when animation sheet is enabled
  71647. * @see http://doc.babylonjs.com/how_to/gui#image
  71648. */
  71649. get cellWidth(): number;
  71650. set cellWidth(value: number);
  71651. /**
  71652. * Gets or sets the cell height to use when animation sheet is enabled
  71653. * @see http://doc.babylonjs.com/how_to/gui#image
  71654. */
  71655. get cellHeight(): number;
  71656. set cellHeight(value: number);
  71657. /**
  71658. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  71659. * @see http://doc.babylonjs.com/how_to/gui#image
  71660. */
  71661. get cellId(): number;
  71662. set cellId(value: number);
  71663. /**
  71664. * Creates a new Image
  71665. * @param name defines the control name
  71666. * @param url defines the image url
  71667. */
  71668. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  71669. /**
  71670. * Tests if a given coordinates belong to the current control
  71671. * @param x defines x coordinate to test
  71672. * @param y defines y coordinate to test
  71673. * @returns true if the coordinates are inside the control
  71674. */
  71675. contains(x: number, y: number): boolean;
  71676. protected _getTypeName(): string;
  71677. /** Force the control to synchronize with its content */
  71678. synchronizeSizeWithContent(): void;
  71679. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  71680. private _prepareWorkingCanvasForOpaqueDetection;
  71681. private _drawImage;
  71682. _draw(context: CanvasRenderingContext2D): void;
  71683. private _renderCornerPatch;
  71684. private _renderNinePatch;
  71685. dispose(): void;
  71686. /** STRETCH_NONE */
  71687. static readonly STRETCH_NONE: number;
  71688. /** STRETCH_FILL */
  71689. static readonly STRETCH_FILL: number;
  71690. /** STRETCH_UNIFORM */
  71691. static readonly STRETCH_UNIFORM: number;
  71692. /** STRETCH_EXTEND */
  71693. static readonly STRETCH_EXTEND: number;
  71694. /** NINE_PATCH */
  71695. static readonly STRETCH_NINE_PATCH: number;
  71696. }
  71697. }
  71698. declare module BABYLON.GUI {
  71699. /**
  71700. * Class used to create 2D buttons
  71701. */
  71702. export class Button extends Rectangle {
  71703. name?: string | undefined;
  71704. /**
  71705. * Function called to generate a pointer enter animation
  71706. */
  71707. pointerEnterAnimation: () => void;
  71708. /**
  71709. * Function called to generate a pointer out animation
  71710. */
  71711. pointerOutAnimation: () => void;
  71712. /**
  71713. * Function called to generate a pointer down animation
  71714. */
  71715. pointerDownAnimation: () => void;
  71716. /**
  71717. * Function called to generate a pointer up animation
  71718. */
  71719. pointerUpAnimation: () => void;
  71720. /**
  71721. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  71722. */
  71723. delegatePickingToChildren: boolean;
  71724. private _image;
  71725. /**
  71726. * Returns the image part of the button (if any)
  71727. */
  71728. get image(): BABYLON.Nullable<Image>;
  71729. private _textBlock;
  71730. /**
  71731. * Returns the image part of the button (if any)
  71732. */
  71733. get textBlock(): BABYLON.Nullable<TextBlock>;
  71734. /**
  71735. * Creates a new Button
  71736. * @param name defines the name of the button
  71737. */
  71738. constructor(name?: string | undefined);
  71739. protected _getTypeName(): string;
  71740. /** @hidden */
  71741. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  71742. /** @hidden */
  71743. _onPointerEnter(target: Control): boolean;
  71744. /** @hidden */
  71745. _onPointerOut(target: Control, force?: boolean): void;
  71746. /** @hidden */
  71747. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  71748. /** @hidden */
  71749. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  71750. /**
  71751. * Creates a new button made with an image and a text
  71752. * @param name defines the name of the button
  71753. * @param text defines the text of the button
  71754. * @param imageUrl defines the url of the image
  71755. * @returns a new Button
  71756. */
  71757. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  71758. /**
  71759. * Creates a new button made with an image
  71760. * @param name defines the name of the button
  71761. * @param imageUrl defines the url of the image
  71762. * @returns a new Button
  71763. */
  71764. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  71765. /**
  71766. * Creates a new button made with a text
  71767. * @param name defines the name of the button
  71768. * @param text defines the text of the button
  71769. * @returns a new Button
  71770. */
  71771. static CreateSimpleButton(name: string, text: string): Button;
  71772. /**
  71773. * Creates a new button made with an image and a centered text
  71774. * @param name defines the name of the button
  71775. * @param text defines the text of the button
  71776. * @param imageUrl defines the url of the image
  71777. * @returns a new Button
  71778. */
  71779. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  71780. }
  71781. }
  71782. declare module BABYLON.GUI {
  71783. /**
  71784. * Class used to create a 2D stack panel container
  71785. */
  71786. export class StackPanel extends Container {
  71787. name?: string | undefined;
  71788. private _isVertical;
  71789. private _manualWidth;
  71790. private _manualHeight;
  71791. private _doNotTrackManualChanges;
  71792. /**
  71793. * Gets or sets a boolean indicating that layou warnings should be ignored
  71794. */
  71795. ignoreLayoutWarnings: boolean;
  71796. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  71797. get isVertical(): boolean;
  71798. set isVertical(value: boolean);
  71799. /**
  71800. * Gets or sets panel width.
  71801. * This value should not be set when in horizontal mode as it will be computed automatically
  71802. */
  71803. set width(value: string | number);
  71804. get width(): string | number;
  71805. /**
  71806. * Gets or sets panel height.
  71807. * This value should not be set when in vertical mode as it will be computed automatically
  71808. */
  71809. set height(value: string | number);
  71810. get height(): string | number;
  71811. /**
  71812. * Creates a new StackPanel
  71813. * @param name defines control name
  71814. */
  71815. constructor(name?: string | undefined);
  71816. protected _getTypeName(): string;
  71817. /** @hidden */
  71818. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  71819. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  71820. protected _postMeasure(): void;
  71821. }
  71822. }
  71823. declare module BABYLON.GUI {
  71824. /**
  71825. * Class used to represent a 2D checkbox
  71826. */
  71827. export class Checkbox extends Control {
  71828. name?: string | undefined;
  71829. private _isChecked;
  71830. private _background;
  71831. private _checkSizeRatio;
  71832. private _thickness;
  71833. /** Gets or sets border thickness */
  71834. get thickness(): number;
  71835. set thickness(value: number);
  71836. /**
  71837. * BABYLON.Observable raised when isChecked property changes
  71838. */
  71839. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  71840. /** Gets or sets a value indicating the ratio between overall size and check size */
  71841. get checkSizeRatio(): number;
  71842. set checkSizeRatio(value: number);
  71843. /** Gets or sets background color */
  71844. get background(): string;
  71845. set background(value: string);
  71846. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  71847. get isChecked(): boolean;
  71848. set isChecked(value: boolean);
  71849. /**
  71850. * Creates a new CheckBox
  71851. * @param name defines the control name
  71852. */
  71853. constructor(name?: string | undefined);
  71854. protected _getTypeName(): string;
  71855. /** @hidden */
  71856. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  71857. /** @hidden */
  71858. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  71859. /**
  71860. * Utility function to easily create a checkbox with a header
  71861. * @param title defines the label to use for the header
  71862. * @param onValueChanged defines the callback to call when value changes
  71863. * @returns a StackPanel containing the checkbox and a textBlock
  71864. */
  71865. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  71866. }
  71867. }
  71868. declare module BABYLON.GUI {
  71869. /**
  71870. * Class used to store key control properties
  71871. */
  71872. export class KeyPropertySet {
  71873. /** Width */
  71874. width?: string;
  71875. /** Height */
  71876. height?: string;
  71877. /** Left padding */
  71878. paddingLeft?: string;
  71879. /** Right padding */
  71880. paddingRight?: string;
  71881. /** Top padding */
  71882. paddingTop?: string;
  71883. /** Bottom padding */
  71884. paddingBottom?: string;
  71885. /** Foreground color */
  71886. color?: string;
  71887. /** Background color */
  71888. background?: string;
  71889. }
  71890. /**
  71891. * Class used to create virtual keyboard
  71892. */
  71893. export class VirtualKeyboard extends StackPanel {
  71894. /** BABYLON.Observable raised when a key is pressed */
  71895. onKeyPressObservable: BABYLON.Observable<string>;
  71896. /** Gets or sets default key button width */
  71897. defaultButtonWidth: string;
  71898. /** Gets or sets default key button height */
  71899. defaultButtonHeight: string;
  71900. /** Gets or sets default key button left padding */
  71901. defaultButtonPaddingLeft: string;
  71902. /** Gets or sets default key button right padding */
  71903. defaultButtonPaddingRight: string;
  71904. /** Gets or sets default key button top padding */
  71905. defaultButtonPaddingTop: string;
  71906. /** Gets or sets default key button bottom padding */
  71907. defaultButtonPaddingBottom: string;
  71908. /** Gets or sets default key button foreground color */
  71909. defaultButtonColor: string;
  71910. /** Gets or sets default key button background color */
  71911. defaultButtonBackground: string;
  71912. /** Gets or sets shift button foreground color */
  71913. shiftButtonColor: string;
  71914. /** Gets or sets shift button thickness*/
  71915. selectedShiftThickness: number;
  71916. /** Gets shift key state */
  71917. shiftState: number;
  71918. protected _getTypeName(): string;
  71919. private _createKey;
  71920. /**
  71921. * Adds a new row of keys
  71922. * @param keys defines the list of keys to add
  71923. * @param propertySets defines the associated property sets
  71924. */
  71925. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  71926. /**
  71927. * Set the shift key to a specific state
  71928. * @param shiftState defines the new shift state
  71929. */
  71930. applyShiftState(shiftState: number): void;
  71931. private _currentlyConnectedInputText;
  71932. private _connectedInputTexts;
  71933. private _onKeyPressObserver;
  71934. /** Gets the input text control currently attached to the keyboard */
  71935. get connectedInputText(): BABYLON.Nullable<InputText>;
  71936. /**
  71937. * Connects the keyboard with an input text control
  71938. *
  71939. * @param input defines the target control
  71940. */
  71941. connect(input: InputText): void;
  71942. /**
  71943. * Disconnects the keyboard from connected InputText controls
  71944. *
  71945. * @param input optionally defines a target control, otherwise all are disconnected
  71946. */
  71947. disconnect(input?: InputText): void;
  71948. private _removeConnectedInputObservables;
  71949. /**
  71950. * Release all resources
  71951. */
  71952. dispose(): void;
  71953. /**
  71954. * Creates a new keyboard using a default layout
  71955. *
  71956. * @param name defines control name
  71957. * @returns a new VirtualKeyboard
  71958. */
  71959. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  71960. }
  71961. }
  71962. declare module BABYLON.GUI {
  71963. /**
  71964. * Class used to create input text control
  71965. */
  71966. export class InputText extends Control implements IFocusableControl {
  71967. name?: string | undefined;
  71968. private _text;
  71969. private _placeholderText;
  71970. private _background;
  71971. private _focusedBackground;
  71972. private _focusedColor;
  71973. private _placeholderColor;
  71974. private _thickness;
  71975. private _margin;
  71976. private _autoStretchWidth;
  71977. private _maxWidth;
  71978. private _isFocused;
  71979. private _blinkTimeout;
  71980. private _blinkIsEven;
  71981. private _cursorOffset;
  71982. private _scrollLeft;
  71983. private _textWidth;
  71984. private _clickedCoordinate;
  71985. private _deadKey;
  71986. private _addKey;
  71987. private _currentKey;
  71988. private _isTextHighlightOn;
  71989. private _textHighlightColor;
  71990. private _highligherOpacity;
  71991. private _highlightedText;
  71992. private _startHighlightIndex;
  71993. private _endHighlightIndex;
  71994. private _cursorIndex;
  71995. private _onFocusSelectAll;
  71996. private _isPointerDown;
  71997. private _onClipboardObserver;
  71998. private _onPointerDblTapObserver;
  71999. /** @hidden */
  72000. _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  72001. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  72002. promptMessage: string;
  72003. /** Force disable prompt on mobile device */
  72004. disableMobilePrompt: boolean;
  72005. /** BABYLON.Observable raised when the text changes */
  72006. onTextChangedObservable: BABYLON.Observable<InputText>;
  72007. /** BABYLON.Observable raised just before an entered character is to be added */
  72008. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  72009. /** BABYLON.Observable raised when the control gets the focus */
  72010. onFocusObservable: BABYLON.Observable<InputText>;
  72011. /** BABYLON.Observable raised when the control loses the focus */
  72012. onBlurObservable: BABYLON.Observable<InputText>;
  72013. /**Observable raised when the text is highlighted */
  72014. onTextHighlightObservable: BABYLON.Observable<InputText>;
  72015. /**Observable raised when copy event is triggered */
  72016. onTextCopyObservable: BABYLON.Observable<InputText>;
  72017. /** BABYLON.Observable raised when cut event is triggered */
  72018. onTextCutObservable: BABYLON.Observable<InputText>;
  72019. /** BABYLON.Observable raised when paste event is triggered */
  72020. onTextPasteObservable: BABYLON.Observable<InputText>;
  72021. /** BABYLON.Observable raised when a key event was processed */
  72022. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  72023. /** Gets or sets the maximum width allowed by the control */
  72024. get maxWidth(): string | number;
  72025. /** Gets the maximum width allowed by the control in pixels */
  72026. get maxWidthInPixels(): number;
  72027. set maxWidth(value: string | number);
  72028. /** Gets or sets the text highlighter transparency; default: 0.4 */
  72029. get highligherOpacity(): number;
  72030. set highligherOpacity(value: number);
  72031. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  72032. get onFocusSelectAll(): boolean;
  72033. set onFocusSelectAll(value: boolean);
  72034. /** Gets or sets the text hightlight color */
  72035. get textHighlightColor(): string;
  72036. set textHighlightColor(value: string);
  72037. /** Gets or sets control margin */
  72038. get margin(): string;
  72039. /** Gets control margin in pixels */
  72040. get marginInPixels(): number;
  72041. set margin(value: string);
  72042. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  72043. get autoStretchWidth(): boolean;
  72044. set autoStretchWidth(value: boolean);
  72045. /** Gets or sets border thickness */
  72046. get thickness(): number;
  72047. set thickness(value: number);
  72048. /** Gets or sets the background color when focused */
  72049. get focusedBackground(): string;
  72050. set focusedBackground(value: string);
  72051. /** Gets or sets the background color when focused */
  72052. get focusedColor(): string;
  72053. set focusedColor(value: string);
  72054. /** Gets or sets the background color */
  72055. get background(): string;
  72056. set background(value: string);
  72057. /** Gets or sets the placeholder color */
  72058. get placeholderColor(): string;
  72059. set placeholderColor(value: string);
  72060. /** Gets or sets the text displayed when the control is empty */
  72061. get placeholderText(): string;
  72062. set placeholderText(value: string);
  72063. /** Gets or sets the dead key flag */
  72064. get deadKey(): boolean;
  72065. set deadKey(flag: boolean);
  72066. /** Gets or sets the highlight text */
  72067. get highlightedText(): string;
  72068. set highlightedText(text: string);
  72069. /** Gets or sets if the current key should be added */
  72070. get addKey(): boolean;
  72071. set addKey(flag: boolean);
  72072. /** Gets or sets the value of the current key being entered */
  72073. get currentKey(): string;
  72074. set currentKey(key: string);
  72075. /** Gets or sets the text displayed in the control */
  72076. get text(): string;
  72077. set text(value: string);
  72078. /** Gets or sets control width */
  72079. get width(): string | number;
  72080. set width(value: string | number);
  72081. /**
  72082. * Creates a new InputText
  72083. * @param name defines the control name
  72084. * @param text defines the text of the control
  72085. */
  72086. constructor(name?: string | undefined, text?: string);
  72087. /** @hidden */
  72088. onBlur(): void;
  72089. /** @hidden */
  72090. onFocus(): void;
  72091. protected _getTypeName(): string;
  72092. /**
  72093. * Function called to get the list of controls that should not steal the focus from this control
  72094. * @returns an array of controls
  72095. */
  72096. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  72097. /** @hidden */
  72098. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  72099. /** @hidden */
  72100. private _updateValueFromCursorIndex;
  72101. /** @hidden */
  72102. private _processDblClick;
  72103. /** @hidden */
  72104. private _selectAllText;
  72105. /**
  72106. * Handles the keyboard event
  72107. * @param evt Defines the KeyboardEvent
  72108. */
  72109. processKeyboard(evt: KeyboardEvent): void;
  72110. /** @hidden */
  72111. private _onCopyText;
  72112. /** @hidden */
  72113. private _onCutText;
  72114. /** @hidden */
  72115. private _onPasteText;
  72116. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  72117. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  72118. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  72119. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  72120. protected _beforeRenderText(text: string): string;
  72121. dispose(): void;
  72122. }
  72123. }
  72124. declare module BABYLON.GUI {
  72125. /**
  72126. * Class used to create a 2D grid container
  72127. */
  72128. export class Grid extends Container {
  72129. name?: string | undefined;
  72130. private _rowDefinitions;
  72131. private _columnDefinitions;
  72132. private _cells;
  72133. private _childControls;
  72134. /**
  72135. * Gets the number of columns
  72136. */
  72137. get columnCount(): number;
  72138. /**
  72139. * Gets the number of rows
  72140. */
  72141. get rowCount(): number;
  72142. /** Gets the list of children */
  72143. get children(): Control[];
  72144. /** Gets the list of cells (e.g. the containers) */
  72145. get cells(): {
  72146. [key: string]: Container;
  72147. };
  72148. /**
  72149. * Gets the definition of a specific row
  72150. * @param index defines the index of the row
  72151. * @returns the row definition
  72152. */
  72153. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  72154. /**
  72155. * Gets the definition of a specific column
  72156. * @param index defines the index of the column
  72157. * @returns the column definition
  72158. */
  72159. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  72160. /**
  72161. * Adds a new row to the grid
  72162. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  72163. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  72164. * @returns the current grid
  72165. */
  72166. addRowDefinition(height: number, isPixel?: boolean): Grid;
  72167. /**
  72168. * Adds a new column to the grid
  72169. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  72170. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  72171. * @returns the current grid
  72172. */
  72173. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  72174. /**
  72175. * Update a row definition
  72176. * @param index defines the index of the row to update
  72177. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  72178. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  72179. * @returns the current grid
  72180. */
  72181. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  72182. /**
  72183. * Update a column definition
  72184. * @param index defines the index of the column to update
  72185. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  72186. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  72187. * @returns the current grid
  72188. */
  72189. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  72190. /**
  72191. * Gets the list of children stored in a specific cell
  72192. * @param row defines the row to check
  72193. * @param column defines the column to check
  72194. * @returns the list of controls
  72195. */
  72196. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  72197. /**
  72198. * Gets a string representing the child cell info (row x column)
  72199. * @param child defines the control to get info from
  72200. * @returns a string containing the child cell info (row x column)
  72201. */
  72202. getChildCellInfo(child: Control): string;
  72203. private _removeCell;
  72204. private _offsetCell;
  72205. /**
  72206. * Remove a column definition at specified index
  72207. * @param index defines the index of the column to remove
  72208. * @returns the current grid
  72209. */
  72210. removeColumnDefinition(index: number): Grid;
  72211. /**
  72212. * Remove a row definition at specified index
  72213. * @param index defines the index of the row to remove
  72214. * @returns the current grid
  72215. */
  72216. removeRowDefinition(index: number): Grid;
  72217. /**
  72218. * Adds a new control to the current grid
  72219. * @param control defines the control to add
  72220. * @param row defines the row where to add the control (0 by default)
  72221. * @param column defines the column where to add the control (0 by default)
  72222. * @returns the current grid
  72223. */
  72224. addControl(control: Control, row?: number, column?: number): Grid;
  72225. /**
  72226. * Removes a control from the current container
  72227. * @param control defines the control to remove
  72228. * @returns the current container
  72229. */
  72230. removeControl(control: Control): Container;
  72231. /**
  72232. * Creates a new Grid
  72233. * @param name defines control name
  72234. */
  72235. constructor(name?: string | undefined);
  72236. protected _getTypeName(): string;
  72237. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  72238. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72239. _flagDescendantsAsMatrixDirty(): void;
  72240. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  72241. /** Releases associated resources */
  72242. dispose(): void;
  72243. }
  72244. }
  72245. declare module BABYLON.GUI {
  72246. /** Class used to create color pickers */
  72247. export class ColorPicker extends Control {
  72248. name?: string | undefined;
  72249. private static _Epsilon;
  72250. private _colorWheelCanvas;
  72251. private _value;
  72252. private _tmpColor;
  72253. private _pointerStartedOnSquare;
  72254. private _pointerStartedOnWheel;
  72255. private _squareLeft;
  72256. private _squareTop;
  72257. private _squareSize;
  72258. private _h;
  72259. private _s;
  72260. private _v;
  72261. private _lastPointerDownID;
  72262. /**
  72263. * BABYLON.Observable raised when the value changes
  72264. */
  72265. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  72266. /** Gets or sets the color of the color picker */
  72267. get value(): BABYLON.Color3;
  72268. set value(value: BABYLON.Color3);
  72269. /**
  72270. * Gets or sets control width
  72271. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  72272. */
  72273. get width(): string | number;
  72274. set width(value: string | number);
  72275. /**
  72276. * Gets or sets control height
  72277. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  72278. */
  72279. get height(): string | number;
  72280. /** Gets or sets control height */
  72281. set height(value: string | number);
  72282. /** Gets or sets control size */
  72283. get size(): string | number;
  72284. set size(value: string | number);
  72285. /**
  72286. * Creates a new ColorPicker
  72287. * @param name defines the control name
  72288. */
  72289. constructor(name?: string | undefined);
  72290. protected _getTypeName(): string;
  72291. /** @hidden */
  72292. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72293. private _updateSquareProps;
  72294. private _drawGradientSquare;
  72295. private _drawCircle;
  72296. private _createColorWheelCanvas;
  72297. /** @hidden */
  72298. _draw(context: CanvasRenderingContext2D): void;
  72299. private _pointerIsDown;
  72300. private _updateValueFromPointer;
  72301. private _isPointOnSquare;
  72302. private _isPointOnWheel;
  72303. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  72304. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  72305. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  72306. /**
  72307. * This function expands the color picker by creating a color picker dialog with manual
  72308. * color value input and the ability to save colors into an array to be used later in
  72309. * subsequent launches of the dialogue.
  72310. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  72311. * @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.
  72312. * @returns picked color as a hex string and the saved colors array as hex strings.
  72313. */
  72314. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  72315. pickerWidth?: string;
  72316. pickerHeight?: string;
  72317. headerHeight?: string;
  72318. lastColor?: string;
  72319. swatchLimit?: number;
  72320. numSwatchesPerLine?: number;
  72321. savedColors?: Array<string>;
  72322. }): Promise<{
  72323. savedColors?: string[];
  72324. pickedColor: string;
  72325. }>;
  72326. }
  72327. }
  72328. declare module BABYLON.GUI {
  72329. /** Class used to create 2D ellipse containers */
  72330. export class Ellipse extends Container {
  72331. name?: string | undefined;
  72332. private _thickness;
  72333. /** Gets or sets border thickness */
  72334. get thickness(): number;
  72335. set thickness(value: number);
  72336. /**
  72337. * Creates a new Ellipse
  72338. * @param name defines the control name
  72339. */
  72340. constructor(name?: string | undefined);
  72341. protected _getTypeName(): string;
  72342. protected _localDraw(context: CanvasRenderingContext2D): void;
  72343. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72344. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  72345. }
  72346. }
  72347. declare module BABYLON.GUI {
  72348. /**
  72349. * Class used to create a password control
  72350. */
  72351. export class InputPassword extends InputText {
  72352. protected _beforeRenderText(text: string): string;
  72353. }
  72354. }
  72355. declare module BABYLON.GUI {
  72356. /** Class used to render 2D lines */
  72357. export class Line extends Control {
  72358. name?: string | undefined;
  72359. private _lineWidth;
  72360. private _x1;
  72361. private _y1;
  72362. private _x2;
  72363. private _y2;
  72364. private _dash;
  72365. private _connectedControl;
  72366. private _connectedControlDirtyObserver;
  72367. /** Gets or sets the dash pattern */
  72368. get dash(): Array<number>;
  72369. set dash(value: Array<number>);
  72370. /** Gets or sets the control connected with the line end */
  72371. get connectedControl(): Control;
  72372. set connectedControl(value: Control);
  72373. /** Gets or sets start coordinates on X axis */
  72374. get x1(): string | number;
  72375. set x1(value: string | number);
  72376. /** Gets or sets start coordinates on Y axis */
  72377. get y1(): string | number;
  72378. set y1(value: string | number);
  72379. /** Gets or sets end coordinates on X axis */
  72380. get x2(): string | number;
  72381. set x2(value: string | number);
  72382. /** Gets or sets end coordinates on Y axis */
  72383. get y2(): string | number;
  72384. set y2(value: string | number);
  72385. /** Gets or sets line width */
  72386. get lineWidth(): number;
  72387. set lineWidth(value: number);
  72388. /** Gets or sets horizontal alignment */
  72389. set horizontalAlignment(value: number);
  72390. /** Gets or sets vertical alignment */
  72391. set verticalAlignment(value: number);
  72392. private get _effectiveX2();
  72393. private get _effectiveY2();
  72394. /**
  72395. * Creates a new Line
  72396. * @param name defines the control name
  72397. */
  72398. constructor(name?: string | undefined);
  72399. protected _getTypeName(): string;
  72400. _draw(context: CanvasRenderingContext2D): void;
  72401. _measure(): void;
  72402. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72403. /**
  72404. * Move one end of the line given 3D cartesian coordinates.
  72405. * @param position Targeted world position
  72406. * @param scene BABYLON.Scene
  72407. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  72408. */
  72409. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  72410. /**
  72411. * Move one end of the line to a position in screen absolute space.
  72412. * @param projectedPosition Position in screen absolute space (X, Y)
  72413. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  72414. */
  72415. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  72416. }
  72417. }
  72418. declare module BABYLON.GUI {
  72419. /**
  72420. * Class used to store a point for a MultiLine object.
  72421. * The point can be pure 2D coordinates, a mesh or a control
  72422. */
  72423. export class MultiLinePoint {
  72424. private _multiLine;
  72425. private _x;
  72426. private _y;
  72427. private _control;
  72428. private _mesh;
  72429. private _controlObserver;
  72430. private _meshObserver;
  72431. /** @hidden */
  72432. _point: BABYLON.Vector2;
  72433. /**
  72434. * Creates a new MultiLinePoint
  72435. * @param multiLine defines the source MultiLine object
  72436. */
  72437. constructor(multiLine: MultiLine);
  72438. /** Gets or sets x coordinate */
  72439. get x(): string | number;
  72440. set x(value: string | number);
  72441. /** Gets or sets y coordinate */
  72442. get y(): string | number;
  72443. set y(value: string | number);
  72444. /** Gets or sets the control associated with this point */
  72445. get control(): BABYLON.Nullable<Control>;
  72446. set control(value: BABYLON.Nullable<Control>);
  72447. /** Gets or sets the mesh associated with this point */
  72448. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  72449. set mesh(value: BABYLON.Nullable<BABYLON.AbstractMesh>);
  72450. /** Resets links */
  72451. resetLinks(): void;
  72452. /**
  72453. * Gets a translation vector
  72454. * @returns the translation vector
  72455. */
  72456. translate(): BABYLON.Vector2;
  72457. private _translatePoint;
  72458. /** Release associated resources */
  72459. dispose(): void;
  72460. }
  72461. }
  72462. declare module BABYLON.GUI {
  72463. /**
  72464. * Class used to create multi line control
  72465. */
  72466. export class MultiLine extends Control {
  72467. name?: string | undefined;
  72468. private _lineWidth;
  72469. private _dash;
  72470. private _points;
  72471. private _minX;
  72472. private _minY;
  72473. private _maxX;
  72474. private _maxY;
  72475. /**
  72476. * Creates a new MultiLine
  72477. * @param name defines the control name
  72478. */
  72479. constructor(name?: string | undefined);
  72480. /** Gets or sets dash pattern */
  72481. get dash(): Array<number>;
  72482. set dash(value: Array<number>);
  72483. /**
  72484. * Gets point stored at specified index
  72485. * @param index defines the index to look for
  72486. * @returns the requested point if found
  72487. */
  72488. getAt(index: number): MultiLinePoint;
  72489. /** Function called when a point is updated */
  72490. onPointUpdate: () => void;
  72491. /**
  72492. * Adds new points to the point collection
  72493. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  72494. * @returns the list of created MultiLinePoint
  72495. */
  72496. add(...items: (AbstractMesh | Control | {
  72497. x: string | number;
  72498. y: string | number;
  72499. })[]): MultiLinePoint[];
  72500. /**
  72501. * Adds a new point to the point collection
  72502. * @param item defines the item (mesh, control or 2d coordiantes) to add
  72503. * @returns the created MultiLinePoint
  72504. */
  72505. push(item?: (AbstractMesh | Control | {
  72506. x: string | number;
  72507. y: string | number;
  72508. })): MultiLinePoint;
  72509. /**
  72510. * Remove a specific value or point from the active point collection
  72511. * @param value defines the value or point to remove
  72512. */
  72513. remove(value: number | MultiLinePoint): void;
  72514. /**
  72515. * Resets this object to initial state (no point)
  72516. */
  72517. reset(): void;
  72518. /**
  72519. * Resets all links
  72520. */
  72521. resetLinks(): void;
  72522. /** Gets or sets line width */
  72523. get lineWidth(): number;
  72524. set lineWidth(value: number);
  72525. set horizontalAlignment(value: number);
  72526. set verticalAlignment(value: number);
  72527. protected _getTypeName(): string;
  72528. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  72529. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72530. _measure(): void;
  72531. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72532. dispose(): void;
  72533. }
  72534. }
  72535. declare module BABYLON.GUI {
  72536. /**
  72537. * Class used to create radio button controls
  72538. */
  72539. export class RadioButton extends Control {
  72540. name?: string | undefined;
  72541. private _isChecked;
  72542. private _background;
  72543. private _checkSizeRatio;
  72544. private _thickness;
  72545. /** Gets or sets border thickness */
  72546. get thickness(): number;
  72547. set thickness(value: number);
  72548. /** Gets or sets group name */
  72549. group: string;
  72550. /** BABYLON.Observable raised when isChecked is changed */
  72551. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  72552. /** Gets or sets a value indicating the ratio between overall size and check size */
  72553. get checkSizeRatio(): number;
  72554. set checkSizeRatio(value: number);
  72555. /** Gets or sets background color */
  72556. get background(): string;
  72557. set background(value: string);
  72558. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  72559. get isChecked(): boolean;
  72560. set isChecked(value: boolean);
  72561. /**
  72562. * Creates a new RadioButton
  72563. * @param name defines the control name
  72564. */
  72565. constructor(name?: string | undefined);
  72566. protected _getTypeName(): string;
  72567. _draw(context: CanvasRenderingContext2D): void;
  72568. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  72569. /**
  72570. * Utility function to easily create a radio button with a header
  72571. * @param title defines the label to use for the header
  72572. * @param group defines the group to use for the radio button
  72573. * @param isChecked defines the initial state of the radio button
  72574. * @param onValueChanged defines the callback to call when value changes
  72575. * @returns a StackPanel containing the radio button and a textBlock
  72576. */
  72577. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  72578. }
  72579. }
  72580. declare module BABYLON.GUI {
  72581. /**
  72582. * Class used to create slider controls
  72583. */
  72584. export class BaseSlider extends Control {
  72585. name?: string | undefined;
  72586. protected _thumbWidth: ValueAndUnit;
  72587. private _minimum;
  72588. private _maximum;
  72589. private _value;
  72590. private _isVertical;
  72591. protected _barOffset: ValueAndUnit;
  72592. private _isThumbClamped;
  72593. protected _displayThumb: boolean;
  72594. private _step;
  72595. private _lastPointerDownID;
  72596. protected _effectiveBarOffset: number;
  72597. protected _renderLeft: number;
  72598. protected _renderTop: number;
  72599. protected _renderWidth: number;
  72600. protected _renderHeight: number;
  72601. protected _backgroundBoxLength: number;
  72602. protected _backgroundBoxThickness: number;
  72603. protected _effectiveThumbThickness: number;
  72604. /** BABYLON.Observable raised when the sldier value changes */
  72605. onValueChangedObservable: BABYLON.Observable<number>;
  72606. /** Gets or sets a boolean indicating if the thumb must be rendered */
  72607. get displayThumb(): boolean;
  72608. set displayThumb(value: boolean);
  72609. /** Gets or sets a step to apply to values (0 by default) */
  72610. get step(): number;
  72611. set step(value: number);
  72612. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  72613. get barOffset(): string | number;
  72614. /** Gets main bar offset in pixels*/
  72615. get barOffsetInPixels(): number;
  72616. set barOffset(value: string | number);
  72617. /** Gets or sets thumb width */
  72618. get thumbWidth(): string | number;
  72619. /** Gets thumb width in pixels */
  72620. get thumbWidthInPixels(): number;
  72621. set thumbWidth(value: string | number);
  72622. /** Gets or sets minimum value */
  72623. get minimum(): number;
  72624. set minimum(value: number);
  72625. /** Gets or sets maximum value */
  72626. get maximum(): number;
  72627. set maximum(value: number);
  72628. /** Gets or sets current value */
  72629. get value(): number;
  72630. set value(value: number);
  72631. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  72632. get isVertical(): boolean;
  72633. set isVertical(value: boolean);
  72634. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  72635. get isThumbClamped(): boolean;
  72636. set isThumbClamped(value: boolean);
  72637. /**
  72638. * Creates a new BaseSlider
  72639. * @param name defines the control name
  72640. */
  72641. constructor(name?: string | undefined);
  72642. protected _getTypeName(): string;
  72643. protected _getThumbPosition(): number;
  72644. protected _getThumbThickness(type: string): number;
  72645. protected _prepareRenderingData(type: string): void;
  72646. private _pointerIsDown;
  72647. /** @hidden */
  72648. protected _updateValueFromPointer(x: number, y: number): void;
  72649. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  72650. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  72651. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  72652. }
  72653. }
  72654. declare module BABYLON.GUI {
  72655. /**
  72656. * Class used to create slider controls
  72657. */
  72658. export class Slider extends BaseSlider {
  72659. name?: string | undefined;
  72660. private _background;
  72661. private _borderColor;
  72662. private _isThumbCircle;
  72663. protected _displayValueBar: boolean;
  72664. /** Gets or sets a boolean indicating if the value bar must be rendered */
  72665. get displayValueBar(): boolean;
  72666. set displayValueBar(value: boolean);
  72667. /** Gets or sets border color */
  72668. get borderColor(): string;
  72669. set borderColor(value: string);
  72670. /** Gets or sets background color */
  72671. get background(): string;
  72672. set background(value: string);
  72673. /** Gets or sets a boolean indicating if the thumb should be round or square */
  72674. get isThumbCircle(): boolean;
  72675. set isThumbCircle(value: boolean);
  72676. /**
  72677. * Creates a new Slider
  72678. * @param name defines the control name
  72679. */
  72680. constructor(name?: string | undefined);
  72681. protected _getTypeName(): string;
  72682. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  72683. }
  72684. }
  72685. declare module BABYLON.GUI {
  72686. /** Class used to create a RadioGroup
  72687. * which contains groups of radio buttons
  72688. */
  72689. export class SelectorGroup {
  72690. /** name of SelectorGroup */
  72691. name: string;
  72692. private _groupPanel;
  72693. private _selectors;
  72694. private _groupHeader;
  72695. /**
  72696. * Creates a new SelectorGroup
  72697. * @param name of group, used as a group heading
  72698. */
  72699. constructor(
  72700. /** name of SelectorGroup */
  72701. name: string);
  72702. /** Gets the groupPanel of the SelectorGroup */
  72703. get groupPanel(): StackPanel;
  72704. /** Gets the selectors array */
  72705. get selectors(): StackPanel[];
  72706. /** Gets and sets the group header */
  72707. get header(): string;
  72708. set header(label: string);
  72709. /** @hidden */
  72710. private _addGroupHeader;
  72711. /** @hidden*/
  72712. _getSelector(selectorNb: number): StackPanel | undefined;
  72713. /** Removes the selector at the given position
  72714. * @param selectorNb the position of the selector within the group
  72715. */
  72716. removeSelector(selectorNb: number): void;
  72717. }
  72718. /** Class used to create a CheckboxGroup
  72719. * which contains groups of checkbox buttons
  72720. */
  72721. export class CheckboxGroup extends SelectorGroup {
  72722. /** Adds a checkbox as a control
  72723. * @param text is the label for the selector
  72724. * @param func is the function called when the Selector is checked
  72725. * @param checked is true when Selector is checked
  72726. */
  72727. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  72728. /** @hidden */
  72729. _setSelectorLabel(selectorNb: number, label: string): void;
  72730. /** @hidden */
  72731. _setSelectorLabelColor(selectorNb: number, color: string): void;
  72732. /** @hidden */
  72733. _setSelectorButtonColor(selectorNb: number, color: string): void;
  72734. /** @hidden */
  72735. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  72736. }
  72737. /** Class used to create a RadioGroup
  72738. * which contains groups of radio buttons
  72739. */
  72740. export class RadioGroup extends SelectorGroup {
  72741. private _selectNb;
  72742. /** Adds a radio button as a control
  72743. * @param label is the label for the selector
  72744. * @param func is the function called when the Selector is checked
  72745. * @param checked is true when Selector is checked
  72746. */
  72747. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  72748. /** @hidden */
  72749. _setSelectorLabel(selectorNb: number, label: string): void;
  72750. /** @hidden */
  72751. _setSelectorLabelColor(selectorNb: number, color: string): void;
  72752. /** @hidden */
  72753. _setSelectorButtonColor(selectorNb: number, color: string): void;
  72754. /** @hidden */
  72755. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  72756. }
  72757. /** Class used to create a SliderGroup
  72758. * which contains groups of slider buttons
  72759. */
  72760. export class SliderGroup extends SelectorGroup {
  72761. /**
  72762. * Adds a slider to the SelectorGroup
  72763. * @param label is the label for the SliderBar
  72764. * @param func is the function called when the Slider moves
  72765. * @param unit is a string describing the units used, eg degrees or metres
  72766. * @param min is the minimum value for the Slider
  72767. * @param max is the maximum value for the Slider
  72768. * @param value is the start value for the Slider between min and max
  72769. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  72770. */
  72771. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  72772. /** @hidden */
  72773. _setSelectorLabel(selectorNb: number, label: string): void;
  72774. /** @hidden */
  72775. _setSelectorLabelColor(selectorNb: number, color: string): void;
  72776. /** @hidden */
  72777. _setSelectorButtonColor(selectorNb: number, color: string): void;
  72778. /** @hidden */
  72779. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  72780. }
  72781. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  72782. * @see http://doc.babylonjs.com/how_to/selector
  72783. */
  72784. export class SelectionPanel extends Rectangle {
  72785. /** name of SelectionPanel */
  72786. name: string;
  72787. /** an array of SelectionGroups */
  72788. groups: SelectorGroup[];
  72789. private _panel;
  72790. private _buttonColor;
  72791. private _buttonBackground;
  72792. private _headerColor;
  72793. private _barColor;
  72794. private _barHeight;
  72795. private _spacerHeight;
  72796. private _labelColor;
  72797. private _groups;
  72798. private _bars;
  72799. /**
  72800. * Creates a new SelectionPanel
  72801. * @param name of SelectionPanel
  72802. * @param groups is an array of SelectionGroups
  72803. */
  72804. constructor(
  72805. /** name of SelectionPanel */
  72806. name: string,
  72807. /** an array of SelectionGroups */
  72808. groups?: SelectorGroup[]);
  72809. protected _getTypeName(): string;
  72810. /** Gets or sets the headerColor */
  72811. get headerColor(): string;
  72812. set headerColor(color: string);
  72813. private _setHeaderColor;
  72814. /** Gets or sets the button color */
  72815. get buttonColor(): string;
  72816. set buttonColor(color: string);
  72817. private _setbuttonColor;
  72818. /** Gets or sets the label color */
  72819. get labelColor(): string;
  72820. set labelColor(color: string);
  72821. private _setLabelColor;
  72822. /** Gets or sets the button background */
  72823. get buttonBackground(): string;
  72824. set buttonBackground(color: string);
  72825. private _setButtonBackground;
  72826. /** Gets or sets the color of separator bar */
  72827. get barColor(): string;
  72828. set barColor(color: string);
  72829. private _setBarColor;
  72830. /** Gets or sets the height of separator bar */
  72831. get barHeight(): string;
  72832. set barHeight(value: string);
  72833. private _setBarHeight;
  72834. /** Gets or sets the height of spacers*/
  72835. get spacerHeight(): string;
  72836. set spacerHeight(value: string);
  72837. private _setSpacerHeight;
  72838. /** Adds a bar between groups */
  72839. private _addSpacer;
  72840. /** Add a group to the selection panel
  72841. * @param group is the selector group to add
  72842. */
  72843. addGroup(group: SelectorGroup): void;
  72844. /** Remove the group from the given position
  72845. * @param groupNb is the position of the group in the list
  72846. */
  72847. removeGroup(groupNb: number): void;
  72848. /** Change a group header label
  72849. * @param label is the new group header label
  72850. * @param groupNb is the number of the group to relabel
  72851. * */
  72852. setHeaderName(label: string, groupNb: number): void;
  72853. /** Change selector label to the one given
  72854. * @param label is the new selector label
  72855. * @param groupNb is the number of the groupcontaining the selector
  72856. * @param selectorNb is the number of the selector within a group to relabel
  72857. * */
  72858. relabel(label: string, groupNb: number, selectorNb: number): void;
  72859. /** For a given group position remove the selector at the given position
  72860. * @param groupNb is the number of the group to remove the selector from
  72861. * @param selectorNb is the number of the selector within the group
  72862. */
  72863. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  72864. /** For a given group position of correct type add a checkbox button
  72865. * @param groupNb is the number of the group to remove the selector from
  72866. * @param label is the label for the selector
  72867. * @param func is the function called when the Selector is checked
  72868. * @param checked is true when Selector is checked
  72869. */
  72870. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  72871. /** For a given group position of correct type add a radio button
  72872. * @param groupNb is the number of the group to remove the selector from
  72873. * @param label is the label for the selector
  72874. * @param func is the function called when the Selector is checked
  72875. * @param checked is true when Selector is checked
  72876. */
  72877. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  72878. /**
  72879. * For a given slider group add a slider
  72880. * @param groupNb is the number of the group to add the slider to
  72881. * @param label is the label for the Slider
  72882. * @param func is the function called when the Slider moves
  72883. * @param unit is a string describing the units used, eg degrees or metres
  72884. * @param min is the minimum value for the Slider
  72885. * @param max is the maximum value for the Slider
  72886. * @param value is the start value for the Slider between min and max
  72887. * @param onVal is the function used to format the value displayed, eg radians to degrees
  72888. */
  72889. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  72890. }
  72891. }
  72892. declare module BABYLON.GUI {
  72893. /**
  72894. * Class used to hold a the container for ScrollViewer
  72895. * @hidden
  72896. */
  72897. export class _ScrollViewerWindow extends Container {
  72898. parentClientWidth: number;
  72899. parentClientHeight: number;
  72900. private _freezeControls;
  72901. private _parentMeasure;
  72902. private _oldLeft;
  72903. private _oldTop;
  72904. get freezeControls(): boolean;
  72905. set freezeControls(value: boolean);
  72906. private _bucketWidth;
  72907. private _bucketHeight;
  72908. private _buckets;
  72909. private _bucketLen;
  72910. get bucketWidth(): number;
  72911. get bucketHeight(): number;
  72912. setBucketSizes(width: number, height: number): void;
  72913. private _useBuckets;
  72914. private _makeBuckets;
  72915. private _dispatchInBuckets;
  72916. private _updateMeasures;
  72917. private _updateChildrenMeasures;
  72918. /**
  72919. * Creates a new ScrollViewerWindow
  72920. * @param name of ScrollViewerWindow
  72921. */
  72922. constructor(name?: string);
  72923. protected _getTypeName(): string;
  72924. /** @hidden */
  72925. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72926. /** @hidden */
  72927. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  72928. private _scrollChildren;
  72929. private _scrollChildrenWithBuckets;
  72930. /** @hidden */
  72931. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  72932. protected _postMeasure(): void;
  72933. }
  72934. }
  72935. declare module BABYLON.GUI {
  72936. /**
  72937. * Class used to create slider controls
  72938. */
  72939. export class ScrollBar extends BaseSlider {
  72940. name?: string | undefined;
  72941. private _background;
  72942. private _borderColor;
  72943. private _tempMeasure;
  72944. /** Gets or sets border color */
  72945. get borderColor(): string;
  72946. set borderColor(value: string);
  72947. /** Gets or sets background color */
  72948. get background(): string;
  72949. set background(value: string);
  72950. /**
  72951. * Creates a new Slider
  72952. * @param name defines the control name
  72953. */
  72954. constructor(name?: string | undefined);
  72955. protected _getTypeName(): string;
  72956. protected _getThumbThickness(): number;
  72957. _draw(context: CanvasRenderingContext2D): void;
  72958. private _first;
  72959. private _originX;
  72960. private _originY;
  72961. /** @hidden */
  72962. protected _updateValueFromPointer(x: number, y: number): void;
  72963. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  72964. }
  72965. }
  72966. declare module BABYLON.GUI {
  72967. /**
  72968. * Class used to create slider controls
  72969. */
  72970. export class ImageScrollBar extends BaseSlider {
  72971. name?: string | undefined;
  72972. private _backgroundBaseImage;
  72973. private _backgroundImage;
  72974. private _thumbImage;
  72975. private _thumbBaseImage;
  72976. private _thumbLength;
  72977. private _thumbHeight;
  72978. private _barImageHeight;
  72979. private _tempMeasure;
  72980. /** Number of 90° rotation to apply on the images when in vertical mode */
  72981. num90RotationInVerticalMode: number;
  72982. /**
  72983. * Gets or sets the image used to render the background for horizontal bar
  72984. */
  72985. get backgroundImage(): Image;
  72986. set backgroundImage(value: Image);
  72987. /**
  72988. * Gets or sets the image used to render the thumb
  72989. */
  72990. get thumbImage(): Image;
  72991. set thumbImage(value: Image);
  72992. /**
  72993. * Gets or sets the length of the thumb
  72994. */
  72995. get thumbLength(): number;
  72996. set thumbLength(value: number);
  72997. /**
  72998. * Gets or sets the height of the thumb
  72999. */
  73000. get thumbHeight(): number;
  73001. set thumbHeight(value: number);
  73002. /**
  73003. * Gets or sets the height of the bar image
  73004. */
  73005. get barImageHeight(): number;
  73006. set barImageHeight(value: number);
  73007. /**
  73008. * Creates a new ImageScrollBar
  73009. * @param name defines the control name
  73010. */
  73011. constructor(name?: string | undefined);
  73012. protected _getTypeName(): string;
  73013. protected _getThumbThickness(): number;
  73014. _draw(context: CanvasRenderingContext2D): void;
  73015. private _first;
  73016. private _originX;
  73017. private _originY;
  73018. /** @hidden */
  73019. protected _updateValueFromPointer(x: number, y: number): void;
  73020. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  73021. }
  73022. }
  73023. declare module BABYLON.GUI {
  73024. /**
  73025. * Class used to hold a viewer window and sliders in a grid
  73026. */
  73027. export class ScrollViewer extends Rectangle {
  73028. private _grid;
  73029. private _horizontalBarSpace;
  73030. private _verticalBarSpace;
  73031. private _dragSpace;
  73032. private _horizontalBar;
  73033. private _verticalBar;
  73034. private _barColor;
  73035. private _barBackground;
  73036. private _barImage;
  73037. private _horizontalBarImage;
  73038. private _verticalBarImage;
  73039. private _barBackgroundImage;
  73040. private _horizontalBarBackgroundImage;
  73041. private _verticalBarBackgroundImage;
  73042. private _barSize;
  73043. private _window;
  73044. private _pointerIsOver;
  73045. private _wheelPrecision;
  73046. private _onPointerObserver;
  73047. private _clientWidth;
  73048. private _clientHeight;
  73049. private _useImageBar;
  73050. private _thumbLength;
  73051. private _thumbHeight;
  73052. private _barImageHeight;
  73053. private _horizontalBarImageHeight;
  73054. private _verticalBarImageHeight;
  73055. /**
  73056. * Gets the horizontal scrollbar
  73057. */
  73058. get horizontalBar(): ScrollBar | ImageScrollBar;
  73059. /**
  73060. * Gets the vertical scrollbar
  73061. */
  73062. get verticalBar(): ScrollBar | ImageScrollBar;
  73063. /**
  73064. * Adds a new control to the current container
  73065. * @param control defines the control to add
  73066. * @returns the current container
  73067. */
  73068. addControl(control: BABYLON.Nullable<Control>): Container;
  73069. /**
  73070. * Removes a control from the current container
  73071. * @param control defines the control to remove
  73072. * @returns the current container
  73073. */
  73074. removeControl(control: Control): Container;
  73075. /** Gets the list of children */
  73076. get children(): Control[];
  73077. _flagDescendantsAsMatrixDirty(): void;
  73078. /**
  73079. * Freezes or unfreezes the controls in the window.
  73080. * When controls are frozen, the scroll viewer can render a lot more quickly but updates to positions/sizes of controls
  73081. * are not taken into account. If you want to change positions/sizes, unfreeze, perform the changes then freeze again
  73082. */
  73083. get freezeControls(): boolean;
  73084. set freezeControls(value: boolean);
  73085. /** Gets the bucket width */
  73086. get bucketWidth(): number;
  73087. /** Gets the bucket height */
  73088. get bucketHeight(): number;
  73089. /**
  73090. * Sets the bucket sizes.
  73091. * When freezeControls is true, setting a non-zero bucket size will improve performances by updating only
  73092. * controls that are visible. The bucket sizes is used to subdivide (internally) the window area to smaller areas into which
  73093. * controls are dispatched. So, the size should be roughly equals to the mean size of all the controls of
  73094. * the window. To disable the usage of buckets, sets either width or height (or both) to 0.
  73095. * Please note that using this option will raise the memory usage (the higher the bucket sizes, the less memory
  73096. * used), that's why it is not enabled by default.
  73097. * @param width width of the bucket
  73098. * @param height height of the bucket
  73099. */
  73100. setBucketSizes(width: number, height: number): void;
  73101. private _forceHorizontalBar;
  73102. private _forceVerticalBar;
  73103. /**
  73104. * Forces the horizontal scroll bar to be displayed
  73105. */
  73106. get forceHorizontalBar(): boolean;
  73107. set forceHorizontalBar(value: boolean);
  73108. /**
  73109. * Forces the vertical scroll bar to be displayed
  73110. */
  73111. get forceVerticalBar(): boolean;
  73112. set forceVerticalBar(value: boolean);
  73113. /**
  73114. * Creates a new ScrollViewer
  73115. * @param name of ScrollViewer
  73116. */
  73117. constructor(name?: string, isImageBased?: boolean);
  73118. /** Reset the scroll viewer window to initial size */
  73119. resetWindow(): void;
  73120. protected _getTypeName(): string;
  73121. private _buildClientSizes;
  73122. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  73123. protected _postMeasure(): void;
  73124. /**
  73125. * Gets or sets the mouse wheel precision
  73126. * from 0 to 1 with a default value of 0.05
  73127. * */
  73128. get wheelPrecision(): number;
  73129. set wheelPrecision(value: number);
  73130. /** Gets or sets the scroll bar container background color */
  73131. get scrollBackground(): string;
  73132. set scrollBackground(color: string);
  73133. /** Gets or sets the bar color */
  73134. get barColor(): string;
  73135. set barColor(color: string);
  73136. /** Gets or sets the bar image */
  73137. get thumbImage(): Image;
  73138. set thumbImage(value: Image);
  73139. /** Gets or sets the horizontal bar image */
  73140. get horizontalThumbImage(): Image;
  73141. set horizontalThumbImage(value: Image);
  73142. /** Gets or sets the vertical bar image */
  73143. get verticalThumbImage(): Image;
  73144. set verticalThumbImage(value: Image);
  73145. /** Gets or sets the size of the bar */
  73146. get barSize(): number;
  73147. set barSize(value: number);
  73148. /** Gets or sets the length of the thumb */
  73149. get thumbLength(): number;
  73150. set thumbLength(value: number);
  73151. /** Gets or sets the height of the thumb */
  73152. get thumbHeight(): number;
  73153. set thumbHeight(value: number);
  73154. /** Gets or sets the height of the bar image */
  73155. get barImageHeight(): number;
  73156. set barImageHeight(value: number);
  73157. /** Gets or sets the height of the horizontal bar image */
  73158. get horizontalBarImageHeight(): number;
  73159. set horizontalBarImageHeight(value: number);
  73160. /** Gets or sets the height of the vertical bar image */
  73161. get verticalBarImageHeight(): number;
  73162. set verticalBarImageHeight(value: number);
  73163. /** Gets or sets the bar background */
  73164. get barBackground(): string;
  73165. set barBackground(color: string);
  73166. /** Gets or sets the bar background image */
  73167. get barImage(): Image;
  73168. set barImage(value: Image);
  73169. /** Gets or sets the horizontal bar background image */
  73170. get horizontalBarImage(): Image;
  73171. set horizontalBarImage(value: Image);
  73172. /** Gets or sets the vertical bar background image */
  73173. get verticalBarImage(): Image;
  73174. set verticalBarImage(value: Image);
  73175. private _setWindowPosition;
  73176. /** @hidden */
  73177. private _updateScroller;
  73178. _link(host: AdvancedDynamicTexture): void;
  73179. /** @hidden */
  73180. private _addBar;
  73181. /** @hidden */
  73182. private _attachWheel;
  73183. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  73184. /** Releases associated resources */
  73185. dispose(): void;
  73186. }
  73187. }
  73188. declare module BABYLON.GUI {
  73189. /** Class used to render a grid */
  73190. export class DisplayGrid extends Control {
  73191. name?: string | undefined;
  73192. private _cellWidth;
  73193. private _cellHeight;
  73194. private _minorLineTickness;
  73195. private _minorLineColor;
  73196. private _majorLineTickness;
  73197. private _majorLineColor;
  73198. private _majorLineFrequency;
  73199. private _background;
  73200. private _displayMajorLines;
  73201. private _displayMinorLines;
  73202. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  73203. get displayMinorLines(): boolean;
  73204. set displayMinorLines(value: boolean);
  73205. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  73206. get displayMajorLines(): boolean;
  73207. set displayMajorLines(value: boolean);
  73208. /** Gets or sets background color (Black by default) */
  73209. get background(): string;
  73210. set background(value: string);
  73211. /** Gets or sets the width of each cell (20 by default) */
  73212. get cellWidth(): number;
  73213. set cellWidth(value: number);
  73214. /** Gets or sets the height of each cell (20 by default) */
  73215. get cellHeight(): number;
  73216. set cellHeight(value: number);
  73217. /** Gets or sets the tickness of minor lines (1 by default) */
  73218. get minorLineTickness(): number;
  73219. set minorLineTickness(value: number);
  73220. /** Gets or sets the color of minor lines (DarkGray by default) */
  73221. get minorLineColor(): string;
  73222. set minorLineColor(value: string);
  73223. /** Gets or sets the tickness of major lines (2 by default) */
  73224. get majorLineTickness(): number;
  73225. set majorLineTickness(value: number);
  73226. /** Gets or sets the color of major lines (White by default) */
  73227. get majorLineColor(): string;
  73228. set majorLineColor(value: string);
  73229. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  73230. get majorLineFrequency(): number;
  73231. set majorLineFrequency(value: number);
  73232. /**
  73233. * Creates a new GridDisplayRectangle
  73234. * @param name defines the control name
  73235. */
  73236. constructor(name?: string | undefined);
  73237. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  73238. protected _getTypeName(): string;
  73239. }
  73240. }
  73241. declare module BABYLON.GUI {
  73242. /**
  73243. * Class used to create slider controls based on images
  73244. */
  73245. export class ImageBasedSlider extends BaseSlider {
  73246. name?: string | undefined;
  73247. private _backgroundImage;
  73248. private _thumbImage;
  73249. private _valueBarImage;
  73250. private _tempMeasure;
  73251. get displayThumb(): boolean;
  73252. set displayThumb(value: boolean);
  73253. /**
  73254. * Gets or sets the image used to render the background
  73255. */
  73256. get backgroundImage(): Image;
  73257. set backgroundImage(value: Image);
  73258. /**
  73259. * Gets or sets the image used to render the value bar
  73260. */
  73261. get valueBarImage(): Image;
  73262. set valueBarImage(value: Image);
  73263. /**
  73264. * Gets or sets the image used to render the thumb
  73265. */
  73266. get thumbImage(): Image;
  73267. set thumbImage(value: Image);
  73268. /**
  73269. * Creates a new ImageBasedSlider
  73270. * @param name defines the control name
  73271. */
  73272. constructor(name?: string | undefined);
  73273. protected _getTypeName(): string;
  73274. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  73275. }
  73276. }
  73277. declare module BABYLON.GUI {
  73278. /**
  73279. * Forcing an export so that this code will execute
  73280. * @hidden
  73281. */
  73282. const name = "Statics";
  73283. }
  73284. declare module BABYLON.GUI {
  73285. /**
  73286. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  73287. */
  73288. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  73289. /**
  73290. * Define the instrumented AdvancedDynamicTexture.
  73291. */
  73292. texture: AdvancedDynamicTexture;
  73293. private _captureRenderTime;
  73294. private _renderTime;
  73295. private _captureLayoutTime;
  73296. private _layoutTime;
  73297. private _onBeginRenderObserver;
  73298. private _onEndRenderObserver;
  73299. private _onBeginLayoutObserver;
  73300. private _onEndLayoutObserver;
  73301. /**
  73302. * Gets the perf counter used to capture render time
  73303. */
  73304. get renderTimeCounter(): BABYLON.PerfCounter;
  73305. /**
  73306. * Gets the perf counter used to capture layout time
  73307. */
  73308. get layoutTimeCounter(): BABYLON.PerfCounter;
  73309. /**
  73310. * Enable or disable the render time capture
  73311. */
  73312. get captureRenderTime(): boolean;
  73313. set captureRenderTime(value: boolean);
  73314. /**
  73315. * Enable or disable the layout time capture
  73316. */
  73317. get captureLayoutTime(): boolean;
  73318. set captureLayoutTime(value: boolean);
  73319. /**
  73320. * Instantiates a new advanced dynamic texture instrumentation.
  73321. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  73322. * @param texture Defines the AdvancedDynamicTexture to instrument
  73323. */
  73324. constructor(
  73325. /**
  73326. * Define the instrumented AdvancedDynamicTexture.
  73327. */
  73328. texture: AdvancedDynamicTexture);
  73329. /**
  73330. * Dispose and release associated resources.
  73331. */
  73332. dispose(): void;
  73333. }
  73334. }
  73335. declare module BABYLON.GUI {
  73336. /**
  73337. * Class used to load GUI via XML.
  73338. */
  73339. export class XmlLoader {
  73340. private _nodes;
  73341. private _nodeTypes;
  73342. private _isLoaded;
  73343. private _objectAttributes;
  73344. private _parentClass;
  73345. /**
  73346. * Create a new xml loader
  73347. * @param parentClass Sets the class context. Used when the loader is instanced inside a class and not in a global context
  73348. */
  73349. constructor(parentClass?: null);
  73350. private _getChainElement;
  73351. private _getClassAttribute;
  73352. private _createGuiElement;
  73353. private _parseGrid;
  73354. private _parseElement;
  73355. private _prepareSourceElement;
  73356. private _parseElementsFromSource;
  73357. private _parseXml;
  73358. /**
  73359. * Gets if the loading has finished.
  73360. * @returns whether the loading has finished or not
  73361. */
  73362. isLoaded(): boolean;
  73363. /**
  73364. * Gets a loaded node / control by id.
  73365. * @param id the Controls id set in the xml
  73366. * @returns element of type Control
  73367. */
  73368. getNodeById(id: string): any;
  73369. /**
  73370. * Gets all loaded nodes / controls
  73371. * @returns Array of controls
  73372. */
  73373. getNodes(): any;
  73374. /**
  73375. * Initiates the xml layout loading
  73376. * @param xmlFile defines the xml layout to load
  73377. * @param rootNode defines the node / control to use as a parent for the loaded layout controls.
  73378. * @param callback defines the callback called on layout load.
  73379. */
  73380. loadLayout(xmlFile: any, rootNode: any, callback: any): void;
  73381. }
  73382. }
  73383. declare module BABYLON.GUI {
  73384. /**
  73385. * Class used to create containers for controls
  73386. */
  73387. export class Container3D extends Control3D {
  73388. private _blockLayout;
  73389. /**
  73390. * Gets the list of child controls
  73391. */
  73392. protected _children: Control3D[];
  73393. /**
  73394. * Gets the list of child controls
  73395. */
  73396. get children(): Array<Control3D>;
  73397. /**
  73398. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  73399. * This is helpful to optimize layout operation when adding multiple children in a row
  73400. */
  73401. get blockLayout(): boolean;
  73402. set blockLayout(value: boolean);
  73403. /**
  73404. * Creates a new container
  73405. * @param name defines the container name
  73406. */
  73407. constructor(name?: string);
  73408. /**
  73409. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  73410. * @returns the current container
  73411. */
  73412. updateLayout(): Container3D;
  73413. /**
  73414. * Gets a boolean indicating if the given control is in the children of this control
  73415. * @param control defines the control to check
  73416. * @returns true if the control is in the child list
  73417. */
  73418. containsControl(control: Control3D): boolean;
  73419. /**
  73420. * Adds a control to the children of this control
  73421. * @param control defines the control to add
  73422. * @returns the current container
  73423. */
  73424. addControl(control: Control3D): Container3D;
  73425. /**
  73426. * This function will be called everytime a new control is added
  73427. */
  73428. protected _arrangeChildren(): void;
  73429. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  73430. /**
  73431. * Removes a control from the children of this control
  73432. * @param control defines the control to remove
  73433. * @returns the current container
  73434. */
  73435. removeControl(control: Control3D): Container3D;
  73436. protected _getTypeName(): string;
  73437. /**
  73438. * Releases all associated resources
  73439. */
  73440. dispose(): void;
  73441. /** Control rotation will remain unchanged */
  73442. static readonly UNSET_ORIENTATION: number;
  73443. /** Control will rotate to make it look at sphere central axis */
  73444. static readonly FACEORIGIN_ORIENTATION: number;
  73445. /** Control will rotate to make it look back at sphere central axis */
  73446. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  73447. /** Control will rotate to look at z axis (0, 0, 1) */
  73448. static readonly FACEFORWARD_ORIENTATION: number;
  73449. /** Control will rotate to look at negative z axis (0, 0, -1) */
  73450. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  73451. }
  73452. }
  73453. declare module BABYLON.GUI {
  73454. /**
  73455. * Class used to manage 3D user interface
  73456. * @see http://doc.babylonjs.com/how_to/gui3d
  73457. */
  73458. export class GUI3DManager implements BABYLON.IDisposable {
  73459. private _scene;
  73460. private _sceneDisposeObserver;
  73461. private _utilityLayer;
  73462. private _rootContainer;
  73463. private _pointerObserver;
  73464. private _pointerOutObserver;
  73465. /** @hidden */
  73466. _lastPickedControl: Control3D;
  73467. /** @hidden */
  73468. _lastControlOver: {
  73469. [pointerId: number]: Control3D;
  73470. };
  73471. /** @hidden */
  73472. _lastControlDown: {
  73473. [pointerId: number]: Control3D;
  73474. };
  73475. /**
  73476. * BABYLON.Observable raised when the point picked by the pointer events changed
  73477. */
  73478. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  73479. /** @hidden */
  73480. _sharedMaterials: {
  73481. [key: string]: BABYLON.Material;
  73482. };
  73483. /** Gets the hosting scene */
  73484. get scene(): BABYLON.Scene;
  73485. /** Gets associated utility layer */
  73486. get utilityLayer(): BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  73487. /**
  73488. * Creates a new GUI3DManager
  73489. * @param scene
  73490. */
  73491. constructor(scene?: BABYLON.Scene);
  73492. private _handlePointerOut;
  73493. private _doPicking;
  73494. /**
  73495. * Gets the root container
  73496. */
  73497. get rootContainer(): Container3D;
  73498. /**
  73499. * Gets a boolean indicating if the given control is in the root child list
  73500. * @param control defines the control to check
  73501. * @returns true if the control is in the root child list
  73502. */
  73503. containsControl(control: Control3D): boolean;
  73504. /**
  73505. * Adds a control to the root child list
  73506. * @param control defines the control to add
  73507. * @returns the current manager
  73508. */
  73509. addControl(control: Control3D): GUI3DManager;
  73510. /**
  73511. * Removes a control from the root child list
  73512. * @param control defines the control to remove
  73513. * @returns the current container
  73514. */
  73515. removeControl(control: Control3D): GUI3DManager;
  73516. /**
  73517. * Releases all associated resources
  73518. */
  73519. dispose(): void;
  73520. }
  73521. }
  73522. declare module BABYLON.GUI {
  73523. /**
  73524. * Class used to transport BABYLON.Vector3 information for pointer events
  73525. */
  73526. export class Vector3WithInfo extends BABYLON.Vector3 {
  73527. /** defines the current mouse button index */
  73528. buttonIndex: number;
  73529. /**
  73530. * Creates a new Vector3WithInfo
  73531. * @param source defines the vector3 data to transport
  73532. * @param buttonIndex defines the current mouse button index
  73533. */
  73534. constructor(source: BABYLON.Vector3,
  73535. /** defines the current mouse button index */
  73536. buttonIndex?: number);
  73537. }
  73538. }
  73539. declare module BABYLON.GUI {
  73540. /**
  73541. * Class used as base class for controls
  73542. */
  73543. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  73544. /** Defines the control name */
  73545. name?: string | undefined;
  73546. /** @hidden */
  73547. _host: GUI3DManager;
  73548. private _node;
  73549. private _downCount;
  73550. private _enterCount;
  73551. private _downPointerIds;
  73552. private _isVisible;
  73553. /** Gets or sets the control position in world space */
  73554. get position(): BABYLON.Vector3;
  73555. set position(value: BABYLON.Vector3);
  73556. /** Gets or sets the control scaling in world space */
  73557. get scaling(): BABYLON.Vector3;
  73558. set scaling(value: BABYLON.Vector3);
  73559. /** Callback used to start pointer enter animation */
  73560. pointerEnterAnimation: () => void;
  73561. /** Callback used to start pointer out animation */
  73562. pointerOutAnimation: () => void;
  73563. /** Callback used to start pointer down animation */
  73564. pointerDownAnimation: () => void;
  73565. /** Callback used to start pointer up animation */
  73566. pointerUpAnimation: () => void;
  73567. /**
  73568. * An event triggered when the pointer move over the control
  73569. */
  73570. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  73571. /**
  73572. * An event triggered when the pointer move out of the control
  73573. */
  73574. onPointerOutObservable: BABYLON.Observable<Control3D>;
  73575. /**
  73576. * An event triggered when the pointer taps the control
  73577. */
  73578. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  73579. /**
  73580. * An event triggered when pointer is up
  73581. */
  73582. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  73583. /**
  73584. * An event triggered when a control is clicked on (with a mouse)
  73585. */
  73586. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  73587. /**
  73588. * An event triggered when pointer enters the control
  73589. */
  73590. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  73591. /**
  73592. * Gets or sets the parent container
  73593. */
  73594. parent: BABYLON.Nullable<Container3D>;
  73595. private _behaviors;
  73596. /**
  73597. * Gets the list of attached behaviors
  73598. * @see http://doc.babylonjs.com/features/behaviour
  73599. */
  73600. get behaviors(): BABYLON.Behavior<Control3D>[];
  73601. /**
  73602. * Attach a behavior to the control
  73603. * @see http://doc.babylonjs.com/features/behaviour
  73604. * @param behavior defines the behavior to attach
  73605. * @returns the current control
  73606. */
  73607. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  73608. /**
  73609. * Remove an attached behavior
  73610. * @see http://doc.babylonjs.com/features/behaviour
  73611. * @param behavior defines the behavior to attach
  73612. * @returns the current control
  73613. */
  73614. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  73615. /**
  73616. * Gets an attached behavior by name
  73617. * @param name defines the name of the behavior to look for
  73618. * @see http://doc.babylonjs.com/features/behaviour
  73619. * @returns null if behavior was not found else the requested behavior
  73620. */
  73621. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  73622. /** Gets or sets a boolean indicating if the control is visible */
  73623. get isVisible(): boolean;
  73624. set isVisible(value: boolean);
  73625. /**
  73626. * Creates a new control
  73627. * @param name defines the control name
  73628. */
  73629. constructor(
  73630. /** Defines the control name */
  73631. name?: string | undefined);
  73632. /**
  73633. * Gets a string representing the class name
  73634. */
  73635. get typeName(): string;
  73636. /**
  73637. * Get the current class name of the control.
  73638. * @returns current class name
  73639. */
  73640. getClassName(): string;
  73641. protected _getTypeName(): string;
  73642. /**
  73643. * Gets the transform node used by this control
  73644. */
  73645. get node(): BABYLON.Nullable<BABYLON.TransformNode>;
  73646. /**
  73647. * Gets the mesh used to render this control
  73648. */
  73649. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  73650. /**
  73651. * Link the control as child of the given node
  73652. * @param node defines the node to link to. Use null to unlink the control
  73653. * @returns the current control
  73654. */
  73655. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  73656. /** @hidden **/
  73657. _prepareNode(scene: BABYLON.Scene): void;
  73658. /**
  73659. * Node creation.
  73660. * Can be overriden by children
  73661. * @param scene defines the scene where the node must be attached
  73662. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  73663. */
  73664. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  73665. /**
  73666. * Affect a material to the given mesh
  73667. * @param mesh defines the mesh which will represent the control
  73668. */
  73669. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  73670. /** @hidden */
  73671. _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  73672. /** @hidden */
  73673. _onPointerEnter(target: Control3D): boolean;
  73674. /** @hidden */
  73675. _onPointerOut(target: Control3D): void;
  73676. /** @hidden */
  73677. _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  73678. /** @hidden */
  73679. _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  73680. /** @hidden */
  73681. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  73682. /** @hidden */
  73683. _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  73684. /** @hidden */
  73685. _disposeNode(): void;
  73686. /**
  73687. * Releases all associated resources
  73688. */
  73689. dispose(): void;
  73690. }
  73691. }
  73692. declare module BABYLON.GUI {
  73693. /**
  73694. * Class used as a root to all buttons
  73695. */
  73696. export class AbstractButton3D extends Control3D {
  73697. /**
  73698. * Creates a new button
  73699. * @param name defines the control name
  73700. */
  73701. constructor(name?: string);
  73702. protected _getTypeName(): string;
  73703. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  73704. }
  73705. }
  73706. declare module BABYLON.GUI {
  73707. /**
  73708. * Class used to create a button in 3D
  73709. */
  73710. export class Button3D extends AbstractButton3D {
  73711. /** @hidden */
  73712. protected _currentMaterial: BABYLON.Material;
  73713. private _facadeTexture;
  73714. private _content;
  73715. private _contentResolution;
  73716. private _contentScaleRatio;
  73717. /**
  73718. * Gets or sets the texture resolution used to render content (512 by default)
  73719. */
  73720. get contentResolution(): BABYLON.int;
  73721. set contentResolution(value: BABYLON.int);
  73722. /**
  73723. * Gets or sets the texture scale ratio used to render content (2 by default)
  73724. */
  73725. get contentScaleRatio(): number;
  73726. set contentScaleRatio(value: number);
  73727. protected _disposeFacadeTexture(): void;
  73728. protected _resetContent(): void;
  73729. /**
  73730. * Creates a new button
  73731. * @param name defines the control name
  73732. */
  73733. constructor(name?: string);
  73734. /**
  73735. * Gets or sets the GUI 2D content used to display the button's facade
  73736. */
  73737. get content(): Control;
  73738. set content(value: Control);
  73739. /**
  73740. * Apply the facade texture (created from the content property).
  73741. * This function can be overloaded by child classes
  73742. * @param facadeTexture defines the AdvancedDynamicTexture to use
  73743. */
  73744. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  73745. protected _getTypeName(): string;
  73746. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  73747. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  73748. /**
  73749. * Releases all associated resources
  73750. */
  73751. dispose(): void;
  73752. }
  73753. }
  73754. declare module BABYLON.GUI {
  73755. /**
  73756. * Abstract class used to create a container panel deployed on the surface of a volume
  73757. */
  73758. export abstract class VolumeBasedPanel extends Container3D {
  73759. private _columns;
  73760. private _rows;
  73761. private _rowThenColum;
  73762. private _orientation;
  73763. protected _cellWidth: number;
  73764. protected _cellHeight: number;
  73765. /**
  73766. * Gets or sets the distance between elements
  73767. */
  73768. margin: number;
  73769. /**
  73770. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  73771. * | Value | Type | Description |
  73772. * | ----- | ----------------------------------- | ----------- |
  73773. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  73774. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  73775. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  73776. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  73777. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  73778. */
  73779. get orientation(): number;
  73780. set orientation(value: number);
  73781. /**
  73782. * Gets or sets the number of columns requested (10 by default).
  73783. * The panel will automatically compute the number of rows based on number of child controls.
  73784. */
  73785. get columns(): BABYLON.int;
  73786. set columns(value: BABYLON.int);
  73787. /**
  73788. * Gets or sets a the number of rows requested.
  73789. * The panel will automatically compute the number of columns based on number of child controls.
  73790. */
  73791. get rows(): BABYLON.int;
  73792. set rows(value: BABYLON.int);
  73793. /**
  73794. * Creates new VolumeBasedPanel
  73795. */
  73796. constructor();
  73797. protected _arrangeChildren(): void;
  73798. /** Child classes must implement this function to provide correct control positioning */
  73799. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  73800. /** Child classes can implement this function to provide additional processing */
  73801. protected _finalProcessing(): void;
  73802. }
  73803. }
  73804. declare module BABYLON.GUI {
  73805. /**
  73806. * Class used to create a container panel deployed on the surface of a cylinder
  73807. */
  73808. export class CylinderPanel extends VolumeBasedPanel {
  73809. private _radius;
  73810. /**
  73811. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  73812. */
  73813. get radius(): BABYLON.float;
  73814. set radius(value: BABYLON.float);
  73815. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  73816. private _cylindricalMapping;
  73817. }
  73818. }
  73819. declare module BABYLON.GUI {
  73820. /** @hidden */
  73821. export var fluentVertexShader: {
  73822. name: string;
  73823. shader: string;
  73824. };
  73825. }
  73826. declare module BABYLON.GUI {
  73827. /** @hidden */
  73828. export var fluentPixelShader: {
  73829. name: string;
  73830. shader: string;
  73831. };
  73832. }
  73833. declare module BABYLON.GUI {
  73834. /** @hidden */
  73835. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  73836. INNERGLOW: boolean;
  73837. BORDER: boolean;
  73838. HOVERLIGHT: boolean;
  73839. TEXTURE: boolean;
  73840. constructor();
  73841. }
  73842. /**
  73843. * Class used to render controls with fluent desgin
  73844. */
  73845. export class FluentMaterial extends BABYLON.PushMaterial {
  73846. /**
  73847. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  73848. */
  73849. innerGlowColorIntensity: number;
  73850. /**
  73851. * Gets or sets the inner glow color (white by default)
  73852. */
  73853. innerGlowColor: BABYLON.Color3;
  73854. /**
  73855. * Gets or sets alpha value (default is 1.0)
  73856. */
  73857. alpha: number;
  73858. /**
  73859. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  73860. */
  73861. albedoColor: BABYLON.Color3;
  73862. /**
  73863. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  73864. */
  73865. renderBorders: boolean;
  73866. /**
  73867. * Gets or sets border width (default is 0.5)
  73868. */
  73869. borderWidth: number;
  73870. /**
  73871. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  73872. */
  73873. edgeSmoothingValue: number;
  73874. /**
  73875. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  73876. */
  73877. borderMinValue: number;
  73878. /**
  73879. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  73880. */
  73881. renderHoverLight: boolean;
  73882. /**
  73883. * Gets or sets the radius used to render the hover light (default is 1.0)
  73884. */
  73885. hoverRadius: number;
  73886. /**
  73887. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  73888. */
  73889. hoverColor: BABYLON.Color4;
  73890. /**
  73891. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  73892. */
  73893. hoverPosition: BABYLON.Vector3;
  73894. private _albedoTexture;
  73895. /** Gets or sets the texture to use for albedo color */
  73896. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  73897. /**
  73898. * Creates a new Fluent material
  73899. * @param name defines the name of the material
  73900. * @param scene defines the hosting scene
  73901. */
  73902. constructor(name: string, scene: BABYLON.Scene);
  73903. needAlphaBlending(): boolean;
  73904. needAlphaTesting(): boolean;
  73905. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  73906. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  73907. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  73908. getActiveTextures(): BABYLON.BaseTexture[];
  73909. hasTexture(texture: BABYLON.BaseTexture): boolean;
  73910. dispose(forceDisposeEffect?: boolean): void;
  73911. clone(name: string): FluentMaterial;
  73912. serialize(): any;
  73913. getClassName(): string;
  73914. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  73915. }
  73916. }
  73917. declare module BABYLON.GUI {
  73918. /**
  73919. * Class used to create a holographic button in 3D
  73920. */
  73921. export class HolographicButton extends Button3D {
  73922. private _backPlate;
  73923. private _textPlate;
  73924. private _frontPlate;
  73925. private _text;
  73926. private _imageUrl;
  73927. private _shareMaterials;
  73928. private _frontMaterial;
  73929. private _backMaterial;
  73930. private _plateMaterial;
  73931. private _pickedPointObserver;
  73932. private _tooltipFade;
  73933. private _tooltipTextBlock;
  73934. private _tooltipTexture;
  73935. private _tooltipMesh;
  73936. private _tooltipHoverObserver;
  73937. private _tooltipOutObserver;
  73938. private _disposeTooltip;
  73939. /**
  73940. * Rendering ground id of all the mesh in the button
  73941. */
  73942. set renderingGroupId(id: number);
  73943. get renderingGroupId(): number;
  73944. /**
  73945. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  73946. */
  73947. set tooltipText(text: BABYLON.Nullable<string>);
  73948. get tooltipText(): BABYLON.Nullable<string>;
  73949. /**
  73950. * Gets or sets text for the button
  73951. */
  73952. get text(): string;
  73953. set text(value: string);
  73954. /**
  73955. * Gets or sets the image url for the button
  73956. */
  73957. get imageUrl(): string;
  73958. set imageUrl(value: string);
  73959. /**
  73960. * Gets the back material used by this button
  73961. */
  73962. get backMaterial(): FluentMaterial;
  73963. /**
  73964. * Gets the front material used by this button
  73965. */
  73966. get frontMaterial(): FluentMaterial;
  73967. /**
  73968. * Gets the plate material used by this button
  73969. */
  73970. get plateMaterial(): BABYLON.StandardMaterial;
  73971. /**
  73972. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  73973. */
  73974. get shareMaterials(): boolean;
  73975. /**
  73976. * Creates a new button
  73977. * @param name defines the control name
  73978. */
  73979. constructor(name?: string, shareMaterials?: boolean);
  73980. protected _getTypeName(): string;
  73981. private _rebuildContent;
  73982. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  73983. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  73984. private _createBackMaterial;
  73985. private _createFrontMaterial;
  73986. private _createPlateMaterial;
  73987. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  73988. /**
  73989. * Releases all associated resources
  73990. */
  73991. dispose(): void;
  73992. }
  73993. }
  73994. declare module BABYLON.GUI {
  73995. /**
  73996. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  73997. */
  73998. export class MeshButton3D extends Button3D {
  73999. /** @hidden */
  74000. protected _currentMesh: BABYLON.Mesh;
  74001. /**
  74002. * Creates a new 3D button based on a mesh
  74003. * @param mesh mesh to become a 3D button
  74004. * @param name defines the control name
  74005. */
  74006. constructor(mesh: BABYLON.Mesh, name?: string);
  74007. protected _getTypeName(): string;
  74008. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  74009. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  74010. }
  74011. }
  74012. declare module BABYLON.GUI {
  74013. /**
  74014. * Class used to create a container panel deployed on the surface of a plane
  74015. */
  74016. export class PlanePanel extends VolumeBasedPanel {
  74017. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  74018. }
  74019. }
  74020. declare module BABYLON.GUI {
  74021. /**
  74022. * Class used to create a container panel where items get randomized planar mapping
  74023. */
  74024. export class ScatterPanel extends VolumeBasedPanel {
  74025. private _iteration;
  74026. /**
  74027. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  74028. */
  74029. get iteration(): BABYLON.float;
  74030. set iteration(value: BABYLON.float);
  74031. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  74032. private _scatterMapping;
  74033. protected _finalProcessing(): void;
  74034. }
  74035. }
  74036. declare module BABYLON.GUI {
  74037. /**
  74038. * Class used to create a container panel deployed on the surface of a sphere
  74039. */
  74040. export class SpherePanel extends VolumeBasedPanel {
  74041. private _radius;
  74042. /**
  74043. * Gets or sets the radius of the sphere where to project controls (5 by default)
  74044. */
  74045. get radius(): BABYLON.float;
  74046. set radius(value: BABYLON.float);
  74047. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  74048. private _sphericalMapping;
  74049. }
  74050. }
  74051. declare module BABYLON.GUI {
  74052. /**
  74053. * Class used to create a stack panel in 3D on XY plane
  74054. */
  74055. export class StackPanel3D extends Container3D {
  74056. private _isVertical;
  74057. /**
  74058. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  74059. */
  74060. get isVertical(): boolean;
  74061. set isVertical(value: boolean);
  74062. /**
  74063. * Gets or sets the distance between elements
  74064. */
  74065. margin: number;
  74066. /**
  74067. * Creates new StackPanel
  74068. * @param isVertical
  74069. */
  74070. constructor(isVertical?: boolean);
  74071. protected _arrangeChildren(): void;
  74072. }
  74073. }
  74074. declare module BABYLON {
  74075. /**
  74076. * Configuration for glTF validation
  74077. */
  74078. export interface IGLTFValidationConfiguration {
  74079. /**
  74080. * The url of the glTF validator.
  74081. */
  74082. url: string;
  74083. }
  74084. /**
  74085. * glTF validation
  74086. */
  74087. export class GLTFValidation {
  74088. /**
  74089. * The configuration. Defaults to `{ url: "https://preview.babylonjs.com/gltf_validator.js" }`.
  74090. */
  74091. static Configuration: IGLTFValidationConfiguration;
  74092. private static _LoadScriptPromise;
  74093. /**
  74094. * Validate a glTF asset using the glTF-Validator.
  74095. * @param data The JSON of a glTF or the array buffer of a binary glTF
  74096. * @param rootUrl The root url for the glTF
  74097. * @param fileName The file name for the glTF
  74098. * @param getExternalResource The callback to get external resources for the glTF validator
  74099. * @returns A promise that resolves with the glTF validation results once complete
  74100. */
  74101. static ValidateAsync(data: string | ArrayBuffer, rootUrl: string, fileName: string, getExternalResource: (uri: string) => Promise<ArrayBuffer>): Promise<BABYLON.GLTF2.IGLTFValidationResults>;
  74102. }
  74103. }
  74104. declare module BABYLON {
  74105. /**
  74106. * Mode that determines the coordinate system to use.
  74107. */
  74108. export enum GLTFLoaderCoordinateSystemMode {
  74109. /**
  74110. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  74111. */
  74112. AUTO = 0,
  74113. /**
  74114. * Sets the useRightHandedSystem flag on the scene.
  74115. */
  74116. FORCE_RIGHT_HANDED = 1
  74117. }
  74118. /**
  74119. * Mode that determines what animations will start.
  74120. */
  74121. export enum GLTFLoaderAnimationStartMode {
  74122. /**
  74123. * No animation will start.
  74124. */
  74125. NONE = 0,
  74126. /**
  74127. * The first animation will start.
  74128. */
  74129. FIRST = 1,
  74130. /**
  74131. * All animations will start.
  74132. */
  74133. ALL = 2
  74134. }
  74135. /**
  74136. * Interface that contains the data for the glTF asset.
  74137. */
  74138. export interface IGLTFLoaderData {
  74139. /**
  74140. * The object that represents the glTF JSON.
  74141. */
  74142. json: Object;
  74143. /**
  74144. * The BIN chunk of a binary glTF.
  74145. */
  74146. bin: Nullable<IDataBuffer>;
  74147. }
  74148. /**
  74149. * Interface for extending the loader.
  74150. */
  74151. export interface IGLTFLoaderExtension {
  74152. /**
  74153. * The name of this extension.
  74154. */
  74155. readonly name: string;
  74156. /**
  74157. * Defines whether this extension is enabled.
  74158. */
  74159. enabled: boolean;
  74160. /**
  74161. * Defines the order of this extension.
  74162. * The loader sorts the extensions using these values when loading.
  74163. */
  74164. order?: number;
  74165. }
  74166. /**
  74167. * Loader state.
  74168. */
  74169. export enum GLTFLoaderState {
  74170. /**
  74171. * The asset is loading.
  74172. */
  74173. LOADING = 0,
  74174. /**
  74175. * The asset is ready for rendering.
  74176. */
  74177. READY = 1,
  74178. /**
  74179. * The asset is completely loaded.
  74180. */
  74181. COMPLETE = 2
  74182. }
  74183. /** @hidden */
  74184. export interface IGLTFLoader extends IDisposable {
  74185. readonly state: Nullable<GLTFLoaderState>;
  74186. importMeshAsync: (meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<{
  74187. meshes: AbstractMesh[];
  74188. particleSystems: IParticleSystem[];
  74189. skeletons: Skeleton[];
  74190. animationGroups: AnimationGroup[];
  74191. }>;
  74192. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  74193. }
  74194. /**
  74195. * File loader for loading glTF files into a scene.
  74196. */
  74197. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  74198. /** @hidden */
  74199. static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  74200. /** @hidden */
  74201. static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  74202. /**
  74203. * Raised when the asset has been parsed
  74204. */
  74205. onParsedObservable: Observable<IGLTFLoaderData>;
  74206. private _onParsedObserver;
  74207. /**
  74208. * Raised when the asset has been parsed
  74209. */
  74210. set onParsed(callback: (loaderData: IGLTFLoaderData) => void);
  74211. /**
  74212. * 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.
  74213. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  74214. * Defaults to true.
  74215. * @hidden
  74216. */
  74217. static IncrementalLoading: boolean;
  74218. /**
  74219. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  74220. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  74221. * @hidden
  74222. */
  74223. static HomogeneousCoordinates: boolean;
  74224. /**
  74225. * The coordinate system mode. Defaults to AUTO.
  74226. */
  74227. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  74228. /**
  74229. * The animation start mode. Defaults to FIRST.
  74230. */
  74231. animationStartMode: GLTFLoaderAnimationStartMode;
  74232. /**
  74233. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  74234. */
  74235. compileMaterials: boolean;
  74236. /**
  74237. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  74238. */
  74239. useClipPlane: boolean;
  74240. /**
  74241. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  74242. */
  74243. compileShadowGenerators: boolean;
  74244. /**
  74245. * Defines if the Alpha blended materials are only applied as coverage.
  74246. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  74247. * If true, no extra effects are applied to transparent pixels.
  74248. */
  74249. transparencyAsCoverage: boolean;
  74250. /**
  74251. * Defines if the loader should use range requests when load binary glTF files from HTTP.
  74252. * Enabling will disable offline support and glTF validator.
  74253. * Defaults to false.
  74254. */
  74255. useRangeRequests: boolean;
  74256. /**
  74257. * Defines if the loader should create instances when multiple glTF nodes point to the same glTF mesh. Defaults to true.
  74258. */
  74259. createInstances: boolean;
  74260. /**
  74261. * Function called before loading a url referenced by the asset.
  74262. */
  74263. preprocessUrlAsync: (url: string) => Promise<string>;
  74264. /**
  74265. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  74266. */
  74267. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  74268. private _onMeshLoadedObserver;
  74269. /**
  74270. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  74271. */
  74272. set onMeshLoaded(callback: (mesh: AbstractMesh) => void);
  74273. /**
  74274. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  74275. */
  74276. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  74277. private _onTextureLoadedObserver;
  74278. /**
  74279. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  74280. */
  74281. set onTextureLoaded(callback: (texture: BaseTexture) => void);
  74282. /**
  74283. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  74284. */
  74285. readonly onMaterialLoadedObservable: Observable<Material>;
  74286. private _onMaterialLoadedObserver;
  74287. /**
  74288. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  74289. */
  74290. set onMaterialLoaded(callback: (material: Material) => void);
  74291. /**
  74292. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  74293. */
  74294. readonly onCameraLoadedObservable: Observable<Camera>;
  74295. private _onCameraLoadedObserver;
  74296. /**
  74297. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  74298. */
  74299. set onCameraLoaded(callback: (camera: Camera) => void);
  74300. /**
  74301. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  74302. * For assets with LODs, raised when all of the LODs are complete.
  74303. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  74304. */
  74305. readonly onCompleteObservable: Observable<void>;
  74306. private _onCompleteObserver;
  74307. /**
  74308. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  74309. * For assets with LODs, raised when all of the LODs are complete.
  74310. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  74311. */
  74312. set onComplete(callback: () => void);
  74313. /**
  74314. * Observable raised when an error occurs.
  74315. */
  74316. readonly onErrorObservable: Observable<any>;
  74317. private _onErrorObserver;
  74318. /**
  74319. * Callback raised when an error occurs.
  74320. */
  74321. set onError(callback: (reason: any) => void);
  74322. /**
  74323. * Observable raised after the loader is disposed.
  74324. */
  74325. readonly onDisposeObservable: Observable<void>;
  74326. private _onDisposeObserver;
  74327. /**
  74328. * Callback raised after the loader is disposed.
  74329. */
  74330. set onDispose(callback: () => void);
  74331. /**
  74332. * Observable raised after a loader extension is created.
  74333. * Set additional options for a loader extension in this event.
  74334. */
  74335. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  74336. private _onExtensionLoadedObserver;
  74337. /**
  74338. * Callback raised after a loader extension is created.
  74339. */
  74340. set onExtensionLoaded(callback: (extension: IGLTFLoaderExtension) => void);
  74341. /**
  74342. * Defines if the loader logging is enabled.
  74343. */
  74344. get loggingEnabled(): boolean;
  74345. set loggingEnabled(value: boolean);
  74346. /**
  74347. * Defines if the loader should capture performance counters.
  74348. */
  74349. get capturePerformanceCounters(): boolean;
  74350. set capturePerformanceCounters(value: boolean);
  74351. /**
  74352. * Defines if the loader should validate the asset.
  74353. */
  74354. validate: boolean;
  74355. /**
  74356. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  74357. */
  74358. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  74359. private _onValidatedObserver;
  74360. /**
  74361. * Callback raised after a loader extension is created.
  74362. */
  74363. set onValidated(callback: (results: BABYLON.GLTF2.IGLTFValidationResults) => void);
  74364. private _loader;
  74365. /**
  74366. * Name of the loader ("gltf")
  74367. */
  74368. name: string;
  74369. /** @hidden */
  74370. extensions: ISceneLoaderPluginExtensions;
  74371. /**
  74372. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  74373. */
  74374. dispose(): void;
  74375. /** @hidden */
  74376. _clear(): void;
  74377. /** @hidden */
  74378. requestFile(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  74379. /** @hidden */
  74380. readFile(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  74381. /** @hidden */
  74382. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  74383. meshes: AbstractMesh[];
  74384. particleSystems: IParticleSystem[];
  74385. skeletons: Skeleton[];
  74386. animationGroups: AnimationGroup[];
  74387. }>;
  74388. /** @hidden */
  74389. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  74390. /** @hidden */
  74391. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  74392. /** @hidden */
  74393. canDirectLoad(data: string): boolean;
  74394. /** @hidden */
  74395. directLoad(scene: Scene, data: string): any;
  74396. /**
  74397. * The callback that allows custom handling of the root url based on the response url.
  74398. * @param rootUrl the original root url
  74399. * @param responseURL the response url if available
  74400. * @returns the new root url
  74401. */
  74402. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  74403. /** @hidden */
  74404. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  74405. /**
  74406. * The loader state or null if the loader is not active.
  74407. */
  74408. get loaderState(): Nullable<GLTFLoaderState>;
  74409. /**
  74410. * Returns a promise that resolves when the asset is completely loaded.
  74411. * @returns a promise that resolves when the asset is completely loaded.
  74412. */
  74413. whenCompleteAsync(): Promise<void>;
  74414. private _validate;
  74415. private _getLoader;
  74416. private _parseJson;
  74417. private _unpackBinaryAsync;
  74418. private _unpackBinaryV1Async;
  74419. private _unpackBinaryV2Async;
  74420. private static _parseVersion;
  74421. private static _compareVersion;
  74422. private static readonly _logSpaces;
  74423. private _logIndentLevel;
  74424. private _loggingEnabled;
  74425. /** @hidden */
  74426. _log: (message: string) => void;
  74427. /** @hidden */
  74428. _logOpen(message: string): void;
  74429. /** @hidden */
  74430. _logClose(): void;
  74431. private _logEnabled;
  74432. private _logDisabled;
  74433. private _capturePerformanceCounters;
  74434. /** @hidden */
  74435. _startPerformanceCounter: (counterName: string) => void;
  74436. /** @hidden */
  74437. _endPerformanceCounter: (counterName: string) => void;
  74438. private _startPerformanceCounterEnabled;
  74439. private _startPerformanceCounterDisabled;
  74440. private _endPerformanceCounterEnabled;
  74441. private _endPerformanceCounterDisabled;
  74442. }
  74443. }
  74444. declare module BABYLON.GLTF1 {
  74445. /**
  74446. * Enums
  74447. * @hidden
  74448. */
  74449. export enum EComponentType {
  74450. BYTE = 5120,
  74451. UNSIGNED_BYTE = 5121,
  74452. SHORT = 5122,
  74453. UNSIGNED_SHORT = 5123,
  74454. FLOAT = 5126
  74455. }
  74456. /** @hidden */
  74457. export enum EShaderType {
  74458. FRAGMENT = 35632,
  74459. VERTEX = 35633
  74460. }
  74461. /** @hidden */
  74462. export enum EParameterType {
  74463. BYTE = 5120,
  74464. UNSIGNED_BYTE = 5121,
  74465. SHORT = 5122,
  74466. UNSIGNED_SHORT = 5123,
  74467. INT = 5124,
  74468. UNSIGNED_INT = 5125,
  74469. FLOAT = 5126,
  74470. FLOAT_VEC2 = 35664,
  74471. FLOAT_VEC3 = 35665,
  74472. FLOAT_VEC4 = 35666,
  74473. INT_VEC2 = 35667,
  74474. INT_VEC3 = 35668,
  74475. INT_VEC4 = 35669,
  74476. BOOL = 35670,
  74477. BOOL_VEC2 = 35671,
  74478. BOOL_VEC3 = 35672,
  74479. BOOL_VEC4 = 35673,
  74480. FLOAT_MAT2 = 35674,
  74481. FLOAT_MAT3 = 35675,
  74482. FLOAT_MAT4 = 35676,
  74483. SAMPLER_2D = 35678
  74484. }
  74485. /** @hidden */
  74486. export enum ETextureWrapMode {
  74487. CLAMP_TO_EDGE = 33071,
  74488. MIRRORED_REPEAT = 33648,
  74489. REPEAT = 10497
  74490. }
  74491. /** @hidden */
  74492. export enum ETextureFilterType {
  74493. NEAREST = 9728,
  74494. LINEAR = 9728,
  74495. NEAREST_MIPMAP_NEAREST = 9984,
  74496. LINEAR_MIPMAP_NEAREST = 9985,
  74497. NEAREST_MIPMAP_LINEAR = 9986,
  74498. LINEAR_MIPMAP_LINEAR = 9987
  74499. }
  74500. /** @hidden */
  74501. export enum ETextureFormat {
  74502. ALPHA = 6406,
  74503. RGB = 6407,
  74504. RGBA = 6408,
  74505. LUMINANCE = 6409,
  74506. LUMINANCE_ALPHA = 6410
  74507. }
  74508. /** @hidden */
  74509. export enum ECullingType {
  74510. FRONT = 1028,
  74511. BACK = 1029,
  74512. FRONT_AND_BACK = 1032
  74513. }
  74514. /** @hidden */
  74515. export enum EBlendingFunction {
  74516. ZERO = 0,
  74517. ONE = 1,
  74518. SRC_COLOR = 768,
  74519. ONE_MINUS_SRC_COLOR = 769,
  74520. DST_COLOR = 774,
  74521. ONE_MINUS_DST_COLOR = 775,
  74522. SRC_ALPHA = 770,
  74523. ONE_MINUS_SRC_ALPHA = 771,
  74524. DST_ALPHA = 772,
  74525. ONE_MINUS_DST_ALPHA = 773,
  74526. CONSTANT_COLOR = 32769,
  74527. ONE_MINUS_CONSTANT_COLOR = 32770,
  74528. CONSTANT_ALPHA = 32771,
  74529. ONE_MINUS_CONSTANT_ALPHA = 32772,
  74530. SRC_ALPHA_SATURATE = 776
  74531. }
  74532. /** @hidden */
  74533. export interface IGLTFProperty {
  74534. extensions?: {
  74535. [key: string]: any;
  74536. };
  74537. extras?: Object;
  74538. }
  74539. /** @hidden */
  74540. export interface IGLTFChildRootProperty extends IGLTFProperty {
  74541. name?: string;
  74542. }
  74543. /** @hidden */
  74544. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  74545. bufferView: string;
  74546. byteOffset: number;
  74547. byteStride: number;
  74548. count: number;
  74549. type: string;
  74550. componentType: EComponentType;
  74551. max?: number[];
  74552. min?: number[];
  74553. name?: string;
  74554. }
  74555. /** @hidden */
  74556. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  74557. buffer: string;
  74558. byteOffset: number;
  74559. byteLength: number;
  74560. byteStride: number;
  74561. target?: number;
  74562. }
  74563. /** @hidden */
  74564. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  74565. uri: string;
  74566. byteLength?: number;
  74567. type?: string;
  74568. }
  74569. /** @hidden */
  74570. export interface IGLTFShader extends IGLTFChildRootProperty {
  74571. uri: string;
  74572. type: EShaderType;
  74573. }
  74574. /** @hidden */
  74575. export interface IGLTFProgram extends IGLTFChildRootProperty {
  74576. attributes: string[];
  74577. fragmentShader: string;
  74578. vertexShader: string;
  74579. }
  74580. /** @hidden */
  74581. export interface IGLTFTechniqueParameter {
  74582. type: number;
  74583. count?: number;
  74584. semantic?: string;
  74585. node?: string;
  74586. value?: number | boolean | string | Array<any>;
  74587. source?: string;
  74588. babylonValue?: any;
  74589. }
  74590. /** @hidden */
  74591. export interface IGLTFTechniqueCommonProfile {
  74592. lightingModel: string;
  74593. texcoordBindings: Object;
  74594. parameters?: Array<any>;
  74595. }
  74596. /** @hidden */
  74597. export interface IGLTFTechniqueStatesFunctions {
  74598. blendColor?: number[];
  74599. blendEquationSeparate?: number[];
  74600. blendFuncSeparate?: number[];
  74601. colorMask: boolean[];
  74602. cullFace: number[];
  74603. }
  74604. /** @hidden */
  74605. export interface IGLTFTechniqueStates {
  74606. enable: number[];
  74607. functions: IGLTFTechniqueStatesFunctions;
  74608. }
  74609. /** @hidden */
  74610. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  74611. parameters: {
  74612. [key: string]: IGLTFTechniqueParameter;
  74613. };
  74614. program: string;
  74615. attributes: {
  74616. [key: string]: string;
  74617. };
  74618. uniforms: {
  74619. [key: string]: string;
  74620. };
  74621. states: IGLTFTechniqueStates;
  74622. }
  74623. /** @hidden */
  74624. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  74625. technique?: string;
  74626. values: string[];
  74627. }
  74628. /** @hidden */
  74629. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  74630. attributes: {
  74631. [key: string]: string;
  74632. };
  74633. indices: string;
  74634. material: string;
  74635. mode?: number;
  74636. }
  74637. /** @hidden */
  74638. export interface IGLTFMesh extends IGLTFChildRootProperty {
  74639. primitives: IGLTFMeshPrimitive[];
  74640. }
  74641. /** @hidden */
  74642. export interface IGLTFImage extends IGLTFChildRootProperty {
  74643. uri: string;
  74644. }
  74645. /** @hidden */
  74646. export interface IGLTFSampler extends IGLTFChildRootProperty {
  74647. magFilter?: number;
  74648. minFilter?: number;
  74649. wrapS?: number;
  74650. wrapT?: number;
  74651. }
  74652. /** @hidden */
  74653. export interface IGLTFTexture extends IGLTFChildRootProperty {
  74654. sampler: string;
  74655. source: string;
  74656. format?: ETextureFormat;
  74657. internalFormat?: ETextureFormat;
  74658. target?: number;
  74659. type?: number;
  74660. babylonTexture?: Texture;
  74661. }
  74662. /** @hidden */
  74663. export interface IGLTFAmbienLight {
  74664. color?: number[];
  74665. }
  74666. /** @hidden */
  74667. export interface IGLTFDirectionalLight {
  74668. color?: number[];
  74669. }
  74670. /** @hidden */
  74671. export interface IGLTFPointLight {
  74672. color?: number[];
  74673. constantAttenuation?: number;
  74674. linearAttenuation?: number;
  74675. quadraticAttenuation?: number;
  74676. }
  74677. /** @hidden */
  74678. export interface IGLTFSpotLight {
  74679. color?: number[];
  74680. constantAttenuation?: number;
  74681. fallOfAngle?: number;
  74682. fallOffExponent?: number;
  74683. linearAttenuation?: number;
  74684. quadraticAttenuation?: number;
  74685. }
  74686. /** @hidden */
  74687. export interface IGLTFLight extends IGLTFChildRootProperty {
  74688. type: string;
  74689. }
  74690. /** @hidden */
  74691. export interface IGLTFCameraOrthographic {
  74692. xmag: number;
  74693. ymag: number;
  74694. zfar: number;
  74695. znear: number;
  74696. }
  74697. /** @hidden */
  74698. export interface IGLTFCameraPerspective {
  74699. aspectRatio: number;
  74700. yfov: number;
  74701. zfar: number;
  74702. znear: number;
  74703. }
  74704. /** @hidden */
  74705. export interface IGLTFCamera extends IGLTFChildRootProperty {
  74706. type: string;
  74707. }
  74708. /** @hidden */
  74709. export interface IGLTFAnimationChannelTarget {
  74710. id: string;
  74711. path: string;
  74712. }
  74713. /** @hidden */
  74714. export interface IGLTFAnimationChannel {
  74715. sampler: string;
  74716. target: IGLTFAnimationChannelTarget;
  74717. }
  74718. /** @hidden */
  74719. export interface IGLTFAnimationSampler {
  74720. input: string;
  74721. output: string;
  74722. interpolation?: string;
  74723. }
  74724. /** @hidden */
  74725. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  74726. channels?: IGLTFAnimationChannel[];
  74727. parameters?: {
  74728. [key: string]: string;
  74729. };
  74730. samplers?: {
  74731. [key: string]: IGLTFAnimationSampler;
  74732. };
  74733. }
  74734. /** @hidden */
  74735. export interface IGLTFNodeInstanceSkin {
  74736. skeletons: string[];
  74737. skin: string;
  74738. meshes: string[];
  74739. }
  74740. /** @hidden */
  74741. export interface IGLTFSkins extends IGLTFChildRootProperty {
  74742. bindShapeMatrix: number[];
  74743. inverseBindMatrices: string;
  74744. jointNames: string[];
  74745. babylonSkeleton?: Skeleton;
  74746. }
  74747. /** @hidden */
  74748. export interface IGLTFNode extends IGLTFChildRootProperty {
  74749. camera?: string;
  74750. children: string[];
  74751. skin?: string;
  74752. jointName?: string;
  74753. light?: string;
  74754. matrix: number[];
  74755. mesh?: string;
  74756. meshes?: string[];
  74757. rotation?: number[];
  74758. scale?: number[];
  74759. translation?: number[];
  74760. babylonNode?: Node;
  74761. }
  74762. /** @hidden */
  74763. export interface IGLTFScene extends IGLTFChildRootProperty {
  74764. nodes: string[];
  74765. }
  74766. /** @hidden */
  74767. export interface IGLTFRuntime {
  74768. extensions: {
  74769. [key: string]: any;
  74770. };
  74771. accessors: {
  74772. [key: string]: IGLTFAccessor;
  74773. };
  74774. buffers: {
  74775. [key: string]: IGLTFBuffer;
  74776. };
  74777. bufferViews: {
  74778. [key: string]: IGLTFBufferView;
  74779. };
  74780. meshes: {
  74781. [key: string]: IGLTFMesh;
  74782. };
  74783. lights: {
  74784. [key: string]: IGLTFLight;
  74785. };
  74786. cameras: {
  74787. [key: string]: IGLTFCamera;
  74788. };
  74789. nodes: {
  74790. [key: string]: IGLTFNode;
  74791. };
  74792. images: {
  74793. [key: string]: IGLTFImage;
  74794. };
  74795. textures: {
  74796. [key: string]: IGLTFTexture;
  74797. };
  74798. shaders: {
  74799. [key: string]: IGLTFShader;
  74800. };
  74801. programs: {
  74802. [key: string]: IGLTFProgram;
  74803. };
  74804. samplers: {
  74805. [key: string]: IGLTFSampler;
  74806. };
  74807. techniques: {
  74808. [key: string]: IGLTFTechnique;
  74809. };
  74810. materials: {
  74811. [key: string]: IGLTFMaterial;
  74812. };
  74813. animations: {
  74814. [key: string]: IGLTFAnimation;
  74815. };
  74816. skins: {
  74817. [key: string]: IGLTFSkins;
  74818. };
  74819. currentScene?: Object;
  74820. scenes: {
  74821. [key: string]: IGLTFScene;
  74822. };
  74823. extensionsUsed: string[];
  74824. extensionsRequired?: string[];
  74825. buffersCount: number;
  74826. shaderscount: number;
  74827. scene: Scene;
  74828. rootUrl: string;
  74829. loadedBufferCount: number;
  74830. loadedBufferViews: {
  74831. [name: string]: ArrayBufferView;
  74832. };
  74833. loadedShaderCount: number;
  74834. importOnlyMeshes: boolean;
  74835. importMeshesNames?: string[];
  74836. dummyNodes: Node[];
  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 data gltf data containing information of the meshes in a loaded file
  74939. * @param rootUrl root url to load from
  74940. * @param onProgress event that fires when loading progress has occured
  74941. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  74942. */
  74943. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<{
  74944. meshes: AbstractMesh[];
  74945. particleSystems: IParticleSystem[];
  74946. skeletons: Skeleton[];
  74947. animationGroups: AnimationGroup[];
  74948. }>;
  74949. private _loadAsync;
  74950. /**
  74951. * Imports all objects from a loaded gltf file and adds them to the scene
  74952. * @param scene the scene the objects should be added to
  74953. * @param data gltf data containing information of the meshes in a loaded file
  74954. * @param rootUrl root url to load from
  74955. * @param onProgress event that fires when loading progress has occured
  74956. * @returns a promise which completes when objects have been loaded to the scene
  74957. */
  74958. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
  74959. private _loadShadersAsync;
  74960. private _loadBuffersAsync;
  74961. private _createNodes;
  74962. }
  74963. /** @hidden */
  74964. export abstract class GLTFLoaderExtension {
  74965. private _name;
  74966. constructor(name: string);
  74967. get name(): string;
  74968. /**
  74969. * Defines an override for loading the runtime
  74970. * Return true to stop further extensions from loading the runtime
  74971. */
  74972. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  74973. /**
  74974. * Defines an onverride for creating gltf runtime
  74975. * Return true to stop further extensions from creating the runtime
  74976. */
  74977. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  74978. /**
  74979. * Defines an override for loading buffers
  74980. * Return true to stop further extensions from loading this buffer
  74981. */
  74982. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  74983. /**
  74984. * Defines an override for loading texture buffers
  74985. * Return true to stop further extensions from loading this texture data
  74986. */
  74987. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  74988. /**
  74989. * Defines an override for creating textures
  74990. * Return true to stop further extensions from loading this texture
  74991. */
  74992. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  74993. /**
  74994. * Defines an override for loading shader strings
  74995. * Return true to stop further extensions from loading this shader data
  74996. */
  74997. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  74998. /**
  74999. * Defines an override for loading materials
  75000. * Return true to stop further extensions from loading this material
  75001. */
  75002. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  75003. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  75004. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  75005. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  75006. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  75007. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  75008. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  75009. private static LoadTextureBufferAsync;
  75010. private static CreateTextureAsync;
  75011. private static ApplyExtensions;
  75012. }
  75013. }
  75014. declare module BABYLON.GLTF1 {
  75015. /** @hidden */
  75016. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  75017. private _bin;
  75018. constructor();
  75019. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  75020. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  75021. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  75022. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  75023. }
  75024. }
  75025. declare module BABYLON.GLTF1 {
  75026. /** @hidden */
  75027. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  75028. constructor();
  75029. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  75030. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  75031. private _loadTexture;
  75032. }
  75033. }
  75034. declare module BABYLON.GLTF2.Loader {
  75035. /**
  75036. * Loader interface with an index field.
  75037. */
  75038. export interface IArrayItem {
  75039. /**
  75040. * The index of this item in the array.
  75041. */
  75042. index: number;
  75043. }
  75044. /**
  75045. * Loader interface with additional members.
  75046. */
  75047. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  75048. /** @hidden */
  75049. _data?: Promise<ArrayBufferView>;
  75050. /** @hidden */
  75051. _babylonVertexBuffer?: Promise<VertexBuffer>;
  75052. }
  75053. /**
  75054. * Loader interface with additional members.
  75055. */
  75056. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  75057. }
  75058. /** @hidden */
  75059. export interface _IAnimationSamplerData {
  75060. input: Float32Array;
  75061. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  75062. output: Float32Array;
  75063. }
  75064. /**
  75065. * Loader interface with additional members.
  75066. */
  75067. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  75068. /** @hidden */
  75069. _data?: Promise<_IAnimationSamplerData>;
  75070. }
  75071. /**
  75072. * Loader interface with additional members.
  75073. */
  75074. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  75075. channels: IAnimationChannel[];
  75076. samplers: IAnimationSampler[];
  75077. /** @hidden */
  75078. _babylonAnimationGroup?: AnimationGroup;
  75079. }
  75080. /**
  75081. * Loader interface with additional members.
  75082. */
  75083. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  75084. /** @hidden */
  75085. _data?: Promise<ArrayBufferView>;
  75086. }
  75087. /**
  75088. * Loader interface with additional members.
  75089. */
  75090. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  75091. /** @hidden */
  75092. _data?: Promise<ArrayBufferView>;
  75093. /** @hidden */
  75094. _babylonBuffer?: Promise<Buffer>;
  75095. }
  75096. /**
  75097. * Loader interface with additional members.
  75098. */
  75099. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  75100. }
  75101. /**
  75102. * Loader interface with additional members.
  75103. */
  75104. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  75105. /** @hidden */
  75106. _data?: Promise<ArrayBufferView>;
  75107. }
  75108. /**
  75109. * Loader interface with additional members.
  75110. */
  75111. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  75112. }
  75113. /**
  75114. * Loader interface with additional members.
  75115. */
  75116. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  75117. }
  75118. /**
  75119. * Loader interface with additional members.
  75120. */
  75121. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  75122. baseColorTexture?: ITextureInfo;
  75123. metallicRoughnessTexture?: ITextureInfo;
  75124. }
  75125. /**
  75126. * Loader interface with additional members.
  75127. */
  75128. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  75129. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  75130. normalTexture?: IMaterialNormalTextureInfo;
  75131. occlusionTexture?: IMaterialOcclusionTextureInfo;
  75132. emissiveTexture?: ITextureInfo;
  75133. /** @hidden */
  75134. _data?: {
  75135. [babylonDrawMode: number]: {
  75136. babylonMaterial: Material;
  75137. babylonMeshes: AbstractMesh[];
  75138. promise: Promise<void>;
  75139. };
  75140. };
  75141. }
  75142. /**
  75143. * Loader interface with additional members.
  75144. */
  75145. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  75146. primitives: IMeshPrimitive[];
  75147. }
  75148. /**
  75149. * Loader interface with additional members.
  75150. */
  75151. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  75152. /** @hidden */
  75153. _instanceData?: {
  75154. babylonSourceMesh: Mesh;
  75155. promise: Promise<any>;
  75156. };
  75157. }
  75158. /**
  75159. * Loader interface with additional members.
  75160. */
  75161. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  75162. /**
  75163. * The parent glTF node.
  75164. */
  75165. parent?: INode;
  75166. /** @hidden */
  75167. _babylonTransformNode?: TransformNode;
  75168. /** @hidden */
  75169. _primitiveBabylonMeshes?: AbstractMesh[];
  75170. /** @hidden */
  75171. _babylonBones?: Bone[];
  75172. /** @hidden */
  75173. _numMorphTargets?: number;
  75174. }
  75175. /** @hidden */
  75176. export interface _ISamplerData {
  75177. noMipMaps: boolean;
  75178. samplingMode: number;
  75179. wrapU: number;
  75180. wrapV: number;
  75181. }
  75182. /**
  75183. * Loader interface with additional members.
  75184. */
  75185. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  75186. /** @hidden */
  75187. _data?: _ISamplerData;
  75188. }
  75189. /**
  75190. * Loader interface with additional members.
  75191. */
  75192. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  75193. }
  75194. /**
  75195. * Loader interface with additional members.
  75196. */
  75197. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  75198. /** @hidden */
  75199. _data?: {
  75200. babylonSkeleton: Skeleton;
  75201. promise: Promise<void>;
  75202. };
  75203. }
  75204. /**
  75205. * Loader interface with additional members.
  75206. */
  75207. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  75208. }
  75209. /**
  75210. * Loader interface with additional members.
  75211. */
  75212. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  75213. }
  75214. /**
  75215. * Loader interface with additional members.
  75216. */
  75217. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  75218. accessors?: IAccessor[];
  75219. animations?: IAnimation[];
  75220. buffers?: IBuffer[];
  75221. bufferViews?: IBufferView[];
  75222. cameras?: ICamera[];
  75223. images?: IImage[];
  75224. materials?: IMaterial[];
  75225. meshes?: IMesh[];
  75226. nodes?: INode[];
  75227. samplers?: ISampler[];
  75228. scenes?: IScene[];
  75229. skins?: ISkin[];
  75230. textures?: ITexture[];
  75231. }
  75232. }
  75233. declare module BABYLON.GLTF2 {
  75234. /**
  75235. * Interface for a glTF loader extension.
  75236. */
  75237. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  75238. /**
  75239. * Called after the loader state changes to LOADING.
  75240. */
  75241. onLoading?(): void;
  75242. /**
  75243. * Called after the loader state changes to READY.
  75244. */
  75245. onReady?(): void;
  75246. /**
  75247. * Define this method to modify the default behavior when loading scenes.
  75248. * @param context The context when loading the asset
  75249. * @param scene The glTF scene property
  75250. * @returns A promise that resolves when the load is complete or null if not handled
  75251. */
  75252. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  75253. /**
  75254. * Define this method to modify the default behavior when loading nodes.
  75255. * @param context The context when loading the asset
  75256. * @param node The glTF node property
  75257. * @param assign A function called synchronously after parsing the glTF properties
  75258. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  75259. */
  75260. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  75261. /**
  75262. * Define this method to modify the default behavior when loading cameras.
  75263. * @param context The context when loading the asset
  75264. * @param camera The glTF camera property
  75265. * @param assign A function called synchronously after parsing the glTF properties
  75266. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  75267. */
  75268. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  75269. /**
  75270. * @hidden Define this method to modify the default behavior when loading vertex data for mesh primitives.
  75271. * @param context The context when loading the asset
  75272. * @param primitive The glTF mesh primitive property
  75273. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  75274. */
  75275. _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  75276. /**
  75277. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  75278. * @param context The context when loading the asset
  75279. * @param name The mesh name when loading the asset
  75280. * @param node The glTF node when loading the asset
  75281. * @param mesh The glTF mesh when loading the asset
  75282. * @param primitive The glTF mesh primitive property
  75283. * @param assign A function called synchronously after parsing the glTF properties
  75284. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  75285. */
  75286. _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  75287. /**
  75288. * @hidden Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  75289. * @param context The context when loading the asset
  75290. * @param material The glTF material property
  75291. * @param assign A function called synchronously after parsing the glTF properties
  75292. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  75293. */
  75294. _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  75295. /**
  75296. * Define this method to modify the default behavior when creating materials.
  75297. * @param context The context when loading the asset
  75298. * @param material The glTF material property
  75299. * @param babylonDrawMode The draw mode for the Babylon material
  75300. * @returns The Babylon material or null if not handled
  75301. */
  75302. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  75303. /**
  75304. * Define this method to modify the default behavior when loading material properties.
  75305. * @param context The context when loading the asset
  75306. * @param material The glTF material property
  75307. * @param babylonMaterial The Babylon material
  75308. * @returns A promise that resolves when the load is complete or null if not handled
  75309. */
  75310. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  75311. /**
  75312. * Define this method to modify the default behavior when loading texture infos.
  75313. * @param context The context when loading the asset
  75314. * @param textureInfo The glTF texture info property
  75315. * @param assign A function called synchronously after parsing the glTF properties
  75316. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  75317. */
  75318. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  75319. /**
  75320. * Define this method to modify the default behavior when loading animations.
  75321. * @param context The context when loading the asset
  75322. * @param animation The glTF animation property
  75323. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  75324. */
  75325. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  75326. /**
  75327. * @hidden Define this method to modify the default behavior when loading skins.
  75328. * @param context The context when loading the asset
  75329. * @param node The glTF node property
  75330. * @param skin The glTF skin property
  75331. * @returns A promise that resolves when the load is complete or null if not handled
  75332. */
  75333. _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  75334. /**
  75335. * @hidden Define this method to modify the default behavior when loading uris.
  75336. * @param context The context when loading the asset
  75337. * @param property The glTF property associated with the uri
  75338. * @param uri The uri to load
  75339. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  75340. */
  75341. _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  75342. /**
  75343. * Define this method to modify the default behavior when loading buffer views.
  75344. * @param context The context when loading the asset
  75345. * @param bufferView The glTF buffer view property
  75346. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  75347. */
  75348. loadBufferViewAsync?(context: string, bufferView: IBufferView): Nullable<Promise<ArrayBufferView>>;
  75349. /**
  75350. * Define this method to modify the default behavior when loading buffers.
  75351. * @param context The context when loading the asset
  75352. * @param buffer The glTF buffer property
  75353. * @param byteOffset The byte offset to load
  75354. * @param byteLength The byte length to load
  75355. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  75356. */
  75357. loadBufferAsync?(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  75358. }
  75359. }
  75360. declare module BABYLON.GLTF2 {
  75361. /**
  75362. * Helper class for working with arrays when loading the glTF asset
  75363. */
  75364. export class ArrayItem {
  75365. /**
  75366. * Gets an item from the given array.
  75367. * @param context The context when loading the asset
  75368. * @param array The array to get the item from
  75369. * @param index The index to the array
  75370. * @returns The array item
  75371. */
  75372. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  75373. /**
  75374. * Assign an `index` field to each item of the given array.
  75375. * @param array The array of items
  75376. */
  75377. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  75378. }
  75379. /**
  75380. * The glTF 2.0 loader
  75381. */
  75382. export class GLTFLoader implements IGLTFLoader {
  75383. /** @hidden */
  75384. _completePromises: Promise<any>[];
  75385. private _disposed;
  75386. private _parent;
  75387. private _state;
  75388. private _extensions;
  75389. private _rootUrl;
  75390. private _fileName;
  75391. private _uniqueRootUrl;
  75392. private _gltf;
  75393. private _bin;
  75394. private _babylonScene;
  75395. private _rootBabylonMesh;
  75396. private _defaultBabylonMaterialData;
  75397. private _progressCallback?;
  75398. private _requests;
  75399. private static readonly _DefaultSampler;
  75400. private static _RegisteredExtensions;
  75401. /**
  75402. * Registers a loader extension.
  75403. * @param name The name of the loader extension.
  75404. * @param factory The factory function that creates the loader extension.
  75405. */
  75406. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  75407. /**
  75408. * Unregisters a loader extension.
  75409. * @param name The name of the loader extension.
  75410. * @returns A boolean indicating whether the extension has been unregistered
  75411. */
  75412. static UnregisterExtension(name: string): boolean;
  75413. /**
  75414. * Gets the loader state.
  75415. */
  75416. get state(): Nullable<GLTFLoaderState>;
  75417. /**
  75418. * The object that represents the glTF JSON.
  75419. */
  75420. get gltf(): IGLTF;
  75421. /**
  75422. * The BIN chunk of a binary glTF.
  75423. */
  75424. get bin(): Nullable<IDataBuffer>;
  75425. /**
  75426. * The parent file loader.
  75427. */
  75428. get parent(): GLTFFileLoader;
  75429. /**
  75430. * The Babylon scene when loading the asset.
  75431. */
  75432. get babylonScene(): Scene;
  75433. /**
  75434. * The root Babylon mesh when loading the asset.
  75435. */
  75436. get rootBabylonMesh(): Mesh;
  75437. /** @hidden */
  75438. constructor(parent: GLTFFileLoader);
  75439. /** @hidden */
  75440. dispose(): void;
  75441. /** @hidden */
  75442. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  75443. meshes: AbstractMesh[];
  75444. particleSystems: IParticleSystem[];
  75445. skeletons: Skeleton[];
  75446. animationGroups: AnimationGroup[];
  75447. }>;
  75448. /** @hidden */
  75449. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  75450. private _loadAsync;
  75451. private _loadData;
  75452. private _setupData;
  75453. private _loadExtensions;
  75454. private _checkExtensions;
  75455. private _setState;
  75456. private _createRootNode;
  75457. /**
  75458. * Loads a glTF scene.
  75459. * @param context The context when loading the asset
  75460. * @param scene The glTF scene property
  75461. * @returns A promise that resolves when the load is complete
  75462. */
  75463. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  75464. private _forEachPrimitive;
  75465. private _getMeshes;
  75466. private _getSkeletons;
  75467. private _getAnimationGroups;
  75468. private _startAnimations;
  75469. /**
  75470. * Loads a glTF node.
  75471. * @param context The context when loading the asset
  75472. * @param node The glTF node property
  75473. * @param assign A function called synchronously after parsing the glTF properties
  75474. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  75475. */
  75476. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  75477. private _loadMeshAsync;
  75478. /**
  75479. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  75480. * @param context The context when loading the asset
  75481. * @param name The mesh name when loading the asset
  75482. * @param node The glTF node when loading the asset
  75483. * @param mesh The glTF mesh when loading the asset
  75484. * @param primitive The glTF mesh primitive property
  75485. * @param assign A function called synchronously after parsing the glTF properties
  75486. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  75487. */
  75488. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  75489. private _loadVertexDataAsync;
  75490. private _createMorphTargets;
  75491. private _loadMorphTargetsAsync;
  75492. private _loadMorphTargetVertexDataAsync;
  75493. private static _LoadTransform;
  75494. private _loadSkinAsync;
  75495. private _loadBones;
  75496. private _loadBone;
  75497. private _loadSkinInverseBindMatricesDataAsync;
  75498. private _updateBoneMatrices;
  75499. private _getNodeMatrix;
  75500. /**
  75501. * Loads a glTF camera.
  75502. * @param context The context when loading the asset
  75503. * @param camera The glTF camera property
  75504. * @param assign A function called synchronously after parsing the glTF properties
  75505. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  75506. */
  75507. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  75508. private _loadAnimationsAsync;
  75509. /**
  75510. * Loads a glTF animation.
  75511. * @param context The context when loading the asset
  75512. * @param animation The glTF animation property
  75513. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  75514. */
  75515. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  75516. /**
  75517. * @hidden Loads a glTF animation channel.
  75518. * @param context The context when loading the asset
  75519. * @param animationContext The context of the animation when loading the asset
  75520. * @param animation The glTF animation property
  75521. * @param channel The glTF animation channel property
  75522. * @param babylonAnimationGroup The babylon animation group property
  75523. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  75524. * @returns A void promise when the channel load is complete
  75525. */
  75526. _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  75527. private _loadAnimationSamplerAsync;
  75528. private _loadBufferAsync;
  75529. /**
  75530. * Loads a glTF buffer view.
  75531. * @param context The context when loading the asset
  75532. * @param bufferView The glTF buffer view property
  75533. * @returns A promise that resolves with the loaded data when the load is complete
  75534. */
  75535. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  75536. private _loadAccessorAsync;
  75537. private _loadFloatAccessorAsync;
  75538. private _loadIndicesAccessorAsync;
  75539. private _loadVertexBufferViewAsync;
  75540. private _loadVertexAccessorAsync;
  75541. private _loadMaterialMetallicRoughnessPropertiesAsync;
  75542. /** @hidden */
  75543. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  75544. private _createDefaultMaterial;
  75545. /**
  75546. * Creates a Babylon material from a glTF material.
  75547. * @param context The context when loading the asset
  75548. * @param material The glTF material property
  75549. * @param babylonDrawMode The draw mode for the Babylon material
  75550. * @returns The Babylon material
  75551. */
  75552. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  75553. /**
  75554. * Loads properties from a glTF material into a Babylon material.
  75555. * @param context The context when loading the asset
  75556. * @param material The glTF material property
  75557. * @param babylonMaterial The Babylon material
  75558. * @returns A promise that resolves when the load is complete
  75559. */
  75560. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  75561. /**
  75562. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  75563. * @param context The context when loading the asset
  75564. * @param material The glTF material property
  75565. * @param babylonMaterial The Babylon material
  75566. * @returns A promise that resolves when the load is complete
  75567. */
  75568. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  75569. /**
  75570. * Loads the alpha properties from a glTF material into a Babylon material.
  75571. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  75572. * @param context The context when loading the asset
  75573. * @param material The glTF material property
  75574. * @param babylonMaterial The Babylon material
  75575. */
  75576. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  75577. /**
  75578. * Loads a glTF texture info.
  75579. * @param context The context when loading the asset
  75580. * @param textureInfo The glTF texture info property
  75581. * @param assign A function called synchronously after parsing the glTF properties
  75582. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  75583. */
  75584. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  75585. private _loadTextureAsync;
  75586. private _loadSampler;
  75587. /**
  75588. * Loads a glTF image.
  75589. * @param context The context when loading the asset
  75590. * @param image The glTF image property
  75591. * @returns A promise that resolves with the loaded data when the load is complete
  75592. */
  75593. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  75594. /**
  75595. * Loads a glTF uri.
  75596. * @param context The context when loading the asset
  75597. * @param property The glTF property associated with the uri
  75598. * @param uri The base64 or relative uri
  75599. * @returns A promise that resolves with the loaded data when the load is complete
  75600. */
  75601. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  75602. private _onProgress;
  75603. /**
  75604. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  75605. * @param babylonObject the Babylon object with metadata
  75606. * @param pointer the JSON pointer
  75607. */
  75608. static AddPointerMetadata(babylonObject: {
  75609. metadata: any;
  75610. }, pointer: string): void;
  75611. private static _GetTextureWrapMode;
  75612. private static _GetTextureSamplingMode;
  75613. private static _GetTypedArrayConstructor;
  75614. private static _GetTypedArray;
  75615. private static _GetNumComponents;
  75616. private static _ValidateUri;
  75617. private static _GetDrawMode;
  75618. private _compileMaterialsAsync;
  75619. private _compileShadowGeneratorsAsync;
  75620. private _forEachExtensions;
  75621. private _applyExtensions;
  75622. private _extensionsOnLoading;
  75623. private _extensionsOnReady;
  75624. private _extensionsLoadSceneAsync;
  75625. private _extensionsLoadNodeAsync;
  75626. private _extensionsLoadCameraAsync;
  75627. private _extensionsLoadVertexDataAsync;
  75628. private _extensionsLoadMeshPrimitiveAsync;
  75629. private _extensionsLoadMaterialAsync;
  75630. private _extensionsCreateMaterial;
  75631. private _extensionsLoadMaterialPropertiesAsync;
  75632. private _extensionsLoadTextureInfoAsync;
  75633. private _extensionsLoadAnimationAsync;
  75634. private _extensionsLoadSkinAsync;
  75635. private _extensionsLoadUriAsync;
  75636. private _extensionsLoadBufferViewAsync;
  75637. private _extensionsLoadBufferAsync;
  75638. /**
  75639. * Helper method called by a loader extension to load an glTF extension.
  75640. * @param context The context when loading the asset
  75641. * @param property The glTF property to load the extension from
  75642. * @param extensionName The name of the extension to load
  75643. * @param actionAsync The action to run
  75644. * @returns The promise returned by actionAsync or null if the extension does not exist
  75645. */
  75646. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  75647. /**
  75648. * Helper method called by a loader extension to load a glTF extra.
  75649. * @param context The context when loading the asset
  75650. * @param property The glTF property to load the extra from
  75651. * @param extensionName The name of the extension to load
  75652. * @param actionAsync The action to run
  75653. * @returns The promise returned by actionAsync or null if the extra does not exist
  75654. */
  75655. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  75656. /**
  75657. * Checks for presence of an extension.
  75658. * @param name The name of the extension to check
  75659. * @returns A boolean indicating the presence of the given extension name in `extensionsUsed`
  75660. */
  75661. isExtensionUsed(name: string): boolean;
  75662. /**
  75663. * Increments the indentation level and logs a message.
  75664. * @param message The message to log
  75665. */
  75666. logOpen(message: string): void;
  75667. /**
  75668. * Decrements the indentation level.
  75669. */
  75670. logClose(): void;
  75671. /**
  75672. * Logs a message
  75673. * @param message The message to log
  75674. */
  75675. log(message: string): void;
  75676. /**
  75677. * Starts a performance counter.
  75678. * @param counterName The name of the performance counter
  75679. */
  75680. startPerformanceCounter(counterName: string): void;
  75681. /**
  75682. * Ends a performance counter.
  75683. * @param counterName The name of the performance counter
  75684. */
  75685. endPerformanceCounter(counterName: string): void;
  75686. }
  75687. }
  75688. declare module BABYLON.GLTF2.Loader.Extensions {
  75689. /**
  75690. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_lights_image_based/README.md)
  75691. */
  75692. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  75693. /**
  75694. * The name of this extension.
  75695. */
  75696. readonly name: string;
  75697. /**
  75698. * Defines whether this extension is enabled.
  75699. */
  75700. enabled: boolean;
  75701. private _loader;
  75702. private _lights?;
  75703. /** @hidden */
  75704. constructor(loader: GLTFLoader);
  75705. /** @hidden */
  75706. dispose(): void;
  75707. /** @hidden */
  75708. onLoading(): void;
  75709. /** @hidden */
  75710. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  75711. private _loadLightAsync;
  75712. }
  75713. }
  75714. declare module BABYLON.GLTF2.Loader.Extensions {
  75715. /**
  75716. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  75717. */
  75718. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  75719. /**
  75720. * The name of this extension.
  75721. */
  75722. readonly name: string;
  75723. /**
  75724. * The draco compression used to decode vertex data or DracoCompression.Default if not defined
  75725. */
  75726. dracoCompression?: DracoCompression;
  75727. /**
  75728. * Defines whether this extension is enabled.
  75729. */
  75730. enabled: boolean;
  75731. private _loader;
  75732. /** @hidden */
  75733. constructor(loader: GLTFLoader);
  75734. /** @hidden */
  75735. dispose(): void;
  75736. /** @hidden */
  75737. _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  75738. }
  75739. }
  75740. declare module BABYLON.GLTF2.Loader.Extensions {
  75741. /**
  75742. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  75743. */
  75744. export class KHR_lights implements IGLTFLoaderExtension {
  75745. /**
  75746. * The name of this extension.
  75747. */
  75748. readonly name: string;
  75749. /**
  75750. * Defines whether this extension is enabled.
  75751. */
  75752. enabled: boolean;
  75753. private _loader;
  75754. private _lights?;
  75755. /** @hidden */
  75756. constructor(loader: GLTFLoader);
  75757. /** @hidden */
  75758. dispose(): void;
  75759. /** @hidden */
  75760. onLoading(): void;
  75761. /** @hidden */
  75762. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  75763. }
  75764. }
  75765. declare module BABYLON.GLTF2.Loader.Extensions {
  75766. /**
  75767. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  75768. */
  75769. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  75770. /**
  75771. * The name of this extension.
  75772. */
  75773. readonly name: string;
  75774. /**
  75775. * Defines whether this extension is enabled.
  75776. */
  75777. enabled: boolean;
  75778. /**
  75779. * Defines a number that determines the order the extensions are applied.
  75780. */
  75781. order: number;
  75782. private _loader;
  75783. /** @hidden */
  75784. constructor(loader: GLTFLoader);
  75785. /** @hidden */
  75786. dispose(): void;
  75787. /** @hidden */
  75788. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  75789. private _loadSpecularGlossinessPropertiesAsync;
  75790. }
  75791. }
  75792. declare module BABYLON.GLTF2.Loader.Extensions {
  75793. /**
  75794. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  75795. */
  75796. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  75797. /**
  75798. * The name of this extension.
  75799. */
  75800. readonly name: string;
  75801. /**
  75802. * Defines whether this extension is enabled.
  75803. */
  75804. enabled: boolean;
  75805. /**
  75806. * Defines a number that determines the order the extensions are applied.
  75807. */
  75808. order: number;
  75809. private _loader;
  75810. /** @hidden */
  75811. constructor(loader: GLTFLoader);
  75812. /** @hidden */
  75813. dispose(): void;
  75814. /** @hidden */
  75815. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  75816. private _loadUnlitPropertiesAsync;
  75817. }
  75818. }
  75819. declare module BABYLON.GLTF2.Loader.Extensions {
  75820. /**
  75821. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1677)
  75822. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#7F7PN6#8)
  75823. * !!! Experimental Extension Subject to Changes !!!
  75824. */
  75825. export class KHR_materials_clearcoat implements IGLTFLoaderExtension {
  75826. /**
  75827. * The name of this extension.
  75828. */
  75829. readonly name: string;
  75830. /**
  75831. * Defines whether this extension is enabled.
  75832. */
  75833. enabled: boolean;
  75834. /**
  75835. * Defines a number that determines the order the extensions are applied.
  75836. */
  75837. order: number;
  75838. private _loader;
  75839. /** @hidden */
  75840. constructor(loader: GLTFLoader);
  75841. /** @hidden */
  75842. dispose(): void;
  75843. /** @hidden */
  75844. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  75845. private _loadClearCoatPropertiesAsync;
  75846. }
  75847. }
  75848. declare module BABYLON.GLTF2.Loader.Extensions {
  75849. /**
  75850. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1688)
  75851. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  75852. * !!! Experimental Extension Subject to Changes !!!
  75853. */
  75854. export class KHR_materials_sheen implements IGLTFLoaderExtension {
  75855. /**
  75856. * The name of this extension.
  75857. */
  75858. readonly name: string;
  75859. /**
  75860. * Defines whether this extension is enabled.
  75861. */
  75862. enabled: boolean;
  75863. /**
  75864. * Defines a number that determines the order the extensions are applied.
  75865. */
  75866. order: number;
  75867. private _loader;
  75868. /** @hidden */
  75869. constructor(loader: GLTFLoader);
  75870. /** @hidden */
  75871. dispose(): void;
  75872. /** @hidden */
  75873. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  75874. private _loadSheenPropertiesAsync;
  75875. }
  75876. }
  75877. declare module BABYLON.GLTF2.Loader.Extensions {
  75878. /**
  75879. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1677)
  75880. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  75881. * !!! Experimental Extension Subject to Changes !!!
  75882. */
  75883. export class KHR_materials_specular implements IGLTFLoaderExtension {
  75884. /**
  75885. * The name of this extension.
  75886. */
  75887. readonly name: string;
  75888. /**
  75889. * Defines whether this extension is enabled.
  75890. */
  75891. enabled: boolean;
  75892. /**
  75893. * Defines a number that determines the order the extensions are applied.
  75894. */
  75895. order: number;
  75896. private _loader;
  75897. /** @hidden */
  75898. constructor(loader: GLTFLoader);
  75899. /** @hidden */
  75900. dispose(): void;
  75901. /** @hidden */
  75902. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  75903. private _loadSpecularPropertiesAsync;
  75904. }
  75905. }
  75906. declare module BABYLON.GLTF2.Loader.Extensions {
  75907. /**
  75908. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_mesh_quantization)
  75909. */
  75910. export class KHR_mesh_quantization implements IGLTFLoaderExtension {
  75911. /**
  75912. * The name of this extension.
  75913. */
  75914. readonly name: string;
  75915. /**
  75916. * Defines whether this extension is enabled.
  75917. */
  75918. enabled: boolean;
  75919. /** @hidden */
  75920. constructor(loader: GLTFLoader);
  75921. /** @hidden */
  75922. dispose(): void;
  75923. }
  75924. }
  75925. declare module BABYLON.GLTF2.Loader.Extensions {
  75926. /**
  75927. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform/README.md)
  75928. */
  75929. export class KHR_texture_transform implements IGLTFLoaderExtension {
  75930. /**
  75931. * The name of this extension.
  75932. */
  75933. readonly name: string;
  75934. /**
  75935. * Defines whether this extension is enabled.
  75936. */
  75937. enabled: boolean;
  75938. private _loader;
  75939. /** @hidden */
  75940. constructor(loader: GLTFLoader);
  75941. /** @hidden */
  75942. dispose(): void;
  75943. /** @hidden */
  75944. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  75945. }
  75946. }
  75947. declare module BABYLON.GLTF2.Loader.Extensions {
  75948. /**
  75949. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  75950. */
  75951. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  75952. /**
  75953. * The name of this extension.
  75954. */
  75955. readonly name: string;
  75956. /**
  75957. * Defines whether this extension is enabled.
  75958. */
  75959. enabled: boolean;
  75960. private _loader;
  75961. private _clips;
  75962. private _emitters;
  75963. /** @hidden */
  75964. constructor(loader: GLTFLoader);
  75965. /** @hidden */
  75966. dispose(): void;
  75967. /** @hidden */
  75968. onLoading(): void;
  75969. /** @hidden */
  75970. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  75971. /** @hidden */
  75972. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  75973. /** @hidden */
  75974. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  75975. private _loadClipAsync;
  75976. private _loadEmitterAsync;
  75977. private _getEventAction;
  75978. private _loadAnimationEventAsync;
  75979. }
  75980. }
  75981. declare module BABYLON.GLTF2.Loader.Extensions {
  75982. /**
  75983. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  75984. */
  75985. export class MSFT_lod implements IGLTFLoaderExtension {
  75986. /**
  75987. * The name of this extension.
  75988. */
  75989. readonly name: string;
  75990. /**
  75991. * Defines whether this extension is enabled.
  75992. */
  75993. enabled: boolean;
  75994. /**
  75995. * Defines a number that determines the order the extensions are applied.
  75996. */
  75997. order: number;
  75998. /**
  75999. * Maximum number of LODs to load, starting from the lowest LOD.
  76000. */
  76001. maxLODsToLoad: number;
  76002. /**
  76003. * Observable raised when all node LODs of one level are loaded.
  76004. * The event data is the index of the loaded LOD starting from zero.
  76005. * Dispose the loader to cancel the loading of the next level of LODs.
  76006. */
  76007. onNodeLODsLoadedObservable: Observable<number>;
  76008. /**
  76009. * Observable raised when all material LODs of one level are loaded.
  76010. * The event data is the index of the loaded LOD starting from zero.
  76011. * Dispose the loader to cancel the loading of the next level of LODs.
  76012. */
  76013. onMaterialLODsLoadedObservable: Observable<number>;
  76014. private _loader;
  76015. private _nodeIndexLOD;
  76016. private _nodeSignalLODs;
  76017. private _nodePromiseLODs;
  76018. private _materialIndexLOD;
  76019. private _materialSignalLODs;
  76020. private _materialPromiseLODs;
  76021. private _indexLOD;
  76022. private _bufferLODs;
  76023. /** @hidden */
  76024. constructor(loader: GLTFLoader);
  76025. /** @hidden */
  76026. dispose(): void;
  76027. /** @hidden */
  76028. onReady(): void;
  76029. /** @hidden */
  76030. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  76031. /** @hidden */
  76032. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  76033. /** @hidden */
  76034. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  76035. /** @hidden */
  76036. _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  76037. /** @hidden */
  76038. loadBufferAsync(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  76039. private _loadBufferLOD;
  76040. /**
  76041. * Gets an array of LOD properties from lowest to highest.
  76042. */
  76043. private _getLODs;
  76044. private _disposeUnusedMaterials;
  76045. }
  76046. }
  76047. declare module BABYLON.GLTF2.Loader.Extensions {
  76048. /** @hidden */
  76049. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  76050. readonly name: string;
  76051. enabled: boolean;
  76052. private _loader;
  76053. constructor(loader: GLTFLoader);
  76054. dispose(): void;
  76055. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  76056. }
  76057. }
  76058. declare module BABYLON.GLTF2.Loader.Extensions {
  76059. /** @hidden */
  76060. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  76061. readonly name: string;
  76062. enabled: boolean;
  76063. private _loader;
  76064. constructor(loader: GLTFLoader);
  76065. dispose(): void;
  76066. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  76067. }
  76068. }
  76069. declare module BABYLON.GLTF2.Loader.Extensions {
  76070. /**
  76071. * Store glTF extras (if present) in BJS objects' metadata
  76072. */
  76073. export class ExtrasAsMetadata implements IGLTFLoaderExtension {
  76074. /**
  76075. * The name of this extension.
  76076. */
  76077. readonly name: string;
  76078. /**
  76079. * Defines whether this extension is enabled.
  76080. */
  76081. enabled: boolean;
  76082. private _loader;
  76083. private _assignExtras;
  76084. /** @hidden */
  76085. constructor(loader: GLTFLoader);
  76086. /** @hidden */
  76087. dispose(): void;
  76088. /** @hidden */
  76089. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  76090. /** @hidden */
  76091. loadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  76092. /** @hidden */
  76093. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  76094. }
  76095. }
  76096. declare module BABYLON {
  76097. /**
  76098. * Class reading and parsing the MTL file bundled with the obj file.
  76099. */
  76100. export class MTLFileLoader {
  76101. /**
  76102. * Invert Y-Axis of referenced textures on load
  76103. */
  76104. static INVERT_TEXTURE_Y: boolean;
  76105. /**
  76106. * All material loaded from the mtl will be set here
  76107. */
  76108. materials: StandardMaterial[];
  76109. /**
  76110. * This function will read the mtl file and create each material described inside
  76111. * This function could be improve by adding :
  76112. * -some component missing (Ni, Tf...)
  76113. * -including the specific options available
  76114. *
  76115. * @param scene defines the scene the material will be created in
  76116. * @param data defines the mtl data to parse
  76117. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  76118. */
  76119. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string): void;
  76120. /**
  76121. * Gets the texture for the material.
  76122. *
  76123. * If the material is imported from input file,
  76124. * We sanitize the url to ensure it takes the textre from aside the material.
  76125. *
  76126. * @param rootUrl The root url to load from
  76127. * @param value The value stored in the mtl
  76128. * @return The Texture
  76129. */
  76130. private static _getTexture;
  76131. }
  76132. }
  76133. declare module BABYLON {
  76134. /**
  76135. * Options for loading OBJ/MTL files
  76136. */
  76137. type MeshLoadOptions = {
  76138. /**
  76139. * Defines if UVs are optimized by default during load.
  76140. */
  76141. OptimizeWithUV: boolean;
  76142. /**
  76143. * Defines custom scaling of UV coordinates of loaded meshes.
  76144. */
  76145. UVScaling: Vector2;
  76146. /**
  76147. * Invert model on y-axis (does a model scaling inversion)
  76148. */
  76149. InvertY: boolean;
  76150. /**
  76151. * Invert Y-Axis of referenced textures on load
  76152. */
  76153. InvertTextureY: boolean;
  76154. /**
  76155. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  76156. */
  76157. ImportVertexColors: boolean;
  76158. /**
  76159. * Compute the normals for the model, even if normals are present in the file.
  76160. */
  76161. ComputeNormals: boolean;
  76162. /**
  76163. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  76164. */
  76165. SkipMaterials: boolean;
  76166. /**
  76167. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  76168. */
  76169. MaterialLoadingFailsSilently: boolean;
  76170. };
  76171. /**
  76172. * OBJ file type loader.
  76173. * This is a babylon scene loader plugin.
  76174. */
  76175. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  76176. /**
  76177. * Defines if UVs are optimized by default during load.
  76178. */
  76179. static OPTIMIZE_WITH_UV: boolean;
  76180. /**
  76181. * Invert model on y-axis (does a model scaling inversion)
  76182. */
  76183. static INVERT_Y: boolean;
  76184. /**
  76185. * Invert Y-Axis of referenced textures on load
  76186. */
  76187. static get INVERT_TEXTURE_Y(): boolean;
  76188. static set INVERT_TEXTURE_Y(value: boolean);
  76189. /**
  76190. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  76191. */
  76192. static IMPORT_VERTEX_COLORS: boolean;
  76193. /**
  76194. * Compute the normals for the model, even if normals are present in the file.
  76195. */
  76196. static COMPUTE_NORMALS: boolean;
  76197. /**
  76198. * Defines custom scaling of UV coordinates of loaded meshes.
  76199. */
  76200. static UV_SCALING: Vector2;
  76201. /**
  76202. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  76203. */
  76204. static SKIP_MATERIALS: boolean;
  76205. /**
  76206. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  76207. *
  76208. * Defaults to true for backwards compatibility.
  76209. */
  76210. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  76211. /**
  76212. * Defines the name of the plugin.
  76213. */
  76214. name: string;
  76215. /**
  76216. * Defines the extension the plugin is able to load.
  76217. */
  76218. extensions: string;
  76219. /** @hidden */
  76220. obj: RegExp;
  76221. /** @hidden */
  76222. group: RegExp;
  76223. /** @hidden */
  76224. mtllib: RegExp;
  76225. /** @hidden */
  76226. usemtl: RegExp;
  76227. /** @hidden */
  76228. smooth: RegExp;
  76229. /** @hidden */
  76230. vertexPattern: RegExp;
  76231. /** @hidden */
  76232. normalPattern: RegExp;
  76233. /** @hidden */
  76234. uvPattern: RegExp;
  76235. /** @hidden */
  76236. facePattern1: RegExp;
  76237. /** @hidden */
  76238. facePattern2: RegExp;
  76239. /** @hidden */
  76240. facePattern3: RegExp;
  76241. /** @hidden */
  76242. facePattern4: RegExp;
  76243. /** @hidden */
  76244. facePattern5: RegExp;
  76245. private _meshLoadOptions;
  76246. /**
  76247. * Creates loader for .OBJ files
  76248. *
  76249. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  76250. */
  76251. constructor(meshLoadOptions?: MeshLoadOptions);
  76252. private static get currentMeshLoadOptions();
  76253. /**
  76254. * Calls synchronously the MTL file attached to this obj.
  76255. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  76256. * Without this function materials are not displayed in the first frame (but displayed after).
  76257. * In consequence it is impossible to get material information in your HTML file
  76258. *
  76259. * @param url The URL of the MTL file
  76260. * @param rootUrl
  76261. * @param onSuccess Callback function to be called when the MTL file is loaded
  76262. * @private
  76263. */
  76264. private _loadMTL;
  76265. /**
  76266. * Instantiates a OBJ file loader plugin.
  76267. * @returns the created plugin
  76268. */
  76269. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  76270. /**
  76271. * If the data string can be loaded directly.
  76272. *
  76273. * @param data string containing the file data
  76274. * @returns if the data can be loaded directly
  76275. */
  76276. canDirectLoad(data: string): boolean;
  76277. /**
  76278. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  76279. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  76280. * @param scene the scene the meshes should be added to
  76281. * @param data the OBJ data to load
  76282. * @param rootUrl root url to load from
  76283. * @param onProgress event that fires when loading progress has occured
  76284. * @param fileName Defines the name of the file to load
  76285. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  76286. */
  76287. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  76288. meshes: AbstractMesh[];
  76289. particleSystems: IParticleSystem[];
  76290. skeletons: Skeleton[];
  76291. animationGroups: AnimationGroup[];
  76292. }>;
  76293. /**
  76294. * Imports all objects from the loaded OBJ data and adds them to the scene
  76295. * @param scene the scene the objects should be added to
  76296. * @param data the OBJ data to load
  76297. * @param rootUrl root url to load from
  76298. * @param onProgress event that fires when loading progress has occured
  76299. * @param fileName Defines the name of the file to load
  76300. * @returns a promise which completes when objects have been loaded to the scene
  76301. */
  76302. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  76303. /**
  76304. * Load into an asset container.
  76305. * @param scene The scene to load into
  76306. * @param data The data to import
  76307. * @param rootUrl The root url for scene and resources
  76308. * @param onProgress The callback when the load progresses
  76309. * @param fileName Defines the name of the file to load
  76310. * @returns The loaded asset container
  76311. */
  76312. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  76313. /**
  76314. * Read the OBJ file and create an Array of meshes.
  76315. * Each mesh contains all information given by the OBJ and the MTL file.
  76316. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  76317. *
  76318. * @param meshesNames
  76319. * @param scene Scene The scene where are displayed the data
  76320. * @param data String The content of the obj file
  76321. * @param rootUrl String The path to the folder
  76322. * @returns Array<AbstractMesh>
  76323. * @private
  76324. */
  76325. private _parseSolid;
  76326. }
  76327. }
  76328. declare module BABYLON {
  76329. /**
  76330. * STL file type loader.
  76331. * This is a babylon scene loader plugin.
  76332. */
  76333. export class STLFileLoader implements ISceneLoaderPlugin {
  76334. /** @hidden */
  76335. solidPattern: RegExp;
  76336. /** @hidden */
  76337. facetsPattern: RegExp;
  76338. /** @hidden */
  76339. normalPattern: RegExp;
  76340. /** @hidden */
  76341. vertexPattern: RegExp;
  76342. /**
  76343. * Defines the name of the plugin.
  76344. */
  76345. name: string;
  76346. /**
  76347. * Defines the extensions the stl loader is able to load.
  76348. * force data to come in as an ArrayBuffer
  76349. * we'll convert to string if it looks like it's an ASCII .stl
  76350. */
  76351. extensions: ISceneLoaderPluginExtensions;
  76352. /**
  76353. * Import meshes into a scene.
  76354. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  76355. * @param scene The scene to import into
  76356. * @param data The data to import
  76357. * @param rootUrl The root url for scene and resources
  76358. * @param meshes The meshes array to import into
  76359. * @param particleSystems The particle systems array to import into
  76360. * @param skeletons The skeletons array to import into
  76361. * @param onError The callback when import fails
  76362. * @returns True if successful or false otherwise
  76363. */
  76364. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  76365. /**
  76366. * Load into a scene.
  76367. * @param scene The scene to load into
  76368. * @param data The data to import
  76369. * @param rootUrl The root url for scene and resources
  76370. * @param onError The callback when import fails
  76371. * @returns true if successful or false otherwise
  76372. */
  76373. load(scene: Scene, data: any, rootUrl: string): boolean;
  76374. /**
  76375. * Load into an asset container.
  76376. * @param scene The scene to load into
  76377. * @param data The data to import
  76378. * @param rootUrl The root url for scene and resources
  76379. * @param onError The callback when import fails
  76380. * @returns The loaded asset container
  76381. */
  76382. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  76383. private _isBinary;
  76384. private _parseBinary;
  76385. private _parseASCII;
  76386. }
  76387. }
  76388. declare module BABYLON {
  76389. /**
  76390. * Class for generating OBJ data from a Babylon scene.
  76391. */
  76392. export class OBJExport {
  76393. /**
  76394. * Exports the geometry of a Mesh array in .OBJ file format (text)
  76395. * @param mesh defines the list of meshes to serialize
  76396. * @param materials defines if materials should be exported
  76397. * @param matlibname defines the name of the associated mtl file
  76398. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  76399. * @returns the OBJ content
  76400. */
  76401. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  76402. /**
  76403. * Exports the material(s) of a mesh in .MTL file format (text)
  76404. * @param mesh defines the mesh to extract the material from
  76405. * @returns the mtl content
  76406. */
  76407. static MTL(mesh: Mesh): string;
  76408. }
  76409. }
  76410. declare module BABYLON {
  76411. /** @hidden */
  76412. export var __IGLTFExporterExtension: number;
  76413. /**
  76414. * Interface for extending the exporter
  76415. * @hidden
  76416. */
  76417. export interface IGLTFExporterExtension {
  76418. /**
  76419. * The name of this extension
  76420. */
  76421. readonly name: string;
  76422. /**
  76423. * Defines whether this extension is enabled
  76424. */
  76425. enabled: boolean;
  76426. /**
  76427. * Defines whether this extension is required
  76428. */
  76429. required: boolean;
  76430. }
  76431. }
  76432. declare module BABYLON.GLTF2.Exporter {
  76433. /** @hidden */
  76434. export var __IGLTFExporterExtensionV2: number;
  76435. /**
  76436. * Interface for a glTF exporter extension
  76437. * @hidden
  76438. */
  76439. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  76440. /**
  76441. * Define this method to modify the default behavior before exporting a texture
  76442. * @param context The context when loading the asset
  76443. * @param babylonTexture The Babylon.js texture
  76444. * @param mimeType The mime-type of the generated image
  76445. * @returns A promise that resolves with the exported texture
  76446. */
  76447. preExportTextureAsync?(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Promise<Texture>;
  76448. /**
  76449. * Define this method to get notified when a texture info is created
  76450. * @param context The context when loading the asset
  76451. * @param textureInfo The glTF texture info
  76452. * @param babylonTexture The Babylon.js texture
  76453. */
  76454. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  76455. /**
  76456. * Define this method to modify the default behavior when exporting texture info
  76457. * @param context The context when loading the asset
  76458. * @param meshPrimitive glTF mesh primitive
  76459. * @param babylonSubMesh Babylon submesh
  76460. * @param binaryWriter glTF serializer binary writer instance
  76461. * @returns nullable IMeshPrimitive promise
  76462. */
  76463. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<IMeshPrimitive>;
  76464. /**
  76465. * Define this method to modify the default behavior when exporting a node
  76466. * @param context The context when exporting the node
  76467. * @param node glTF node
  76468. * @param babylonNode BabylonJS node
  76469. * @returns nullable INode promise
  76470. */
  76471. postExportNodeAsync?(context: string, node: INode, babylonNode: Node): Promise<INode>;
  76472. /**
  76473. * Define this method to modify the default behavior when exporting a material
  76474. * @param material glTF material
  76475. * @param babylonMaterial BabylonJS material
  76476. * @returns nullable IMaterial promise
  76477. */
  76478. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  76479. /**
  76480. * Define this method to return additional textures to export from a material
  76481. * @param material glTF material
  76482. * @param babylonMaterial BabylonJS material
  76483. * @returns List of textures
  76484. */
  76485. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  76486. /** Gets a boolean indicating that this extension was used */
  76487. wasUsed: boolean;
  76488. /** Gets a boolean indicating that this extension is required for the file to work */
  76489. required: boolean;
  76490. /**
  76491. * Called after the exporter state changes to EXPORTING
  76492. */
  76493. onExporting?(): void;
  76494. }
  76495. }
  76496. declare module BABYLON.GLTF2.Exporter {
  76497. /**
  76498. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  76499. * @hidden
  76500. */
  76501. export class _GLTFMaterialExporter {
  76502. /**
  76503. * Represents the dielectric specular values for R, G and B
  76504. */
  76505. private static readonly _DielectricSpecular;
  76506. /**
  76507. * Allows the maximum specular power to be defined for material calculations
  76508. */
  76509. private static readonly _MaxSpecularPower;
  76510. /**
  76511. * Mapping to store textures
  76512. */
  76513. private _textureMap;
  76514. /**
  76515. * Numeric tolerance value
  76516. */
  76517. private static readonly _Epsilon;
  76518. /**
  76519. * Reference to the glTF Exporter
  76520. */
  76521. private _exporter;
  76522. constructor(exporter: _Exporter);
  76523. /**
  76524. * Specifies if two colors are approximately equal in value
  76525. * @param color1 first color to compare to
  76526. * @param color2 second color to compare to
  76527. * @param epsilon threshold value
  76528. */
  76529. private static FuzzyEquals;
  76530. /**
  76531. * Gets the materials from a Babylon scene and converts them to glTF materials
  76532. * @param scene babylonjs scene
  76533. * @param mimeType texture mime type
  76534. * @param images array of images
  76535. * @param textures array of textures
  76536. * @param materials array of materials
  76537. * @param imageData mapping of texture names to base64 textures
  76538. * @param hasTextureCoords specifies if texture coordinates are present on the material
  76539. */
  76540. _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  76541. /**
  76542. * Makes a copy of the glTF material without the texture parameters
  76543. * @param originalMaterial original glTF material
  76544. * @returns glTF material without texture parameters
  76545. */
  76546. _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  76547. /**
  76548. * Specifies if the material has any texture parameters present
  76549. * @param material glTF Material
  76550. * @returns boolean specifying if texture parameters are present
  76551. */
  76552. _hasTexturesPresent(material: IMaterial): boolean;
  76553. /**
  76554. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  76555. * @param babylonStandardMaterial
  76556. * @returns glTF Metallic Roughness Material representation
  76557. */
  76558. _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  76559. /**
  76560. * Computes the metallic factor
  76561. * @param diffuse diffused value
  76562. * @param specular specular value
  76563. * @param oneMinusSpecularStrength one minus the specular strength
  76564. * @returns metallic value
  76565. */
  76566. static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  76567. /**
  76568. * Sets the glTF alpha mode to a glTF material from the Babylon Material
  76569. * @param glTFMaterial glTF material
  76570. * @param babylonMaterial Babylon material
  76571. */
  76572. private static _SetAlphaMode;
  76573. /**
  76574. * Converts a Babylon Standard Material to a glTF Material
  76575. * @param babylonStandardMaterial BJS Standard Material
  76576. * @param mimeType mime type to use for the textures
  76577. * @param images array of glTF image interfaces
  76578. * @param textures array of glTF texture interfaces
  76579. * @param materials array of glTF material interfaces
  76580. * @param imageData map of image file name to data
  76581. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  76582. */
  76583. _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  76584. private _finishMaterial;
  76585. /**
  76586. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  76587. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  76588. * @param mimeType mime type to use for the textures
  76589. * @param images array of glTF image interfaces
  76590. * @param textures array of glTF texture interfaces
  76591. * @param materials array of glTF material interfaces
  76592. * @param imageData map of image file name to data
  76593. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  76594. */
  76595. _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  76596. /**
  76597. * Converts an image typed array buffer to a base64 image
  76598. * @param buffer typed array buffer
  76599. * @param width width of the image
  76600. * @param height height of the image
  76601. * @param mimeType mimetype of the image
  76602. * @returns base64 image string
  76603. */
  76604. private _createBase64FromCanvasAsync;
  76605. /**
  76606. * Generates a white texture based on the specified width and height
  76607. * @param width width of the texture in pixels
  76608. * @param height height of the texture in pixels
  76609. * @param scene babylonjs scene
  76610. * @returns white texture
  76611. */
  76612. private _createWhiteTexture;
  76613. /**
  76614. * 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
  76615. * @param texture1 first texture to resize
  76616. * @param texture2 second texture to resize
  76617. * @param scene babylonjs scene
  76618. * @returns resized textures or null
  76619. */
  76620. private _resizeTexturesToSameDimensions;
  76621. /**
  76622. * Converts an array of pixels to a Float32Array
  76623. * Throws an error if the pixel format is not supported
  76624. * @param pixels - array buffer containing pixel values
  76625. * @returns Float32 of pixels
  76626. */
  76627. private _convertPixelArrayToFloat32;
  76628. /**
  76629. * Convert Specular Glossiness Textures to Metallic Roughness
  76630. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  76631. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  76632. * @param diffuseTexture texture used to store diffuse information
  76633. * @param specularGlossinessTexture texture used to store specular and glossiness information
  76634. * @param factors specular glossiness material factors
  76635. * @param mimeType the mime type to use for the texture
  76636. * @returns pbr metallic roughness interface or null
  76637. */
  76638. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  76639. /**
  76640. * Converts specular glossiness material properties to metallic roughness
  76641. * @param specularGlossiness interface with specular glossiness material properties
  76642. * @returns interface with metallic roughness material properties
  76643. */
  76644. private _convertSpecularGlossinessToMetallicRoughness;
  76645. /**
  76646. * Calculates the surface reflectance, independent of lighting conditions
  76647. * @param color Color source to calculate brightness from
  76648. * @returns number representing the perceived brightness, or zero if color is undefined
  76649. */
  76650. private _getPerceivedBrightness;
  76651. /**
  76652. * Returns the maximum color component value
  76653. * @param color
  76654. * @returns maximum color component value, or zero if color is null or undefined
  76655. */
  76656. private _getMaxComponent;
  76657. /**
  76658. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  76659. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  76660. * @param mimeType mime type to use for the textures
  76661. * @param images array of glTF image interfaces
  76662. * @param textures array of glTF texture interfaces
  76663. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  76664. * @param imageData map of image file name to data
  76665. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  76666. * @returns glTF PBR Metallic Roughness factors
  76667. */
  76668. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  76669. private _getGLTFTextureSampler;
  76670. private _getGLTFTextureWrapMode;
  76671. private _getGLTFTextureWrapModesSampler;
  76672. /**
  76673. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  76674. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  76675. * @param mimeType mime type to use for the textures
  76676. * @param images array of glTF image interfaces
  76677. * @param textures array of glTF texture interfaces
  76678. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  76679. * @param imageData map of image file name to data
  76680. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  76681. * @returns glTF PBR Metallic Roughness factors
  76682. */
  76683. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  76684. /**
  76685. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  76686. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  76687. * @param mimeType mime type to use for the textures
  76688. * @param images array of glTF image interfaces
  76689. * @param textures array of glTF texture interfaces
  76690. * @param materials array of glTF material interfaces
  76691. * @param imageData map of image file name to data
  76692. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  76693. */
  76694. _convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  76695. private setMetallicRoughnessPbrMaterial;
  76696. private getPixelsFromTexture;
  76697. /**
  76698. * Extracts a texture from a Babylon texture into file data and glTF data
  76699. * @param babylonTexture Babylon texture to extract
  76700. * @param mimeType Mime Type of the babylonTexture
  76701. * @return glTF texture info, or null if the texture format is not supported
  76702. */
  76703. _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  76704. _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  76705. /**
  76706. * Builds a texture from base64 string
  76707. * @param base64Texture base64 texture string
  76708. * @param baseTextureName Name to use for the texture
  76709. * @param mimeType image mime type for the texture
  76710. * @param images array of images
  76711. * @param textures array of textures
  76712. * @param imageData map of image data
  76713. * @returns glTF texture info, or null if the texture format is not supported
  76714. */
  76715. private _getTextureInfoFromBase64;
  76716. }
  76717. }
  76718. declare module BABYLON {
  76719. /**
  76720. * Class for holding and downloading glTF file data
  76721. */
  76722. export class GLTFData {
  76723. /**
  76724. * Object which contains the file name as the key and its data as the value
  76725. */
  76726. glTFFiles: {
  76727. [fileName: string]: string | Blob;
  76728. };
  76729. /**
  76730. * Initializes the glTF file object
  76731. */
  76732. constructor();
  76733. /**
  76734. * Downloads the glTF data as files based on their names and data
  76735. */
  76736. downloadFiles(): void;
  76737. }
  76738. }
  76739. declare module BABYLON {
  76740. /**
  76741. * Holds a collection of exporter options and parameters
  76742. */
  76743. export interface IExportOptions {
  76744. /**
  76745. * Function which indicates whether a babylon node should be exported or not
  76746. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  76747. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  76748. */
  76749. shouldExportNode?(node: Node): boolean;
  76750. /**
  76751. * Function used to extract the part of node's metadata that will be exported into glTF node extras
  76752. * @param metadata source metadata to read from
  76753. * @returns the data to store to glTF node extras
  76754. */
  76755. metadataSelector?(metadata: any): any;
  76756. /**
  76757. * The sample rate to bake animation curves
  76758. */
  76759. animationSampleRate?: number;
  76760. /**
  76761. * Begin serialization without waiting for the scene to be ready
  76762. */
  76763. exportWithoutWaitingForScene?: boolean;
  76764. }
  76765. /**
  76766. * Class for generating glTF data from a Babylon scene.
  76767. */
  76768. export class GLTF2Export {
  76769. /**
  76770. * Exports the geometry of the scene to .gltf file format asynchronously
  76771. * @param scene Babylon scene with scene hierarchy information
  76772. * @param filePrefix File prefix to use when generating the glTF file
  76773. * @param options Exporter options
  76774. * @returns Returns an object with a .gltf file and associates texture names
  76775. * as keys and their data and paths as values
  76776. */
  76777. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  76778. private static _PreExportAsync;
  76779. private static _PostExportAsync;
  76780. /**
  76781. * Exports the geometry of the scene to .glb file format asychronously
  76782. * @param scene Babylon scene with scene hierarchy information
  76783. * @param filePrefix File prefix to use when generating glb file
  76784. * @param options Exporter options
  76785. * @returns Returns an object with a .glb filename as key and data as value
  76786. */
  76787. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  76788. }
  76789. }
  76790. declare module BABYLON.GLTF2.Exporter {
  76791. /**
  76792. * @hidden
  76793. */
  76794. export class _GLTFUtilities {
  76795. /**
  76796. * Creates a buffer view based on the supplied arguments
  76797. * @param bufferIndex index value of the specified buffer
  76798. * @param byteOffset byte offset value
  76799. * @param byteLength byte length of the bufferView
  76800. * @param byteStride byte distance between conequential elements
  76801. * @param name name of the buffer view
  76802. * @returns bufferView for glTF
  76803. */
  76804. static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  76805. /**
  76806. * Creates an accessor based on the supplied arguments
  76807. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  76808. * @param name The name of the accessor
  76809. * @param type The type of the accessor
  76810. * @param componentType The datatype of components in the attribute
  76811. * @param count The number of attributes referenced by this accessor
  76812. * @param byteOffset The offset relative to the start of the bufferView in bytes
  76813. * @param min Minimum value of each component in this attribute
  76814. * @param max Maximum value of each component in this attribute
  76815. * @returns accessor for glTF
  76816. */
  76817. static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  76818. /**
  76819. * Calculates the minimum and maximum values of an array of position floats
  76820. * @param positions Positions array of a mesh
  76821. * @param vertexStart Starting vertex offset to calculate min and max values
  76822. * @param vertexCount Number of vertices to check for min and max values
  76823. * @returns min number array and max number array
  76824. */
  76825. static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  76826. min: number[];
  76827. max: number[];
  76828. };
  76829. /**
  76830. * Converts a new right-handed Vector3
  76831. * @param vector vector3 array
  76832. * @returns right-handed Vector3
  76833. */
  76834. static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  76835. /**
  76836. * Converts a Vector3 to right-handed
  76837. * @param vector Vector3 to convert to right-handed
  76838. */
  76839. static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  76840. /**
  76841. * Converts a three element number array to right-handed
  76842. * @param vector number array to convert to right-handed
  76843. */
  76844. static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  76845. /**
  76846. * Converts a new right-handed Vector3
  76847. * @param vector vector3 array
  76848. * @returns right-handed Vector3
  76849. */
  76850. static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  76851. /**
  76852. * Converts a Vector3 to right-handed
  76853. * @param vector Vector3 to convert to right-handed
  76854. */
  76855. static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  76856. /**
  76857. * Converts a three element number array to right-handed
  76858. * @param vector number array to convert to right-handed
  76859. */
  76860. static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  76861. /**
  76862. * Converts a Vector4 to right-handed
  76863. * @param vector Vector4 to convert to right-handed
  76864. */
  76865. static _GetRightHandedVector4FromRef(vector: Vector4): void;
  76866. /**
  76867. * Converts a Vector4 to right-handed
  76868. * @param vector Vector4 to convert to right-handed
  76869. */
  76870. static _GetRightHandedArray4FromRef(vector: number[]): void;
  76871. /**
  76872. * Converts a Quaternion to right-handed
  76873. * @param quaternion Source quaternion to convert to right-handed
  76874. */
  76875. static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  76876. /**
  76877. * Converts a Quaternion to right-handed
  76878. * @param quaternion Source quaternion to convert to right-handed
  76879. */
  76880. static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void;
  76881. static _NormalizeTangentFromRef(tangent: Vector4): void;
  76882. }
  76883. }
  76884. declare module BABYLON.GLTF2.Exporter {
  76885. /**
  76886. * Converts Babylon Scene into glTF 2.0.
  76887. * @hidden
  76888. */
  76889. export class _Exporter {
  76890. /**
  76891. * Stores the glTF to export
  76892. */
  76893. _glTF: IGLTF;
  76894. /**
  76895. * Stores all generated buffer views, which represents views into the main glTF buffer data
  76896. */
  76897. _bufferViews: IBufferView[];
  76898. /**
  76899. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  76900. */
  76901. _accessors: IAccessor[];
  76902. /**
  76903. * Stores all the generated nodes, which contains transform and/or mesh information per node
  76904. */
  76905. private _nodes;
  76906. /**
  76907. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  76908. */
  76909. private _scenes;
  76910. /**
  76911. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  76912. */
  76913. private _meshes;
  76914. /**
  76915. * Stores all the generated material information, which represents the appearance of each primitive
  76916. */
  76917. _materials: IMaterial[];
  76918. _materialMap: {
  76919. [materialID: number]: number;
  76920. };
  76921. /**
  76922. * Stores all the generated texture information, which is referenced by glTF materials
  76923. */
  76924. _textures: ITexture[];
  76925. /**
  76926. * Stores all the generated image information, which is referenced by glTF textures
  76927. */
  76928. _images: IImage[];
  76929. /**
  76930. * Stores all the texture samplers
  76931. */
  76932. _samplers: ISampler[];
  76933. /**
  76934. * Stores all the generated animation samplers, which is referenced by glTF animations
  76935. */
  76936. /**
  76937. * Stores the animations for glTF models
  76938. */
  76939. private _animations;
  76940. /**
  76941. * Stores the total amount of bytes stored in the glTF buffer
  76942. */
  76943. private _totalByteLength;
  76944. /**
  76945. * Stores a reference to the Babylon scene containing the source geometry and material information
  76946. */
  76947. _babylonScene: Scene;
  76948. /**
  76949. * Stores a map of the image data, where the key is the file name and the value
  76950. * is the image data
  76951. */
  76952. _imageData: {
  76953. [fileName: string]: {
  76954. data: Uint8Array;
  76955. mimeType: ImageMimeType;
  76956. };
  76957. };
  76958. /**
  76959. * Stores a map of the unique id of a node to its index in the node array
  76960. */
  76961. private _nodeMap;
  76962. /**
  76963. * Specifies if the Babylon scene should be converted to right-handed on export
  76964. */
  76965. _convertToRightHandedSystem: boolean;
  76966. /**
  76967. * Baked animation sample rate
  76968. */
  76969. private _animationSampleRate;
  76970. private _options;
  76971. private _localEngine;
  76972. _glTFMaterialExporter: _GLTFMaterialExporter;
  76973. private _extensions;
  76974. private static _ExtensionNames;
  76975. private static _ExtensionFactories;
  76976. private _applyExtension;
  76977. private _applyExtensions;
  76978. _extensionsPreExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Promise<Nullable<BaseTexture>>;
  76979. _extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<Nullable<IMeshPrimitive>>;
  76980. _extensionsPostExportNodeAsync(context: string, node: INode, babylonNode: Node): Promise<Nullable<INode>>;
  76981. _extensionsPostExportMaterialAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<Nullable<IMaterial>>;
  76982. _extensionsPostExportMaterialAdditionalTextures(context: string, material: IMaterial, babylonMaterial: Material): BaseTexture[];
  76983. _extensionsPostExportTextures(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  76984. private _forEachExtensions;
  76985. private _extensionsOnExporting;
  76986. /**
  76987. * Load glTF serializer extensions
  76988. */
  76989. private _loadExtensions;
  76990. /**
  76991. * Creates a glTF Exporter instance, which can accept optional exporter options
  76992. * @param babylonScene Babylon scene object
  76993. * @param options Options to modify the behavior of the exporter
  76994. */
  76995. constructor(babylonScene: Scene, options?: IExportOptions);
  76996. dispose(): void;
  76997. /**
  76998. * Registers a glTF exporter extension
  76999. * @param name Name of the extension to export
  77000. * @param factory The factory function that creates the exporter extension
  77001. */
  77002. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  77003. /**
  77004. * Un-registers an exporter extension
  77005. * @param name The name fo the exporter extension
  77006. * @returns A boolean indicating whether the extension has been un-registered
  77007. */
  77008. static UnregisterExtension(name: string): boolean;
  77009. /**
  77010. * Lazy load a local engine
  77011. */
  77012. _getLocalEngine(): Engine;
  77013. private reorderIndicesBasedOnPrimitiveMode;
  77014. /**
  77015. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  77016. * clock-wise during export to glTF
  77017. * @param submesh BabylonJS submesh
  77018. * @param primitiveMode Primitive mode of the mesh
  77019. * @param sideOrientation the winding order of the submesh
  77020. * @param vertexBufferKind The type of vertex attribute
  77021. * @param meshAttributeArray The vertex attribute data
  77022. * @param byteOffset The offset to the binary data
  77023. * @param binaryWriter The binary data for the glTF file
  77024. */
  77025. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  77026. /**
  77027. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  77028. * clock-wise during export to glTF
  77029. * @param submesh BabylonJS submesh
  77030. * @param primitiveMode Primitive mode of the mesh
  77031. * @param sideOrientation the winding order of the submesh
  77032. * @param vertexBufferKind The type of vertex attribute
  77033. * @param meshAttributeArray The vertex attribute data
  77034. * @param byteOffset The offset to the binary data
  77035. * @param binaryWriter The binary data for the glTF file
  77036. */
  77037. private reorderTriangleFillMode;
  77038. /**
  77039. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  77040. * clock-wise during export to glTF
  77041. * @param submesh BabylonJS submesh
  77042. * @param primitiveMode Primitive mode of the mesh
  77043. * @param sideOrientation the winding order of the submesh
  77044. * @param vertexBufferKind The type of vertex attribute
  77045. * @param meshAttributeArray The vertex attribute data
  77046. * @param byteOffset The offset to the binary data
  77047. * @param binaryWriter The binary data for the glTF file
  77048. */
  77049. private reorderTriangleStripDrawMode;
  77050. /**
  77051. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  77052. * clock-wise during export to glTF
  77053. * @param submesh BabylonJS submesh
  77054. * @param primitiveMode Primitive mode of the mesh
  77055. * @param sideOrientation the winding order of the submesh
  77056. * @param vertexBufferKind The type of vertex attribute
  77057. * @param meshAttributeArray The vertex attribute data
  77058. * @param byteOffset The offset to the binary data
  77059. * @param binaryWriter The binary data for the glTF file
  77060. */
  77061. private reorderTriangleFanMode;
  77062. /**
  77063. * Writes the vertex attribute data to binary
  77064. * @param vertices The vertices to write to the binary writer
  77065. * @param byteOffset The offset into the binary writer to overwrite binary data
  77066. * @param vertexAttributeKind The vertex attribute type
  77067. * @param meshAttributeArray The vertex attribute data
  77068. * @param binaryWriter The writer containing the binary data
  77069. */
  77070. private writeVertexAttributeData;
  77071. /**
  77072. * Writes mesh attribute data to a data buffer
  77073. * Returns the bytelength of the data
  77074. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  77075. * @param meshAttributeArray Array containing the attribute data
  77076. * @param binaryWriter The buffer to write the binary data to
  77077. * @param indices Used to specify the order of the vertex data
  77078. */
  77079. writeAttributeData(vertexBufferKind: string, meshAttributeArray: FloatArray, byteStride: number, binaryWriter: _BinaryWriter): void;
  77080. /**
  77081. * Generates glTF json data
  77082. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  77083. * @param glTFPrefix Text to use when prefixing a glTF file
  77084. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  77085. * @returns json data as string
  77086. */
  77087. private generateJSON;
  77088. /**
  77089. * Generates data for .gltf and .bin files based on the glTF prefix string
  77090. * @param glTFPrefix Text to use when prefixing a glTF file
  77091. * @param dispose Dispose the exporter
  77092. * @returns GLTFData with glTF file data
  77093. */
  77094. _generateGLTFAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  77095. /**
  77096. * Creates a binary buffer for glTF
  77097. * @returns array buffer for binary data
  77098. */
  77099. private _generateBinaryAsync;
  77100. /**
  77101. * Pads the number to a multiple of 4
  77102. * @param num number to pad
  77103. * @returns padded number
  77104. */
  77105. private _getPadding;
  77106. /**
  77107. * @hidden
  77108. */
  77109. _generateGLBAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  77110. /**
  77111. * Sets the TRS for each node
  77112. * @param node glTF Node for storing the transformation data
  77113. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  77114. */
  77115. private setNodeTransformation;
  77116. private getVertexBufferFromMesh;
  77117. /**
  77118. * Creates a bufferview based on the vertices type for the Babylon mesh
  77119. * @param kind Indicates the type of vertices data
  77120. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  77121. * @param binaryWriter The buffer to write the bufferview data to
  77122. */
  77123. private createBufferViewKind;
  77124. /**
  77125. * The primitive mode of the Babylon mesh
  77126. * @param babylonMesh The BabylonJS mesh
  77127. */
  77128. private getMeshPrimitiveMode;
  77129. /**
  77130. * Sets the primitive mode of the glTF mesh primitive
  77131. * @param meshPrimitive glTF mesh primitive
  77132. * @param primitiveMode The primitive mode
  77133. */
  77134. private setPrimitiveMode;
  77135. /**
  77136. * Sets the vertex attribute accessor based of the glTF mesh primitive
  77137. * @param meshPrimitive glTF mesh primitive
  77138. * @param attributeKind vertex attribute
  77139. * @returns boolean specifying if uv coordinates are present
  77140. */
  77141. private setAttributeKind;
  77142. /**
  77143. * Sets data for the primitive attributes of each submesh
  77144. * @param mesh glTF Mesh object to store the primitive attribute information
  77145. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  77146. * @param binaryWriter Buffer to write the attribute data to
  77147. */
  77148. private setPrimitiveAttributesAsync;
  77149. /**
  77150. * Creates a glTF scene based on the array of meshes
  77151. * Returns the the total byte offset
  77152. * @param babylonScene Babylon scene to get the mesh data from
  77153. * @param binaryWriter Buffer to write binary data to
  77154. */
  77155. private createSceneAsync;
  77156. /**
  77157. * Creates a mapping of Node unique id to node index and handles animations
  77158. * @param babylonScene Babylon Scene
  77159. * @param nodes Babylon transform nodes
  77160. * @param binaryWriter Buffer to write binary data to
  77161. * @returns Node mapping of unique id to index
  77162. */
  77163. private createNodeMapAndAnimationsAsync;
  77164. /**
  77165. * Creates a glTF node from a Babylon mesh
  77166. * @param babylonMesh Source Babylon mesh
  77167. * @param binaryWriter Buffer for storing geometry data
  77168. * @returns glTF node
  77169. */
  77170. private createNodeAsync;
  77171. }
  77172. /**
  77173. * @hidden
  77174. *
  77175. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  77176. */
  77177. export class _BinaryWriter {
  77178. /**
  77179. * Array buffer which stores all binary data
  77180. */
  77181. private _arrayBuffer;
  77182. /**
  77183. * View of the array buffer
  77184. */
  77185. private _dataView;
  77186. /**
  77187. * byte offset of data in array buffer
  77188. */
  77189. private _byteOffset;
  77190. /**
  77191. * Initialize binary writer with an initial byte length
  77192. * @param byteLength Initial byte length of the array buffer
  77193. */
  77194. constructor(byteLength: number);
  77195. /**
  77196. * Resize the array buffer to the specified byte length
  77197. * @param byteLength
  77198. */
  77199. private resizeBuffer;
  77200. /**
  77201. * Get an array buffer with the length of the byte offset
  77202. * @returns ArrayBuffer resized to the byte offset
  77203. */
  77204. getArrayBuffer(): ArrayBuffer;
  77205. /**
  77206. * Get the byte offset of the array buffer
  77207. * @returns byte offset
  77208. */
  77209. getByteOffset(): number;
  77210. /**
  77211. * Stores an UInt8 in the array buffer
  77212. * @param entry
  77213. * @param byteOffset If defined, specifies where to set the value as an offset.
  77214. */
  77215. setUInt8(entry: number, byteOffset?: number): void;
  77216. /**
  77217. * Gets an UInt32 in the array buffer
  77218. * @param entry
  77219. * @param byteOffset If defined, specifies where to set the value as an offset.
  77220. */
  77221. getUInt32(byteOffset: number): number;
  77222. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  77223. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  77224. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  77225. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  77226. /**
  77227. * Stores a Float32 in the array buffer
  77228. * @param entry
  77229. */
  77230. setFloat32(entry: number, byteOffset?: number): void;
  77231. /**
  77232. * Stores an UInt32 in the array buffer
  77233. * @param entry
  77234. * @param byteOffset If defined, specifies where to set the value as an offset.
  77235. */
  77236. setUInt32(entry: number, byteOffset?: number): void;
  77237. }
  77238. }
  77239. declare module BABYLON.GLTF2.Exporter {
  77240. /**
  77241. * @hidden
  77242. * Interface to store animation data.
  77243. */
  77244. export interface _IAnimationData {
  77245. /**
  77246. * Keyframe data.
  77247. */
  77248. inputs: number[];
  77249. /**
  77250. * Value data.
  77251. */
  77252. outputs: number[][];
  77253. /**
  77254. * Animation interpolation data.
  77255. */
  77256. samplerInterpolation: AnimationSamplerInterpolation;
  77257. /**
  77258. * Minimum keyframe value.
  77259. */
  77260. inputsMin: number;
  77261. /**
  77262. * Maximum keyframe value.
  77263. */
  77264. inputsMax: number;
  77265. }
  77266. /**
  77267. * @hidden
  77268. */
  77269. export interface _IAnimationInfo {
  77270. /**
  77271. * The target channel for the animation
  77272. */
  77273. animationChannelTargetPath: AnimationChannelTargetPath;
  77274. /**
  77275. * The glTF accessor type for the data.
  77276. */
  77277. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4;
  77278. /**
  77279. * Specifies if quaternions should be used.
  77280. */
  77281. useQuaternion: boolean;
  77282. }
  77283. /**
  77284. * @hidden
  77285. * Utility class for generating glTF animation data from BabylonJS.
  77286. */
  77287. export class _GLTFAnimation {
  77288. /**
  77289. * @ignore
  77290. *
  77291. * Creates glTF channel animation from BabylonJS animation.
  77292. * @param babylonTransformNode - BabylonJS mesh.
  77293. * @param animation - animation.
  77294. * @param animationChannelTargetPath - The target animation channel.
  77295. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  77296. * @param useQuaternion - Specifies if quaternions are used.
  77297. * @returns nullable IAnimationData
  77298. */
  77299. static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  77300. private static _DeduceAnimationInfo;
  77301. /**
  77302. * @ignore
  77303. * Create node animations from the transform node animations
  77304. * @param babylonNode
  77305. * @param runtimeGLTFAnimation
  77306. * @param idleGLTFAnimations
  77307. * @param nodeMap
  77308. * @param nodes
  77309. * @param binaryWriter
  77310. * @param bufferViews
  77311. * @param accessors
  77312. * @param convertToRightHandedSystem
  77313. */
  77314. static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  77315. [key: number]: number;
  77316. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  77317. /**
  77318. * @ignore
  77319. * Create node animations from the animation groups
  77320. * @param babylonScene
  77321. * @param glTFAnimations
  77322. * @param nodeMap
  77323. * @param nodes
  77324. * @param binaryWriter
  77325. * @param bufferViews
  77326. * @param accessors
  77327. * @param convertToRightHandedSystem
  77328. */
  77329. static _CreateNodeAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  77330. [key: number]: number;
  77331. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  77332. private static AddAnimation;
  77333. /**
  77334. * Create a baked animation
  77335. * @param babylonTransformNode BabylonJS mesh
  77336. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  77337. * @param animationChannelTargetPath animation target channel
  77338. * @param minFrame minimum animation frame
  77339. * @param maxFrame maximum animation frame
  77340. * @param fps frames per second of the animation
  77341. * @param inputs input key frames of the animation
  77342. * @param outputs output key frame data of the animation
  77343. * @param convertToRightHandedSystem converts the values to right-handed
  77344. * @param useQuaternion specifies if quaternions should be used
  77345. */
  77346. private static _CreateBakedAnimation;
  77347. private static _ConvertFactorToVector3OrQuaternion;
  77348. private static _SetInterpolatedValue;
  77349. /**
  77350. * Creates linear animation from the animation key frames
  77351. * @param babylonTransformNode BabylonJS mesh
  77352. * @param animation BabylonJS animation
  77353. * @param animationChannelTargetPath The target animation channel
  77354. * @param frameDelta The difference between the last and first frame of the animation
  77355. * @param inputs Array to store the key frame times
  77356. * @param outputs Array to store the key frame data
  77357. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  77358. * @param useQuaternion Specifies if quaternions are used in the animation
  77359. */
  77360. private static _CreateLinearOrStepAnimation;
  77361. /**
  77362. * Creates cubic spline animation from the animation key frames
  77363. * @param babylonTransformNode BabylonJS mesh
  77364. * @param animation BabylonJS animation
  77365. * @param animationChannelTargetPath The target animation channel
  77366. * @param frameDelta The difference between the last and first frame of the animation
  77367. * @param inputs Array to store the key frame times
  77368. * @param outputs Array to store the key frame data
  77369. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  77370. * @param useQuaternion Specifies if quaternions are used in the animation
  77371. */
  77372. private static _CreateCubicSplineAnimation;
  77373. private static _GetBasePositionRotationOrScale;
  77374. /**
  77375. * Adds a key frame value
  77376. * @param keyFrame
  77377. * @param animation
  77378. * @param outputs
  77379. * @param animationChannelTargetPath
  77380. * @param basePositionRotationOrScale
  77381. * @param convertToRightHandedSystem
  77382. * @param useQuaternion
  77383. */
  77384. private static _AddKeyframeValue;
  77385. /**
  77386. * Determine the interpolation based on the key frames
  77387. * @param keyFrames
  77388. * @param animationChannelTargetPath
  77389. * @param useQuaternion
  77390. */
  77391. private static _DeduceInterpolation;
  77392. /**
  77393. * Adds an input tangent or output tangent to the output data
  77394. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  77395. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  77396. * @param outputs The animation data by keyframe
  77397. * @param animationChannelTargetPath The target animation channel
  77398. * @param interpolation The interpolation type
  77399. * @param keyFrame The key frame with the animation data
  77400. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  77401. * @param useQuaternion Specifies if quaternions are used
  77402. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  77403. */
  77404. private static AddSplineTangent;
  77405. /**
  77406. * Get the minimum and maximum key frames' frame values
  77407. * @param keyFrames animation key frames
  77408. * @returns the minimum and maximum key frame value
  77409. */
  77410. private static calculateMinMaxKeyFrames;
  77411. }
  77412. }
  77413. declare module BABYLON.GLTF2.Exporter {
  77414. /** @hidden */
  77415. export var textureTransformPixelShader: {
  77416. name: string;
  77417. shader: string;
  77418. };
  77419. }
  77420. declare module BABYLON.GLTF2.Exporter.Extensions {
  77421. /**
  77422. * @hidden
  77423. */
  77424. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  77425. private _recordedTextures;
  77426. /** Name of this extension */
  77427. readonly name: string;
  77428. /** Defines whether this extension is enabled */
  77429. enabled: boolean;
  77430. /** Defines whether this extension is required */
  77431. required: boolean;
  77432. /** Reference to the glTF exporter */
  77433. private _wasUsed;
  77434. constructor(exporter: _Exporter);
  77435. dispose(): void;
  77436. /** @hidden */
  77437. get wasUsed(): boolean;
  77438. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  77439. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Promise<Texture>;
  77440. /**
  77441. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  77442. * @param babylonTexture
  77443. * @param offset
  77444. * @param rotation
  77445. * @param scale
  77446. * @param scene
  77447. */
  77448. private _textureTransformTextureAsync;
  77449. }
  77450. }
  77451. declare module BABYLON.GLTF2.Exporter.Extensions {
  77452. /**
  77453. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  77454. */
  77455. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  77456. /** The name of this extension. */
  77457. readonly name: string;
  77458. /** Defines whether this extension is enabled. */
  77459. enabled: boolean;
  77460. /** Defines whether this extension is required */
  77461. required: boolean;
  77462. /** Reference to the glTF exporter */
  77463. private _exporter;
  77464. private _lights;
  77465. /** @hidden */
  77466. constructor(exporter: _Exporter);
  77467. /** @hidden */
  77468. dispose(): void;
  77469. /** @hidden */
  77470. get wasUsed(): boolean;
  77471. /** @hidden */
  77472. onExporting(): void;
  77473. /**
  77474. * Define this method to modify the default behavior when exporting a node
  77475. * @param context The context when exporting the node
  77476. * @param node glTF node
  77477. * @param babylonNode BabylonJS node
  77478. * @returns nullable INode promise
  77479. */
  77480. postExportNodeAsync(context: string, node: INode, babylonNode: Node): Promise<INode>;
  77481. }
  77482. }
  77483. declare module BABYLON.GLTF2.Exporter.Extensions {
  77484. /**
  77485. * @hidden
  77486. */
  77487. export class KHR_materials_sheen implements IGLTFExporterExtensionV2 {
  77488. /** Name of this extension */
  77489. readonly name: string;
  77490. /** Defines whether this extension is enabled */
  77491. enabled: boolean;
  77492. /** Defines whether this extension is required */
  77493. required: boolean;
  77494. /** Reference to the glTF exporter */
  77495. private _textureInfos;
  77496. private _exportedTextures;
  77497. private _wasUsed;
  77498. constructor(exporter: _Exporter);
  77499. dispose(): void;
  77500. /** @hidden */
  77501. get wasUsed(): boolean;
  77502. private _getTextureIndex;
  77503. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  77504. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  77505. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  77506. }
  77507. }
  77508. declare module BABYLON {
  77509. /**
  77510. * Class for generating STL data from a Babylon scene.
  77511. */
  77512. export class STLExport {
  77513. /**
  77514. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  77515. * @param meshes list defines the mesh to serialize
  77516. * @param download triggers the automatic download of the file.
  77517. * @param fileName changes the downloads fileName.
  77518. * @param binary changes the STL to a binary type.
  77519. * @param isLittleEndian toggle for binary type exporter.
  77520. * @returns the STL as UTF8 string
  77521. */
  77522. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean): any;
  77523. }
  77524. }
  77525. declare module "babylonjs-gltf2interface" {
  77526. export = BABYLON.GLTF2;
  77527. }
  77528. /**
  77529. * Module for glTF 2.0 Interface
  77530. */
  77531. declare module BABYLON.GLTF2 {
  77532. /**
  77533. * The datatype of the components in the attribute
  77534. */
  77535. const enum AccessorComponentType {
  77536. /**
  77537. * Byte
  77538. */
  77539. BYTE = 5120,
  77540. /**
  77541. * Unsigned Byte
  77542. */
  77543. UNSIGNED_BYTE = 5121,
  77544. /**
  77545. * Short
  77546. */
  77547. SHORT = 5122,
  77548. /**
  77549. * Unsigned Short
  77550. */
  77551. UNSIGNED_SHORT = 5123,
  77552. /**
  77553. * Unsigned Int
  77554. */
  77555. UNSIGNED_INT = 5125,
  77556. /**
  77557. * Float
  77558. */
  77559. FLOAT = 5126,
  77560. }
  77561. /**
  77562. * Specifies if the attirbute is a scalar, vector, or matrix
  77563. */
  77564. const enum AccessorType {
  77565. /**
  77566. * Scalar
  77567. */
  77568. SCALAR = "SCALAR",
  77569. /**
  77570. * Vector2
  77571. */
  77572. VEC2 = "VEC2",
  77573. /**
  77574. * Vector3
  77575. */
  77576. VEC3 = "VEC3",
  77577. /**
  77578. * Vector4
  77579. */
  77580. VEC4 = "VEC4",
  77581. /**
  77582. * Matrix2x2
  77583. */
  77584. MAT2 = "MAT2",
  77585. /**
  77586. * Matrix3x3
  77587. */
  77588. MAT3 = "MAT3",
  77589. /**
  77590. * Matrix4x4
  77591. */
  77592. MAT4 = "MAT4",
  77593. }
  77594. /**
  77595. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  77596. */
  77597. const enum AnimationChannelTargetPath {
  77598. /**
  77599. * Translation
  77600. */
  77601. TRANSLATION = "translation",
  77602. /**
  77603. * Rotation
  77604. */
  77605. ROTATION = "rotation",
  77606. /**
  77607. * Scale
  77608. */
  77609. SCALE = "scale",
  77610. /**
  77611. * Weights
  77612. */
  77613. WEIGHTS = "weights",
  77614. }
  77615. /**
  77616. * Interpolation algorithm
  77617. */
  77618. const enum AnimationSamplerInterpolation {
  77619. /**
  77620. * The animated values are linearly interpolated between keyframes
  77621. */
  77622. LINEAR = "LINEAR",
  77623. /**
  77624. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  77625. */
  77626. STEP = "STEP",
  77627. /**
  77628. * The animation's interpolation is computed using a cubic spline with specified tangents
  77629. */
  77630. CUBICSPLINE = "CUBICSPLINE",
  77631. }
  77632. /**
  77633. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  77634. */
  77635. const enum CameraType {
  77636. /**
  77637. * A perspective camera containing properties to create a perspective projection matrix
  77638. */
  77639. PERSPECTIVE = "perspective",
  77640. /**
  77641. * An orthographic camera containing properties to create an orthographic projection matrix
  77642. */
  77643. ORTHOGRAPHIC = "orthographic",
  77644. }
  77645. /**
  77646. * The mime-type of the image
  77647. */
  77648. const enum ImageMimeType {
  77649. /**
  77650. * JPEG Mime-type
  77651. */
  77652. JPEG = "image/jpeg",
  77653. /**
  77654. * PNG Mime-type
  77655. */
  77656. PNG = "image/png",
  77657. }
  77658. /**
  77659. * The alpha rendering mode of the material
  77660. */
  77661. const enum MaterialAlphaMode {
  77662. /**
  77663. * The alpha value is ignored and the rendered output is fully opaque
  77664. */
  77665. OPAQUE = "OPAQUE",
  77666. /**
  77667. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  77668. */
  77669. MASK = "MASK",
  77670. /**
  77671. * 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)
  77672. */
  77673. BLEND = "BLEND",
  77674. }
  77675. /**
  77676. * The type of the primitives to render
  77677. */
  77678. const enum MeshPrimitiveMode {
  77679. /**
  77680. * Points
  77681. */
  77682. POINTS = 0,
  77683. /**
  77684. * Lines
  77685. */
  77686. LINES = 1,
  77687. /**
  77688. * Line Loop
  77689. */
  77690. LINE_LOOP = 2,
  77691. /**
  77692. * Line Strip
  77693. */
  77694. LINE_STRIP = 3,
  77695. /**
  77696. * Triangles
  77697. */
  77698. TRIANGLES = 4,
  77699. /**
  77700. * Triangle Strip
  77701. */
  77702. TRIANGLE_STRIP = 5,
  77703. /**
  77704. * Triangle Fan
  77705. */
  77706. TRIANGLE_FAN = 6,
  77707. }
  77708. /**
  77709. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  77710. */
  77711. const enum TextureMagFilter {
  77712. /**
  77713. * Nearest
  77714. */
  77715. NEAREST = 9728,
  77716. /**
  77717. * Linear
  77718. */
  77719. LINEAR = 9729,
  77720. }
  77721. /**
  77722. * Minification filter. All valid values correspond to WebGL enums
  77723. */
  77724. const enum TextureMinFilter {
  77725. /**
  77726. * Nearest
  77727. */
  77728. NEAREST = 9728,
  77729. /**
  77730. * Linear
  77731. */
  77732. LINEAR = 9729,
  77733. /**
  77734. * Nearest Mip-Map Nearest
  77735. */
  77736. NEAREST_MIPMAP_NEAREST = 9984,
  77737. /**
  77738. * Linear Mipmap Nearest
  77739. */
  77740. LINEAR_MIPMAP_NEAREST = 9985,
  77741. /**
  77742. * Nearest Mipmap Linear
  77743. */
  77744. NEAREST_MIPMAP_LINEAR = 9986,
  77745. /**
  77746. * Linear Mipmap Linear
  77747. */
  77748. LINEAR_MIPMAP_LINEAR = 9987,
  77749. }
  77750. /**
  77751. * S (U) wrapping mode. All valid values correspond to WebGL enums
  77752. */
  77753. const enum TextureWrapMode {
  77754. /**
  77755. * Clamp to Edge
  77756. */
  77757. CLAMP_TO_EDGE = 33071,
  77758. /**
  77759. * Mirrored Repeat
  77760. */
  77761. MIRRORED_REPEAT = 33648,
  77762. /**
  77763. * Repeat
  77764. */
  77765. REPEAT = 10497,
  77766. }
  77767. /**
  77768. * glTF Property
  77769. */
  77770. interface IProperty {
  77771. /**
  77772. * Dictionary object with extension-specific objects
  77773. */
  77774. extensions?: {
  77775. [key: string]: any;
  77776. };
  77777. /**
  77778. * Application-Specific data
  77779. */
  77780. extras?: any;
  77781. }
  77782. /**
  77783. * glTF Child of Root Property
  77784. */
  77785. interface IChildRootProperty extends IProperty {
  77786. /**
  77787. * The user-defined name of this object
  77788. */
  77789. name?: string;
  77790. }
  77791. /**
  77792. * Indices of those attributes that deviate from their initialization value
  77793. */
  77794. interface IAccessorSparseIndices extends IProperty {
  77795. /**
  77796. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  77797. */
  77798. bufferView: number;
  77799. /**
  77800. * The offset relative to the start of the bufferView in bytes. Must be aligned
  77801. */
  77802. byteOffset?: number;
  77803. /**
  77804. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  77805. */
  77806. componentType: AccessorComponentType;
  77807. }
  77808. /**
  77809. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  77810. */
  77811. interface IAccessorSparseValues extends IProperty {
  77812. /**
  77813. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  77814. */
  77815. bufferView: number;
  77816. /**
  77817. * The offset relative to the start of the bufferView in bytes. Must be aligned
  77818. */
  77819. byteOffset?: number;
  77820. }
  77821. /**
  77822. * Sparse storage of attributes that deviate from their initialization value
  77823. */
  77824. interface IAccessorSparse extends IProperty {
  77825. /**
  77826. * The number of attributes encoded in this sparse accessor
  77827. */
  77828. count: number;
  77829. /**
  77830. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  77831. */
  77832. indices: IAccessorSparseIndices;
  77833. /**
  77834. * 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
  77835. */
  77836. values: IAccessorSparseValues;
  77837. }
  77838. /**
  77839. * 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
  77840. */
  77841. interface IAccessor extends IChildRootProperty {
  77842. /**
  77843. * The index of the bufferview
  77844. */
  77845. bufferView?: number;
  77846. /**
  77847. * The offset relative to the start of the bufferView in bytes
  77848. */
  77849. byteOffset?: number;
  77850. /**
  77851. * The datatype of components in the attribute
  77852. */
  77853. componentType: AccessorComponentType;
  77854. /**
  77855. * Specifies whether integer data values should be normalized
  77856. */
  77857. normalized?: boolean;
  77858. /**
  77859. * The number of attributes referenced by this accessor
  77860. */
  77861. count: number;
  77862. /**
  77863. * Specifies if the attribute is a scalar, vector, or matrix
  77864. */
  77865. type: AccessorType;
  77866. /**
  77867. * Maximum value of each component in this attribute
  77868. */
  77869. max?: number[];
  77870. /**
  77871. * Minimum value of each component in this attribute
  77872. */
  77873. min?: number[];
  77874. /**
  77875. * Sparse storage of attributes that deviate from their initialization value
  77876. */
  77877. sparse?: IAccessorSparse;
  77878. }
  77879. /**
  77880. * Targets an animation's sampler at a node's property
  77881. */
  77882. interface IAnimationChannel extends IProperty {
  77883. /**
  77884. * The index of a sampler in this animation used to compute the value for the target
  77885. */
  77886. sampler: number;
  77887. /**
  77888. * The index of the node and TRS property to target
  77889. */
  77890. target: IAnimationChannelTarget;
  77891. }
  77892. /**
  77893. * The index of the node and TRS property that an animation channel targets
  77894. */
  77895. interface IAnimationChannelTarget extends IProperty {
  77896. /**
  77897. * The index of the node to target
  77898. */
  77899. node: number;
  77900. /**
  77901. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  77902. */
  77903. path: AnimationChannelTargetPath;
  77904. }
  77905. /**
  77906. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  77907. */
  77908. interface IAnimationSampler extends IProperty {
  77909. /**
  77910. * The index of an accessor containing keyframe input values, e.g., time
  77911. */
  77912. input: number;
  77913. /**
  77914. * Interpolation algorithm
  77915. */
  77916. interpolation?: AnimationSamplerInterpolation;
  77917. /**
  77918. * The index of an accessor, containing keyframe output values
  77919. */
  77920. output: number;
  77921. }
  77922. /**
  77923. * A keyframe animation
  77924. */
  77925. interface IAnimation extends IChildRootProperty {
  77926. /**
  77927. * An array of channels, each of which targets an animation's sampler at a node's property
  77928. */
  77929. channels: IAnimationChannel[];
  77930. /**
  77931. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  77932. */
  77933. samplers: IAnimationSampler[];
  77934. }
  77935. /**
  77936. * Metadata about the glTF asset
  77937. */
  77938. interface IAsset extends IChildRootProperty {
  77939. /**
  77940. * A copyright message suitable for display to credit the content creator
  77941. */
  77942. copyright?: string;
  77943. /**
  77944. * Tool that generated this glTF model. Useful for debugging
  77945. */
  77946. generator?: string;
  77947. /**
  77948. * The glTF version that this asset targets
  77949. */
  77950. version: string;
  77951. /**
  77952. * The minimum glTF version that this asset targets
  77953. */
  77954. minVersion?: string;
  77955. }
  77956. /**
  77957. * A buffer points to binary geometry, animation, or skins
  77958. */
  77959. interface IBuffer extends IChildRootProperty {
  77960. /**
  77961. * 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
  77962. */
  77963. uri?: string;
  77964. /**
  77965. * The length of the buffer in bytes
  77966. */
  77967. byteLength: number;
  77968. }
  77969. /**
  77970. * A view into a buffer generally representing a subset of the buffer
  77971. */
  77972. interface IBufferView extends IChildRootProperty {
  77973. /**
  77974. * The index of the buffer
  77975. */
  77976. buffer: number;
  77977. /**
  77978. * The offset into the buffer in bytes
  77979. */
  77980. byteOffset?: number;
  77981. /**
  77982. * The lenth of the bufferView in bytes
  77983. */
  77984. byteLength: number;
  77985. /**
  77986. * The stride, in bytes
  77987. */
  77988. byteStride?: number;
  77989. }
  77990. /**
  77991. * An orthographic camera containing properties to create an orthographic projection matrix
  77992. */
  77993. interface ICameraOrthographic extends IProperty {
  77994. /**
  77995. * The floating-point horizontal magnification of the view. Must not be zero
  77996. */
  77997. xmag: number;
  77998. /**
  77999. * The floating-point vertical magnification of the view. Must not be zero
  78000. */
  78001. ymag: number;
  78002. /**
  78003. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  78004. */
  78005. zfar: number;
  78006. /**
  78007. * The floating-point distance to the near clipping plane
  78008. */
  78009. znear: number;
  78010. }
  78011. /**
  78012. * A perspective camera containing properties to create a perspective projection matrix
  78013. */
  78014. interface ICameraPerspective extends IProperty {
  78015. /**
  78016. * The floating-point aspect ratio of the field of view
  78017. */
  78018. aspectRatio?: number;
  78019. /**
  78020. * The floating-point vertical field of view in radians
  78021. */
  78022. yfov: number;
  78023. /**
  78024. * The floating-point distance to the far clipping plane
  78025. */
  78026. zfar?: number;
  78027. /**
  78028. * The floating-point distance to the near clipping plane
  78029. */
  78030. znear: number;
  78031. }
  78032. /**
  78033. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  78034. */
  78035. interface ICamera extends IChildRootProperty {
  78036. /**
  78037. * An orthographic camera containing properties to create an orthographic projection matrix
  78038. */
  78039. orthographic?: ICameraOrthographic;
  78040. /**
  78041. * A perspective camera containing properties to create a perspective projection matrix
  78042. */
  78043. perspective?: ICameraPerspective;
  78044. /**
  78045. * Specifies if the camera uses a perspective or orthographic projection
  78046. */
  78047. type: CameraType;
  78048. }
  78049. /**
  78050. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  78051. */
  78052. interface IImage extends IChildRootProperty {
  78053. /**
  78054. * 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
  78055. */
  78056. uri?: string;
  78057. /**
  78058. * The image's MIME type
  78059. */
  78060. mimeType?: ImageMimeType;
  78061. /**
  78062. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  78063. */
  78064. bufferView?: number;
  78065. }
  78066. /**
  78067. * Material Normal Texture Info
  78068. */
  78069. interface IMaterialNormalTextureInfo extends ITextureInfo {
  78070. /**
  78071. * The scalar multiplier applied to each normal vector of the normal texture
  78072. */
  78073. scale?: number;
  78074. }
  78075. /**
  78076. * Material Occlusion Texture Info
  78077. */
  78078. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  78079. /**
  78080. * A scalar multiplier controlling the amount of occlusion applied
  78081. */
  78082. strength?: number;
  78083. }
  78084. /**
  78085. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  78086. */
  78087. interface IMaterialPbrMetallicRoughness {
  78088. /**
  78089. * The material's base color factor
  78090. */
  78091. baseColorFactor?: number[];
  78092. /**
  78093. * The base color texture
  78094. */
  78095. baseColorTexture?: ITextureInfo;
  78096. /**
  78097. * The metalness of the material
  78098. */
  78099. metallicFactor?: number;
  78100. /**
  78101. * The roughness of the material
  78102. */
  78103. roughnessFactor?: number;
  78104. /**
  78105. * The metallic-roughness texture
  78106. */
  78107. metallicRoughnessTexture?: ITextureInfo;
  78108. }
  78109. /**
  78110. * The material appearance of a primitive
  78111. */
  78112. interface IMaterial extends IChildRootProperty {
  78113. /**
  78114. * 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
  78115. */
  78116. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  78117. /**
  78118. * The normal map texture
  78119. */
  78120. normalTexture?: IMaterialNormalTextureInfo;
  78121. /**
  78122. * The occlusion map texture
  78123. */
  78124. occlusionTexture?: IMaterialOcclusionTextureInfo;
  78125. /**
  78126. * The emissive map texture
  78127. */
  78128. emissiveTexture?: ITextureInfo;
  78129. /**
  78130. * 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
  78131. */
  78132. emissiveFactor?: number[];
  78133. /**
  78134. * The alpha rendering mode of the material
  78135. */
  78136. alphaMode?: MaterialAlphaMode;
  78137. /**
  78138. * The alpha cutoff value of the material
  78139. */
  78140. alphaCutoff?: number;
  78141. /**
  78142. * Specifies whether the material is double sided
  78143. */
  78144. doubleSided?: boolean;
  78145. }
  78146. /**
  78147. * Geometry to be rendered with the given material
  78148. */
  78149. interface IMeshPrimitive extends IProperty {
  78150. /**
  78151. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  78152. */
  78153. attributes: {
  78154. [name: string]: number;
  78155. };
  78156. /**
  78157. * The index of the accessor that contains the indices
  78158. */
  78159. indices?: number;
  78160. /**
  78161. * The index of the material to apply to this primitive when rendering
  78162. */
  78163. material?: number;
  78164. /**
  78165. * The type of primitives to render. All valid values correspond to WebGL enums
  78166. */
  78167. mode?: MeshPrimitiveMode;
  78168. /**
  78169. * 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
  78170. */
  78171. targets?: {
  78172. [name: string]: number;
  78173. }[];
  78174. }
  78175. /**
  78176. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  78177. */
  78178. interface IMesh extends IChildRootProperty {
  78179. /**
  78180. * An array of primitives, each defining geometry to be rendered with a material
  78181. */
  78182. primitives: IMeshPrimitive[];
  78183. /**
  78184. * Array of weights to be applied to the Morph Targets
  78185. */
  78186. weights?: number[];
  78187. }
  78188. /**
  78189. * A node in the node hierarchy
  78190. */
  78191. interface INode extends IChildRootProperty {
  78192. /**
  78193. * The index of the camera referenced by this node
  78194. */
  78195. camera?: number;
  78196. /**
  78197. * The indices of this node's children
  78198. */
  78199. children?: number[];
  78200. /**
  78201. * The index of the skin referenced by this node
  78202. */
  78203. skin?: number;
  78204. /**
  78205. * A floating-point 4x4 transformation matrix stored in column-major order
  78206. */
  78207. matrix?: number[];
  78208. /**
  78209. * The index of the mesh in this node
  78210. */
  78211. mesh?: number;
  78212. /**
  78213. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  78214. */
  78215. rotation?: number[];
  78216. /**
  78217. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  78218. */
  78219. scale?: number[];
  78220. /**
  78221. * The node's translation along the x, y, and z axes
  78222. */
  78223. translation?: number[];
  78224. /**
  78225. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  78226. */
  78227. weights?: number[];
  78228. }
  78229. /**
  78230. * Texture sampler properties for filtering and wrapping modes
  78231. */
  78232. interface ISampler extends IChildRootProperty {
  78233. /**
  78234. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  78235. */
  78236. magFilter?: TextureMagFilter;
  78237. /**
  78238. * Minification filter. All valid values correspond to WebGL enums
  78239. */
  78240. minFilter?: TextureMinFilter;
  78241. /**
  78242. * S (U) wrapping mode. All valid values correspond to WebGL enums
  78243. */
  78244. wrapS?: TextureWrapMode;
  78245. /**
  78246. * T (V) wrapping mode. All valid values correspond to WebGL enums
  78247. */
  78248. wrapT?: TextureWrapMode;
  78249. }
  78250. /**
  78251. * The root nodes of a scene
  78252. */
  78253. interface IScene extends IChildRootProperty {
  78254. /**
  78255. * The indices of each root node
  78256. */
  78257. nodes: number[];
  78258. }
  78259. /**
  78260. * Joints and matrices defining a skin
  78261. */
  78262. interface ISkin extends IChildRootProperty {
  78263. /**
  78264. * 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
  78265. */
  78266. inverseBindMatrices?: number;
  78267. /**
  78268. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  78269. */
  78270. skeleton?: number;
  78271. /**
  78272. * 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)
  78273. */
  78274. joints: number[];
  78275. }
  78276. /**
  78277. * A texture and its sampler
  78278. */
  78279. interface ITexture extends IChildRootProperty {
  78280. /**
  78281. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  78282. */
  78283. sampler?: number;
  78284. /**
  78285. * The index of the image used by this texture
  78286. */
  78287. source: number;
  78288. }
  78289. /**
  78290. * Reference to a texture
  78291. */
  78292. interface ITextureInfo extends IProperty {
  78293. /**
  78294. * The index of the texture
  78295. */
  78296. index: number;
  78297. /**
  78298. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  78299. */
  78300. texCoord?: number;
  78301. }
  78302. /**
  78303. * The root object for a glTF asset
  78304. */
  78305. interface IGLTF extends IProperty {
  78306. /**
  78307. * An array of accessors. An accessor is a typed view into a bufferView
  78308. */
  78309. accessors?: IAccessor[];
  78310. /**
  78311. * An array of keyframe animations
  78312. */
  78313. animations?: IAnimation[];
  78314. /**
  78315. * Metadata about the glTF asset
  78316. */
  78317. asset: IAsset;
  78318. /**
  78319. * An array of buffers. A buffer points to binary geometry, animation, or skins
  78320. */
  78321. buffers?: IBuffer[];
  78322. /**
  78323. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  78324. */
  78325. bufferViews?: IBufferView[];
  78326. /**
  78327. * An array of cameras
  78328. */
  78329. cameras?: ICamera[];
  78330. /**
  78331. * Names of glTF extensions used somewhere in this asset
  78332. */
  78333. extensionsUsed?: string[];
  78334. /**
  78335. * Names of glTF extensions required to properly load this asset
  78336. */
  78337. extensionsRequired?: string[];
  78338. /**
  78339. * An array of images. An image defines data used to create a texture
  78340. */
  78341. images?: IImage[];
  78342. /**
  78343. * An array of materials. A material defines the appearance of a primitive
  78344. */
  78345. materials?: IMaterial[];
  78346. /**
  78347. * An array of meshes. A mesh is a set of primitives to be rendered
  78348. */
  78349. meshes?: IMesh[];
  78350. /**
  78351. * An array of nodes
  78352. */
  78353. nodes?: INode[];
  78354. /**
  78355. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  78356. */
  78357. samplers?: ISampler[];
  78358. /**
  78359. * The index of the default scene
  78360. */
  78361. scene?: number;
  78362. /**
  78363. * An array of scenes
  78364. */
  78365. scenes?: IScene[];
  78366. /**
  78367. * An array of skins. A skin is defined by joints and matrices
  78368. */
  78369. skins?: ISkin[];
  78370. /**
  78371. * An array of textures
  78372. */
  78373. textures?: ITexture[];
  78374. }
  78375. /**
  78376. * The glTF validation results
  78377. * @ignore
  78378. */
  78379. interface IGLTFValidationResults {
  78380. info: {
  78381. generator: string;
  78382. hasAnimations: boolean;
  78383. hasDefaultScene: boolean;
  78384. hasMaterials: boolean;
  78385. hasMorphTargets: boolean;
  78386. hasSkins: boolean;
  78387. hasTextures: boolean;
  78388. maxAttributesUsed: number;
  78389. primitivesCount: number
  78390. };
  78391. issues: {
  78392. messages: Array<string>;
  78393. numErrors: number;
  78394. numHints: number;
  78395. numInfos: number;
  78396. numWarnings: number;
  78397. truncated: boolean
  78398. };
  78399. mimeType: string;
  78400. uri: string;
  78401. validatedAt: string;
  78402. validatorVersion: string;
  78403. }
  78404. /**
  78405. * The glTF validation options
  78406. */
  78407. interface IGLTFValidationOptions {
  78408. /** Uri to use */
  78409. uri?: string;
  78410. /** Function used to load external resources */
  78411. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  78412. /** Boolean indicating that we need to validate accessor data */
  78413. validateAccessorData?: boolean;
  78414. /** max number of issues allowed */
  78415. maxIssues?: number;
  78416. /** Ignored issues */
  78417. ignoredIssues?: Array<string>;
  78418. /** Value to override severy settings */
  78419. severityOverrides?: Object;
  78420. }
  78421. /**
  78422. * The glTF validator object
  78423. * @ignore
  78424. */
  78425. interface IGLTFValidator {
  78426. validateBytes: (data: Uint8Array, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  78427. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  78428. }
  78429. }
  78430. declare module BABYLON {
  78431. /** @hidden */
  78432. export var cellPixelShader: {
  78433. name: string;
  78434. shader: string;
  78435. };
  78436. }
  78437. declare module BABYLON {
  78438. /** @hidden */
  78439. export var cellVertexShader: {
  78440. name: string;
  78441. shader: string;
  78442. };
  78443. }
  78444. declare module BABYLON {
  78445. export class CellMaterial extends BABYLON.PushMaterial {
  78446. private _diffuseTexture;
  78447. diffuseTexture: BABYLON.BaseTexture;
  78448. diffuseColor: BABYLON.Color3;
  78449. _computeHighLevel: boolean;
  78450. computeHighLevel: boolean;
  78451. private _disableLighting;
  78452. disableLighting: boolean;
  78453. private _maxSimultaneousLights;
  78454. maxSimultaneousLights: number;
  78455. private _renderId;
  78456. constructor(name: string, scene: BABYLON.Scene);
  78457. needAlphaBlending(): boolean;
  78458. needAlphaTesting(): boolean;
  78459. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  78460. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  78461. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  78462. getAnimatables(): BABYLON.IAnimatable[];
  78463. getActiveTextures(): BABYLON.BaseTexture[];
  78464. hasTexture(texture: BABYLON.BaseTexture): boolean;
  78465. dispose(forceDisposeEffect?: boolean): void;
  78466. getClassName(): string;
  78467. clone(name: string): CellMaterial;
  78468. serialize(): any;
  78469. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  78470. }
  78471. }
  78472. declare module BABYLON {
  78473. export class CustomShaderStructure {
  78474. FragmentStore: string;
  78475. VertexStore: string;
  78476. constructor();
  78477. }
  78478. export class ShaderSpecialParts {
  78479. constructor();
  78480. Fragment_Begin: string;
  78481. Fragment_Definitions: string;
  78482. Fragment_MainBegin: string;
  78483. Fragment_Custom_Diffuse: string;
  78484. Fragment_Before_Lights: string;
  78485. Fragment_Before_Fog: string;
  78486. Fragment_Custom_Alpha: string;
  78487. Fragment_Before_FragColor: string;
  78488. Vertex_Begin: string;
  78489. Vertex_Definitions: string;
  78490. Vertex_MainBegin: string;
  78491. Vertex_Before_PositionUpdated: string;
  78492. Vertex_Before_NormalUpdated: string;
  78493. Vertex_MainEnd: string;
  78494. }
  78495. export class CustomMaterial extends BABYLON.StandardMaterial {
  78496. static ShaderIndexer: number;
  78497. CustomParts: ShaderSpecialParts;
  78498. _isCreatedShader: boolean;
  78499. _createdShaderName: string;
  78500. _customUniform: string[];
  78501. _newUniforms: string[];
  78502. _newUniformInstances: any[];
  78503. _newSamplerInstances: BABYLON.Texture[];
  78504. FragmentShader: string;
  78505. VertexShader: string;
  78506. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  78507. ReviewUniform(name: string, arr: string[]): string[];
  78508. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.StandardMaterialDefines): string;
  78509. constructor(name: string, scene: BABYLON.Scene);
  78510. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  78511. Fragment_Begin(shaderPart: string): CustomMaterial;
  78512. Fragment_Definitions(shaderPart: string): CustomMaterial;
  78513. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  78514. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  78515. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  78516. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  78517. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  78518. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  78519. Vertex_Begin(shaderPart: string): CustomMaterial;
  78520. Vertex_Definitions(shaderPart: string): CustomMaterial;
  78521. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  78522. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  78523. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  78524. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  78525. }
  78526. }
  78527. declare module BABYLON {
  78528. export class ShaderAlebdoParts {
  78529. constructor();
  78530. Fragment_Begin: string;
  78531. Fragment_Definitions: string;
  78532. Fragment_MainBegin: string;
  78533. Fragment_Custom_Albedo: string;
  78534. Fragment_Before_Lights: string;
  78535. Fragment_Custom_MetallicRoughness: string;
  78536. Fragment_Custom_MicroSurface: string;
  78537. Fragment_Before_Fog: string;
  78538. Fragment_Custom_Alpha: string;
  78539. Fragment_Before_FragColor: string;
  78540. Vertex_Begin: string;
  78541. Vertex_Definitions: string;
  78542. Vertex_MainBegin: string;
  78543. Vertex_Before_PositionUpdated: string;
  78544. Vertex_Before_NormalUpdated: string;
  78545. Vertex_MainEnd: string;
  78546. }
  78547. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  78548. static ShaderIndexer: number;
  78549. CustomParts: ShaderAlebdoParts;
  78550. _isCreatedShader: boolean;
  78551. _createdShaderName: string;
  78552. _customUniform: string[];
  78553. _newUniforms: string[];
  78554. _newUniformInstances: any[];
  78555. _newSamplerInstances: BABYLON.Texture[];
  78556. FragmentShader: string;
  78557. VertexShader: string;
  78558. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  78559. ReviewUniform(name: string, arr: string[]): string[];
  78560. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.PBRMaterialDefines): string;
  78561. constructor(name: string, scene: BABYLON.Scene);
  78562. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  78563. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  78564. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  78565. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  78566. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  78567. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  78568. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  78569. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  78570. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  78571. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  78572. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  78573. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  78574. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  78575. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  78576. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  78577. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  78578. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  78579. }
  78580. }
  78581. declare module BABYLON {
  78582. /** @hidden */
  78583. export var firePixelShader: {
  78584. name: string;
  78585. shader: string;
  78586. };
  78587. }
  78588. declare module BABYLON {
  78589. /** @hidden */
  78590. export var fireVertexShader: {
  78591. name: string;
  78592. shader: string;
  78593. };
  78594. }
  78595. declare module BABYLON {
  78596. export class FireMaterial extends BABYLON.PushMaterial {
  78597. private _diffuseTexture;
  78598. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  78599. private _distortionTexture;
  78600. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  78601. private _opacityTexture;
  78602. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  78603. diffuseColor: BABYLON.Color3;
  78604. speed: number;
  78605. private _scaledDiffuse;
  78606. private _renderId;
  78607. private _lastTime;
  78608. constructor(name: string, scene: BABYLON.Scene);
  78609. needAlphaBlending(): boolean;
  78610. needAlphaTesting(): boolean;
  78611. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  78612. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  78613. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  78614. getAnimatables(): BABYLON.IAnimatable[];
  78615. getActiveTextures(): BABYLON.BaseTexture[];
  78616. hasTexture(texture: BABYLON.BaseTexture): boolean;
  78617. getClassName(): string;
  78618. dispose(forceDisposeEffect?: boolean): void;
  78619. clone(name: string): FireMaterial;
  78620. serialize(): any;
  78621. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  78622. }
  78623. }
  78624. declare module BABYLON {
  78625. /** @hidden */
  78626. export var furPixelShader: {
  78627. name: string;
  78628. shader: string;
  78629. };
  78630. }
  78631. declare module BABYLON {
  78632. /** @hidden */
  78633. export var furVertexShader: {
  78634. name: string;
  78635. shader: string;
  78636. };
  78637. }
  78638. declare module BABYLON {
  78639. export class FurMaterial extends BABYLON.PushMaterial {
  78640. private _diffuseTexture;
  78641. diffuseTexture: BABYLON.BaseTexture;
  78642. private _heightTexture;
  78643. heightTexture: BABYLON.BaseTexture;
  78644. diffuseColor: BABYLON.Color3;
  78645. furLength: number;
  78646. furAngle: number;
  78647. furColor: BABYLON.Color3;
  78648. furOffset: number;
  78649. furSpacing: number;
  78650. furGravity: BABYLON.Vector3;
  78651. furSpeed: number;
  78652. furDensity: number;
  78653. furOcclusion: number;
  78654. furTexture: BABYLON.DynamicTexture;
  78655. private _disableLighting;
  78656. disableLighting: boolean;
  78657. private _maxSimultaneousLights;
  78658. maxSimultaneousLights: number;
  78659. highLevelFur: boolean;
  78660. _meshes: BABYLON.AbstractMesh[];
  78661. private _renderId;
  78662. private _furTime;
  78663. constructor(name: string, scene: BABYLON.Scene);
  78664. get furTime(): number;
  78665. set furTime(furTime: number);
  78666. needAlphaBlending(): boolean;
  78667. needAlphaTesting(): boolean;
  78668. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  78669. updateFur(): void;
  78670. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  78671. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  78672. getAnimatables(): BABYLON.IAnimatable[];
  78673. getActiveTextures(): BABYLON.BaseTexture[];
  78674. hasTexture(texture: BABYLON.BaseTexture): boolean;
  78675. dispose(forceDisposeEffect?: boolean): void;
  78676. clone(name: string): FurMaterial;
  78677. serialize(): any;
  78678. getClassName(): string;
  78679. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  78680. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  78681. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  78682. }
  78683. }
  78684. declare module BABYLON {
  78685. /** @hidden */
  78686. export var gradientPixelShader: {
  78687. name: string;
  78688. shader: string;
  78689. };
  78690. }
  78691. declare module BABYLON {
  78692. /** @hidden */
  78693. export var gradientVertexShader: {
  78694. name: string;
  78695. shader: string;
  78696. };
  78697. }
  78698. declare module BABYLON {
  78699. export class GradientMaterial extends BABYLON.PushMaterial {
  78700. private _maxSimultaneousLights;
  78701. maxSimultaneousLights: number;
  78702. topColor: BABYLON.Color3;
  78703. topColorAlpha: number;
  78704. bottomColor: BABYLON.Color3;
  78705. bottomColorAlpha: number;
  78706. offset: number;
  78707. scale: number;
  78708. smoothness: number;
  78709. private _disableLighting;
  78710. disableLighting: boolean;
  78711. private _renderId;
  78712. constructor(name: string, scene: BABYLON.Scene);
  78713. needAlphaBlending(): boolean;
  78714. needAlphaTesting(): boolean;
  78715. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  78716. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  78717. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  78718. getAnimatables(): BABYLON.IAnimatable[];
  78719. dispose(forceDisposeEffect?: boolean): void;
  78720. clone(name: string): GradientMaterial;
  78721. serialize(): any;
  78722. getClassName(): string;
  78723. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  78724. }
  78725. }
  78726. declare module BABYLON {
  78727. /** @hidden */
  78728. export var gridPixelShader: {
  78729. name: string;
  78730. shader: string;
  78731. };
  78732. }
  78733. declare module BABYLON {
  78734. /** @hidden */
  78735. export var gridVertexShader: {
  78736. name: string;
  78737. shader: string;
  78738. };
  78739. }
  78740. declare module BABYLON {
  78741. /**
  78742. * The grid materials allows you to wrap any shape with a grid.
  78743. * Colors are customizable.
  78744. */
  78745. export class GridMaterial extends BABYLON.PushMaterial {
  78746. /**
  78747. * Main color of the grid (e.g. between lines)
  78748. */
  78749. mainColor: BABYLON.Color3;
  78750. /**
  78751. * Color of the grid lines.
  78752. */
  78753. lineColor: BABYLON.Color3;
  78754. /**
  78755. * The scale of the grid compared to unit.
  78756. */
  78757. gridRatio: number;
  78758. /**
  78759. * Allows setting an offset for the grid lines.
  78760. */
  78761. gridOffset: BABYLON.Vector3;
  78762. /**
  78763. * The frequency of thicker lines.
  78764. */
  78765. majorUnitFrequency: number;
  78766. /**
  78767. * The visibility of minor units in the grid.
  78768. */
  78769. minorUnitVisibility: number;
  78770. /**
  78771. * The grid opacity outside of the lines.
  78772. */
  78773. opacity: number;
  78774. /**
  78775. * Determine RBG output is premultiplied by alpha value.
  78776. */
  78777. preMultiplyAlpha: boolean;
  78778. private _opacityTexture;
  78779. opacityTexture: BABYLON.BaseTexture;
  78780. private _gridControl;
  78781. private _renderId;
  78782. /**
  78783. * constructor
  78784. * @param name The name given to the material in order to identify it afterwards.
  78785. * @param scene The scene the material is used in.
  78786. */
  78787. constructor(name: string, scene: BABYLON.Scene);
  78788. /**
  78789. * Returns wehter or not the grid requires alpha blending.
  78790. */
  78791. needAlphaBlending(): boolean;
  78792. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  78793. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  78794. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  78795. /**
  78796. * Dispose the material and its associated resources.
  78797. * @param forceDisposeEffect will also dispose the used effect when true
  78798. */
  78799. dispose(forceDisposeEffect?: boolean): void;
  78800. clone(name: string): GridMaterial;
  78801. serialize(): any;
  78802. getClassName(): string;
  78803. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  78804. }
  78805. }
  78806. declare module BABYLON {
  78807. /** @hidden */
  78808. export var lavaPixelShader: {
  78809. name: string;
  78810. shader: string;
  78811. };
  78812. }
  78813. declare module BABYLON {
  78814. /** @hidden */
  78815. export var lavaVertexShader: {
  78816. name: string;
  78817. shader: string;
  78818. };
  78819. }
  78820. declare module BABYLON {
  78821. export class LavaMaterial extends BABYLON.PushMaterial {
  78822. private _diffuseTexture;
  78823. diffuseTexture: BABYLON.BaseTexture;
  78824. noiseTexture: BABYLON.BaseTexture;
  78825. fogColor: BABYLON.Color3;
  78826. speed: number;
  78827. movingSpeed: number;
  78828. lowFrequencySpeed: number;
  78829. fogDensity: number;
  78830. private _lastTime;
  78831. diffuseColor: BABYLON.Color3;
  78832. private _disableLighting;
  78833. disableLighting: boolean;
  78834. private _unlit;
  78835. unlit: boolean;
  78836. private _maxSimultaneousLights;
  78837. maxSimultaneousLights: number;
  78838. private _scaledDiffuse;
  78839. private _renderId;
  78840. constructor(name: string, scene: BABYLON.Scene);
  78841. needAlphaBlending(): boolean;
  78842. needAlphaTesting(): boolean;
  78843. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  78844. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  78845. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  78846. getAnimatables(): BABYLON.IAnimatable[];
  78847. getActiveTextures(): BABYLON.BaseTexture[];
  78848. hasTexture(texture: BABYLON.BaseTexture): boolean;
  78849. dispose(forceDisposeEffect?: boolean): void;
  78850. clone(name: string): LavaMaterial;
  78851. serialize(): any;
  78852. getClassName(): string;
  78853. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  78854. }
  78855. }
  78856. declare module BABYLON {
  78857. /** @hidden */
  78858. export var mixPixelShader: {
  78859. name: string;
  78860. shader: string;
  78861. };
  78862. }
  78863. declare module BABYLON {
  78864. /** @hidden */
  78865. export var mixVertexShader: {
  78866. name: string;
  78867. shader: string;
  78868. };
  78869. }
  78870. declare module BABYLON {
  78871. export class MixMaterial extends BABYLON.PushMaterial {
  78872. /**
  78873. * Mix textures
  78874. */
  78875. private _mixTexture1;
  78876. mixTexture1: BABYLON.BaseTexture;
  78877. private _mixTexture2;
  78878. mixTexture2: BABYLON.BaseTexture;
  78879. /**
  78880. * Diffuse textures
  78881. */
  78882. private _diffuseTexture1;
  78883. diffuseTexture1: BABYLON.Texture;
  78884. private _diffuseTexture2;
  78885. diffuseTexture2: BABYLON.Texture;
  78886. private _diffuseTexture3;
  78887. diffuseTexture3: BABYLON.Texture;
  78888. private _diffuseTexture4;
  78889. diffuseTexture4: BABYLON.Texture;
  78890. private _diffuseTexture5;
  78891. diffuseTexture5: BABYLON.Texture;
  78892. private _diffuseTexture6;
  78893. diffuseTexture6: BABYLON.Texture;
  78894. private _diffuseTexture7;
  78895. diffuseTexture7: BABYLON.Texture;
  78896. private _diffuseTexture8;
  78897. diffuseTexture8: BABYLON.Texture;
  78898. /**
  78899. * Uniforms
  78900. */
  78901. diffuseColor: BABYLON.Color3;
  78902. specularColor: BABYLON.Color3;
  78903. specularPower: number;
  78904. private _disableLighting;
  78905. disableLighting: boolean;
  78906. private _maxSimultaneousLights;
  78907. maxSimultaneousLights: number;
  78908. private _renderId;
  78909. constructor(name: string, scene: BABYLON.Scene);
  78910. needAlphaBlending(): boolean;
  78911. needAlphaTesting(): boolean;
  78912. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  78913. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  78914. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  78915. getAnimatables(): BABYLON.IAnimatable[];
  78916. getActiveTextures(): BABYLON.BaseTexture[];
  78917. hasTexture(texture: BABYLON.BaseTexture): boolean;
  78918. dispose(forceDisposeEffect?: boolean): void;
  78919. clone(name: string): MixMaterial;
  78920. serialize(): any;
  78921. getClassName(): string;
  78922. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  78923. }
  78924. }
  78925. declare module BABYLON {
  78926. /** @hidden */
  78927. export var normalPixelShader: {
  78928. name: string;
  78929. shader: string;
  78930. };
  78931. }
  78932. declare module BABYLON {
  78933. /** @hidden */
  78934. export var normalVertexShader: {
  78935. name: string;
  78936. shader: string;
  78937. };
  78938. }
  78939. declare module BABYLON {
  78940. export class NormalMaterial extends BABYLON.PushMaterial {
  78941. private _diffuseTexture;
  78942. diffuseTexture: BABYLON.BaseTexture;
  78943. diffuseColor: BABYLON.Color3;
  78944. private _disableLighting;
  78945. disableLighting: boolean;
  78946. private _maxSimultaneousLights;
  78947. maxSimultaneousLights: number;
  78948. private _renderId;
  78949. constructor(name: string, scene: BABYLON.Scene);
  78950. needAlphaBlending(): boolean;
  78951. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  78952. needAlphaTesting(): boolean;
  78953. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  78954. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  78955. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  78956. getAnimatables(): BABYLON.IAnimatable[];
  78957. getActiveTextures(): BABYLON.BaseTexture[];
  78958. hasTexture(texture: BABYLON.BaseTexture): boolean;
  78959. dispose(forceDisposeEffect?: boolean): void;
  78960. clone(name: string): NormalMaterial;
  78961. serialize(): any;
  78962. getClassName(): string;
  78963. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  78964. }
  78965. }
  78966. declare module BABYLON {
  78967. /** @hidden */
  78968. export var shadowOnlyPixelShader: {
  78969. name: string;
  78970. shader: string;
  78971. };
  78972. }
  78973. declare module BABYLON {
  78974. /** @hidden */
  78975. export var shadowOnlyVertexShader: {
  78976. name: string;
  78977. shader: string;
  78978. };
  78979. }
  78980. declare module BABYLON {
  78981. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  78982. private _renderId;
  78983. private _activeLight;
  78984. constructor(name: string, scene: BABYLON.Scene);
  78985. shadowColor: BABYLON.Color3;
  78986. needAlphaBlending(): boolean;
  78987. needAlphaTesting(): boolean;
  78988. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  78989. get activeLight(): BABYLON.IShadowLight;
  78990. set activeLight(light: BABYLON.IShadowLight);
  78991. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  78992. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  78993. clone(name: string): ShadowOnlyMaterial;
  78994. serialize(): any;
  78995. getClassName(): string;
  78996. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  78997. }
  78998. }
  78999. declare module BABYLON {
  79000. /** @hidden */
  79001. export var simplePixelShader: {
  79002. name: string;
  79003. shader: string;
  79004. };
  79005. }
  79006. declare module BABYLON {
  79007. /** @hidden */
  79008. export var simpleVertexShader: {
  79009. name: string;
  79010. shader: string;
  79011. };
  79012. }
  79013. declare module BABYLON {
  79014. export class SimpleMaterial extends BABYLON.PushMaterial {
  79015. private _diffuseTexture;
  79016. diffuseTexture: BABYLON.BaseTexture;
  79017. diffuseColor: BABYLON.Color3;
  79018. private _disableLighting;
  79019. disableLighting: boolean;
  79020. private _maxSimultaneousLights;
  79021. maxSimultaneousLights: number;
  79022. private _renderId;
  79023. constructor(name: string, scene: BABYLON.Scene);
  79024. needAlphaBlending(): boolean;
  79025. needAlphaTesting(): boolean;
  79026. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  79027. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  79028. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  79029. getAnimatables(): BABYLON.IAnimatable[];
  79030. getActiveTextures(): BABYLON.BaseTexture[];
  79031. hasTexture(texture: BABYLON.BaseTexture): boolean;
  79032. dispose(forceDisposeEffect?: boolean): void;
  79033. clone(name: string): SimpleMaterial;
  79034. serialize(): any;
  79035. getClassName(): string;
  79036. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  79037. }
  79038. }
  79039. declare module BABYLON {
  79040. /** @hidden */
  79041. export var skyPixelShader: {
  79042. name: string;
  79043. shader: string;
  79044. };
  79045. }
  79046. declare module BABYLON {
  79047. /** @hidden */
  79048. export var skyVertexShader: {
  79049. name: string;
  79050. shader: string;
  79051. };
  79052. }
  79053. declare module BABYLON {
  79054. /**
  79055. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  79056. * @see https://doc.babylonjs.com/extensions/sky
  79057. */
  79058. export class SkyMaterial extends BABYLON.PushMaterial {
  79059. /**
  79060. * Defines the overall luminance of sky in interval ]0, 1[.
  79061. */
  79062. luminance: number;
  79063. /**
  79064. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  79065. */
  79066. turbidity: number;
  79067. /**
  79068. * Defines the sky appearance (light intensity).
  79069. */
  79070. rayleigh: number;
  79071. /**
  79072. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  79073. */
  79074. mieCoefficient: number;
  79075. /**
  79076. * Defines the amount of haze particles following the Mie scattering theory.
  79077. */
  79078. mieDirectionalG: number;
  79079. /**
  79080. * Defines the distance of the sun according to the active scene camera.
  79081. */
  79082. distance: number;
  79083. /**
  79084. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  79085. * "inclined".
  79086. */
  79087. inclination: number;
  79088. /**
  79089. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  79090. * an object direction and a reference direction.
  79091. */
  79092. azimuth: number;
  79093. /**
  79094. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  79095. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  79096. */
  79097. sunPosition: BABYLON.Vector3;
  79098. /**
  79099. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  79100. * .sunPosition property.
  79101. */
  79102. useSunPosition: boolean;
  79103. /**
  79104. * Defines an offset vector used to get a horizon offset.
  79105. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  79106. */
  79107. cameraOffset: BABYLON.Vector3;
  79108. private _cameraPosition;
  79109. private _renderId;
  79110. /**
  79111. * Instantiates a new sky material.
  79112. * This material allows to create dynamic and texture free
  79113. * effects for skyboxes by taking care of the atmosphere state.
  79114. * @see https://doc.babylonjs.com/extensions/sky
  79115. * @param name Define the name of the material in the scene
  79116. * @param scene Define the scene the material belong to
  79117. */
  79118. constructor(name: string, scene: BABYLON.Scene);
  79119. /**
  79120. * Specifies if the material will require alpha blending
  79121. * @returns a boolean specifying if alpha blending is needed
  79122. */
  79123. needAlphaBlending(): boolean;
  79124. /**
  79125. * Specifies if this material should be rendered in alpha test mode
  79126. * @returns false as the sky material doesn't need alpha testing.
  79127. */
  79128. needAlphaTesting(): boolean;
  79129. /**
  79130. * Get the texture used for alpha test purpose.
  79131. * @returns null as the sky material has no texture.
  79132. */
  79133. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  79134. /**
  79135. * Get if the submesh is ready to be used and all its information available.
  79136. * Child classes can use it to update shaders
  79137. * @param mesh defines the mesh to check
  79138. * @param subMesh defines which submesh to check
  79139. * @param useInstances specifies that instances should be used
  79140. * @returns a boolean indicating that the submesh is ready or not
  79141. */
  79142. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  79143. /**
  79144. * Binds the submesh to this material by preparing the effect and shader to draw
  79145. * @param world defines the world transformation matrix
  79146. * @param mesh defines the mesh containing the submesh
  79147. * @param subMesh defines the submesh to bind the material to
  79148. */
  79149. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  79150. /**
  79151. * Get the list of animatables in the material.
  79152. * @returns the list of animatables object used in the material
  79153. */
  79154. getAnimatables(): BABYLON.IAnimatable[];
  79155. /**
  79156. * Disposes the material
  79157. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  79158. */
  79159. dispose(forceDisposeEffect?: boolean): void;
  79160. /**
  79161. * Makes a duplicate of the material, and gives it a new name
  79162. * @param name defines the new name for the duplicated material
  79163. * @returns the cloned material
  79164. */
  79165. clone(name: string): SkyMaterial;
  79166. /**
  79167. * Serializes this material in a JSON representation
  79168. * @returns the serialized material object
  79169. */
  79170. serialize(): any;
  79171. /**
  79172. * Gets the current class name of the material e.g. "SkyMaterial"
  79173. * Mainly use in serialization.
  79174. * @returns the class name
  79175. */
  79176. getClassName(): string;
  79177. /**
  79178. * Creates a sky material from parsed material data
  79179. * @param source defines the JSON representation of the material
  79180. * @param scene defines the hosting scene
  79181. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  79182. * @returns a new sky material
  79183. */
  79184. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  79185. }
  79186. }
  79187. declare module BABYLON {
  79188. /** @hidden */
  79189. export var terrainPixelShader: {
  79190. name: string;
  79191. shader: string;
  79192. };
  79193. }
  79194. declare module BABYLON {
  79195. /** @hidden */
  79196. export var terrainVertexShader: {
  79197. name: string;
  79198. shader: string;
  79199. };
  79200. }
  79201. declare module BABYLON {
  79202. export class TerrainMaterial extends BABYLON.PushMaterial {
  79203. private _mixTexture;
  79204. mixTexture: BABYLON.BaseTexture;
  79205. private _diffuseTexture1;
  79206. diffuseTexture1: BABYLON.Texture;
  79207. private _diffuseTexture2;
  79208. diffuseTexture2: BABYLON.Texture;
  79209. private _diffuseTexture3;
  79210. diffuseTexture3: BABYLON.Texture;
  79211. private _bumpTexture1;
  79212. bumpTexture1: BABYLON.Texture;
  79213. private _bumpTexture2;
  79214. bumpTexture2: BABYLON.Texture;
  79215. private _bumpTexture3;
  79216. bumpTexture3: BABYLON.Texture;
  79217. diffuseColor: BABYLON.Color3;
  79218. specularColor: BABYLON.Color3;
  79219. specularPower: number;
  79220. private _disableLighting;
  79221. disableLighting: boolean;
  79222. private _maxSimultaneousLights;
  79223. maxSimultaneousLights: number;
  79224. private _renderId;
  79225. constructor(name: string, scene: BABYLON.Scene);
  79226. needAlphaBlending(): boolean;
  79227. needAlphaTesting(): boolean;
  79228. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  79229. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  79230. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  79231. getAnimatables(): BABYLON.IAnimatable[];
  79232. getActiveTextures(): BABYLON.BaseTexture[];
  79233. hasTexture(texture: BABYLON.BaseTexture): boolean;
  79234. dispose(forceDisposeEffect?: boolean): void;
  79235. clone(name: string): TerrainMaterial;
  79236. serialize(): any;
  79237. getClassName(): string;
  79238. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  79239. }
  79240. }
  79241. declare module BABYLON {
  79242. /** @hidden */
  79243. export var triplanarPixelShader: {
  79244. name: string;
  79245. shader: string;
  79246. };
  79247. }
  79248. declare module BABYLON {
  79249. /** @hidden */
  79250. export var triplanarVertexShader: {
  79251. name: string;
  79252. shader: string;
  79253. };
  79254. }
  79255. declare module BABYLON {
  79256. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  79257. mixTexture: BABYLON.BaseTexture;
  79258. private _diffuseTextureX;
  79259. diffuseTextureX: BABYLON.BaseTexture;
  79260. private _diffuseTextureY;
  79261. diffuseTextureY: BABYLON.BaseTexture;
  79262. private _diffuseTextureZ;
  79263. diffuseTextureZ: BABYLON.BaseTexture;
  79264. private _normalTextureX;
  79265. normalTextureX: BABYLON.BaseTexture;
  79266. private _normalTextureY;
  79267. normalTextureY: BABYLON.BaseTexture;
  79268. private _normalTextureZ;
  79269. normalTextureZ: BABYLON.BaseTexture;
  79270. tileSize: number;
  79271. diffuseColor: BABYLON.Color3;
  79272. specularColor: BABYLON.Color3;
  79273. specularPower: number;
  79274. private _disableLighting;
  79275. disableLighting: boolean;
  79276. private _maxSimultaneousLights;
  79277. maxSimultaneousLights: number;
  79278. private _renderId;
  79279. constructor(name: string, scene: BABYLON.Scene);
  79280. needAlphaBlending(): boolean;
  79281. needAlphaTesting(): boolean;
  79282. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  79283. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  79284. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  79285. getAnimatables(): BABYLON.IAnimatable[];
  79286. getActiveTextures(): BABYLON.BaseTexture[];
  79287. hasTexture(texture: BABYLON.BaseTexture): boolean;
  79288. dispose(forceDisposeEffect?: boolean): void;
  79289. clone(name: string): TriPlanarMaterial;
  79290. serialize(): any;
  79291. getClassName(): string;
  79292. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  79293. }
  79294. }
  79295. declare module BABYLON {
  79296. /** @hidden */
  79297. export var waterPixelShader: {
  79298. name: string;
  79299. shader: string;
  79300. };
  79301. }
  79302. declare module BABYLON {
  79303. /** @hidden */
  79304. export var waterVertexShader: {
  79305. name: string;
  79306. shader: string;
  79307. };
  79308. }
  79309. declare module BABYLON {
  79310. export class WaterMaterial extends BABYLON.PushMaterial {
  79311. renderTargetSize: BABYLON.Vector2;
  79312. private _bumpTexture;
  79313. bumpTexture: BABYLON.BaseTexture;
  79314. diffuseColor: BABYLON.Color3;
  79315. specularColor: BABYLON.Color3;
  79316. specularPower: number;
  79317. private _disableLighting;
  79318. disableLighting: boolean;
  79319. private _maxSimultaneousLights;
  79320. maxSimultaneousLights: number;
  79321. /**
  79322. * @param {number}: Represents the wind force
  79323. */
  79324. windForce: number;
  79325. /**
  79326. * @param {Vector2}: The direction of the wind in the plane (X, Z)
  79327. */
  79328. windDirection: BABYLON.Vector2;
  79329. /**
  79330. * @param {number}: Wave height, represents the height of the waves
  79331. */
  79332. waveHeight: number;
  79333. /**
  79334. * @param {number}: Bump height, represents the bump height related to the bump map
  79335. */
  79336. bumpHeight: number;
  79337. /**
  79338. * @param {boolean}: Add a smaller moving bump to less steady waves.
  79339. */
  79340. private _bumpSuperimpose;
  79341. bumpSuperimpose: boolean;
  79342. /**
  79343. * @param {boolean}: Color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  79344. */
  79345. private _fresnelSeparate;
  79346. fresnelSeparate: boolean;
  79347. /**
  79348. * @param {boolean}: bump Waves modify the reflection.
  79349. */
  79350. private _bumpAffectsReflection;
  79351. bumpAffectsReflection: boolean;
  79352. /**
  79353. * @param {number}: The water color blended with the refraction (near)
  79354. */
  79355. waterColor: BABYLON.Color3;
  79356. /**
  79357. * @param {number}: The blend factor related to the water color
  79358. */
  79359. colorBlendFactor: number;
  79360. /**
  79361. * @param {number}: The water color blended with the reflection (far)
  79362. */
  79363. waterColor2: BABYLON.Color3;
  79364. /**
  79365. * @param {number}: The blend factor related to the water color (reflection, far)
  79366. */
  79367. colorBlendFactor2: number;
  79368. /**
  79369. * @param {number}: Represents the maximum length of a wave
  79370. */
  79371. waveLength: number;
  79372. /**
  79373. * @param {number}: Defines the waves speed
  79374. */
  79375. waveSpeed: number;
  79376. /**
  79377. * Sets or gets whether or not automatic clipping should be enabled or not. Setting to true will save performances and
  79378. * will avoid calculating useless pixels in the pixel shader of the water material.
  79379. */
  79380. disableClipPlane: boolean;
  79381. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  79382. private _mesh;
  79383. private _refractionRTT;
  79384. private _reflectionRTT;
  79385. private _reflectionTransform;
  79386. private _lastTime;
  79387. private _lastDeltaTime;
  79388. private _renderId;
  79389. private _useLogarithmicDepth;
  79390. private _waitingRenderList;
  79391. private _imageProcessingConfiguration;
  79392. private _imageProcessingObserver;
  79393. /**
  79394. * Gets a boolean indicating that current material needs to register RTT
  79395. */
  79396. get hasRenderTargetTextures(): boolean;
  79397. /**
  79398. * Constructor
  79399. */
  79400. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  79401. get useLogarithmicDepth(): boolean;
  79402. set useLogarithmicDepth(value: boolean);
  79403. get refractionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  79404. get reflectionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  79405. addToRenderList(node: any): void;
  79406. enableRenderTargets(enable: boolean): void;
  79407. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  79408. get renderTargetsEnabled(): boolean;
  79409. needAlphaBlending(): boolean;
  79410. needAlphaTesting(): boolean;
  79411. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  79412. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  79413. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  79414. private _createRenderTargets;
  79415. getAnimatables(): BABYLON.IAnimatable[];
  79416. getActiveTextures(): BABYLON.BaseTexture[];
  79417. hasTexture(texture: BABYLON.BaseTexture): boolean;
  79418. dispose(forceDisposeEffect?: boolean): void;
  79419. clone(name: string): WaterMaterial;
  79420. serialize(): any;
  79421. getClassName(): string;
  79422. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  79423. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  79424. }
  79425. }
  79426. declare module BABYLON {
  79427. /** @hidden */
  79428. export var asciiartPixelShader: {
  79429. name: string;
  79430. shader: string;
  79431. };
  79432. }
  79433. declare module BABYLON {
  79434. /**
  79435. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  79436. *
  79437. * It basically takes care rendering the font front the given font size to a texture.
  79438. * This is used later on in the postprocess.
  79439. */
  79440. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  79441. private _font;
  79442. private _text;
  79443. private _charSize;
  79444. /**
  79445. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  79446. */
  79447. get charSize(): number;
  79448. /**
  79449. * Create a new instance of the Ascii Art FontTexture class
  79450. * @param name the name of the texture
  79451. * @param font the font to use, use the W3C CSS notation
  79452. * @param text the caracter set to use in the rendering.
  79453. * @param scene the scene that owns the texture
  79454. */
  79455. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  79456. /**
  79457. * Gets the max char width of a font.
  79458. * @param font the font to use, use the W3C CSS notation
  79459. * @return the max char width
  79460. */
  79461. private getFontWidth;
  79462. /**
  79463. * Gets the max char height of a font.
  79464. * @param font the font to use, use the W3C CSS notation
  79465. * @return the max char height
  79466. */
  79467. private getFontHeight;
  79468. /**
  79469. * Clones the current AsciiArtTexture.
  79470. * @return the clone of the texture.
  79471. */
  79472. clone(): AsciiArtFontTexture;
  79473. /**
  79474. * Parses a json object representing the texture and returns an instance of it.
  79475. * @param source the source JSON representation
  79476. * @param scene the scene to create the texture for
  79477. * @return the parsed texture
  79478. */
  79479. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  79480. }
  79481. /**
  79482. * Option available in the Ascii Art Post Process.
  79483. */
  79484. export interface IAsciiArtPostProcessOptions {
  79485. /**
  79486. * The font to use following the w3c font definition.
  79487. */
  79488. font?: string;
  79489. /**
  79490. * The character set to use in the postprocess.
  79491. */
  79492. characterSet?: string;
  79493. /**
  79494. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  79495. * This number is defined between 0 and 1;
  79496. */
  79497. mixToTile?: number;
  79498. /**
  79499. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  79500. * This number is defined between 0 and 1;
  79501. */
  79502. mixToNormal?: number;
  79503. }
  79504. /**
  79505. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  79506. *
  79507. * Simmply add it to your scene and let the nerd that lives in you have fun.
  79508. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  79509. */
  79510. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  79511. /**
  79512. * The font texture used to render the char in the post process.
  79513. */
  79514. private _asciiArtFontTexture;
  79515. /**
  79516. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  79517. * This number is defined between 0 and 1;
  79518. */
  79519. mixToTile: number;
  79520. /**
  79521. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  79522. * This number is defined between 0 and 1;
  79523. */
  79524. mixToNormal: number;
  79525. /**
  79526. * Instantiates a new Ascii Art Post Process.
  79527. * @param name the name to give to the postprocess
  79528. * @camera the camera to apply the post process to.
  79529. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  79530. */
  79531. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  79532. }
  79533. }
  79534. declare module BABYLON {
  79535. /** @hidden */
  79536. export var digitalrainPixelShader: {
  79537. name: string;
  79538. shader: string;
  79539. };
  79540. }
  79541. declare module BABYLON {
  79542. /**
  79543. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  79544. *
  79545. * It basically takes care rendering the font front the given font size to a texture.
  79546. * This is used later on in the postprocess.
  79547. */
  79548. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  79549. private _font;
  79550. private _text;
  79551. private _charSize;
  79552. /**
  79553. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  79554. */
  79555. get charSize(): number;
  79556. /**
  79557. * Create a new instance of the Digital Rain FontTexture class
  79558. * @param name the name of the texture
  79559. * @param font the font to use, use the W3C CSS notation
  79560. * @param text the caracter set to use in the rendering.
  79561. * @param scene the scene that owns the texture
  79562. */
  79563. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  79564. /**
  79565. * Gets the max char width of a font.
  79566. * @param font the font to use, use the W3C CSS notation
  79567. * @return the max char width
  79568. */
  79569. private getFontWidth;
  79570. /**
  79571. * Gets the max char height of a font.
  79572. * @param font the font to use, use the W3C CSS notation
  79573. * @return the max char height
  79574. */
  79575. private getFontHeight;
  79576. /**
  79577. * Clones the current DigitalRainFontTexture.
  79578. * @return the clone of the texture.
  79579. */
  79580. clone(): DigitalRainFontTexture;
  79581. /**
  79582. * Parses a json object representing the texture and returns an instance of it.
  79583. * @param source the source JSON representation
  79584. * @param scene the scene to create the texture for
  79585. * @return the parsed texture
  79586. */
  79587. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  79588. }
  79589. /**
  79590. * Option available in the Digital Rain Post Process.
  79591. */
  79592. export interface IDigitalRainPostProcessOptions {
  79593. /**
  79594. * The font to use following the w3c font definition.
  79595. */
  79596. font?: string;
  79597. /**
  79598. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  79599. * This number is defined between 0 and 1;
  79600. */
  79601. mixToTile?: number;
  79602. /**
  79603. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  79604. * This number is defined between 0 and 1;
  79605. */
  79606. mixToNormal?: number;
  79607. }
  79608. /**
  79609. * DigitalRainPostProcess helps rendering everithing in digital rain.
  79610. *
  79611. * Simmply add it to your scene and let the nerd that lives in you have fun.
  79612. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  79613. */
  79614. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  79615. /**
  79616. * The font texture used to render the char in the post process.
  79617. */
  79618. private _digitalRainFontTexture;
  79619. /**
  79620. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  79621. * This number is defined between 0 and 1;
  79622. */
  79623. mixToTile: number;
  79624. /**
  79625. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  79626. * This number is defined between 0 and 1;
  79627. */
  79628. mixToNormal: number;
  79629. /**
  79630. * Instantiates a new Digital Rain Post Process.
  79631. * @param name the name to give to the postprocess
  79632. * @camera the camera to apply the post process to.
  79633. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  79634. */
  79635. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  79636. }
  79637. }
  79638. declare module BABYLON {
  79639. /** @hidden */
  79640. export var brickProceduralTexturePixelShader: {
  79641. name: string;
  79642. shader: string;
  79643. };
  79644. }
  79645. declare module BABYLON {
  79646. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  79647. private _numberOfBricksHeight;
  79648. private _numberOfBricksWidth;
  79649. private _jointColor;
  79650. private _brickColor;
  79651. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  79652. updateShaderUniforms(): void;
  79653. get numberOfBricksHeight(): number;
  79654. set numberOfBricksHeight(value: number);
  79655. get numberOfBricksWidth(): number;
  79656. set numberOfBricksWidth(value: number);
  79657. get jointColor(): BABYLON.Color3;
  79658. set jointColor(value: BABYLON.Color3);
  79659. get brickColor(): BABYLON.Color3;
  79660. set brickColor(value: BABYLON.Color3);
  79661. /**
  79662. * Serializes this brick procedural texture
  79663. * @returns a serialized brick procedural texture object
  79664. */
  79665. serialize(): any;
  79666. /**
  79667. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  79668. * @param parsedTexture defines parsed texture data
  79669. * @param scene defines the current scene
  79670. * @param rootUrl defines the root URL containing brick procedural texture information
  79671. * @returns a parsed Brick Procedural BABYLON.Texture
  79672. */
  79673. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  79674. }
  79675. }
  79676. declare module BABYLON {
  79677. /** @hidden */
  79678. export var cloudProceduralTexturePixelShader: {
  79679. name: string;
  79680. shader: string;
  79681. };
  79682. }
  79683. declare module BABYLON {
  79684. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  79685. private _skyColor;
  79686. private _cloudColor;
  79687. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  79688. updateShaderUniforms(): void;
  79689. get skyColor(): BABYLON.Color4;
  79690. set skyColor(value: BABYLON.Color4);
  79691. get cloudColor(): BABYLON.Color4;
  79692. set cloudColor(value: BABYLON.Color4);
  79693. /**
  79694. * Serializes this cloud procedural texture
  79695. * @returns a serialized cloud procedural texture object
  79696. */
  79697. serialize(): any;
  79698. /**
  79699. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  79700. * @param parsedTexture defines parsed texture data
  79701. * @param scene defines the current scene
  79702. * @param rootUrl defines the root URL containing cloud procedural texture information
  79703. * @returns a parsed Cloud Procedural BABYLON.Texture
  79704. */
  79705. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  79706. }
  79707. }
  79708. declare module BABYLON {
  79709. /** @hidden */
  79710. export var fireProceduralTexturePixelShader: {
  79711. name: string;
  79712. shader: string;
  79713. };
  79714. }
  79715. declare module BABYLON {
  79716. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  79717. private _time;
  79718. private _speed;
  79719. private _autoGenerateTime;
  79720. private _fireColors;
  79721. private _alphaThreshold;
  79722. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  79723. updateShaderUniforms(): void;
  79724. render(useCameraPostProcess?: boolean): void;
  79725. static get PurpleFireColors(): BABYLON.Color3[];
  79726. static get GreenFireColors(): BABYLON.Color3[];
  79727. static get RedFireColors(): BABYLON.Color3[];
  79728. static get BlueFireColors(): BABYLON.Color3[];
  79729. get autoGenerateTime(): boolean;
  79730. set autoGenerateTime(value: boolean);
  79731. get fireColors(): BABYLON.Color3[];
  79732. set fireColors(value: BABYLON.Color3[]);
  79733. get time(): number;
  79734. set time(value: number);
  79735. get speed(): BABYLON.Vector2;
  79736. set speed(value: BABYLON.Vector2);
  79737. get alphaThreshold(): number;
  79738. set alphaThreshold(value: number);
  79739. /**
  79740. * Serializes this fire procedural texture
  79741. * @returns a serialized fire procedural texture object
  79742. */
  79743. serialize(): any;
  79744. /**
  79745. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  79746. * @param parsedTexture defines parsed texture data
  79747. * @param scene defines the current scene
  79748. * @param rootUrl defines the root URL containing fire procedural texture information
  79749. * @returns a parsed Fire Procedural BABYLON.Texture
  79750. */
  79751. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  79752. }
  79753. }
  79754. declare module BABYLON {
  79755. /** @hidden */
  79756. export var grassProceduralTexturePixelShader: {
  79757. name: string;
  79758. shader: string;
  79759. };
  79760. }
  79761. declare module BABYLON {
  79762. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  79763. private _grassColors;
  79764. private _groundColor;
  79765. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  79766. updateShaderUniforms(): void;
  79767. get grassColors(): BABYLON.Color3[];
  79768. set grassColors(value: BABYLON.Color3[]);
  79769. get groundColor(): BABYLON.Color3;
  79770. set groundColor(value: BABYLON.Color3);
  79771. /**
  79772. * Serializes this grass procedural texture
  79773. * @returns a serialized grass procedural texture object
  79774. */
  79775. serialize(): any;
  79776. /**
  79777. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  79778. * @param parsedTexture defines parsed texture data
  79779. * @param scene defines the current scene
  79780. * @param rootUrl defines the root URL containing grass procedural texture information
  79781. * @returns a parsed Grass Procedural BABYLON.Texture
  79782. */
  79783. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  79784. }
  79785. }
  79786. declare module BABYLON {
  79787. /** @hidden */
  79788. export var marbleProceduralTexturePixelShader: {
  79789. name: string;
  79790. shader: string;
  79791. };
  79792. }
  79793. declare module BABYLON {
  79794. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  79795. private _numberOfTilesHeight;
  79796. private _numberOfTilesWidth;
  79797. private _amplitude;
  79798. private _jointColor;
  79799. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  79800. updateShaderUniforms(): void;
  79801. get numberOfTilesHeight(): number;
  79802. set numberOfTilesHeight(value: number);
  79803. get amplitude(): number;
  79804. set amplitude(value: number);
  79805. get numberOfTilesWidth(): number;
  79806. set numberOfTilesWidth(value: number);
  79807. get jointColor(): BABYLON.Color3;
  79808. set jointColor(value: BABYLON.Color3);
  79809. /**
  79810. * Serializes this marble procedural texture
  79811. * @returns a serialized marble procedural texture object
  79812. */
  79813. serialize(): any;
  79814. /**
  79815. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  79816. * @param parsedTexture defines parsed texture data
  79817. * @param scene defines the current scene
  79818. * @param rootUrl defines the root URL containing marble procedural texture information
  79819. * @returns a parsed Marble Procedural BABYLON.Texture
  79820. */
  79821. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  79822. }
  79823. }
  79824. declare module BABYLON {
  79825. /** @hidden */
  79826. export var normalMapProceduralTexturePixelShader: {
  79827. name: string;
  79828. shader: string;
  79829. };
  79830. }
  79831. declare module BABYLON {
  79832. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  79833. private _baseTexture;
  79834. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  79835. updateShaderUniforms(): void;
  79836. render(useCameraPostProcess?: boolean): void;
  79837. resize(size: any, generateMipMaps: any): void;
  79838. get baseTexture(): BABYLON.Texture;
  79839. set baseTexture(texture: BABYLON.Texture);
  79840. /**
  79841. * Serializes this normal map procedural texture
  79842. * @returns a serialized normal map procedural texture object
  79843. */
  79844. serialize(): any;
  79845. /**
  79846. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  79847. * @param parsedTexture defines parsed texture data
  79848. * @param scene defines the current scene
  79849. * @param rootUrl defines the root URL containing normal map procedural texture information
  79850. * @returns a parsed Normal Map Procedural BABYLON.Texture
  79851. */
  79852. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  79853. }
  79854. }
  79855. declare module BABYLON {
  79856. /** @hidden */
  79857. export var perlinNoiseProceduralTexturePixelShader: {
  79858. name: string;
  79859. shader: string;
  79860. };
  79861. }
  79862. declare module BABYLON {
  79863. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  79864. time: number;
  79865. timeScale: number;
  79866. translationSpeed: number;
  79867. private _currentTranslation;
  79868. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  79869. updateShaderUniforms(): void;
  79870. render(useCameraPostProcess?: boolean): void;
  79871. resize(size: any, generateMipMaps: any): void;
  79872. /**
  79873. * Serializes this perlin noise procedural texture
  79874. * @returns a serialized perlin noise procedural texture object
  79875. */
  79876. serialize(): any;
  79877. /**
  79878. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  79879. * @param parsedTexture defines parsed texture data
  79880. * @param scene defines the current scene
  79881. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  79882. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  79883. */
  79884. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  79885. }
  79886. }
  79887. declare module BABYLON {
  79888. /** @hidden */
  79889. export var roadProceduralTexturePixelShader: {
  79890. name: string;
  79891. shader: string;
  79892. };
  79893. }
  79894. declare module BABYLON {
  79895. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  79896. private _roadColor;
  79897. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  79898. updateShaderUniforms(): void;
  79899. get roadColor(): BABYLON.Color3;
  79900. set roadColor(value: BABYLON.Color3);
  79901. /**
  79902. * Serializes this road procedural texture
  79903. * @returns a serialized road procedural texture object
  79904. */
  79905. serialize(): any;
  79906. /**
  79907. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  79908. * @param parsedTexture defines parsed texture data
  79909. * @param scene defines the current scene
  79910. * @param rootUrl defines the root URL containing road procedural texture information
  79911. * @returns a parsed Road Procedural BABYLON.Texture
  79912. */
  79913. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  79914. }
  79915. }
  79916. declare module BABYLON {
  79917. /** @hidden */
  79918. export var starfieldProceduralTexturePixelShader: {
  79919. name: string;
  79920. shader: string;
  79921. };
  79922. }
  79923. declare module BABYLON {
  79924. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  79925. private _time;
  79926. private _alpha;
  79927. private _beta;
  79928. private _zoom;
  79929. private _formuparam;
  79930. private _stepsize;
  79931. private _tile;
  79932. private _brightness;
  79933. private _darkmatter;
  79934. private _distfading;
  79935. private _saturation;
  79936. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  79937. updateShaderUniforms(): void;
  79938. get time(): number;
  79939. set time(value: number);
  79940. get alpha(): number;
  79941. set alpha(value: number);
  79942. get beta(): number;
  79943. set beta(value: number);
  79944. get formuparam(): number;
  79945. set formuparam(value: number);
  79946. get stepsize(): number;
  79947. set stepsize(value: number);
  79948. get zoom(): number;
  79949. set zoom(value: number);
  79950. get tile(): number;
  79951. set tile(value: number);
  79952. get brightness(): number;
  79953. set brightness(value: number);
  79954. get darkmatter(): number;
  79955. set darkmatter(value: number);
  79956. get distfading(): number;
  79957. set distfading(value: number);
  79958. get saturation(): number;
  79959. set saturation(value: number);
  79960. /**
  79961. * Serializes this starfield procedural texture
  79962. * @returns a serialized starfield procedural texture object
  79963. */
  79964. serialize(): any;
  79965. /**
  79966. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  79967. * @param parsedTexture defines parsed texture data
  79968. * @param scene defines the current scene
  79969. * @param rootUrl defines the root URL containing startfield procedural texture information
  79970. * @returns a parsed Starfield Procedural BABYLON.Texture
  79971. */
  79972. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  79973. }
  79974. }
  79975. declare module BABYLON {
  79976. /** @hidden */
  79977. export var woodProceduralTexturePixelShader: {
  79978. name: string;
  79979. shader: string;
  79980. };
  79981. }
  79982. declare module BABYLON {
  79983. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  79984. private _ampScale;
  79985. private _woodColor;
  79986. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  79987. updateShaderUniforms(): void;
  79988. get ampScale(): number;
  79989. set ampScale(value: number);
  79990. get woodColor(): BABYLON.Color3;
  79991. set woodColor(value: BABYLON.Color3);
  79992. /**
  79993. * Serializes this wood procedural texture
  79994. * @returns a serialized wood procedural texture object
  79995. */
  79996. serialize(): any;
  79997. /**
  79998. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  79999. * @param parsedTexture defines parsed texture data
  80000. * @param scene defines the current scene
  80001. * @param rootUrl defines the root URL containing wood procedural texture information
  80002. * @returns a parsed Wood Procedural BABYLON.Texture
  80003. */
  80004. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  80005. }
  80006. }