documentation.d.ts 3.3 MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585315863158731588315893159031591315923159331594315953159631597315983159931600316013160231603316043160531606316073160831609316103161131612316133161431615316163161731618316193162031621316223162331624316253162631627316283162931630316313163231633316343163531636316373163831639316403164131642316433164431645316463164731648316493165031651316523165331654316553165631657316583165931660316613166231663316643166531666316673166831669316703167131672316733167431675316763167731678316793168031681316823168331684316853168631687316883168931690316913169231693316943169531696316973169831699317003170131702317033170431705317063170731708317093171031711317123171331714317153171631717317183171931720317213172231723317243172531726317273172831729317303173131732317333173431735317363173731738317393174031741317423174331744317453174631747317483174931750317513175231753317543175531756317573175831759317603176131762317633176431765317663176731768317693177031771317723177331774317753177631777317783177931780317813178231783317843178531786317873178831789317903179131792317933179431795317963179731798317993180031801318023180331804318053180631807318083180931810318113181231813318143181531816318173181831819318203182131822318233182431825318263182731828318293183031831318323183331834318353183631837318383183931840318413184231843318443184531846318473184831849318503185131852318533185431855318563185731858318593186031861318623186331864318653186631867318683186931870318713187231873318743187531876318773187831879318803188131882318833188431885318863188731888318893189031891318923189331894318953189631897318983189931900319013190231903319043190531906319073190831909319103191131912319133191431915319163191731918319193192031921319223192331924319253192631927319283192931930319313193231933319343193531936319373193831939319403194131942319433194431945319463194731948319493195031951319523195331954319553195631957319583195931960319613196231963319643196531966319673196831969319703197131972319733197431975319763197731978319793198031981319823198331984319853198631987319883198931990319913199231993319943199531996319973199831999320003200132002320033200432005320063200732008320093201032011320123201332014320153201632017320183201932020320213202232023320243202532026320273202832029320303203132032320333203432035320363203732038320393204032041320423204332044320453204632047320483204932050320513205232053320543205532056320573205832059320603206132062320633206432065320663206732068320693207032071320723207332074320753207632077320783207932080320813208232083320843208532086320873208832089320903209132092320933209432095320963209732098320993210032101321023210332104321053210632107321083210932110321113211232113321143211532116321173211832119321203212132122321233212432125321263212732128321293213032131321323213332134321353213632137321383213932140321413214232143321443214532146321473214832149321503215132152321533215432155321563215732158321593216032161321623216332164321653216632167321683216932170321713217232173321743217532176321773217832179321803218132182321833218432185321863218732188321893219032191321923219332194321953219632197321983219932200322013220232203322043220532206322073220832209322103221132212322133221432215322163221732218322193222032221322223222332224322253222632227322283222932230322313223232233322343223532236322373223832239322403224132242322433224432245322463224732248322493225032251322523225332254322553225632257322583225932260322613226232263322643226532266322673226832269322703227132272322733227432275322763227732278322793228032281322823228332284322853228632287322883228932290322913229232293322943229532296322973229832299323003230132302323033230432305323063230732308323093231032311323123231332314323153231632317323183231932320323213232232323323243232532326323273232832329323303233132332323333233432335323363233732338323393234032341323423234332344323453234632347323483234932350323513235232353323543235532356323573235832359323603236132362323633236432365323663236732368323693237032371323723237332374323753237632377323783237932380323813238232383323843238532386323873238832389323903239132392323933239432395323963239732398323993240032401324023240332404324053240632407324083240932410324113241232413324143241532416324173241832419324203242132422324233242432425324263242732428324293243032431324323243332434324353243632437324383243932440324413244232443324443244532446324473244832449324503245132452324533245432455324563245732458324593246032461324623246332464324653246632467324683246932470324713247232473324743247532476324773247832479324803248132482324833248432485324863248732488324893249032491324923249332494324953249632497324983249932500325013250232503325043250532506325073250832509325103251132512325133251432515325163251732518325193252032521325223252332524325253252632527325283252932530325313253232533325343253532536325373253832539325403254132542325433254432545325463254732548325493255032551325523255332554325553255632557325583255932560325613256232563325643256532566325673256832569325703257132572325733257432575325763257732578325793258032581325823258332584325853258632587325883258932590325913259232593325943259532596325973259832599326003260132602326033260432605326063260732608326093261032611326123261332614326153261632617326183261932620326213262232623326243262532626326273262832629326303263132632326333263432635326363263732638326393264032641326423264332644326453264632647326483264932650326513265232653326543265532656326573265832659326603266132662326633266432665326663266732668326693267032671326723267332674326753267632677326783267932680326813268232683326843268532686326873268832689326903269132692326933269432695326963269732698326993270032701327023270332704327053270632707327083270932710327113271232713327143271532716327173271832719327203272132722327233272432725327263272732728327293273032731327323273332734327353273632737327383273932740327413274232743327443274532746327473274832749327503275132752327533275432755327563275732758327593276032761327623276332764327653276632767327683276932770327713277232773327743277532776327773277832779327803278132782327833278432785327863278732788327893279032791327923279332794327953279632797327983279932800328013280232803328043280532806328073280832809328103281132812328133281432815328163281732818328193282032821328223282332824328253282632827328283282932830328313283232833328343283532836328373283832839328403284132842328433284432845328463284732848328493285032851328523285332854328553285632857328583285932860328613286232863328643286532866328673286832869328703287132872328733287432875328763287732878328793288032881328823288332884328853288632887328883288932890328913289232893328943289532896328973289832899329003290132902329033290432905329063290732908329093291032911329123291332914329153291632917329183291932920329213292232923329243292532926329273292832929329303293132932329333293432935329363293732938329393294032941329423294332944329453294632947329483294932950329513295232953329543295532956329573295832959329603296132962329633296432965329663296732968329693297032971329723297332974329753297632977329783297932980329813298232983329843298532986329873298832989329903299132992329933299432995329963299732998329993300033001330023300333004330053300633007330083300933010330113301233013330143301533016330173301833019330203302133022330233302433025330263302733028330293303033031330323303333034330353303633037330383303933040330413304233043330443304533046330473304833049330503305133052330533305433055330563305733058330593306033061330623306333064330653306633067330683306933070330713307233073330743307533076330773307833079330803308133082330833308433085330863308733088330893309033091330923309333094330953309633097330983309933100331013310233103331043310533106331073310833109331103311133112331133311433115331163311733118331193312033121331223312333124331253312633127331283312933130331313313233133331343313533136331373313833139331403314133142331433314433145331463314733148331493315033151331523315333154331553315633157331583315933160331613316233163331643316533166331673316833169331703317133172331733317433175331763317733178331793318033181331823318333184331853318633187331883318933190331913319233193331943319533196331973319833199332003320133202332033320433205332063320733208332093321033211332123321333214332153321633217332183321933220332213322233223332243322533226332273322833229332303323133232332333323433235332363323733238332393324033241332423324333244332453324633247332483324933250332513325233253332543325533256332573325833259332603326133262332633326433265332663326733268332693327033271332723327333274332753327633277332783327933280332813328233283332843328533286332873328833289332903329133292332933329433295332963329733298332993330033301333023330333304333053330633307333083330933310333113331233313333143331533316333173331833319333203332133322333233332433325333263332733328333293333033331333323333333334333353333633337333383333933340333413334233343333443334533346333473334833349333503335133352333533335433355333563335733358333593336033361333623336333364333653336633367333683336933370333713337233373333743337533376333773337833379333803338133382333833338433385333863338733388333893339033391333923339333394333953339633397333983339933400334013340233403334043340533406334073340833409334103341133412334133341433415334163341733418334193342033421334223342333424334253342633427334283342933430334313343233433334343343533436334373343833439334403344133442334433344433445334463344733448334493345033451334523345333454334553345633457334583345933460334613346233463334643346533466334673346833469334703347133472334733347433475334763347733478334793348033481334823348333484334853348633487334883348933490334913349233493334943349533496334973349833499335003350133502335033350433505335063350733508335093351033511335123351333514335153351633517335183351933520335213352233523335243352533526335273352833529335303353133532335333353433535335363353733538335393354033541335423354333544335453354633547335483354933550335513355233553335543355533556335573355833559335603356133562335633356433565335663356733568335693357033571335723357333574335753357633577335783357933580335813358233583335843358533586335873358833589335903359133592335933359433595335963359733598335993360033601336023360333604336053360633607336083360933610336113361233613336143361533616336173361833619336203362133622336233362433625336263362733628336293363033631336323363333634336353363633637336383363933640336413364233643336443364533646336473364833649336503365133652336533365433655336563365733658336593366033661336623366333664336653366633667336683366933670336713367233673336743367533676336773367833679336803368133682336833368433685336863368733688336893369033691336923369333694336953369633697336983369933700337013370233703337043370533706337073370833709337103371133712337133371433715337163371733718337193372033721337223372333724337253372633727337283372933730337313373233733337343373533736337373373833739337403374133742337433374433745337463374733748337493375033751337523375333754337553375633757337583375933760337613376233763337643376533766337673376833769337703377133772337733377433775337763377733778337793378033781337823378333784337853378633787337883378933790337913379233793337943379533796337973379833799338003380133802338033380433805338063380733808338093381033811338123381333814338153381633817338183381933820338213382233823338243382533826338273382833829338303383133832338333383433835338363383733838338393384033841338423384333844338453384633847338483384933850338513385233853338543385533856338573385833859338603386133862338633386433865338663386733868338693387033871338723387333874338753387633877338783387933880338813388233883338843388533886338873388833889338903389133892338933389433895338963389733898338993390033901339023390333904339053390633907339083390933910339113391233913339143391533916339173391833919339203392133922339233392433925339263392733928339293393033931339323393333934339353393633937339383393933940339413394233943339443394533946339473394833949339503395133952339533395433955339563395733958339593396033961339623396333964339653396633967339683396933970339713397233973339743397533976339773397833979339803398133982339833398433985339863398733988339893399033991339923399333994339953399633997339983399934000340013400234003340043400534006340073400834009340103401134012340133401434015340163401734018340193402034021340223402334024340253402634027340283402934030340313403234033340343403534036340373403834039340403404134042340433404434045340463404734048340493405034051340523405334054340553405634057340583405934060340613406234063340643406534066340673406834069340703407134072340733407434075340763407734078340793408034081340823408334084340853408634087340883408934090340913409234093340943409534096340973409834099341003410134102341033410434105341063410734108341093411034111341123411334114341153411634117341183411934120341213412234123341243412534126341273412834129341303413134132341333413434135341363413734138341393414034141341423414334144341453414634147341483414934150341513415234153341543415534156341573415834159341603416134162341633416434165341663416734168341693417034171341723417334174341753417634177341783417934180341813418234183341843418534186341873418834189341903419134192341933419434195341963419734198341993420034201342023420334204342053420634207342083420934210342113421234213342143421534216342173421834219342203422134222342233422434225342263422734228342293423034231342323423334234342353423634237342383423934240342413424234243342443424534246342473424834249342503425134252342533425434255342563425734258342593426034261342623426334264342653426634267342683426934270342713427234273342743427534276342773427834279342803428134282342833428434285342863428734288342893429034291342923429334294342953429634297342983429934300343013430234303343043430534306343073430834309343103431134312343133431434315343163431734318343193432034321343223432334324343253432634327343283432934330343313433234333343343433534336343373433834339343403434134342343433434434345343463434734348343493435034351343523435334354343553435634357343583435934360343613436234363343643436534366343673436834369343703437134372343733437434375343763437734378343793438034381343823438334384343853438634387343883438934390343913439234393343943439534396343973439834399344003440134402344033440434405344063440734408344093441034411344123441334414344153441634417344183441934420344213442234423344243442534426344273442834429344303443134432344333443434435344363443734438344393444034441344423444334444344453444634447344483444934450344513445234453344543445534456344573445834459344603446134462344633446434465344663446734468344693447034471344723447334474344753447634477344783447934480344813448234483344843448534486344873448834489344903449134492344933449434495344963449734498344993450034501345023450334504345053450634507345083450934510345113451234513345143451534516345173451834519345203452134522345233452434525345263452734528345293453034531345323453334534345353453634537345383453934540345413454234543345443454534546345473454834549345503455134552345533455434555345563455734558345593456034561345623456334564345653456634567345683456934570345713457234573345743457534576345773457834579345803458134582345833458434585345863458734588345893459034591345923459334594345953459634597345983459934600346013460234603346043460534606346073460834609346103461134612346133461434615346163461734618346193462034621346223462334624346253462634627346283462934630346313463234633346343463534636346373463834639346403464134642346433464434645346463464734648346493465034651346523465334654346553465634657346583465934660346613466234663346643466534666346673466834669346703467134672346733467434675346763467734678346793468034681346823468334684346853468634687346883468934690346913469234693346943469534696346973469834699347003470134702347033470434705347063470734708347093471034711347123471334714347153471634717347183471934720347213472234723347243472534726347273472834729347303473134732347333473434735347363473734738347393474034741347423474334744347453474634747347483474934750347513475234753347543475534756347573475834759347603476134762347633476434765347663476734768347693477034771347723477334774347753477634777347783477934780347813478234783347843478534786347873478834789347903479134792347933479434795347963479734798347993480034801348023480334804348053480634807348083480934810348113481234813348143481534816348173481834819348203482134822348233482434825348263482734828348293483034831348323483334834348353483634837348383483934840348413484234843348443484534846348473484834849348503485134852348533485434855348563485734858348593486034861348623486334864348653486634867348683486934870348713487234873348743487534876348773487834879348803488134882348833488434885348863488734888348893489034891348923489334894348953489634897348983489934900349013490234903349043490534906349073490834909349103491134912349133491434915349163491734918349193492034921349223492334924349253492634927349283492934930349313493234933349343493534936349373493834939349403494134942349433494434945349463494734948349493495034951349523495334954349553495634957349583495934960349613496234963349643496534966349673496834969349703497134972349733497434975349763497734978349793498034981349823498334984349853498634987349883498934990349913499234993349943499534996349973499834999350003500135002350033500435005350063500735008350093501035011350123501335014350153501635017350183501935020350213502235023350243502535026350273502835029350303503135032350333503435035350363503735038350393504035041350423504335044350453504635047350483504935050350513505235053350543505535056350573505835059350603506135062350633506435065350663506735068350693507035071350723507335074350753507635077350783507935080350813508235083350843508535086350873508835089350903509135092350933509435095350963509735098350993510035101351023510335104351053510635107351083510935110351113511235113351143511535116351173511835119351203512135122351233512435125351263512735128351293513035131351323513335134351353513635137351383513935140351413514235143351443514535146351473514835149351503515135152351533515435155351563515735158351593516035161351623516335164351653516635167351683516935170351713517235173351743517535176351773517835179351803518135182351833518435185351863518735188351893519035191351923519335194351953519635197351983519935200352013520235203352043520535206352073520835209352103521135212352133521435215352163521735218352193522035221352223522335224352253522635227352283522935230352313523235233352343523535236352373523835239352403524135242352433524435245352463524735248352493525035251352523525335254352553525635257352583525935260352613526235263352643526535266352673526835269352703527135272352733527435275352763527735278352793528035281352823528335284352853528635287352883528935290352913529235293352943529535296352973529835299353003530135302353033530435305353063530735308353093531035311353123531335314353153531635317353183531935320353213532235323353243532535326353273532835329353303533135332353333533435335353363533735338353393534035341353423534335344353453534635347353483534935350353513535235353353543535535356353573535835359353603536135362353633536435365353663536735368353693537035371353723537335374353753537635377353783537935380353813538235383353843538535386353873538835389353903539135392353933539435395353963539735398353993540035401354023540335404354053540635407354083540935410354113541235413354143541535416354173541835419354203542135422354233542435425354263542735428354293543035431354323543335434354353543635437354383543935440354413544235443354443544535446354473544835449354503545135452354533545435455354563545735458354593546035461354623546335464354653546635467354683546935470354713547235473354743547535476354773547835479354803548135482354833548435485354863548735488354893549035491354923549335494354953549635497354983549935500355013550235503355043550535506355073550835509355103551135512355133551435515355163551735518355193552035521355223552335524355253552635527355283552935530355313553235533355343553535536355373553835539355403554135542355433554435545355463554735548355493555035551355523555335554355553555635557355583555935560355613556235563355643556535566355673556835569355703557135572355733557435575355763557735578355793558035581355823558335584355853558635587355883558935590355913559235593355943559535596355973559835599356003560135602356033560435605356063560735608356093561035611356123561335614356153561635617356183561935620356213562235623356243562535626356273562835629356303563135632356333563435635356363563735638356393564035641356423564335644356453564635647356483564935650356513565235653356543565535656356573565835659356603566135662356633566435665356663566735668356693567035671356723567335674356753567635677356783567935680356813568235683356843568535686356873568835689356903569135692356933569435695356963569735698356993570035701357023570335704357053570635707357083570935710357113571235713357143571535716357173571835719357203572135722357233572435725357263572735728357293573035731357323573335734357353573635737357383573935740357413574235743357443574535746357473574835749357503575135752357533575435755357563575735758357593576035761357623576335764357653576635767357683576935770357713577235773357743577535776357773577835779357803578135782357833578435785357863578735788357893579035791357923579335794357953579635797357983579935800358013580235803358043580535806358073580835809358103581135812358133581435815358163581735818358193582035821358223582335824358253582635827358283582935830358313583235833358343583535836358373583835839358403584135842358433584435845358463584735848358493585035851358523585335854358553585635857358583585935860358613586235863358643586535866358673586835869358703587135872358733587435875358763587735878358793588035881358823588335884358853588635887358883588935890358913589235893358943589535896358973589835899359003590135902359033590435905359063590735908359093591035911359123591335914359153591635917359183591935920359213592235923359243592535926359273592835929359303593135932359333593435935359363593735938359393594035941359423594335944359453594635947359483594935950359513595235953359543595535956359573595835959359603596135962359633596435965359663596735968359693597035971359723597335974359753597635977359783597935980359813598235983359843598535986359873598835989359903599135992359933599435995359963599735998359993600036001360023600336004360053600636007360083600936010360113601236013360143601536016360173601836019360203602136022360233602436025360263602736028360293603036031360323603336034360353603636037360383603936040360413604236043360443604536046360473604836049360503605136052360533605436055360563605736058360593606036061360623606336064360653606636067360683606936070360713607236073360743607536076360773607836079360803608136082360833608436085360863608736088360893609036091360923609336094360953609636097360983609936100361013610236103361043610536106361073610836109361103611136112361133611436115361163611736118361193612036121361223612336124361253612636127361283612936130361313613236133361343613536136361373613836139361403614136142361433614436145361463614736148361493615036151361523615336154361553615636157361583615936160361613616236163361643616536166361673616836169361703617136172361733617436175361763617736178361793618036181361823618336184361853618636187361883618936190361913619236193361943619536196361973619836199362003620136202362033620436205362063620736208362093621036211362123621336214362153621636217362183621936220362213622236223362243622536226362273622836229362303623136232362333623436235362363623736238362393624036241362423624336244362453624636247362483624936250362513625236253362543625536256362573625836259362603626136262362633626436265362663626736268362693627036271362723627336274362753627636277362783627936280362813628236283362843628536286362873628836289362903629136292362933629436295362963629736298362993630036301363023630336304363053630636307363083630936310363113631236313363143631536316363173631836319363203632136322363233632436325363263632736328363293633036331363323633336334363353633636337363383633936340363413634236343363443634536346363473634836349363503635136352363533635436355363563635736358363593636036361363623636336364363653636636367363683636936370363713637236373363743637536376363773637836379363803638136382363833638436385363863638736388363893639036391363923639336394363953639636397363983639936400364013640236403364043640536406364073640836409364103641136412364133641436415364163641736418364193642036421364223642336424364253642636427364283642936430364313643236433364343643536436364373643836439364403644136442364433644436445364463644736448364493645036451364523645336454364553645636457364583645936460364613646236463364643646536466364673646836469364703647136472364733647436475364763647736478364793648036481364823648336484364853648636487364883648936490364913649236493364943649536496364973649836499365003650136502365033650436505365063650736508365093651036511365123651336514365153651636517365183651936520365213652236523365243652536526365273652836529365303653136532365333653436535365363653736538365393654036541365423654336544365453654636547365483654936550365513655236553365543655536556365573655836559365603656136562365633656436565365663656736568365693657036571365723657336574365753657636577365783657936580365813658236583365843658536586365873658836589365903659136592365933659436595365963659736598365993660036601366023660336604366053660636607366083660936610366113661236613366143661536616366173661836619366203662136622366233662436625366263662736628366293663036631366323663336634366353663636637366383663936640366413664236643366443664536646366473664836649366503665136652366533665436655366563665736658366593666036661366623666336664366653666636667366683666936670366713667236673366743667536676366773667836679366803668136682366833668436685366863668736688366893669036691366923669336694366953669636697366983669936700367013670236703367043670536706367073670836709367103671136712367133671436715367163671736718367193672036721367223672336724367253672636727367283672936730367313673236733367343673536736367373673836739367403674136742367433674436745367463674736748367493675036751367523675336754367553675636757367583675936760367613676236763367643676536766367673676836769367703677136772367733677436775367763677736778367793678036781367823678336784367853678636787367883678936790367913679236793367943679536796367973679836799368003680136802368033680436805368063680736808368093681036811368123681336814368153681636817368183681936820368213682236823368243682536826368273682836829368303683136832368333683436835368363683736838368393684036841368423684336844368453684636847368483684936850368513685236853368543685536856368573685836859368603686136862368633686436865368663686736868368693687036871368723687336874368753687636877368783687936880368813688236883368843688536886368873688836889368903689136892368933689436895368963689736898368993690036901369023690336904369053690636907369083690936910369113691236913369143691536916369173691836919369203692136922369233692436925369263692736928369293693036931369323693336934369353693636937369383693936940369413694236943369443694536946369473694836949369503695136952369533695436955369563695736958369593696036961369623696336964369653696636967369683696936970369713697236973369743697536976369773697836979369803698136982369833698436985369863698736988369893699036991369923699336994369953699636997369983699937000370013700237003370043700537006370073700837009370103701137012370133701437015370163701737018370193702037021370223702337024370253702637027370283702937030370313703237033370343703537036370373703837039370403704137042370433704437045370463704737048370493705037051370523705337054370553705637057370583705937060370613706237063370643706537066370673706837069370703707137072370733707437075370763707737078370793708037081370823708337084370853708637087370883708937090370913709237093370943709537096370973709837099371003710137102371033710437105371063710737108371093711037111371123711337114371153711637117371183711937120371213712237123371243712537126371273712837129371303713137132371333713437135371363713737138371393714037141371423714337144371453714637147371483714937150371513715237153371543715537156371573715837159371603716137162371633716437165371663716737168371693717037171371723717337174371753717637177371783717937180371813718237183371843718537186371873718837189371903719137192371933719437195371963719737198371993720037201372023720337204372053720637207372083720937210372113721237213372143721537216372173721837219372203722137222372233722437225372263722737228372293723037231372323723337234372353723637237372383723937240372413724237243372443724537246372473724837249372503725137252372533725437255372563725737258372593726037261372623726337264372653726637267372683726937270372713727237273372743727537276372773727837279372803728137282372833728437285372863728737288372893729037291372923729337294372953729637297372983729937300373013730237303373043730537306373073730837309373103731137312373133731437315373163731737318373193732037321373223732337324373253732637327373283732937330373313733237333373343733537336373373733837339373403734137342373433734437345373463734737348373493735037351373523735337354373553735637357373583735937360373613736237363373643736537366373673736837369373703737137372373733737437375373763737737378373793738037381373823738337384373853738637387373883738937390373913739237393373943739537396373973739837399374003740137402374033740437405374063740737408374093741037411374123741337414374153741637417374183741937420374213742237423374243742537426374273742837429374303743137432374333743437435374363743737438374393744037441374423744337444374453744637447374483744937450374513745237453374543745537456374573745837459374603746137462374633746437465374663746737468374693747037471374723747337474374753747637477374783747937480374813748237483374843748537486374873748837489374903749137492374933749437495374963749737498374993750037501375023750337504375053750637507375083750937510375113751237513375143751537516375173751837519375203752137522375233752437525375263752737528375293753037531375323753337534375353753637537375383753937540375413754237543375443754537546375473754837549375503755137552375533755437555375563755737558375593756037561375623756337564375653756637567375683756937570375713757237573375743757537576375773757837579375803758137582375833758437585375863758737588375893759037591375923759337594375953759637597375983759937600376013760237603376043760537606376073760837609376103761137612376133761437615376163761737618376193762037621376223762337624376253762637627376283762937630376313763237633376343763537636376373763837639376403764137642376433764437645376463764737648376493765037651376523765337654376553765637657376583765937660376613766237663376643766537666376673766837669376703767137672376733767437675376763767737678376793768037681376823768337684376853768637687376883768937690376913769237693376943769537696376973769837699377003770137702377033770437705377063770737708377093771037711377123771337714377153771637717377183771937720377213772237723377243772537726377273772837729377303773137732377333773437735377363773737738377393774037741377423774337744377453774637747377483774937750377513775237753377543775537756377573775837759377603776137762377633776437765377663776737768377693777037771377723777337774377753777637777377783777937780377813778237783377843778537786377873778837789377903779137792377933779437795377963779737798377993780037801378023780337804378053780637807378083780937810378113781237813378143781537816378173781837819378203782137822378233782437825378263782737828378293783037831378323783337834378353783637837378383783937840378413784237843378443784537846378473784837849378503785137852378533785437855378563785737858378593786037861378623786337864378653786637867378683786937870378713787237873378743787537876378773787837879378803788137882378833788437885378863788737888378893789037891378923789337894378953789637897378983789937900379013790237903379043790537906379073790837909379103791137912379133791437915379163791737918379193792037921379223792337924379253792637927379283792937930379313793237933379343793537936379373793837939379403794137942379433794437945379463794737948379493795037951379523795337954379553795637957379583795937960379613796237963379643796537966379673796837969379703797137972379733797437975379763797737978379793798037981379823798337984379853798637987379883798937990379913799237993379943799537996379973799837999380003800138002380033800438005380063800738008380093801038011380123801338014380153801638017380183801938020380213802238023380243802538026380273802838029380303803138032380333803438035380363803738038380393804038041380423804338044380453804638047380483804938050380513805238053380543805538056380573805838059380603806138062380633806438065380663806738068380693807038071380723807338074380753807638077380783807938080380813808238083380843808538086380873808838089380903809138092380933809438095380963809738098380993810038101381023810338104381053810638107381083810938110381113811238113381143811538116381173811838119381203812138122381233812438125381263812738128381293813038131381323813338134381353813638137381383813938140381413814238143381443814538146381473814838149381503815138152381533815438155381563815738158381593816038161381623816338164381653816638167381683816938170381713817238173381743817538176381773817838179381803818138182381833818438185381863818738188381893819038191381923819338194381953819638197381983819938200382013820238203382043820538206382073820838209382103821138212382133821438215382163821738218382193822038221382223822338224382253822638227382283822938230382313823238233382343823538236382373823838239382403824138242382433824438245382463824738248382493825038251382523825338254382553825638257382583825938260382613826238263382643826538266382673826838269382703827138272382733827438275382763827738278382793828038281382823828338284382853828638287382883828938290382913829238293382943829538296382973829838299383003830138302383033830438305383063830738308383093831038311383123831338314383153831638317383183831938320383213832238323383243832538326383273832838329383303833138332383333833438335383363833738338383393834038341383423834338344383453834638347383483834938350383513835238353383543835538356383573835838359383603836138362383633836438365383663836738368383693837038371383723837338374383753837638377383783837938380383813838238383383843838538386383873838838389383903839138392383933839438395383963839738398383993840038401384023840338404384053840638407384083840938410384113841238413384143841538416384173841838419384203842138422384233842438425384263842738428384293843038431384323843338434384353843638437384383843938440384413844238443384443844538446384473844838449384503845138452384533845438455384563845738458384593846038461384623846338464384653846638467384683846938470384713847238473384743847538476384773847838479384803848138482384833848438485384863848738488384893849038491384923849338494384953849638497384983849938500385013850238503385043850538506385073850838509385103851138512385133851438515385163851738518385193852038521385223852338524385253852638527385283852938530385313853238533385343853538536385373853838539385403854138542385433854438545385463854738548385493855038551385523855338554385553855638557385583855938560385613856238563385643856538566385673856838569385703857138572385733857438575385763857738578385793858038581385823858338584385853858638587385883858938590385913859238593385943859538596385973859838599386003860138602386033860438605386063860738608386093861038611386123861338614386153861638617386183861938620386213862238623386243862538626386273862838629386303863138632386333863438635386363863738638386393864038641386423864338644386453864638647386483864938650386513865238653386543865538656386573865838659386603866138662386633866438665386663866738668386693867038671386723867338674386753867638677386783867938680386813868238683386843868538686386873868838689386903869138692386933869438695386963869738698386993870038701387023870338704387053870638707387083870938710387113871238713387143871538716387173871838719387203872138722387233872438725387263872738728387293873038731387323873338734387353873638737387383873938740387413874238743387443874538746387473874838749387503875138752387533875438755387563875738758387593876038761387623876338764387653876638767387683876938770387713877238773387743877538776387773877838779387803878138782387833878438785387863878738788387893879038791387923879338794387953879638797387983879938800388013880238803388043880538806388073880838809388103881138812388133881438815388163881738818388193882038821388223882338824388253882638827388283882938830388313883238833388343883538836388373883838839388403884138842388433884438845388463884738848388493885038851388523885338854388553885638857388583885938860388613886238863388643886538866388673886838869388703887138872388733887438875388763887738878388793888038881388823888338884388853888638887388883888938890388913889238893388943889538896388973889838899389003890138902389033890438905389063890738908389093891038911389123891338914389153891638917389183891938920389213892238923389243892538926389273892838929389303893138932389333893438935389363893738938389393894038941389423894338944389453894638947389483894938950389513895238953389543895538956389573895838959389603896138962389633896438965389663896738968389693897038971389723897338974389753897638977389783897938980389813898238983389843898538986389873898838989389903899138992389933899438995389963899738998389993900039001390023900339004390053900639007390083900939010390113901239013390143901539016390173901839019390203902139022390233902439025390263902739028390293903039031390323903339034390353903639037390383903939040390413904239043390443904539046390473904839049390503905139052390533905439055390563905739058390593906039061390623906339064390653906639067390683906939070390713907239073390743907539076390773907839079390803908139082390833908439085390863908739088390893909039091390923909339094390953909639097390983909939100391013910239103391043910539106391073910839109391103911139112391133911439115391163911739118391193912039121391223912339124391253912639127391283912939130391313913239133391343913539136391373913839139391403914139142391433914439145391463914739148391493915039151391523915339154391553915639157391583915939160391613916239163391643916539166391673916839169391703917139172391733917439175391763917739178391793918039181391823918339184391853918639187391883918939190391913919239193391943919539196391973919839199392003920139202392033920439205392063920739208392093921039211392123921339214392153921639217392183921939220392213922239223392243922539226392273922839229392303923139232392333923439235392363923739238392393924039241392423924339244392453924639247392483924939250392513925239253392543925539256392573925839259392603926139262392633926439265392663926739268392693927039271392723927339274392753927639277392783927939280392813928239283392843928539286392873928839289392903929139292392933929439295392963929739298392993930039301393023930339304393053930639307393083930939310393113931239313393143931539316393173931839319393203932139322393233932439325393263932739328393293933039331393323933339334393353933639337393383933939340393413934239343393443934539346393473934839349393503935139352393533935439355393563935739358393593936039361393623936339364393653936639367393683936939370393713937239373393743937539376393773937839379393803938139382393833938439385393863938739388393893939039391393923939339394393953939639397393983939939400394013940239403394043940539406394073940839409394103941139412394133941439415394163941739418394193942039421394223942339424394253942639427394283942939430394313943239433394343943539436394373943839439394403944139442394433944439445394463944739448394493945039451394523945339454394553945639457394583945939460394613946239463394643946539466394673946839469394703947139472394733947439475394763947739478394793948039481394823948339484394853948639487394883948939490394913949239493394943949539496394973949839499395003950139502395033950439505395063950739508395093951039511395123951339514395153951639517395183951939520395213952239523395243952539526395273952839529395303953139532395333953439535395363953739538395393954039541395423954339544395453954639547395483954939550395513955239553395543955539556395573955839559395603956139562395633956439565395663956739568395693957039571395723957339574395753957639577395783957939580395813958239583395843958539586395873958839589395903959139592395933959439595395963959739598395993960039601396023960339604396053960639607396083960939610396113961239613396143961539616396173961839619396203962139622396233962439625396263962739628396293963039631396323963339634396353963639637396383963939640396413964239643396443964539646396473964839649396503965139652396533965439655396563965739658396593966039661396623966339664396653966639667396683966939670396713967239673396743967539676396773967839679396803968139682396833968439685396863968739688396893969039691396923969339694396953969639697396983969939700397013970239703397043970539706397073970839709397103971139712397133971439715397163971739718397193972039721397223972339724397253972639727397283972939730397313973239733397343973539736397373973839739397403974139742397433974439745397463974739748397493975039751397523975339754397553975639757397583975939760397613976239763397643976539766397673976839769397703977139772397733977439775397763977739778397793978039781397823978339784397853978639787397883978939790397913979239793397943979539796397973979839799398003980139802398033980439805398063980739808398093981039811398123981339814398153981639817398183981939820398213982239823398243982539826398273982839829398303983139832398333983439835398363983739838398393984039841398423984339844398453984639847398483984939850398513985239853398543985539856398573985839859398603986139862398633986439865398663986739868398693987039871398723987339874398753987639877398783987939880398813988239883398843988539886398873988839889398903989139892398933989439895398963989739898398993990039901399023990339904399053990639907399083990939910399113991239913399143991539916399173991839919399203992139922399233992439925399263992739928399293993039931399323993339934399353993639937399383993939940399413994239943399443994539946399473994839949399503995139952399533995439955399563995739958399593996039961399623996339964399653996639967399683996939970399713997239973399743997539976399773997839979399803998139982399833998439985399863998739988399893999039991399923999339994399953999639997399983999940000400014000240003400044000540006400074000840009400104001140012400134001440015400164001740018400194002040021400224002340024400254002640027400284002940030400314003240033400344003540036400374003840039400404004140042400434004440045400464004740048400494005040051400524005340054400554005640057400584005940060400614006240063400644006540066400674006840069400704007140072400734007440075400764007740078400794008040081400824008340084400854008640087400884008940090400914009240093400944009540096400974009840099401004010140102401034010440105401064010740108401094011040111401124011340114401154011640117401184011940120401214012240123401244012540126401274012840129401304013140132401334013440135401364013740138401394014040141401424014340144401454014640147401484014940150401514015240153401544015540156401574015840159401604016140162401634016440165401664016740168401694017040171401724017340174401754017640177401784017940180401814018240183401844018540186401874018840189401904019140192401934019440195401964019740198401994020040201402024020340204402054020640207402084020940210402114021240213402144021540216402174021840219402204022140222402234022440225402264022740228402294023040231402324023340234402354023640237402384023940240402414024240243402444024540246402474024840249402504025140252402534025440255402564025740258402594026040261402624026340264402654026640267402684026940270402714027240273402744027540276402774027840279402804028140282402834028440285402864028740288402894029040291402924029340294402954029640297402984029940300403014030240303403044030540306403074030840309403104031140312403134031440315403164031740318403194032040321403224032340324403254032640327403284032940330403314033240333403344033540336403374033840339403404034140342403434034440345403464034740348403494035040351403524035340354403554035640357403584035940360403614036240363403644036540366403674036840369403704037140372403734037440375403764037740378403794038040381403824038340384403854038640387403884038940390403914039240393403944039540396403974039840399404004040140402404034040440405404064040740408404094041040411404124041340414404154041640417404184041940420404214042240423404244042540426404274042840429404304043140432404334043440435404364043740438404394044040441404424044340444404454044640447404484044940450404514045240453404544045540456404574045840459404604046140462404634046440465404664046740468404694047040471404724047340474404754047640477404784047940480404814048240483404844048540486404874048840489404904049140492404934049440495404964049740498404994050040501405024050340504405054050640507405084050940510405114051240513405144051540516405174051840519405204052140522405234052440525405264052740528405294053040531405324053340534405354053640537405384053940540405414054240543405444054540546405474054840549405504055140552405534055440555405564055740558405594056040561405624056340564405654056640567405684056940570405714057240573405744057540576405774057840579405804058140582405834058440585405864058740588405894059040591405924059340594405954059640597405984059940600406014060240603406044060540606406074060840609406104061140612406134061440615406164061740618406194062040621406224062340624406254062640627406284062940630406314063240633406344063540636406374063840639406404064140642406434064440645406464064740648406494065040651406524065340654406554065640657406584065940660406614066240663406644066540666406674066840669406704067140672406734067440675406764067740678406794068040681406824068340684406854068640687406884068940690406914069240693406944069540696406974069840699407004070140702407034070440705407064070740708407094071040711407124071340714407154071640717407184071940720407214072240723407244072540726407274072840729407304073140732407334073440735407364073740738407394074040741407424074340744407454074640747407484074940750407514075240753407544075540756407574075840759407604076140762407634076440765407664076740768407694077040771407724077340774407754077640777407784077940780407814078240783407844078540786407874078840789407904079140792407934079440795407964079740798407994080040801408024080340804408054080640807408084080940810408114081240813408144081540816408174081840819408204082140822408234082440825408264082740828408294083040831408324083340834408354083640837408384083940840408414084240843408444084540846408474084840849408504085140852408534085440855408564085740858408594086040861408624086340864408654086640867408684086940870408714087240873408744087540876408774087840879408804088140882408834088440885408864088740888408894089040891408924089340894408954089640897408984089940900409014090240903409044090540906409074090840909409104091140912409134091440915409164091740918409194092040921409224092340924409254092640927409284092940930409314093240933409344093540936409374093840939409404094140942409434094440945409464094740948409494095040951409524095340954409554095640957409584095940960409614096240963409644096540966409674096840969409704097140972409734097440975409764097740978409794098040981409824098340984409854098640987409884098940990409914099240993409944099540996409974099840999410004100141002410034100441005410064100741008410094101041011410124101341014410154101641017410184101941020410214102241023410244102541026410274102841029410304103141032410334103441035410364103741038410394104041041410424104341044410454104641047410484104941050410514105241053410544105541056410574105841059410604106141062410634106441065410664106741068410694107041071410724107341074410754107641077410784107941080410814108241083410844108541086410874108841089410904109141092410934109441095410964109741098410994110041101411024110341104411054110641107411084110941110411114111241113411144111541116411174111841119411204112141122411234112441125411264112741128411294113041131411324113341134411354113641137411384113941140411414114241143411444114541146411474114841149411504115141152411534115441155411564115741158411594116041161411624116341164411654116641167411684116941170411714117241173411744117541176411774117841179411804118141182411834118441185411864118741188411894119041191411924119341194411954119641197411984119941200412014120241203412044120541206412074120841209412104121141212412134121441215412164121741218412194122041221412224122341224412254122641227412284122941230412314123241233412344123541236412374123841239412404124141242412434124441245412464124741248412494125041251412524125341254412554125641257412584125941260412614126241263412644126541266412674126841269412704127141272412734127441275412764127741278412794128041281412824128341284412854128641287412884128941290412914129241293412944129541296412974129841299413004130141302413034130441305413064130741308413094131041311413124131341314413154131641317413184131941320413214132241323413244132541326413274132841329413304133141332413334133441335413364133741338413394134041341413424134341344413454134641347413484134941350413514135241353413544135541356413574135841359413604136141362413634136441365413664136741368413694137041371413724137341374413754137641377413784137941380413814138241383413844138541386413874138841389413904139141392413934139441395413964139741398413994140041401414024140341404414054140641407414084140941410414114141241413414144141541416414174141841419414204142141422414234142441425414264142741428414294143041431414324143341434414354143641437414384143941440414414144241443414444144541446414474144841449414504145141452414534145441455414564145741458414594146041461414624146341464414654146641467414684146941470414714147241473414744147541476414774147841479414804148141482414834148441485414864148741488414894149041491414924149341494414954149641497414984149941500415014150241503415044150541506415074150841509415104151141512415134151441515415164151741518415194152041521415224152341524415254152641527415284152941530415314153241533415344153541536415374153841539415404154141542415434154441545415464154741548415494155041551415524155341554415554155641557415584155941560415614156241563415644156541566415674156841569415704157141572415734157441575415764157741578415794158041581415824158341584415854158641587415884158941590415914159241593415944159541596415974159841599416004160141602416034160441605416064160741608416094161041611416124161341614416154161641617416184161941620416214162241623416244162541626416274162841629416304163141632416334163441635416364163741638416394164041641416424164341644416454164641647416484164941650416514165241653416544165541656416574165841659416604166141662416634166441665416664166741668416694167041671416724167341674416754167641677416784167941680416814168241683416844168541686416874168841689416904169141692416934169441695416964169741698416994170041701417024170341704417054170641707417084170941710417114171241713417144171541716417174171841719417204172141722417234172441725417264172741728417294173041731417324173341734417354173641737417384173941740417414174241743417444174541746417474174841749417504175141752417534175441755417564175741758417594176041761417624176341764417654176641767417684176941770417714177241773417744177541776417774177841779417804178141782417834178441785417864178741788417894179041791417924179341794417954179641797417984179941800418014180241803418044180541806418074180841809418104181141812418134181441815418164181741818418194182041821418224182341824418254182641827418284182941830418314183241833418344183541836418374183841839418404184141842418434184441845418464184741848418494185041851418524185341854418554185641857418584185941860418614186241863418644186541866418674186841869418704187141872418734187441875418764187741878418794188041881418824188341884418854188641887418884188941890418914189241893418944189541896418974189841899419004190141902419034190441905419064190741908419094191041911419124191341914419154191641917419184191941920419214192241923419244192541926419274192841929419304193141932419334193441935419364193741938419394194041941419424194341944419454194641947419484194941950419514195241953419544195541956419574195841959419604196141962419634196441965419664196741968419694197041971419724197341974419754197641977419784197941980419814198241983419844198541986419874198841989419904199141992419934199441995419964199741998419994200042001420024200342004420054200642007420084200942010420114201242013420144201542016420174201842019420204202142022420234202442025420264202742028420294203042031420324203342034420354203642037420384203942040420414204242043420444204542046420474204842049420504205142052420534205442055420564205742058420594206042061420624206342064420654206642067420684206942070420714207242073420744207542076420774207842079420804208142082420834208442085420864208742088420894209042091420924209342094420954209642097420984209942100421014210242103421044210542106421074210842109421104211142112421134211442115421164211742118421194212042121421224212342124421254212642127421284212942130421314213242133421344213542136421374213842139421404214142142421434214442145421464214742148421494215042151421524215342154421554215642157421584215942160421614216242163421644216542166421674216842169421704217142172421734217442175421764217742178421794218042181421824218342184421854218642187421884218942190421914219242193421944219542196421974219842199422004220142202422034220442205422064220742208422094221042211422124221342214422154221642217422184221942220422214222242223422244222542226422274222842229422304223142232422334223442235422364223742238422394224042241422424224342244422454224642247422484224942250422514225242253422544225542256422574225842259422604226142262422634226442265422664226742268422694227042271422724227342274422754227642277422784227942280422814228242283422844228542286422874228842289422904229142292422934229442295422964229742298422994230042301423024230342304423054230642307423084230942310423114231242313423144231542316423174231842319423204232142322423234232442325423264232742328423294233042331423324233342334423354233642337423384233942340423414234242343423444234542346423474234842349423504235142352423534235442355423564235742358423594236042361423624236342364423654236642367423684236942370423714237242373423744237542376423774237842379423804238142382423834238442385423864238742388423894239042391423924239342394423954239642397423984239942400424014240242403424044240542406424074240842409424104241142412424134241442415424164241742418424194242042421424224242342424424254242642427424284242942430424314243242433424344243542436424374243842439424404244142442424434244442445424464244742448424494245042451424524245342454424554245642457424584245942460424614246242463424644246542466424674246842469424704247142472424734247442475424764247742478424794248042481424824248342484424854248642487424884248942490424914249242493424944249542496424974249842499425004250142502425034250442505425064250742508425094251042511425124251342514425154251642517425184251942520425214252242523425244252542526425274252842529425304253142532425334253442535425364253742538425394254042541425424254342544425454254642547425484254942550425514255242553425544255542556425574255842559425604256142562425634256442565425664256742568425694257042571425724257342574425754257642577425784257942580425814258242583425844258542586425874258842589425904259142592425934259442595425964259742598425994260042601426024260342604426054260642607426084260942610426114261242613426144261542616426174261842619426204262142622426234262442625426264262742628426294263042631426324263342634426354263642637426384263942640426414264242643426444264542646426474264842649426504265142652426534265442655426564265742658426594266042661426624266342664426654266642667426684266942670426714267242673426744267542676426774267842679426804268142682426834268442685426864268742688426894269042691426924269342694426954269642697426984269942700427014270242703427044270542706427074270842709427104271142712427134271442715427164271742718427194272042721427224272342724427254272642727427284272942730427314273242733427344273542736427374273842739427404274142742427434274442745427464274742748427494275042751427524275342754427554275642757427584275942760427614276242763427644276542766427674276842769427704277142772427734277442775427764277742778427794278042781427824278342784427854278642787427884278942790427914279242793427944279542796427974279842799428004280142802428034280442805428064280742808428094281042811428124281342814428154281642817428184281942820428214282242823428244282542826428274282842829428304283142832428334283442835428364283742838428394284042841428424284342844428454284642847428484284942850428514285242853428544285542856428574285842859428604286142862428634286442865428664286742868428694287042871428724287342874428754287642877428784287942880428814288242883428844288542886428874288842889428904289142892428934289442895428964289742898428994290042901429024290342904429054290642907429084290942910429114291242913429144291542916429174291842919429204292142922429234292442925429264292742928429294293042931429324293342934429354293642937429384293942940429414294242943429444294542946429474294842949429504295142952429534295442955429564295742958429594296042961429624296342964429654296642967429684296942970429714297242973429744297542976429774297842979429804298142982429834298442985429864298742988429894299042991429924299342994429954299642997429984299943000430014300243003430044300543006430074300843009430104301143012430134301443015430164301743018430194302043021430224302343024430254302643027430284302943030430314303243033430344303543036430374303843039430404304143042430434304443045430464304743048430494305043051430524305343054430554305643057430584305943060430614306243063430644306543066430674306843069430704307143072430734307443075430764307743078430794308043081430824308343084430854308643087430884308943090430914309243093430944309543096430974309843099431004310143102431034310443105431064310743108431094311043111431124311343114431154311643117431184311943120431214312243123431244312543126431274312843129431304313143132431334313443135431364313743138431394314043141431424314343144431454314643147431484314943150431514315243153431544315543156431574315843159431604316143162431634316443165431664316743168431694317043171431724317343174431754317643177431784317943180431814318243183431844318543186431874318843189431904319143192431934319443195431964319743198431994320043201432024320343204432054320643207432084320943210432114321243213432144321543216432174321843219432204322143222432234322443225432264322743228432294323043231432324323343234432354323643237432384323943240432414324243243432444324543246432474324843249432504325143252432534325443255432564325743258432594326043261432624326343264432654326643267432684326943270432714327243273432744327543276432774327843279432804328143282432834328443285432864328743288432894329043291432924329343294432954329643297432984329943300433014330243303433044330543306433074330843309433104331143312433134331443315433164331743318433194332043321433224332343324433254332643327433284332943330433314333243333433344333543336433374333843339433404334143342433434334443345433464334743348433494335043351433524335343354433554335643357433584335943360433614336243363433644336543366433674336843369433704337143372433734337443375433764337743378433794338043381433824338343384433854338643387433884338943390433914339243393433944339543396433974339843399434004340143402434034340443405434064340743408434094341043411434124341343414434154341643417434184341943420434214342243423434244342543426434274342843429434304343143432434334343443435434364343743438434394344043441434424344343444434454344643447434484344943450434514345243453434544345543456434574345843459434604346143462434634346443465434664346743468434694347043471434724347343474434754347643477434784347943480434814348243483434844348543486434874348843489434904349143492434934349443495434964349743498434994350043501435024350343504435054350643507435084350943510435114351243513435144351543516435174351843519435204352143522435234352443525435264352743528435294353043531435324353343534435354353643537435384353943540435414354243543435444354543546435474354843549435504355143552435534355443555435564355743558435594356043561435624356343564435654356643567435684356943570435714357243573435744357543576435774357843579435804358143582435834358443585435864358743588435894359043591435924359343594435954359643597435984359943600436014360243603436044360543606436074360843609436104361143612436134361443615436164361743618436194362043621436224362343624436254362643627436284362943630436314363243633436344363543636436374363843639436404364143642436434364443645436464364743648436494365043651436524365343654436554365643657436584365943660436614366243663436644366543666436674366843669436704367143672436734367443675436764367743678436794368043681436824368343684436854368643687436884368943690436914369243693436944369543696436974369843699437004370143702437034370443705437064370743708437094371043711437124371343714437154371643717437184371943720437214372243723437244372543726437274372843729437304373143732437334373443735437364373743738437394374043741437424374343744437454374643747437484374943750437514375243753437544375543756437574375843759437604376143762437634376443765437664376743768437694377043771437724377343774437754377643777437784377943780437814378243783437844378543786437874378843789437904379143792437934379443795437964379743798437994380043801438024380343804438054380643807438084380943810438114381243813438144381543816438174381843819438204382143822438234382443825438264382743828438294383043831438324383343834438354383643837438384383943840438414384243843438444384543846438474384843849438504385143852438534385443855438564385743858438594386043861438624386343864438654386643867438684386943870438714387243873438744387543876438774387843879438804388143882438834388443885438864388743888438894389043891438924389343894438954389643897438984389943900439014390243903439044390543906439074390843909439104391143912439134391443915439164391743918439194392043921439224392343924439254392643927439284392943930439314393243933439344393543936439374393843939439404394143942439434394443945439464394743948439494395043951439524395343954439554395643957439584395943960439614396243963439644396543966439674396843969439704397143972439734397443975439764397743978439794398043981439824398343984439854398643987439884398943990439914399243993439944399543996439974399843999440004400144002440034400444005440064400744008440094401044011440124401344014440154401644017440184401944020440214402244023440244402544026440274402844029440304403144032440334403444035440364403744038440394404044041440424404344044440454404644047440484404944050440514405244053440544405544056440574405844059440604406144062440634406444065440664406744068440694407044071440724407344074440754407644077440784407944080440814408244083440844408544086440874408844089440904409144092440934409444095440964409744098440994410044101441024410344104441054410644107441084410944110441114411244113441144411544116441174411844119441204412144122441234412444125441264412744128441294413044131441324413344134441354413644137441384413944140441414414244143441444414544146441474414844149441504415144152441534415444155441564415744158441594416044161441624416344164441654416644167441684416944170441714417244173441744417544176441774417844179441804418144182441834418444185441864418744188441894419044191441924419344194441954419644197441984419944200442014420244203442044420544206442074420844209442104421144212442134421444215442164421744218442194422044221442224422344224442254422644227442284422944230442314423244233442344423544236442374423844239442404424144242442434424444245442464424744248442494425044251442524425344254442554425644257442584425944260442614426244263442644426544266442674426844269442704427144272442734427444275442764427744278442794428044281442824428344284442854428644287442884428944290442914429244293442944429544296442974429844299443004430144302443034430444305443064430744308443094431044311443124431344314443154431644317443184431944320443214432244323443244432544326443274432844329443304433144332443334433444335443364433744338443394434044341443424434344344443454434644347443484434944350443514435244353443544435544356443574435844359443604436144362443634436444365443664436744368443694437044371443724437344374443754437644377443784437944380443814438244383443844438544386443874438844389443904439144392443934439444395443964439744398443994440044401444024440344404444054440644407444084440944410444114441244413444144441544416444174441844419444204442144422444234442444425444264442744428444294443044431444324443344434444354443644437444384443944440444414444244443444444444544446444474444844449444504445144452444534445444455444564445744458444594446044461444624446344464444654446644467444684446944470444714447244473444744447544476444774447844479444804448144482444834448444485444864448744488444894449044491444924449344494444954449644497444984449944500445014450244503445044450544506445074450844509445104451144512445134451444515445164451744518445194452044521445224452344524445254452644527445284452944530445314453244533445344453544536445374453844539445404454144542445434454444545445464454744548445494455044551445524455344554445554455644557445584455944560445614456244563445644456544566445674456844569445704457144572445734457444575445764457744578445794458044581445824458344584445854458644587445884458944590445914459244593445944459544596445974459844599446004460144602446034460444605446064460744608446094461044611446124461344614446154461644617446184461944620446214462244623446244462544626446274462844629446304463144632446334463444635446364463744638446394464044641446424464344644446454464644647446484464944650446514465244653446544465544656446574465844659446604466144662446634466444665446664466744668446694467044671446724467344674446754467644677446784467944680446814468244683446844468544686446874468844689446904469144692446934469444695446964469744698446994470044701447024470344704447054470644707447084470944710447114471244713447144471544716447174471844719447204472144722447234472444725447264472744728447294473044731447324473344734447354473644737447384473944740447414474244743447444474544746447474474844749447504475144752447534475444755447564475744758447594476044761447624476344764447654476644767447684476944770447714477244773447744477544776447774477844779447804478144782447834478444785447864478744788447894479044791447924479344794447954479644797447984479944800448014480244803448044480544806448074480844809448104481144812448134481444815448164481744818448194482044821448224482344824448254482644827448284482944830448314483244833448344483544836448374483844839448404484144842448434484444845448464484744848448494485044851448524485344854448554485644857448584485944860448614486244863448644486544866448674486844869448704487144872448734487444875448764487744878448794488044881448824488344884448854488644887448884488944890448914489244893448944489544896448974489844899449004490144902449034490444905449064490744908449094491044911449124491344914449154491644917449184491944920449214492244923449244492544926449274492844929449304493144932449334493444935449364493744938449394494044941449424494344944449454494644947449484494944950449514495244953449544495544956449574495844959449604496144962449634496444965449664496744968449694497044971449724497344974449754497644977449784497944980449814498244983449844498544986449874498844989449904499144992449934499444995449964499744998449994500045001450024500345004450054500645007450084500945010450114501245013450144501545016450174501845019450204502145022450234502445025450264502745028450294503045031450324503345034450354503645037450384503945040450414504245043450444504545046450474504845049450504505145052450534505445055450564505745058450594506045061450624506345064450654506645067450684506945070450714507245073450744507545076450774507845079450804508145082450834508445085450864508745088450894509045091450924509345094450954509645097450984509945100451014510245103451044510545106451074510845109451104511145112451134511445115451164511745118451194512045121451224512345124451254512645127451284512945130451314513245133451344513545136451374513845139451404514145142451434514445145451464514745148451494515045151451524515345154451554515645157451584515945160451614516245163451644516545166451674516845169451704517145172451734517445175451764517745178451794518045181451824518345184451854518645187451884518945190451914519245193451944519545196451974519845199452004520145202452034520445205452064520745208452094521045211452124521345214452154521645217452184521945220452214522245223452244522545226452274522845229452304523145232452334523445235452364523745238452394524045241452424524345244452454524645247452484524945250452514525245253452544525545256452574525845259452604526145262452634526445265452664526745268452694527045271452724527345274452754527645277452784527945280452814528245283452844528545286452874528845289452904529145292452934529445295452964529745298452994530045301453024530345304453054530645307453084530945310453114531245313453144531545316453174531845319453204532145322453234532445325453264532745328453294533045331453324533345334453354533645337453384533945340453414534245343453444534545346453474534845349453504535145352453534535445355453564535745358453594536045361453624536345364453654536645367453684536945370453714537245373453744537545376453774537845379453804538145382453834538445385453864538745388453894539045391453924539345394453954539645397453984539945400454014540245403454044540545406454074540845409454104541145412454134541445415454164541745418454194542045421454224542345424454254542645427454284542945430454314543245433454344543545436454374543845439454404544145442454434544445445454464544745448454494545045451454524545345454454554545645457454584545945460454614546245463454644546545466454674546845469454704547145472454734547445475454764547745478454794548045481454824548345484454854548645487454884548945490454914549245493454944549545496454974549845499455004550145502455034550445505455064550745508455094551045511455124551345514455154551645517455184551945520455214552245523455244552545526455274552845529455304553145532455334553445535455364553745538455394554045541455424554345544455454554645547455484554945550455514555245553455544555545556455574555845559455604556145562455634556445565455664556745568455694557045571455724557345574455754557645577455784557945580455814558245583455844558545586455874558845589455904559145592455934559445595455964559745598455994560045601456024560345604456054560645607456084560945610456114561245613456144561545616456174561845619456204562145622456234562445625456264562745628456294563045631456324563345634456354563645637456384563945640456414564245643456444564545646456474564845649456504565145652456534565445655456564565745658456594566045661456624566345664456654566645667456684566945670456714567245673456744567545676456774567845679456804568145682456834568445685456864568745688456894569045691456924569345694456954569645697456984569945700457014570245703457044570545706457074570845709457104571145712457134571445715457164571745718457194572045721457224572345724457254572645727457284572945730457314573245733457344573545736457374573845739457404574145742457434574445745457464574745748457494575045751457524575345754457554575645757457584575945760457614576245763457644576545766457674576845769457704577145772457734577445775457764577745778457794578045781457824578345784457854578645787457884578945790457914579245793457944579545796457974579845799458004580145802458034580445805458064580745808458094581045811458124581345814458154581645817458184581945820458214582245823458244582545826458274582845829458304583145832458334583445835458364583745838458394584045841458424584345844458454584645847458484584945850458514585245853458544585545856458574585845859458604586145862458634586445865458664586745868458694587045871458724587345874458754587645877458784587945880458814588245883458844588545886458874588845889458904589145892458934589445895458964589745898458994590045901459024590345904459054590645907459084590945910459114591245913459144591545916459174591845919459204592145922459234592445925459264592745928459294593045931459324593345934459354593645937459384593945940459414594245943459444594545946459474594845949459504595145952459534595445955459564595745958459594596045961459624596345964459654596645967459684596945970459714597245973459744597545976459774597845979459804598145982459834598445985459864598745988459894599045991459924599345994459954599645997459984599946000460014600246003460044600546006460074600846009460104601146012460134601446015460164601746018460194602046021460224602346024460254602646027460284602946030460314603246033460344603546036460374603846039460404604146042460434604446045460464604746048460494605046051460524605346054460554605646057460584605946060460614606246063460644606546066460674606846069460704607146072460734607446075460764607746078460794608046081460824608346084460854608646087460884608946090460914609246093460944609546096460974609846099461004610146102461034610446105461064610746108461094611046111461124611346114461154611646117461184611946120461214612246123461244612546126461274612846129461304613146132461334613446135461364613746138461394614046141461424614346144461454614646147461484614946150461514615246153461544615546156461574615846159461604616146162461634616446165461664616746168461694617046171461724617346174461754617646177461784617946180461814618246183461844618546186461874618846189461904619146192461934619446195461964619746198461994620046201462024620346204462054620646207462084620946210462114621246213462144621546216462174621846219462204622146222462234622446225462264622746228462294623046231462324623346234462354623646237462384623946240462414624246243462444624546246462474624846249462504625146252462534625446255462564625746258462594626046261462624626346264462654626646267462684626946270462714627246273462744627546276462774627846279462804628146282462834628446285462864628746288462894629046291462924629346294462954629646297462984629946300463014630246303463044630546306463074630846309463104631146312463134631446315463164631746318463194632046321463224632346324463254632646327463284632946330463314633246333463344633546336463374633846339463404634146342463434634446345463464634746348463494635046351463524635346354463554635646357463584635946360463614636246363463644636546366463674636846369463704637146372463734637446375463764637746378463794638046381463824638346384463854638646387463884638946390463914639246393463944639546396463974639846399464004640146402464034640446405464064640746408464094641046411464124641346414464154641646417464184641946420464214642246423464244642546426464274642846429464304643146432464334643446435464364643746438464394644046441464424644346444464454644646447464484644946450464514645246453464544645546456464574645846459464604646146462464634646446465464664646746468464694647046471464724647346474464754647646477464784647946480464814648246483464844648546486464874648846489464904649146492464934649446495464964649746498464994650046501465024650346504465054650646507465084650946510465114651246513465144651546516465174651846519465204652146522465234652446525465264652746528465294653046531465324653346534465354653646537465384653946540465414654246543465444654546546465474654846549465504655146552465534655446555465564655746558465594656046561465624656346564465654656646567465684656946570465714657246573465744657546576465774657846579465804658146582465834658446585465864658746588465894659046591465924659346594465954659646597465984659946600466014660246603466044660546606466074660846609466104661146612466134661446615466164661746618466194662046621466224662346624466254662646627466284662946630466314663246633466344663546636466374663846639466404664146642466434664446645466464664746648466494665046651466524665346654466554665646657466584665946660466614666246663466644666546666466674666846669466704667146672466734667446675466764667746678466794668046681466824668346684466854668646687466884668946690466914669246693466944669546696466974669846699467004670146702467034670446705467064670746708467094671046711467124671346714467154671646717467184671946720467214672246723467244672546726467274672846729467304673146732467334673446735467364673746738467394674046741467424674346744467454674646747467484674946750467514675246753467544675546756467574675846759467604676146762467634676446765467664676746768467694677046771467724677346774467754677646777467784677946780467814678246783467844678546786467874678846789467904679146792467934679446795467964679746798467994680046801468024680346804468054680646807468084680946810468114681246813468144681546816468174681846819468204682146822468234682446825468264682746828468294683046831468324683346834468354683646837468384683946840468414684246843468444684546846468474684846849468504685146852468534685446855468564685746858468594686046861468624686346864468654686646867468684686946870468714687246873468744687546876468774687846879468804688146882468834688446885468864688746888468894689046891468924689346894468954689646897468984689946900469014690246903469044690546906469074690846909469104691146912469134691446915469164691746918469194692046921469224692346924469254692646927469284692946930469314693246933469344693546936469374693846939469404694146942469434694446945469464694746948469494695046951469524695346954469554695646957469584695946960469614696246963469644696546966469674696846969469704697146972469734697446975469764697746978469794698046981469824698346984469854698646987469884698946990469914699246993469944699546996469974699846999470004700147002470034700447005470064700747008470094701047011470124701347014470154701647017470184701947020470214702247023470244702547026470274702847029470304703147032470334703447035470364703747038470394704047041470424704347044470454704647047470484704947050470514705247053470544705547056470574705847059470604706147062470634706447065470664706747068470694707047071470724707347074470754707647077470784707947080470814708247083470844708547086470874708847089470904709147092470934709447095470964709747098470994710047101471024710347104471054710647107471084710947110471114711247113471144711547116471174711847119471204712147122471234712447125471264712747128471294713047131471324713347134471354713647137471384713947140471414714247143471444714547146471474714847149471504715147152471534715447155471564715747158471594716047161471624716347164471654716647167471684716947170471714717247173471744717547176471774717847179471804718147182471834718447185471864718747188471894719047191471924719347194471954719647197471984719947200472014720247203472044720547206472074720847209472104721147212472134721447215472164721747218472194722047221472224722347224472254722647227472284722947230472314723247233472344723547236472374723847239472404724147242472434724447245472464724747248472494725047251472524725347254472554725647257472584725947260472614726247263472644726547266472674726847269472704727147272472734727447275472764727747278472794728047281472824728347284472854728647287472884728947290472914729247293472944729547296472974729847299473004730147302473034730447305473064730747308473094731047311473124731347314473154731647317473184731947320473214732247323473244732547326473274732847329473304733147332473334733447335473364733747338473394734047341473424734347344473454734647347473484734947350473514735247353473544735547356473574735847359473604736147362473634736447365473664736747368473694737047371473724737347374473754737647377473784737947380473814738247383473844738547386473874738847389473904739147392473934739447395473964739747398473994740047401474024740347404474054740647407474084740947410474114741247413474144741547416474174741847419474204742147422474234742447425474264742747428474294743047431474324743347434474354743647437474384743947440474414744247443474444744547446474474744847449474504745147452474534745447455474564745747458474594746047461474624746347464474654746647467474684746947470474714747247473474744747547476474774747847479474804748147482474834748447485474864748747488474894749047491474924749347494474954749647497474984749947500475014750247503475044750547506475074750847509475104751147512475134751447515475164751747518475194752047521475224752347524475254752647527475284752947530475314753247533475344753547536475374753847539475404754147542475434754447545475464754747548475494755047551475524755347554475554755647557475584755947560475614756247563475644756547566475674756847569475704757147572475734757447575475764757747578475794758047581475824758347584475854758647587475884758947590475914759247593475944759547596475974759847599476004760147602476034760447605476064760747608476094761047611476124761347614476154761647617476184761947620476214762247623476244762547626476274762847629476304763147632476334763447635476364763747638476394764047641476424764347644476454764647647476484764947650476514765247653476544765547656476574765847659476604766147662476634766447665476664766747668476694767047671476724767347674476754767647677476784767947680476814768247683476844768547686476874768847689476904769147692476934769447695476964769747698476994770047701477024770347704477054770647707477084770947710477114771247713477144771547716477174771847719477204772147722477234772447725477264772747728477294773047731477324773347734477354773647737477384773947740477414774247743477444774547746477474774847749477504775147752477534775447755477564775747758477594776047761477624776347764477654776647767477684776947770477714777247773477744777547776477774777847779477804778147782477834778447785477864778747788477894779047791477924779347794477954779647797477984779947800478014780247803478044780547806478074780847809478104781147812478134781447815478164781747818478194782047821478224782347824478254782647827478284782947830478314783247833478344783547836478374783847839478404784147842478434784447845478464784747848478494785047851478524785347854478554785647857478584785947860478614786247863478644786547866478674786847869478704787147872478734787447875478764787747878478794788047881478824788347884478854788647887478884788947890478914789247893478944789547896478974789847899479004790147902479034790447905479064790747908479094791047911479124791347914479154791647917479184791947920479214792247923479244792547926479274792847929479304793147932479334793447935479364793747938479394794047941479424794347944479454794647947479484794947950479514795247953479544795547956479574795847959479604796147962479634796447965479664796747968479694797047971479724797347974479754797647977479784797947980479814798247983479844798547986479874798847989479904799147992479934799447995479964799747998479994800048001480024800348004480054800648007480084800948010480114801248013480144801548016480174801848019480204802148022480234802448025480264802748028480294803048031480324803348034480354803648037480384803948040480414804248043480444804548046480474804848049480504805148052480534805448055480564805748058480594806048061480624806348064480654806648067480684806948070480714807248073480744807548076480774807848079480804808148082480834808448085480864808748088480894809048091480924809348094480954809648097480984809948100481014810248103481044810548106481074810848109481104811148112481134811448115481164811748118481194812048121481224812348124481254812648127481284812948130481314813248133481344813548136481374813848139481404814148142481434814448145481464814748148481494815048151481524815348154481554815648157481584815948160481614816248163481644816548166481674816848169481704817148172481734817448175481764817748178481794818048181481824818348184481854818648187481884818948190481914819248193481944819548196481974819848199482004820148202482034820448205482064820748208482094821048211482124821348214482154821648217482184821948220482214822248223482244822548226482274822848229482304823148232482334823448235482364823748238482394824048241482424824348244482454824648247482484824948250482514825248253482544825548256482574825848259482604826148262482634826448265482664826748268482694827048271482724827348274482754827648277482784827948280482814828248283482844828548286482874828848289482904829148292482934829448295482964829748298482994830048301483024830348304483054830648307483084830948310483114831248313483144831548316483174831848319483204832148322483234832448325483264832748328483294833048331483324833348334483354833648337483384833948340483414834248343483444834548346483474834848349483504835148352483534835448355483564835748358483594836048361483624836348364483654836648367483684836948370483714837248373483744837548376483774837848379483804838148382483834838448385483864838748388483894839048391483924839348394483954839648397483984839948400484014840248403484044840548406484074840848409484104841148412484134841448415484164841748418484194842048421484224842348424484254842648427484284842948430484314843248433484344843548436484374843848439484404844148442484434844448445484464844748448484494845048451484524845348454484554845648457484584845948460484614846248463484644846548466484674846848469484704847148472484734847448475484764847748478484794848048481484824848348484484854848648487484884848948490484914849248493484944849548496484974849848499485004850148502485034850448505485064850748508485094851048511485124851348514485154851648517485184851948520485214852248523485244852548526485274852848529485304853148532485334853448535485364853748538485394854048541485424854348544485454854648547485484854948550485514855248553485544855548556485574855848559485604856148562485634856448565485664856748568485694857048571485724857348574485754857648577485784857948580485814858248583485844858548586485874858848589485904859148592485934859448595485964859748598485994860048601486024860348604486054860648607486084860948610486114861248613486144861548616486174861848619486204862148622486234862448625486264862748628486294863048631486324863348634486354863648637486384863948640486414864248643486444864548646486474864848649486504865148652486534865448655486564865748658486594866048661486624866348664486654866648667486684866948670486714867248673486744867548676486774867848679486804868148682486834868448685486864868748688486894869048691486924869348694486954869648697486984869948700487014870248703487044870548706487074870848709487104871148712487134871448715487164871748718487194872048721487224872348724487254872648727487284872948730487314873248733487344873548736487374873848739487404874148742487434874448745487464874748748487494875048751487524875348754487554875648757487584875948760487614876248763487644876548766487674876848769487704877148772487734877448775487764877748778487794878048781487824878348784487854878648787487884878948790487914879248793487944879548796487974879848799488004880148802488034880448805488064880748808488094881048811488124881348814488154881648817488184881948820488214882248823488244882548826488274882848829488304883148832488334883448835488364883748838488394884048841488424884348844488454884648847488484884948850488514885248853488544885548856488574885848859488604886148862488634886448865488664886748868488694887048871488724887348874488754887648877488784887948880488814888248883488844888548886488874888848889488904889148892488934889448895488964889748898488994890048901489024890348904489054890648907489084890948910489114891248913489144891548916489174891848919489204892148922489234892448925489264892748928489294893048931489324893348934489354893648937489384893948940489414894248943489444894548946489474894848949489504895148952489534895448955489564895748958489594896048961489624896348964489654896648967489684896948970489714897248973489744897548976489774897848979489804898148982489834898448985489864898748988489894899048991489924899348994489954899648997489984899949000490014900249003490044900549006490074900849009490104901149012490134901449015490164901749018490194902049021490224902349024490254902649027490284902949030490314903249033490344903549036490374903849039490404904149042490434904449045490464904749048490494905049051490524905349054490554905649057490584905949060490614906249063490644906549066490674906849069490704907149072490734907449075490764907749078490794908049081490824908349084490854908649087490884908949090490914909249093490944909549096490974909849099491004910149102491034910449105491064910749108491094911049111491124911349114491154911649117491184911949120491214912249123491244912549126491274912849129491304913149132491334913449135491364913749138491394914049141491424914349144491454914649147491484914949150491514915249153491544915549156491574915849159491604916149162491634916449165491664916749168491694917049171491724917349174491754917649177491784917949180491814918249183491844918549186491874918849189491904919149192491934919449195491964919749198491994920049201492024920349204492054920649207492084920949210492114921249213492144921549216492174921849219492204922149222492234922449225492264922749228492294923049231492324923349234492354923649237492384923949240492414924249243492444924549246492474924849249492504925149252492534925449255492564925749258492594926049261492624926349264492654926649267492684926949270492714927249273492744927549276492774927849279492804928149282492834928449285492864928749288492894929049291492924929349294492954929649297492984929949300493014930249303493044930549306493074930849309493104931149312493134931449315493164931749318493194932049321493224932349324493254932649327493284932949330493314933249333493344933549336493374933849339493404934149342493434934449345493464934749348493494935049351493524935349354493554935649357493584935949360493614936249363493644936549366493674936849369493704937149372493734937449375493764937749378493794938049381493824938349384493854938649387493884938949390493914939249393493944939549396493974939849399494004940149402494034940449405494064940749408494094941049411494124941349414494154941649417494184941949420494214942249423494244942549426494274942849429494304943149432494334943449435494364943749438494394944049441494424944349444494454944649447494484944949450494514945249453494544945549456494574945849459494604946149462494634946449465494664946749468494694947049471494724947349474494754947649477494784947949480494814948249483494844948549486494874948849489494904949149492494934949449495494964949749498494994950049501495024950349504495054950649507495084950949510495114951249513495144951549516495174951849519495204952149522495234952449525495264952749528495294953049531495324953349534495354953649537495384953949540495414954249543495444954549546495474954849549495504955149552495534955449555495564955749558495594956049561495624956349564495654956649567495684956949570495714957249573495744957549576495774957849579495804958149582495834958449585495864958749588495894959049591495924959349594495954959649597495984959949600496014960249603496044960549606496074960849609496104961149612496134961449615496164961749618496194962049621496224962349624496254962649627496284962949630496314963249633496344963549636496374963849639496404964149642496434964449645496464964749648496494965049651496524965349654496554965649657496584965949660496614966249663496644966549666496674966849669496704967149672496734967449675496764967749678496794968049681496824968349684496854968649687496884968949690496914969249693496944969549696496974969849699497004970149702497034970449705497064970749708497094971049711497124971349714497154971649717497184971949720497214972249723497244972549726497274972849729497304973149732497334973449735497364973749738497394974049741497424974349744497454974649747497484974949750497514975249753497544975549756497574975849759497604976149762497634976449765497664976749768497694977049771497724977349774497754977649777497784977949780497814978249783497844978549786497874978849789497904979149792497934979449795497964979749798497994980049801498024980349804498054980649807498084980949810498114981249813498144981549816498174981849819498204982149822498234982449825498264982749828498294983049831498324983349834498354983649837498384983949840498414984249843498444984549846498474984849849498504985149852498534985449855498564985749858498594986049861498624986349864498654986649867498684986949870498714987249873498744987549876498774987849879498804988149882498834988449885498864988749888498894989049891498924989349894498954989649897498984989949900499014990249903499044990549906499074990849909499104991149912499134991449915499164991749918499194992049921499224992349924499254992649927499284992949930499314993249933499344993549936499374993849939499404994149942499434994449945499464994749948499494995049951499524995349954499554995649957499584995949960499614996249963499644996549966499674996849969499704997149972499734997449975499764997749978499794998049981499824998349984499854998649987499884998949990499914999249993499944999549996499974999849999500005000150002500035000450005500065000750008500095001050011500125001350014500155001650017500185001950020500215002250023500245002550026500275002850029500305003150032500335003450035500365003750038500395004050041500425004350044500455004650047500485004950050500515005250053500545005550056500575005850059500605006150062500635006450065500665006750068500695007050071500725007350074500755007650077500785007950080500815008250083500845008550086500875008850089500905009150092500935009450095500965009750098500995010050101501025010350104501055010650107501085010950110501115011250113501145011550116501175011850119501205012150122501235012450125501265012750128501295013050131501325013350134501355013650137501385013950140501415014250143501445014550146501475014850149501505015150152501535015450155501565015750158501595016050161501625016350164501655016650167501685016950170501715017250173501745017550176501775017850179501805018150182501835018450185501865018750188501895019050191501925019350194501955019650197501985019950200502015020250203502045020550206502075020850209502105021150212502135021450215502165021750218502195022050221502225022350224502255022650227502285022950230502315023250233502345023550236502375023850239502405024150242502435024450245502465024750248502495025050251502525025350254502555025650257502585025950260502615026250263502645026550266502675026850269502705027150272502735027450275502765027750278502795028050281502825028350284502855028650287502885028950290502915029250293502945029550296502975029850299503005030150302503035030450305503065030750308503095031050311503125031350314503155031650317503185031950320503215032250323503245032550326503275032850329503305033150332503335033450335503365033750338503395034050341503425034350344503455034650347503485034950350503515035250353503545035550356503575035850359503605036150362503635036450365503665036750368503695037050371503725037350374503755037650377503785037950380503815038250383503845038550386503875038850389503905039150392503935039450395503965039750398503995040050401504025040350404504055040650407504085040950410504115041250413504145041550416504175041850419504205042150422504235042450425504265042750428504295043050431504325043350434504355043650437504385043950440504415044250443504445044550446504475044850449504505045150452504535045450455504565045750458504595046050461504625046350464504655046650467504685046950470504715047250473504745047550476504775047850479504805048150482504835048450485504865048750488504895049050491504925049350494504955049650497504985049950500505015050250503505045050550506505075050850509505105051150512505135051450515505165051750518505195052050521505225052350524505255052650527505285052950530505315053250533505345053550536505375053850539505405054150542505435054450545505465054750548505495055050551505525055350554505555055650557505585055950560505615056250563505645056550566505675056850569505705057150572505735057450575505765057750578505795058050581505825058350584505855058650587505885058950590505915059250593505945059550596505975059850599506005060150602506035060450605506065060750608506095061050611506125061350614506155061650617506185061950620506215062250623506245062550626506275062850629506305063150632506335063450635506365063750638506395064050641506425064350644506455064650647506485064950650506515065250653506545065550656506575065850659506605066150662506635066450665506665066750668506695067050671506725067350674506755067650677506785067950680506815068250683506845068550686506875068850689506905069150692506935069450695506965069750698506995070050701507025070350704507055070650707507085070950710507115071250713507145071550716507175071850719507205072150722507235072450725507265072750728507295073050731507325073350734507355073650737507385073950740507415074250743507445074550746507475074850749507505075150752507535075450755507565075750758507595076050761507625076350764507655076650767507685076950770507715077250773507745077550776507775077850779507805078150782507835078450785507865078750788507895079050791507925079350794507955079650797507985079950800508015080250803508045080550806508075080850809508105081150812508135081450815508165081750818508195082050821508225082350824508255082650827508285082950830508315083250833508345083550836508375083850839508405084150842508435084450845508465084750848508495085050851508525085350854508555085650857508585085950860508615086250863508645086550866508675086850869508705087150872508735087450875508765087750878508795088050881508825088350884508855088650887508885088950890508915089250893508945089550896508975089850899509005090150902509035090450905509065090750908509095091050911509125091350914509155091650917509185091950920509215092250923509245092550926509275092850929509305093150932509335093450935509365093750938509395094050941509425094350944509455094650947509485094950950509515095250953509545095550956509575095850959509605096150962509635096450965509665096750968509695097050971509725097350974509755097650977509785097950980509815098250983509845098550986509875098850989509905099150992509935099450995509965099750998509995100051001510025100351004510055100651007510085100951010510115101251013510145101551016510175101851019510205102151022510235102451025510265102751028510295103051031510325103351034510355103651037510385103951040510415104251043510445104551046510475104851049510505105151052510535105451055510565105751058510595106051061510625106351064510655106651067510685106951070510715107251073510745107551076510775107851079510805108151082510835108451085510865108751088510895109051091510925109351094510955109651097510985109951100511015110251103511045110551106511075110851109511105111151112511135111451115511165111751118511195112051121511225112351124511255112651127511285112951130511315113251133511345113551136511375113851139511405114151142511435114451145511465114751148511495115051151511525115351154511555115651157511585115951160511615116251163511645116551166511675116851169511705117151172511735117451175511765117751178511795118051181511825118351184511855118651187511885118951190511915119251193511945119551196511975119851199512005120151202512035120451205512065120751208512095121051211512125121351214512155121651217512185121951220512215122251223512245122551226512275122851229512305123151232512335123451235512365123751238512395124051241512425124351244512455124651247512485124951250512515125251253512545125551256512575125851259512605126151262512635126451265512665126751268512695127051271512725127351274512755127651277512785127951280512815128251283512845128551286512875128851289512905129151292512935129451295512965129751298512995130051301513025130351304513055130651307513085130951310513115131251313513145131551316513175131851319513205132151322513235132451325513265132751328513295133051331513325133351334513355133651337513385133951340513415134251343513445134551346513475134851349513505135151352513535135451355513565135751358513595136051361513625136351364513655136651367513685136951370513715137251373513745137551376513775137851379513805138151382513835138451385513865138751388513895139051391513925139351394513955139651397513985139951400514015140251403514045140551406514075140851409514105141151412514135141451415514165141751418514195142051421514225142351424514255142651427514285142951430514315143251433514345143551436514375143851439514405144151442514435144451445514465144751448514495145051451514525145351454514555145651457514585145951460514615146251463514645146551466514675146851469514705147151472514735147451475514765147751478514795148051481514825148351484514855148651487514885148951490514915149251493514945149551496514975149851499515005150151502515035150451505515065150751508515095151051511515125151351514515155151651517515185151951520515215152251523515245152551526515275152851529515305153151532515335153451535515365153751538515395154051541515425154351544515455154651547515485154951550515515155251553515545155551556515575155851559515605156151562515635156451565515665156751568515695157051571515725157351574515755157651577515785157951580515815158251583515845158551586515875158851589515905159151592515935159451595515965159751598515995160051601516025160351604516055160651607516085160951610516115161251613516145161551616516175161851619516205162151622516235162451625516265162751628516295163051631516325163351634516355163651637516385163951640516415164251643516445164551646516475164851649516505165151652516535165451655516565165751658516595166051661516625166351664516655166651667516685166951670516715167251673516745167551676516775167851679516805168151682516835168451685516865168751688516895169051691516925169351694516955169651697516985169951700517015170251703517045170551706517075170851709517105171151712517135171451715517165171751718517195172051721517225172351724517255172651727517285172951730517315173251733517345173551736517375173851739517405174151742517435174451745517465174751748517495175051751517525175351754517555175651757517585175951760517615176251763517645176551766517675176851769517705177151772517735177451775517765177751778517795178051781517825178351784517855178651787517885178951790517915179251793517945179551796517975179851799518005180151802518035180451805518065180751808518095181051811518125181351814518155181651817518185181951820518215182251823518245182551826518275182851829518305183151832518335183451835518365183751838518395184051841518425184351844518455184651847518485184951850518515185251853518545185551856518575185851859518605186151862518635186451865518665186751868518695187051871518725187351874518755187651877518785187951880518815188251883518845188551886518875188851889518905189151892518935189451895518965189751898518995190051901519025190351904519055190651907519085190951910519115191251913519145191551916519175191851919519205192151922519235192451925519265192751928519295193051931519325193351934519355193651937519385193951940519415194251943519445194551946519475194851949519505195151952519535195451955519565195751958519595196051961519625196351964519655196651967519685196951970519715197251973519745197551976519775197851979519805198151982519835198451985519865198751988519895199051991519925199351994519955199651997519985199952000520015200252003520045200552006520075200852009520105201152012520135201452015520165201752018520195202052021520225202352024520255202652027520285202952030520315203252033520345203552036520375203852039520405204152042520435204452045520465204752048520495205052051520525205352054520555205652057520585205952060520615206252063520645206552066520675206852069520705207152072520735207452075520765207752078520795208052081520825208352084520855208652087520885208952090520915209252093520945209552096520975209852099521005210152102521035210452105521065210752108521095211052111521125211352114521155211652117521185211952120521215212252123521245212552126521275212852129521305213152132521335213452135521365213752138521395214052141521425214352144521455214652147521485214952150521515215252153521545215552156521575215852159521605216152162521635216452165521665216752168521695217052171521725217352174521755217652177521785217952180521815218252183521845218552186521875218852189521905219152192521935219452195521965219752198521995220052201522025220352204522055220652207522085220952210522115221252213522145221552216522175221852219522205222152222522235222452225522265222752228522295223052231522325223352234522355223652237522385223952240522415224252243522445224552246522475224852249522505225152252522535225452255522565225752258522595226052261522625226352264522655226652267522685226952270522715227252273522745227552276522775227852279522805228152282522835228452285522865228752288522895229052291522925229352294522955229652297522985229952300523015230252303523045230552306523075230852309523105231152312523135231452315523165231752318523195232052321523225232352324523255232652327523285232952330523315233252333523345233552336523375233852339523405234152342523435234452345523465234752348523495235052351523525235352354523555235652357523585235952360523615236252363523645236552366523675236852369523705237152372523735237452375523765237752378523795238052381523825238352384523855238652387523885238952390523915239252393523945239552396523975239852399524005240152402524035240452405524065240752408524095241052411524125241352414524155241652417524185241952420524215242252423524245242552426524275242852429524305243152432524335243452435524365243752438524395244052441524425244352444524455244652447524485244952450524515245252453524545245552456524575245852459524605246152462524635246452465524665246752468524695247052471524725247352474524755247652477524785247952480524815248252483524845248552486524875248852489524905249152492524935249452495524965249752498524995250052501525025250352504525055250652507525085250952510525115251252513525145251552516525175251852519525205252152522525235252452525525265252752528525295253052531525325253352534525355253652537525385253952540525415254252543525445254552546525475254852549525505255152552525535255452555525565255752558525595256052561525625256352564525655256652567525685256952570525715257252573525745257552576525775257852579525805258152582525835258452585525865258752588525895259052591525925259352594525955259652597525985259952600526015260252603526045260552606526075260852609526105261152612526135261452615526165261752618526195262052621526225262352624526255262652627526285262952630526315263252633526345263552636526375263852639526405264152642526435264452645526465264752648526495265052651526525265352654526555265652657526585265952660526615266252663526645266552666526675266852669526705267152672526735267452675526765267752678526795268052681526825268352684526855268652687526885268952690526915269252693526945269552696526975269852699527005270152702527035270452705527065270752708527095271052711527125271352714527155271652717527185271952720527215272252723527245272552726527275272852729527305273152732527335273452735527365273752738527395274052741527425274352744527455274652747527485274952750527515275252753527545275552756527575275852759527605276152762527635276452765527665276752768527695277052771527725277352774527755277652777527785277952780527815278252783527845278552786527875278852789527905279152792527935279452795527965279752798527995280052801528025280352804528055280652807528085280952810528115281252813528145281552816528175281852819528205282152822528235282452825528265282752828528295283052831528325283352834528355283652837528385283952840528415284252843528445284552846528475284852849528505285152852528535285452855528565285752858528595286052861528625286352864528655286652867528685286952870528715287252873528745287552876528775287852879528805288152882528835288452885528865288752888528895289052891528925289352894528955289652897528985289952900529015290252903529045290552906529075290852909529105291152912529135291452915529165291752918529195292052921529225292352924529255292652927529285292952930529315293252933529345293552936529375293852939529405294152942529435294452945529465294752948529495295052951529525295352954529555295652957529585295952960529615296252963529645296552966529675296852969529705297152972529735297452975529765297752978529795298052981529825298352984529855298652987529885298952990529915299252993529945299552996529975299852999530005300153002530035300453005530065300753008530095301053011530125301353014530155301653017530185301953020530215302253023530245302553026530275302853029530305303153032530335303453035530365303753038530395304053041530425304353044530455304653047530485304953050530515305253053530545305553056530575305853059530605306153062530635306453065530665306753068530695307053071530725307353074530755307653077530785307953080530815308253083530845308553086530875308853089530905309153092530935309453095530965309753098530995310053101531025310353104531055310653107531085310953110531115311253113531145311553116531175311853119531205312153122531235312453125531265312753128531295313053131531325313353134531355313653137531385313953140531415314253143531445314553146531475314853149531505315153152531535315453155531565315753158531595316053161531625316353164531655316653167531685316953170531715317253173531745317553176531775317853179531805318153182531835318453185531865318753188531895319053191531925319353194531955319653197531985319953200532015320253203532045320553206532075320853209532105321153212532135321453215532165321753218532195322053221532225322353224532255322653227532285322953230532315323253233532345323553236532375323853239532405324153242532435324453245532465324753248532495325053251532525325353254532555325653257532585325953260532615326253263532645326553266532675326853269532705327153272532735327453275532765327753278532795328053281532825328353284532855328653287532885328953290532915329253293532945329553296532975329853299533005330153302533035330453305533065330753308533095331053311533125331353314533155331653317533185331953320533215332253323533245332553326533275332853329533305333153332533335333453335533365333753338533395334053341533425334353344533455334653347533485334953350533515335253353533545335553356533575335853359533605336153362533635336453365533665336753368533695337053371533725337353374533755337653377533785337953380533815338253383533845338553386533875338853389533905339153392533935339453395533965339753398533995340053401534025340353404534055340653407534085340953410534115341253413534145341553416534175341853419534205342153422534235342453425534265342753428534295343053431534325343353434534355343653437534385343953440534415344253443534445344553446534475344853449534505345153452534535345453455534565345753458534595346053461534625346353464534655346653467534685346953470534715347253473534745347553476534775347853479534805348153482534835348453485534865348753488534895349053491534925349353494534955349653497534985349953500535015350253503535045350553506535075350853509535105351153512535135351453515535165351753518535195352053521535225352353524535255352653527535285352953530535315353253533535345353553536535375353853539535405354153542535435354453545535465354753548535495355053551535525355353554535555355653557535585355953560535615356253563535645356553566535675356853569535705357153572535735357453575535765357753578535795358053581535825358353584535855358653587535885358953590535915359253593535945359553596535975359853599536005360153602536035360453605536065360753608536095361053611536125361353614536155361653617536185361953620536215362253623536245362553626536275362853629536305363153632536335363453635536365363753638536395364053641536425364353644536455364653647536485364953650536515365253653536545365553656536575365853659536605366153662536635366453665536665366753668536695367053671536725367353674536755367653677536785367953680536815368253683536845368553686536875368853689536905369153692536935369453695536965369753698536995370053701537025370353704537055370653707537085370953710537115371253713537145371553716537175371853719537205372153722537235372453725537265372753728537295373053731537325373353734537355373653737537385373953740537415374253743537445374553746537475374853749537505375153752537535375453755537565375753758537595376053761537625376353764537655376653767537685376953770537715377253773537745377553776537775377853779537805378153782537835378453785537865378753788537895379053791537925379353794537955379653797537985379953800538015380253803538045380553806538075380853809538105381153812538135381453815538165381753818538195382053821538225382353824538255382653827538285382953830538315383253833538345383553836538375383853839538405384153842538435384453845538465384753848538495385053851538525385353854538555385653857538585385953860538615386253863538645386553866538675386853869538705387153872538735387453875538765387753878538795388053881538825388353884538855388653887538885388953890538915389253893538945389553896538975389853899539005390153902539035390453905539065390753908539095391053911539125391353914539155391653917539185391953920539215392253923539245392553926539275392853929539305393153932539335393453935539365393753938539395394053941539425394353944539455394653947539485394953950539515395253953539545395553956539575395853959539605396153962539635396453965539665396753968539695397053971539725397353974539755397653977539785397953980539815398253983539845398553986539875398853989539905399153992539935399453995539965399753998539995400054001540025400354004540055400654007540085400954010540115401254013540145401554016540175401854019540205402154022540235402454025540265402754028540295403054031540325403354034540355403654037540385403954040540415404254043540445404554046540475404854049540505405154052540535405454055540565405754058540595406054061540625406354064540655406654067540685406954070540715407254073540745407554076540775407854079540805408154082540835408454085540865408754088540895409054091540925409354094540955409654097540985409954100541015410254103541045410554106541075410854109541105411154112541135411454115541165411754118541195412054121541225412354124541255412654127541285412954130541315413254133541345413554136541375413854139541405414154142541435414454145541465414754148541495415054151541525415354154541555415654157541585415954160541615416254163541645416554166541675416854169541705417154172541735417454175541765417754178541795418054181541825418354184541855418654187541885418954190541915419254193541945419554196541975419854199542005420154202542035420454205542065420754208542095421054211542125421354214542155421654217542185421954220542215422254223542245422554226542275422854229542305423154232542335423454235542365423754238542395424054241542425424354244542455424654247542485424954250542515425254253542545425554256542575425854259542605426154262542635426454265542665426754268542695427054271542725427354274542755427654277542785427954280542815428254283542845428554286542875428854289542905429154292542935429454295542965429754298542995430054301543025430354304543055430654307543085430954310543115431254313543145431554316543175431854319543205432154322543235432454325543265432754328543295433054331543325433354334543355433654337543385433954340543415434254343543445434554346543475434854349543505435154352543535435454355543565435754358543595436054361543625436354364543655436654367543685436954370543715437254373543745437554376543775437854379543805438154382543835438454385543865438754388543895439054391543925439354394543955439654397543985439954400544015440254403544045440554406544075440854409544105441154412544135441454415544165441754418544195442054421544225442354424544255442654427544285442954430544315443254433544345443554436544375443854439544405444154442544435444454445544465444754448544495445054451544525445354454544555445654457544585445954460544615446254463544645446554466544675446854469544705447154472544735447454475544765447754478544795448054481544825448354484544855448654487544885448954490544915449254493544945449554496544975449854499545005450154502545035450454505545065450754508545095451054511545125451354514545155451654517545185451954520545215452254523545245452554526545275452854529545305453154532545335453454535545365453754538545395454054541545425454354544545455454654547545485454954550545515455254553545545455554556545575455854559545605456154562545635456454565545665456754568545695457054571545725457354574545755457654577545785457954580545815458254583545845458554586545875458854589545905459154592545935459454595545965459754598545995460054601546025460354604546055460654607546085460954610546115461254613546145461554616546175461854619546205462154622546235462454625546265462754628546295463054631546325463354634546355463654637546385463954640546415464254643546445464554646546475464854649546505465154652546535465454655546565465754658546595466054661546625466354664546655466654667546685466954670546715467254673546745467554676546775467854679546805468154682546835468454685546865468754688546895469054691546925469354694546955469654697546985469954700547015470254703547045470554706547075470854709547105471154712547135471454715547165471754718547195472054721547225472354724547255472654727547285472954730547315473254733547345473554736547375473854739547405474154742547435474454745547465474754748547495475054751547525475354754547555475654757547585475954760547615476254763547645476554766547675476854769547705477154772547735477454775547765477754778547795478054781547825478354784547855478654787547885478954790547915479254793547945479554796547975479854799548005480154802548035480454805548065480754808548095481054811548125481354814548155481654817548185481954820548215482254823548245482554826548275482854829548305483154832548335483454835548365483754838548395484054841548425484354844548455484654847548485484954850548515485254853548545485554856548575485854859548605486154862548635486454865548665486754868548695487054871548725487354874548755487654877548785487954880548815488254883548845488554886548875488854889548905489154892548935489454895548965489754898548995490054901549025490354904549055490654907549085490954910549115491254913549145491554916549175491854919549205492154922549235492454925549265492754928549295493054931549325493354934549355493654937549385493954940549415494254943549445494554946549475494854949549505495154952549535495454955549565495754958549595496054961549625496354964549655496654967549685496954970549715497254973549745497554976549775497854979549805498154982549835498454985549865498754988549895499054991549925499354994549955499654997549985499955000550015500255003550045500555006550075500855009550105501155012550135501455015550165501755018550195502055021550225502355024550255502655027550285502955030550315503255033550345503555036550375503855039550405504155042550435504455045550465504755048550495505055051550525505355054550555505655057550585505955060550615506255063550645506555066550675506855069550705507155072550735507455075550765507755078550795508055081550825508355084550855508655087550885508955090550915509255093550945509555096550975509855099551005510155102551035510455105551065510755108551095511055111551125511355114551155511655117551185511955120551215512255123551245512555126551275512855129551305513155132551335513455135551365513755138551395514055141551425514355144551455514655147551485514955150551515515255153551545515555156551575515855159551605516155162551635516455165551665516755168551695517055171551725517355174551755517655177551785517955180551815518255183551845518555186551875518855189551905519155192551935519455195551965519755198551995520055201552025520355204552055520655207552085520955210552115521255213552145521555216552175521855219552205522155222552235522455225552265522755228552295523055231552325523355234552355523655237552385523955240552415524255243552445524555246552475524855249552505525155252552535525455255552565525755258552595526055261552625526355264552655526655267552685526955270552715527255273552745527555276552775527855279552805528155282552835528455285552865528755288552895529055291552925529355294552955529655297552985529955300553015530255303553045530555306553075530855309553105531155312553135531455315553165531755318553195532055321553225532355324553255532655327553285532955330553315533255333553345533555336553375533855339553405534155342553435534455345553465534755348553495535055351553525535355354553555535655357553585535955360553615536255363553645536555366553675536855369553705537155372553735537455375553765537755378553795538055381553825538355384553855538655387553885538955390553915539255393553945539555396553975539855399554005540155402554035540455405554065540755408554095541055411554125541355414554155541655417554185541955420554215542255423554245542555426554275542855429554305543155432554335543455435554365543755438554395544055441554425544355444554455544655447554485544955450554515545255453554545545555456554575545855459554605546155462554635546455465554665546755468554695547055471554725547355474554755547655477554785547955480554815548255483554845548555486554875548855489554905549155492554935549455495554965549755498554995550055501555025550355504555055550655507555085550955510555115551255513555145551555516555175551855519555205552155522555235552455525555265552755528555295553055531555325553355534555355553655537555385553955540555415554255543555445554555546555475554855549555505555155552555535555455555555565555755558555595556055561555625556355564555655556655567555685556955570555715557255573555745557555576555775557855579555805558155582555835558455585555865558755588555895559055591555925559355594555955559655597555985559955600556015560255603556045560555606556075560855609556105561155612556135561455615556165561755618556195562055621556225562355624556255562655627556285562955630556315563255633556345563555636556375563855639556405564155642556435564455645556465564755648556495565055651556525565355654556555565655657556585565955660556615566255663556645566555666556675566855669556705567155672556735567455675556765567755678556795568055681556825568355684556855568655687556885568955690556915569255693556945569555696556975569855699557005570155702557035570455705557065570755708557095571055711557125571355714557155571655717557185571955720557215572255723557245572555726557275572855729557305573155732557335573455735557365573755738557395574055741557425574355744557455574655747557485574955750557515575255753557545575555756557575575855759557605576155762557635576455765557665576755768557695577055771557725577355774557755577655777557785577955780557815578255783557845578555786557875578855789557905579155792557935579455795557965579755798557995580055801558025580355804558055580655807558085580955810558115581255813558145581555816558175581855819558205582155822558235582455825558265582755828558295583055831558325583355834558355583655837558385583955840558415584255843558445584555846558475584855849558505585155852558535585455855558565585755858558595586055861558625586355864558655586655867558685586955870558715587255873558745587555876558775587855879558805588155882558835588455885558865588755888558895589055891558925589355894558955589655897558985589955900559015590255903559045590555906559075590855909559105591155912559135591455915559165591755918559195592055921559225592355924559255592655927559285592955930559315593255933559345593555936559375593855939559405594155942559435594455945559465594755948559495595055951559525595355954559555595655957559585595955960559615596255963559645596555966559675596855969559705597155972559735597455975559765597755978559795598055981559825598355984559855598655987559885598955990559915599255993559945599555996559975599855999560005600156002560035600456005560065600756008560095601056011560125601356014560155601656017560185601956020560215602256023560245602556026560275602856029560305603156032560335603456035560365603756038560395604056041560425604356044560455604656047560485604956050560515605256053560545605556056560575605856059560605606156062560635606456065560665606756068560695607056071560725607356074560755607656077560785607956080560815608256083560845608556086560875608856089560905609156092560935609456095560965609756098560995610056101561025610356104561055610656107561085610956110561115611256113561145611556116561175611856119561205612156122561235612456125561265612756128561295613056131561325613356134561355613656137561385613956140561415614256143561445614556146561475614856149561505615156152561535615456155561565615756158561595616056161561625616356164561655616656167561685616956170561715617256173561745617556176561775617856179561805618156182561835618456185561865618756188561895619056191561925619356194561955619656197561985619956200562015620256203562045620556206562075620856209562105621156212562135621456215562165621756218562195622056221562225622356224562255622656227562285622956230562315623256233562345623556236562375623856239562405624156242562435624456245562465624756248562495625056251562525625356254562555625656257562585625956260562615626256263562645626556266562675626856269562705627156272562735627456275562765627756278562795628056281562825628356284562855628656287562885628956290562915629256293562945629556296562975629856299563005630156302563035630456305563065630756308563095631056311563125631356314563155631656317563185631956320563215632256323563245632556326563275632856329563305633156332563335633456335563365633756338563395634056341563425634356344563455634656347563485634956350563515635256353563545635556356563575635856359563605636156362563635636456365563665636756368563695637056371563725637356374563755637656377563785637956380563815638256383563845638556386563875638856389563905639156392563935639456395563965639756398563995640056401564025640356404564055640656407564085640956410564115641256413564145641556416564175641856419564205642156422564235642456425564265642756428564295643056431564325643356434564355643656437564385643956440564415644256443564445644556446564475644856449564505645156452564535645456455564565645756458564595646056461564625646356464564655646656467564685646956470564715647256473564745647556476564775647856479564805648156482564835648456485564865648756488564895649056491564925649356494564955649656497564985649956500565015650256503565045650556506565075650856509565105651156512565135651456515565165651756518565195652056521565225652356524565255652656527565285652956530565315653256533565345653556536565375653856539565405654156542565435654456545565465654756548565495655056551565525655356554565555655656557565585655956560565615656256563565645656556566565675656856569565705657156572565735657456575565765657756578565795658056581565825658356584565855658656587565885658956590565915659256593565945659556596565975659856599566005660156602566035660456605566065660756608566095661056611566125661356614566155661656617566185661956620566215662256623566245662556626566275662856629566305663156632566335663456635566365663756638566395664056641566425664356644566455664656647566485664956650566515665256653566545665556656566575665856659566605666156662566635666456665566665666756668566695667056671566725667356674566755667656677566785667956680566815668256683566845668556686566875668856689566905669156692566935669456695566965669756698566995670056701567025670356704567055670656707567085670956710567115671256713567145671556716567175671856719567205672156722567235672456725567265672756728567295673056731567325673356734567355673656737567385673956740567415674256743567445674556746567475674856749567505675156752567535675456755567565675756758567595676056761567625676356764567655676656767567685676956770567715677256773567745677556776567775677856779567805678156782567835678456785567865678756788567895679056791567925679356794567955679656797567985679956800568015680256803568045680556806568075680856809568105681156812568135681456815568165681756818568195682056821568225682356824568255682656827568285682956830568315683256833568345683556836568375683856839568405684156842568435684456845568465684756848568495685056851568525685356854568555685656857568585685956860568615686256863568645686556866568675686856869568705687156872568735687456875568765687756878568795688056881568825688356884568855688656887568885688956890568915689256893568945689556896568975689856899569005690156902569035690456905569065690756908569095691056911569125691356914569155691656917569185691956920569215692256923569245692556926569275692856929569305693156932569335693456935569365693756938569395694056941569425694356944569455694656947569485694956950569515695256953569545695556956569575695856959569605696156962569635696456965569665696756968569695697056971569725697356974569755697656977569785697956980569815698256983569845698556986569875698856989569905699156992569935699456995569965699756998569995700057001570025700357004570055700657007570085700957010570115701257013570145701557016570175701857019570205702157022570235702457025570265702757028570295703057031570325703357034570355703657037570385703957040570415704257043570445704557046570475704857049570505705157052570535705457055570565705757058570595706057061570625706357064570655706657067570685706957070570715707257073570745707557076570775707857079570805708157082570835708457085570865708757088570895709057091570925709357094570955709657097570985709957100571015710257103571045710557106571075710857109571105711157112571135711457115571165711757118571195712057121571225712357124571255712657127571285712957130571315713257133571345713557136571375713857139571405714157142571435714457145571465714757148571495715057151571525715357154571555715657157571585715957160571615716257163571645716557166571675716857169571705717157172571735717457175571765717757178571795718057181571825718357184571855718657187571885718957190571915719257193571945719557196571975719857199572005720157202572035720457205572065720757208572095721057211572125721357214572155721657217572185721957220572215722257223572245722557226572275722857229572305723157232572335723457235572365723757238572395724057241572425724357244572455724657247572485724957250572515725257253572545725557256572575725857259572605726157262572635726457265572665726757268572695727057271572725727357274572755727657277572785727957280572815728257283572845728557286572875728857289572905729157292572935729457295572965729757298572995730057301573025730357304573055730657307573085730957310573115731257313573145731557316573175731857319573205732157322573235732457325573265732757328573295733057331573325733357334573355733657337573385733957340573415734257343573445734557346573475734857349573505735157352573535735457355573565735757358573595736057361573625736357364573655736657367573685736957370573715737257373573745737557376573775737857379573805738157382573835738457385573865738757388573895739057391573925739357394573955739657397573985739957400574015740257403574045740557406574075740857409574105741157412574135741457415574165741757418574195742057421574225742357424574255742657427574285742957430574315743257433574345743557436574375743857439574405744157442574435744457445574465744757448574495745057451574525745357454574555745657457574585745957460574615746257463574645746557466574675746857469574705747157472574735747457475574765747757478574795748057481574825748357484574855748657487574885748957490574915749257493574945749557496574975749857499575005750157502575035750457505575065750757508575095751057511575125751357514575155751657517575185751957520575215752257523575245752557526575275752857529575305753157532575335753457535575365753757538575395754057541575425754357544575455754657547575485754957550575515755257553575545755557556575575755857559575605756157562575635756457565575665756757568575695757057571575725757357574575755757657577575785757957580575815758257583575845758557586575875758857589575905759157592575935759457595575965759757598575995760057601576025760357604576055760657607576085760957610576115761257613576145761557616576175761857619576205762157622576235762457625576265762757628576295763057631576325763357634576355763657637576385763957640576415764257643576445764557646576475764857649576505765157652576535765457655576565765757658576595766057661576625766357664576655766657667576685766957670576715767257673576745767557676576775767857679576805768157682576835768457685576865768757688576895769057691576925769357694576955769657697576985769957700577015770257703577045770557706577075770857709577105771157712577135771457715577165771757718577195772057721577225772357724577255772657727577285772957730577315773257733577345773557736577375773857739577405774157742577435774457745577465774757748577495775057751577525775357754577555775657757577585775957760577615776257763577645776557766577675776857769577705777157772577735777457775577765777757778577795778057781577825778357784577855778657787577885778957790577915779257793577945779557796577975779857799578005780157802578035780457805578065780757808578095781057811578125781357814578155781657817578185781957820578215782257823578245782557826578275782857829578305783157832578335783457835578365783757838578395784057841578425784357844578455784657847578485784957850578515785257853578545785557856578575785857859578605786157862578635786457865578665786757868578695787057871578725787357874578755787657877578785787957880578815788257883578845788557886578875788857889578905789157892578935789457895578965789757898578995790057901579025790357904579055790657907579085790957910579115791257913579145791557916579175791857919579205792157922579235792457925579265792757928579295793057931579325793357934579355793657937579385793957940579415794257943579445794557946579475794857949579505795157952579535795457955579565795757958579595796057961579625796357964579655796657967579685796957970579715797257973579745797557976579775797857979579805798157982579835798457985579865798757988579895799057991579925799357994579955799657997579985799958000580015800258003580045800558006580075800858009580105801158012580135801458015580165801758018580195802058021580225802358024580255802658027580285802958030580315803258033580345803558036580375803858039580405804158042580435804458045580465804758048580495805058051580525805358054580555805658057580585805958060580615806258063580645806558066580675806858069580705807158072580735807458075580765807758078580795808058081580825808358084580855808658087580885808958090580915809258093580945809558096580975809858099581005810158102581035810458105581065810758108581095811058111581125811358114581155811658117581185811958120581215812258123581245812558126581275812858129581305813158132581335813458135581365813758138581395814058141581425814358144581455814658147581485814958150581515815258153581545815558156581575815858159581605816158162581635816458165581665816758168581695817058171581725817358174581755817658177581785817958180581815818258183581845818558186581875818858189581905819158192581935819458195581965819758198581995820058201582025820358204582055820658207582085820958210582115821258213582145821558216582175821858219582205822158222582235822458225582265822758228582295823058231582325823358234582355823658237582385823958240582415824258243582445824558246582475824858249582505825158252582535825458255582565825758258582595826058261582625826358264582655826658267582685826958270582715827258273582745827558276582775827858279582805828158282582835828458285582865828758288582895829058291582925829358294582955829658297582985829958300583015830258303583045830558306583075830858309583105831158312583135831458315583165831758318583195832058321583225832358324583255832658327583285832958330583315833258333583345833558336583375833858339583405834158342583435834458345583465834758348583495835058351583525835358354583555835658357583585835958360583615836258363583645836558366583675836858369583705837158372583735837458375583765837758378583795838058381583825838358384583855838658387583885838958390583915839258393583945839558396583975839858399584005840158402584035840458405584065840758408584095841058411584125841358414584155841658417584185841958420584215842258423584245842558426584275842858429584305843158432584335843458435584365843758438584395844058441584425844358444584455844658447584485844958450584515845258453584545845558456584575845858459584605846158462584635846458465584665846758468584695847058471584725847358474584755847658477584785847958480584815848258483584845848558486584875848858489584905849158492584935849458495584965849758498584995850058501585025850358504585055850658507585085850958510585115851258513585145851558516585175851858519585205852158522585235852458525585265852758528585295853058531585325853358534585355853658537585385853958540585415854258543585445854558546585475854858549585505855158552585535855458555585565855758558585595856058561585625856358564585655856658567585685856958570585715857258573585745857558576585775857858579585805858158582585835858458585585865858758588585895859058591585925859358594585955859658597585985859958600586015860258603586045860558606586075860858609586105861158612586135861458615586165861758618586195862058621586225862358624586255862658627586285862958630586315863258633586345863558636586375863858639586405864158642586435864458645586465864758648586495865058651586525865358654586555865658657586585865958660586615866258663586645866558666586675866858669586705867158672586735867458675586765867758678586795868058681586825868358684586855868658687586885868958690586915869258693586945869558696586975869858699587005870158702587035870458705587065870758708587095871058711587125871358714587155871658717587185871958720587215872258723587245872558726587275872858729587305873158732587335873458735587365873758738587395874058741587425874358744587455874658747587485874958750587515875258753587545875558756587575875858759587605876158762587635876458765587665876758768587695877058771587725877358774587755877658777587785877958780587815878258783587845878558786587875878858789587905879158792587935879458795587965879758798587995880058801588025880358804588055880658807588085880958810588115881258813588145881558816588175881858819588205882158822588235882458825588265882758828588295883058831588325883358834588355883658837588385883958840588415884258843588445884558846588475884858849588505885158852588535885458855588565885758858588595886058861588625886358864588655886658867588685886958870588715887258873588745887558876588775887858879588805888158882588835888458885588865888758888588895889058891588925889358894588955889658897588985889958900589015890258903589045890558906589075890858909589105891158912589135891458915589165891758918589195892058921589225892358924589255892658927589285892958930589315893258933589345893558936589375893858939589405894158942589435894458945589465894758948589495895058951589525895358954589555895658957589585895958960589615896258963589645896558966589675896858969589705897158972589735897458975589765897758978589795898058981589825898358984589855898658987589885898958990589915899258993589945899558996589975899858999590005900159002590035900459005590065900759008590095901059011590125901359014590155901659017590185901959020590215902259023590245902559026590275902859029590305903159032590335903459035590365903759038590395904059041590425904359044590455904659047590485904959050590515905259053590545905559056590575905859059590605906159062590635906459065590665906759068590695907059071590725907359074590755907659077590785907959080590815908259083590845908559086590875908859089590905909159092590935909459095590965909759098590995910059101591025910359104591055910659107591085910959110591115911259113591145911559116591175911859119591205912159122591235912459125591265912759128591295913059131591325913359134591355913659137591385913959140591415914259143591445914559146591475914859149591505915159152591535915459155591565915759158591595916059161591625916359164591655916659167591685916959170591715917259173591745917559176591775917859179591805918159182591835918459185591865918759188591895919059191591925919359194591955919659197591985919959200592015920259203592045920559206592075920859209592105921159212592135921459215592165921759218592195922059221592225922359224592255922659227592285922959230592315923259233592345923559236592375923859239592405924159242592435924459245592465924759248592495925059251592525925359254592555925659257592585925959260592615926259263592645926559266592675926859269592705927159272592735927459275592765927759278592795928059281592825928359284592855928659287592885928959290592915929259293592945929559296592975929859299593005930159302593035930459305593065930759308593095931059311593125931359314593155931659317593185931959320593215932259323593245932559326593275932859329593305933159332593335933459335593365933759338593395934059341593425934359344593455934659347593485934959350593515935259353593545935559356593575935859359593605936159362593635936459365593665936759368593695937059371593725937359374593755937659377593785937959380593815938259383593845938559386593875938859389593905939159392593935939459395593965939759398593995940059401594025940359404594055940659407594085940959410594115941259413594145941559416594175941859419594205942159422594235942459425594265942759428594295943059431594325943359434594355943659437594385943959440594415944259443594445944559446594475944859449594505945159452594535945459455594565945759458594595946059461594625946359464594655946659467594685946959470594715947259473594745947559476594775947859479594805948159482594835948459485594865948759488594895949059491594925949359494594955949659497594985949959500595015950259503595045950559506595075950859509595105951159512595135951459515595165951759518595195952059521595225952359524595255952659527595285952959530595315953259533595345953559536595375953859539595405954159542595435954459545595465954759548595495955059551595525955359554595555955659557595585955959560595615956259563595645956559566595675956859569595705957159572595735957459575595765957759578595795958059581595825958359584595855958659587595885958959590595915959259593595945959559596595975959859599596005960159602596035960459605596065960759608596095961059611596125961359614596155961659617596185961959620596215962259623596245962559626596275962859629596305963159632596335963459635596365963759638596395964059641596425964359644596455964659647596485964959650596515965259653596545965559656596575965859659596605966159662596635966459665596665966759668596695967059671596725967359674596755967659677596785967959680596815968259683596845968559686596875968859689596905969159692596935969459695596965969759698596995970059701597025970359704597055970659707597085970959710597115971259713597145971559716597175971859719597205972159722597235972459725597265972759728597295973059731597325973359734597355973659737597385973959740597415974259743597445974559746597475974859749597505975159752597535975459755597565975759758597595976059761597625976359764597655976659767597685976959770597715977259773597745977559776597775977859779597805978159782597835978459785597865978759788597895979059791597925979359794597955979659797597985979959800598015980259803598045980559806598075980859809598105981159812598135981459815598165981759818598195982059821598225982359824598255982659827598285982959830598315983259833598345983559836598375983859839598405984159842598435984459845598465984759848598495985059851598525985359854598555985659857598585985959860598615986259863598645986559866598675986859869598705987159872598735987459875598765987759878598795988059881598825988359884598855988659887598885988959890598915989259893598945989559896598975989859899599005990159902599035990459905599065990759908599095991059911599125991359914599155991659917599185991959920599215992259923599245992559926599275992859929599305993159932599335993459935599365993759938599395994059941599425994359944599455994659947599485994959950599515995259953599545995559956599575995859959599605996159962599635996459965599665996759968599695997059971599725997359974599755997659977599785997959980599815998259983599845998559986599875998859989599905999159992599935999459995599965999759998599996000060001600026000360004600056000660007600086000960010600116001260013600146001560016600176001860019600206002160022600236002460025600266002760028600296003060031600326003360034600356003660037600386003960040600416004260043600446004560046600476004860049600506005160052600536005460055600566005760058600596006060061600626006360064600656006660067600686006960070600716007260073600746007560076600776007860079600806008160082600836008460085600866008760088600896009060091600926009360094600956009660097600986009960100601016010260103601046010560106601076010860109601106011160112601136011460115601166011760118601196012060121601226012360124601256012660127601286012960130601316013260133601346013560136601376013860139601406014160142601436014460145601466014760148601496015060151601526015360154601556015660157601586015960160601616016260163601646016560166601676016860169601706017160172601736017460175601766017760178601796018060181601826018360184601856018660187601886018960190601916019260193601946019560196601976019860199602006020160202602036020460205602066020760208602096021060211602126021360214602156021660217602186021960220602216022260223602246022560226602276022860229602306023160232602336023460235602366023760238602396024060241602426024360244602456024660247602486024960250602516025260253602546025560256602576025860259602606026160262602636026460265602666026760268602696027060271602726027360274602756027660277602786027960280602816028260283602846028560286602876028860289602906029160292602936029460295602966029760298602996030060301603026030360304603056030660307603086030960310603116031260313603146031560316603176031860319603206032160322603236032460325603266032760328603296033060331603326033360334603356033660337603386033960340603416034260343603446034560346603476034860349603506035160352603536035460355603566035760358603596036060361603626036360364603656036660367603686036960370603716037260373603746037560376603776037860379603806038160382603836038460385603866038760388603896039060391603926039360394603956039660397603986039960400604016040260403604046040560406604076040860409604106041160412604136041460415604166041760418604196042060421604226042360424604256042660427604286042960430604316043260433604346043560436604376043860439604406044160442604436044460445604466044760448604496045060451604526045360454604556045660457604586045960460604616046260463604646046560466604676046860469604706047160472604736047460475604766047760478604796048060481604826048360484604856048660487604886048960490604916049260493604946049560496604976049860499605006050160502605036050460505605066050760508605096051060511605126051360514605156051660517605186051960520605216052260523605246052560526605276052860529605306053160532605336053460535605366053760538605396054060541605426054360544605456054660547605486054960550605516055260553605546055560556605576055860559605606056160562605636056460565605666056760568605696057060571605726057360574605756057660577605786057960580605816058260583605846058560586605876058860589605906059160592605936059460595605966059760598605996060060601606026060360604606056060660607606086060960610606116061260613606146061560616606176061860619606206062160622606236062460625606266062760628606296063060631606326063360634606356063660637606386063960640606416064260643606446064560646606476064860649606506065160652606536065460655606566065760658606596066060661606626066360664606656066660667606686066960670606716067260673606746067560676606776067860679606806068160682606836068460685606866068760688606896069060691606926069360694606956069660697606986069960700607016070260703607046070560706607076070860709607106071160712607136071460715607166071760718607196072060721607226072360724607256072660727607286072960730607316073260733607346073560736607376073860739607406074160742607436074460745607466074760748607496075060751607526075360754607556075660757607586075960760607616076260763607646076560766607676076860769607706077160772607736077460775607766077760778607796078060781607826078360784607856078660787607886078960790607916079260793607946079560796607976079860799608006080160802608036080460805608066080760808608096081060811608126081360814608156081660817608186081960820608216082260823608246082560826608276082860829608306083160832608336083460835608366083760838608396084060841608426084360844608456084660847608486084960850608516085260853608546085560856608576085860859608606086160862608636086460865608666086760868608696087060871608726087360874608756087660877608786087960880608816088260883608846088560886608876088860889608906089160892608936089460895608966089760898608996090060901609026090360904609056090660907609086090960910609116091260913609146091560916609176091860919609206092160922609236092460925609266092760928609296093060931609326093360934609356093660937609386093960940609416094260943609446094560946609476094860949609506095160952609536095460955609566095760958609596096060961609626096360964609656096660967609686096960970609716097260973609746097560976609776097860979609806098160982609836098460985609866098760988609896099060991609926099360994609956099660997609986099961000610016100261003610046100561006610076100861009610106101161012610136101461015610166101761018610196102061021610226102361024610256102661027610286102961030610316103261033610346103561036610376103861039610406104161042610436104461045610466104761048610496105061051610526105361054610556105661057610586105961060610616106261063610646106561066610676106861069610706107161072610736107461075610766107761078610796108061081610826108361084610856108661087610886108961090610916109261093610946109561096610976109861099611006110161102611036110461105611066110761108611096111061111611126111361114611156111661117611186111961120611216112261123611246112561126611276112861129611306113161132611336113461135611366113761138611396114061141611426114361144611456114661147611486114961150611516115261153611546115561156611576115861159611606116161162611636116461165611666116761168611696117061171611726117361174611756117661177611786117961180611816118261183611846118561186611876118861189611906119161192611936119461195611966119761198611996120061201612026120361204612056120661207612086120961210612116121261213612146121561216612176121861219612206122161222612236122461225612266122761228612296123061231612326123361234612356123661237612386123961240612416124261243612446124561246612476124861249612506125161252612536125461255612566125761258612596126061261612626126361264612656126661267612686126961270612716127261273612746127561276612776127861279612806128161282612836128461285612866128761288612896129061291612926129361294612956129661297612986129961300613016130261303613046130561306613076130861309613106131161312613136131461315613166131761318613196132061321613226132361324613256132661327613286132961330613316133261333613346133561336613376133861339613406134161342613436134461345613466134761348613496135061351613526135361354613556135661357613586135961360613616136261363613646136561366613676136861369613706137161372613736137461375613766137761378613796138061381613826138361384613856138661387613886138961390613916139261393613946139561396613976139861399614006140161402614036140461405614066140761408614096141061411614126141361414614156141661417614186141961420614216142261423614246142561426614276142861429614306143161432614336143461435614366143761438614396144061441614426144361444614456144661447614486144961450614516145261453614546145561456614576145861459614606146161462614636146461465614666146761468614696147061471614726147361474614756147661477614786147961480614816148261483614846148561486614876148861489614906149161492614936149461495614966149761498614996150061501615026150361504615056150661507615086150961510615116151261513615146151561516615176151861519615206152161522615236152461525615266152761528615296153061531615326153361534615356153661537615386153961540615416154261543615446154561546615476154861549615506155161552615536155461555615566155761558615596156061561615626156361564615656156661567615686156961570615716157261573615746157561576615776157861579615806158161582615836158461585615866158761588615896159061591615926159361594615956159661597615986159961600616016160261603616046160561606616076160861609616106161161612616136161461615616166161761618616196162061621616226162361624616256162661627616286162961630616316163261633616346163561636616376163861639616406164161642616436164461645616466164761648616496165061651616526165361654616556165661657616586165961660616616166261663616646166561666616676166861669616706167161672616736167461675616766167761678616796168061681616826168361684616856168661687616886168961690616916169261693616946169561696616976169861699617006170161702617036170461705617066170761708617096171061711617126171361714617156171661717617186171961720617216172261723617246172561726617276172861729617306173161732617336173461735617366173761738617396174061741617426174361744617456174661747617486174961750617516175261753617546175561756617576175861759617606176161762617636176461765617666176761768617696177061771617726177361774617756177661777617786177961780617816178261783617846178561786617876178861789617906179161792617936179461795617966179761798617996180061801618026180361804618056180661807618086180961810618116181261813618146181561816618176181861819618206182161822618236182461825618266182761828618296183061831618326183361834618356183661837618386183961840618416184261843618446184561846618476184861849618506185161852618536185461855618566185761858618596186061861618626186361864618656186661867618686186961870618716187261873618746187561876618776187861879618806188161882618836188461885618866188761888618896189061891618926189361894618956189661897618986189961900619016190261903619046190561906619076190861909619106191161912619136191461915619166191761918619196192061921619226192361924619256192661927619286192961930619316193261933619346193561936619376193861939619406194161942619436194461945619466194761948619496195061951619526195361954619556195661957619586195961960619616196261963619646196561966619676196861969619706197161972619736197461975619766197761978619796198061981619826198361984619856198661987619886198961990619916199261993619946199561996619976199861999620006200162002620036200462005620066200762008620096201062011620126201362014620156201662017620186201962020620216202262023620246202562026620276202862029620306203162032620336203462035620366203762038620396204062041620426204362044620456204662047620486204962050620516205262053620546205562056620576205862059620606206162062620636206462065620666206762068620696207062071620726207362074620756207662077620786207962080620816208262083620846208562086620876208862089620906209162092620936209462095620966209762098620996210062101621026210362104621056210662107621086210962110621116211262113621146211562116621176211862119621206212162122621236212462125621266212762128621296213062131621326213362134621356213662137621386213962140621416214262143621446214562146621476214862149621506215162152621536215462155621566215762158621596216062161621626216362164621656216662167621686216962170621716217262173621746217562176621776217862179621806218162182621836218462185621866218762188621896219062191621926219362194621956219662197621986219962200622016220262203622046220562206622076220862209622106221162212622136221462215622166221762218622196222062221622226222362224622256222662227622286222962230622316223262233622346223562236622376223862239622406224162242622436224462245622466224762248622496225062251622526225362254622556225662257622586225962260622616226262263622646226562266622676226862269622706227162272622736227462275622766227762278622796228062281622826228362284622856228662287622886228962290622916229262293622946229562296622976229862299623006230162302623036230462305623066230762308623096231062311623126231362314623156231662317623186231962320623216232262323623246232562326623276232862329623306233162332623336233462335623366233762338623396234062341623426234362344623456234662347623486234962350623516235262353623546235562356623576235862359623606236162362623636236462365623666236762368623696237062371623726237362374623756237662377623786237962380623816238262383623846238562386623876238862389623906239162392623936239462395623966239762398623996240062401624026240362404624056240662407624086240962410624116241262413624146241562416624176241862419624206242162422624236242462425624266242762428624296243062431624326243362434624356243662437624386243962440624416244262443624446244562446624476244862449624506245162452624536245462455624566245762458624596246062461624626246362464624656246662467624686246962470624716247262473624746247562476624776247862479624806248162482624836248462485624866248762488624896249062491624926249362494624956249662497624986249962500625016250262503625046250562506625076250862509625106251162512625136251462515625166251762518625196252062521625226252362524625256252662527625286252962530625316253262533625346253562536625376253862539625406254162542625436254462545625466254762548625496255062551625526255362554625556255662557625586255962560625616256262563625646256562566625676256862569625706257162572625736257462575625766257762578625796258062581625826258362584625856258662587625886258962590625916259262593625946259562596625976259862599626006260162602626036260462605626066260762608626096261062611626126261362614626156261662617626186261962620626216262262623626246262562626626276262862629626306263162632626336263462635626366263762638626396264062641626426264362644626456264662647626486264962650626516265262653626546265562656626576265862659626606266162662626636266462665626666266762668626696267062671626726267362674626756267662677626786267962680626816268262683626846268562686626876268862689626906269162692626936269462695626966269762698626996270062701627026270362704627056270662707627086270962710627116271262713627146271562716627176271862719627206272162722627236272462725627266272762728627296273062731627326273362734627356273662737627386273962740627416274262743627446274562746627476274862749627506275162752627536275462755627566275762758627596276062761627626276362764627656276662767627686276962770627716277262773627746277562776627776277862779627806278162782627836278462785627866278762788627896279062791627926279362794627956279662797627986279962800628016280262803628046280562806628076280862809628106281162812628136281462815628166281762818628196282062821628226282362824628256282662827628286282962830628316283262833628346283562836628376283862839628406284162842628436284462845628466284762848628496285062851628526285362854628556285662857628586285962860628616286262863628646286562866628676286862869628706287162872628736287462875628766287762878628796288062881628826288362884628856288662887628886288962890628916289262893628946289562896628976289862899629006290162902629036290462905629066290762908629096291062911629126291362914629156291662917629186291962920629216292262923629246292562926629276292862929629306293162932629336293462935629366293762938629396294062941629426294362944629456294662947629486294962950629516295262953629546295562956629576295862959629606296162962629636296462965629666296762968629696297062971629726297362974629756297662977629786297962980629816298262983629846298562986629876298862989629906299162992629936299462995629966299762998629996300063001630026300363004630056300663007630086300963010630116301263013630146301563016630176301863019630206302163022630236302463025630266302763028630296303063031630326303363034630356303663037630386303963040630416304263043630446304563046630476304863049630506305163052630536305463055630566305763058630596306063061630626306363064630656306663067630686306963070630716307263073630746307563076630776307863079630806308163082630836308463085630866308763088630896309063091630926309363094630956309663097630986309963100631016310263103631046310563106631076310863109631106311163112631136311463115631166311763118631196312063121631226312363124631256312663127631286312963130631316313263133631346313563136631376313863139631406314163142631436314463145631466314763148631496315063151631526315363154631556315663157631586315963160631616316263163631646316563166631676316863169631706317163172631736317463175631766317763178631796318063181631826318363184631856318663187631886318963190631916319263193631946319563196631976319863199632006320163202632036320463205632066320763208632096321063211632126321363214632156321663217632186321963220632216322263223632246322563226632276322863229632306323163232632336323463235632366323763238632396324063241632426324363244632456324663247632486324963250632516325263253632546325563256632576325863259632606326163262632636326463265632666326763268632696327063271632726327363274632756327663277632786327963280632816328263283632846328563286632876328863289632906329163292632936329463295632966329763298632996330063301633026330363304633056330663307633086330963310633116331263313633146331563316633176331863319633206332163322633236332463325633266332763328633296333063331633326333363334633356333663337633386333963340633416334263343633446334563346633476334863349633506335163352633536335463355633566335763358633596336063361633626336363364633656336663367633686336963370633716337263373633746337563376633776337863379633806338163382633836338463385633866338763388633896339063391633926339363394633956339663397633986339963400634016340263403634046340563406634076340863409634106341163412634136341463415634166341763418634196342063421634226342363424634256342663427634286342963430634316343263433634346343563436634376343863439634406344163442634436344463445634466344763448634496345063451634526345363454634556345663457634586345963460634616346263463634646346563466634676346863469634706347163472634736347463475634766347763478634796348063481634826348363484634856348663487634886348963490634916349263493634946349563496634976349863499635006350163502635036350463505635066350763508635096351063511635126351363514635156351663517635186351963520635216352263523635246352563526635276352863529635306353163532635336353463535635366353763538635396354063541635426354363544635456354663547635486354963550635516355263553635546355563556635576355863559635606356163562635636356463565635666356763568635696357063571635726357363574635756357663577635786357963580635816358263583635846358563586635876358863589635906359163592635936359463595635966359763598635996360063601636026360363604636056360663607636086360963610636116361263613636146361563616636176361863619636206362163622636236362463625636266362763628636296363063631636326363363634636356363663637636386363963640636416364263643636446364563646636476364863649636506365163652636536365463655636566365763658636596366063661636626366363664636656366663667636686366963670636716367263673636746367563676636776367863679636806368163682636836368463685636866368763688636896369063691636926369363694636956369663697636986369963700637016370263703637046370563706637076370863709637106371163712637136371463715637166371763718637196372063721637226372363724637256372663727637286372963730637316373263733637346373563736637376373863739637406374163742637436374463745637466374763748637496375063751637526375363754637556375663757637586375963760637616376263763637646376563766637676376863769637706377163772637736377463775637766377763778637796378063781637826378363784637856378663787637886378963790637916379263793637946379563796637976379863799638006380163802638036380463805638066380763808638096381063811638126381363814638156381663817638186381963820638216382263823638246382563826638276382863829638306383163832638336383463835638366383763838638396384063841638426384363844638456384663847638486384963850638516385263853638546385563856638576385863859638606386163862638636386463865638666386763868638696387063871638726387363874638756387663877638786387963880638816388263883638846388563886638876388863889638906389163892638936389463895638966389763898638996390063901639026390363904639056390663907639086390963910639116391263913639146391563916639176391863919639206392163922639236392463925639266392763928639296393063931639326393363934639356393663937639386393963940639416394263943639446394563946639476394863949639506395163952639536395463955639566395763958639596396063961639626396363964639656396663967639686396963970639716397263973639746397563976639776397863979639806398163982639836398463985639866398763988639896399063991639926399363994639956399663997639986399964000640016400264003640046400564006640076400864009640106401164012640136401464015640166401764018640196402064021640226402364024640256402664027640286402964030640316403264033640346403564036640376403864039640406404164042640436404464045640466404764048640496405064051640526405364054640556405664057640586405964060640616406264063640646406564066640676406864069640706407164072640736407464075640766407764078640796408064081640826408364084640856408664087640886408964090640916409264093640946409564096640976409864099641006410164102641036410464105641066410764108641096411064111641126411364114641156411664117641186411964120641216412264123641246412564126641276412864129641306413164132641336413464135641366413764138641396414064141641426414364144641456414664147641486414964150641516415264153641546415564156641576415864159641606416164162641636416464165641666416764168641696417064171641726417364174641756417664177641786417964180641816418264183641846418564186641876418864189641906419164192641936419464195641966419764198641996420064201642026420364204642056420664207642086420964210642116421264213642146421564216642176421864219642206422164222642236422464225642266422764228642296423064231642326423364234642356423664237642386423964240642416424264243642446424564246642476424864249642506425164252642536425464255642566425764258642596426064261642626426364264642656426664267642686426964270642716427264273642746427564276642776427864279642806428164282642836428464285642866428764288642896429064291642926429364294642956429664297642986429964300643016430264303643046430564306643076430864309643106431164312643136431464315643166431764318643196432064321643226432364324643256432664327643286432964330643316433264333643346433564336643376433864339643406434164342643436434464345643466434764348643496435064351643526435364354643556435664357643586435964360643616436264363643646436564366643676436864369643706437164372643736437464375643766437764378643796438064381643826438364384643856438664387643886438964390643916439264393643946439564396643976439864399644006440164402644036440464405644066440764408644096441064411644126441364414644156441664417644186441964420644216442264423644246442564426644276442864429644306443164432644336443464435644366443764438644396444064441644426444364444644456444664447644486444964450644516445264453644546445564456644576445864459644606446164462644636446464465644666446764468644696447064471644726447364474644756447664477644786447964480644816448264483644846448564486644876448864489644906449164492644936449464495644966449764498644996450064501645026450364504645056450664507645086450964510645116451264513645146451564516645176451864519645206452164522645236452464525645266452764528645296453064531645326453364534645356453664537645386453964540645416454264543645446454564546645476454864549645506455164552645536455464555645566455764558645596456064561645626456364564645656456664567645686456964570645716457264573645746457564576645776457864579645806458164582645836458464585645866458764588645896459064591645926459364594645956459664597645986459964600646016460264603646046460564606646076460864609646106461164612646136461464615646166461764618646196462064621646226462364624646256462664627646286462964630646316463264633646346463564636646376463864639646406464164642646436464464645646466464764648646496465064651646526465364654646556465664657646586465964660646616466264663646646466564666646676466864669646706467164672646736467464675646766467764678646796468064681646826468364684646856468664687646886468964690646916469264693646946469564696646976469864699647006470164702647036470464705647066470764708647096471064711647126471364714647156471664717647186471964720647216472264723647246472564726647276472864729647306473164732647336473464735647366473764738647396474064741647426474364744647456474664747647486474964750647516475264753647546475564756647576475864759647606476164762647636476464765647666476764768647696477064771647726477364774647756477664777647786477964780647816478264783647846478564786647876478864789647906479164792647936479464795647966479764798647996480064801648026480364804648056480664807648086480964810648116481264813648146481564816648176481864819648206482164822648236482464825648266482764828648296483064831648326483364834648356483664837648386483964840648416484264843648446484564846648476484864849648506485164852648536485464855648566485764858648596486064861648626486364864648656486664867648686486964870648716487264873648746487564876648776487864879648806488164882648836488464885648866488764888648896489064891648926489364894648956489664897648986489964900649016490264903649046490564906649076490864909649106491164912649136491464915649166491764918649196492064921649226492364924649256492664927649286492964930649316493264933649346493564936649376493864939649406494164942649436494464945649466494764948649496495064951649526495364954649556495664957649586495964960649616496264963649646496564966649676496864969649706497164972649736497464975649766497764978649796498064981649826498364984649856498664987649886498964990649916499264993649946499564996649976499864999650006500165002650036500465005650066500765008650096501065011650126501365014650156501665017650186501965020650216502265023650246502565026650276502865029650306503165032650336503465035650366503765038650396504065041650426504365044650456504665047650486504965050650516505265053650546505565056650576505865059650606506165062650636506465065650666506765068650696507065071650726507365074650756507665077650786507965080650816508265083650846508565086650876508865089650906509165092650936509465095650966509765098650996510065101651026510365104651056510665107651086510965110651116511265113651146511565116651176511865119651206512165122651236512465125651266512765128651296513065131651326513365134651356513665137651386513965140651416514265143651446514565146651476514865149651506515165152651536515465155651566515765158651596516065161651626516365164651656516665167651686516965170651716517265173651746517565176651776517865179651806518165182651836518465185651866518765188651896519065191651926519365194651956519665197651986519965200652016520265203652046520565206652076520865209652106521165212652136521465215652166521765218652196522065221652226522365224652256522665227652286522965230652316523265233652346523565236652376523865239652406524165242652436524465245652466524765248652496525065251652526525365254652556525665257652586525965260652616526265263652646526565266652676526865269652706527165272652736527465275652766527765278652796528065281652826528365284652856528665287652886528965290652916529265293652946529565296652976529865299653006530165302653036530465305653066530765308653096531065311653126531365314653156531665317653186531965320653216532265323653246532565326653276532865329653306533165332653336533465335653366533765338653396534065341653426534365344653456534665347653486534965350653516535265353653546535565356653576535865359653606536165362653636536465365653666536765368653696537065371653726537365374653756537665377653786537965380653816538265383653846538565386653876538865389653906539165392653936539465395653966539765398653996540065401654026540365404654056540665407654086540965410654116541265413654146541565416654176541865419654206542165422654236542465425654266542765428654296543065431654326543365434654356543665437654386543965440654416544265443654446544565446654476544865449654506545165452654536545465455654566545765458654596546065461654626546365464654656546665467654686546965470654716547265473654746547565476654776547865479654806548165482654836548465485654866548765488654896549065491654926549365494654956549665497654986549965500655016550265503655046550565506655076550865509655106551165512655136551465515655166551765518655196552065521655226552365524655256552665527655286552965530655316553265533655346553565536655376553865539655406554165542655436554465545655466554765548655496555065551655526555365554655556555665557655586555965560655616556265563655646556565566655676556865569655706557165572655736557465575655766557765578655796558065581655826558365584655856558665587655886558965590655916559265593655946559565596655976559865599656006560165602656036560465605656066560765608656096561065611656126561365614656156561665617656186561965620656216562265623656246562565626656276562865629656306563165632656336563465635656366563765638656396564065641656426564365644656456564665647656486564965650656516565265653656546565565656656576565865659656606566165662656636566465665656666566765668656696567065671656726567365674656756567665677656786567965680656816568265683656846568565686656876568865689656906569165692656936569465695656966569765698656996570065701657026570365704657056570665707657086570965710657116571265713657146571565716657176571865719657206572165722657236572465725657266572765728657296573065731657326573365734657356573665737657386573965740657416574265743657446574565746657476574865749657506575165752657536575465755657566575765758657596576065761657626576365764657656576665767657686576965770657716577265773657746577565776657776577865779657806578165782657836578465785657866578765788657896579065791657926579365794657956579665797657986579965800658016580265803658046580565806658076580865809658106581165812658136581465815658166581765818658196582065821658226582365824658256582665827658286582965830658316583265833658346583565836658376583865839658406584165842658436584465845658466584765848658496585065851658526585365854658556585665857658586585965860658616586265863658646586565866658676586865869658706587165872658736587465875658766587765878658796588065881658826588365884658856588665887658886588965890658916589265893658946589565896658976589865899659006590165902659036590465905659066590765908659096591065911659126591365914659156591665917659186591965920659216592265923659246592565926659276592865929659306593165932659336593465935659366593765938659396594065941659426594365944659456594665947659486594965950659516595265953659546595565956659576595865959659606596165962659636596465965659666596765968659696597065971659726597365974659756597665977659786597965980659816598265983659846598565986659876598865989659906599165992659936599465995659966599765998659996600066001660026600366004660056600666007660086600966010660116601266013660146601566016660176601866019660206602166022660236602466025660266602766028660296603066031660326603366034660356603666037660386603966040660416604266043660446604566046660476604866049660506605166052660536605466055660566605766058660596606066061660626606366064660656606666067660686606966070660716607266073660746607566076660776607866079660806608166082660836608466085660866608766088660896609066091660926609366094660956609666097660986609966100661016610266103661046610566106661076610866109661106611166112661136611466115661166611766118661196612066121661226612366124661256612666127661286612966130661316613266133661346613566136661376613866139661406614166142661436614466145661466614766148661496615066151661526615366154661556615666157661586615966160661616616266163661646616566166661676616866169661706617166172661736617466175661766617766178661796618066181661826618366184661856618666187661886618966190661916619266193661946619566196661976619866199662006620166202662036620466205662066620766208662096621066211662126621366214662156621666217662186621966220662216622266223662246622566226662276622866229662306623166232662336623466235662366623766238662396624066241662426624366244662456624666247662486624966250662516625266253662546625566256662576625866259662606626166262662636626466265662666626766268662696627066271662726627366274662756627666277662786627966280662816628266283662846628566286662876628866289662906629166292662936629466295662966629766298662996630066301663026630366304663056630666307663086630966310663116631266313663146631566316663176631866319663206632166322663236632466325663266632766328663296633066331663326633366334663356633666337663386633966340663416634266343663446634566346663476634866349663506635166352663536635466355663566635766358663596636066361663626636366364663656636666367663686636966370663716637266373663746637566376663776637866379663806638166382663836638466385663866638766388663896639066391663926639366394663956639666397663986639966400664016640266403664046640566406664076640866409664106641166412664136641466415664166641766418664196642066421664226642366424664256642666427664286642966430664316643266433664346643566436664376643866439664406644166442664436644466445664466644766448664496645066451664526645366454664556645666457664586645966460664616646266463664646646566466664676646866469664706647166472664736647466475664766647766478664796648066481664826648366484664856648666487664886648966490664916649266493664946649566496664976649866499665006650166502665036650466505665066650766508665096651066511665126651366514665156651666517665186651966520665216652266523665246652566526665276652866529665306653166532665336653466535665366653766538665396654066541665426654366544665456654666547665486654966550665516655266553665546655566556665576655866559665606656166562665636656466565665666656766568665696657066571665726657366574665756657666577665786657966580665816658266583665846658566586665876658866589665906659166592665936659466595665966659766598665996660066601666026660366604666056660666607666086660966610666116661266613666146661566616666176661866619666206662166622666236662466625666266662766628666296663066631666326663366634666356663666637666386663966640666416664266643666446664566646666476664866649666506665166652666536665466655666566665766658666596666066661666626666366664666656666666667666686666966670666716667266673666746667566676666776667866679666806668166682666836668466685666866668766688666896669066691666926669366694666956669666697666986669966700667016670266703667046670566706667076670866709667106671166712667136671466715667166671766718667196672066721667226672366724667256672666727667286672966730667316673266733667346673566736667376673866739667406674166742667436674466745667466674766748667496675066751667526675366754667556675666757667586675966760667616676266763667646676566766667676676866769667706677166772667736677466775667766677766778667796678066781667826678366784667856678666787667886678966790667916679266793667946679566796667976679866799668006680166802668036680466805668066680766808668096681066811668126681366814668156681666817668186681966820668216682266823668246682566826668276682866829668306683166832668336683466835668366683766838668396684066841668426684366844668456684666847668486684966850668516685266853668546685566856668576685866859668606686166862668636686466865668666686766868668696687066871668726687366874668756687666877668786687966880668816688266883668846688566886668876688866889668906689166892668936689466895668966689766898668996690066901669026690366904669056690666907669086690966910669116691266913669146691566916669176691866919669206692166922669236692466925669266692766928669296693066931669326693366934669356693666937669386693966940669416694266943669446694566946669476694866949669506695166952669536695466955669566695766958669596696066961669626696366964669656696666967669686696966970669716697266973669746697566976669776697866979669806698166982669836698466985669866698766988669896699066991669926699366994669956699666997669986699967000670016700267003670046700567006670076700867009670106701167012670136701467015670166701767018670196702067021670226702367024670256702667027670286702967030670316703267033670346703567036670376703867039670406704167042670436704467045670466704767048670496705067051670526705367054670556705667057670586705967060670616706267063670646706567066670676706867069670706707167072670736707467075670766707767078670796708067081670826708367084670856708667087670886708967090670916709267093670946709567096670976709867099671006710167102671036710467105671066710767108671096711067111671126711367114671156711667117671186711967120671216712267123671246712567126671276712867129671306713167132671336713467135671366713767138671396714067141671426714367144671456714667147671486714967150671516715267153671546715567156671576715867159671606716167162671636716467165671666716767168671696717067171671726717367174671756717667177671786717967180671816718267183671846718567186671876718867189671906719167192671936719467195671966719767198671996720067201672026720367204672056720667207672086720967210672116721267213672146721567216672176721867219672206722167222672236722467225672266722767228672296723067231672326723367234672356723667237672386723967240672416724267243672446724567246672476724867249672506725167252672536725467255672566725767258672596726067261672626726367264672656726667267672686726967270672716727267273672746727567276672776727867279672806728167282672836728467285672866728767288672896729067291672926729367294672956729667297672986729967300673016730267303673046730567306673076730867309673106731167312673136731467315673166731767318673196732067321673226732367324673256732667327673286732967330673316733267333673346733567336673376733867339673406734167342673436734467345673466734767348673496735067351673526735367354673556735667357673586735967360673616736267363673646736567366673676736867369673706737167372673736737467375673766737767378673796738067381673826738367384673856738667387673886738967390673916739267393673946739567396673976739867399674006740167402674036740467405674066740767408674096741067411674126741367414674156741667417674186741967420674216742267423674246742567426674276742867429674306743167432674336743467435674366743767438674396744067441674426744367444674456744667447674486744967450674516745267453674546745567456674576745867459674606746167462674636746467465674666746767468674696747067471674726747367474674756747667477674786747967480674816748267483674846748567486674876748867489674906749167492674936749467495674966749767498674996750067501675026750367504675056750667507675086750967510675116751267513675146751567516675176751867519675206752167522675236752467525675266752767528675296753067531675326753367534675356753667537675386753967540675416754267543675446754567546675476754867549675506755167552675536755467555675566755767558675596756067561675626756367564675656756667567675686756967570675716757267573675746757567576675776757867579675806758167582675836758467585675866758767588675896759067591675926759367594675956759667597675986759967600676016760267603676046760567606676076760867609676106761167612676136761467615676166761767618676196762067621676226762367624676256762667627676286762967630676316763267633676346763567636676376763867639676406764167642676436764467645676466764767648676496765067651676526765367654676556765667657676586765967660676616766267663676646766567666676676766867669676706767167672676736767467675676766767767678676796768067681676826768367684676856768667687676886768967690676916769267693676946769567696676976769867699677006770167702677036770467705677066770767708677096771067711677126771367714677156771667717677186771967720677216772267723677246772567726677276772867729677306773167732677336773467735677366773767738677396774067741677426774367744677456774667747677486774967750677516775267753677546775567756677576775867759677606776167762677636776467765677666776767768677696777067771677726777367774677756777667777677786777967780677816778267783677846778567786677876778867789677906779167792677936779467795677966779767798677996780067801678026780367804678056780667807678086780967810678116781267813678146781567816678176781867819678206782167822678236782467825678266782767828678296783067831678326783367834678356783667837678386783967840678416784267843678446784567846678476784867849678506785167852678536785467855678566785767858678596786067861678626786367864678656786667867678686786967870678716787267873678746787567876678776787867879678806788167882678836788467885678866788767888678896789067891678926789367894678956789667897678986789967900679016790267903679046790567906679076790867909679106791167912679136791467915679166791767918679196792067921679226792367924679256792667927679286792967930679316793267933679346793567936679376793867939679406794167942679436794467945679466794767948679496795067951679526795367954679556795667957679586795967960679616796267963679646796567966679676796867969679706797167972679736797467975679766797767978679796798067981679826798367984679856798667987679886798967990679916799267993679946799567996679976799867999680006800168002680036800468005680066800768008680096801068011680126801368014680156801668017680186801968020680216802268023680246802568026680276802868029680306803168032680336803468035680366803768038680396804068041680426804368044680456804668047680486804968050680516805268053680546805568056680576805868059680606806168062680636806468065680666806768068680696807068071680726807368074680756807668077680786807968080680816808268083680846808568086680876808868089680906809168092680936809468095680966809768098680996810068101681026810368104681056810668107681086810968110681116811268113681146811568116681176811868119681206812168122681236812468125681266812768128681296813068131681326813368134681356813668137681386813968140681416814268143681446814568146681476814868149681506815168152681536815468155681566815768158681596816068161681626816368164681656816668167681686816968170681716817268173681746817568176681776817868179681806818168182681836818468185681866818768188681896819068191681926819368194681956819668197681986819968200682016820268203682046820568206682076820868209682106821168212682136821468215682166821768218682196822068221682226822368224682256822668227682286822968230682316823268233682346823568236682376823868239682406824168242682436824468245682466824768248682496825068251682526825368254682556825668257682586825968260682616826268263682646826568266682676826868269682706827168272682736827468275682766827768278682796828068281682826828368284682856828668287682886828968290682916829268293682946829568296682976829868299683006830168302683036830468305683066830768308683096831068311683126831368314683156831668317683186831968320683216832268323683246832568326683276832868329683306833168332683336833468335683366833768338683396834068341683426834368344683456834668347683486834968350683516835268353683546835568356683576835868359683606836168362683636836468365683666836768368683696837068371683726837368374683756837668377683786837968380683816838268383683846838568386683876838868389683906839168392683936839468395683966839768398683996840068401684026840368404684056840668407684086840968410684116841268413684146841568416684176841868419684206842168422684236842468425684266842768428684296843068431684326843368434684356843668437684386843968440684416844268443684446844568446684476844868449684506845168452684536845468455684566845768458684596846068461684626846368464684656846668467684686846968470684716847268473684746847568476684776847868479684806848168482684836848468485684866848768488684896849068491684926849368494684956849668497684986849968500685016850268503685046850568506685076850868509685106851168512685136851468515685166851768518685196852068521685226852368524685256852668527685286852968530685316853268533685346853568536685376853868539685406854168542685436854468545685466854768548685496855068551685526855368554685556855668557685586855968560685616856268563685646856568566685676856868569685706857168572685736857468575685766857768578685796858068581685826858368584685856858668587685886858968590685916859268593685946859568596685976859868599686006860168602686036860468605686066860768608686096861068611686126861368614686156861668617686186861968620686216862268623686246862568626686276862868629686306863168632686336863468635686366863768638686396864068641686426864368644686456864668647686486864968650686516865268653686546865568656686576865868659686606866168662686636866468665686666866768668686696867068671686726867368674686756867668677686786867968680686816868268683686846868568686686876868868689686906869168692686936869468695686966869768698686996870068701687026870368704687056870668707687086870968710687116871268713687146871568716687176871868719687206872168722687236872468725687266872768728687296873068731687326873368734687356873668737687386873968740687416874268743687446874568746687476874868749687506875168752687536875468755687566875768758687596876068761687626876368764687656876668767687686876968770687716877268773687746877568776687776877868779687806878168782687836878468785687866878768788687896879068791687926879368794687956879668797687986879968800688016880268803688046880568806688076880868809688106881168812688136881468815688166881768818688196882068821688226882368824688256882668827688286882968830688316883268833688346883568836688376883868839688406884168842688436884468845688466884768848688496885068851688526885368854688556885668857688586885968860688616886268863688646886568866688676886868869688706887168872688736887468875688766887768878688796888068881688826888368884688856888668887688886888968890688916889268893688946889568896688976889868899689006890168902689036890468905689066890768908689096891068911689126891368914689156891668917689186891968920689216892268923689246892568926689276892868929689306893168932689336893468935689366893768938689396894068941689426894368944689456894668947689486894968950689516895268953689546895568956689576895868959689606896168962689636896468965689666896768968689696897068971689726897368974689756897668977689786897968980689816898268983689846898568986689876898868989689906899168992689936899468995689966899768998689996900069001690026900369004690056900669007690086900969010690116901269013690146901569016690176901869019690206902169022690236902469025690266902769028690296903069031690326903369034690356903669037690386903969040690416904269043690446904569046690476904869049690506905169052690536905469055690566905769058690596906069061690626906369064690656906669067690686906969070690716907269073690746907569076690776907869079690806908169082690836908469085690866908769088690896909069091690926909369094690956909669097690986909969100691016910269103691046910569106691076910869109691106911169112691136911469115691166911769118691196912069121691226912369124691256912669127691286912969130691316913269133691346913569136691376913869139691406914169142691436914469145691466914769148691496915069151691526915369154691556915669157691586915969160691616916269163691646916569166691676916869169691706917169172691736917469175691766917769178691796918069181691826918369184691856918669187691886918969190691916919269193691946919569196691976919869199692006920169202692036920469205692066920769208692096921069211692126921369214692156921669217692186921969220692216922269223692246922569226692276922869229692306923169232692336923469235692366923769238692396924069241692426924369244692456924669247692486924969250692516925269253692546925569256692576925869259692606926169262692636926469265692666926769268692696927069271692726927369274692756927669277692786927969280692816928269283692846928569286692876928869289692906929169292692936929469295692966929769298692996930069301693026930369304693056930669307693086930969310693116931269313693146931569316693176931869319693206932169322693236932469325693266932769328693296933069331693326933369334693356933669337693386933969340693416934269343693446934569346693476934869349693506935169352693536935469355693566935769358693596936069361693626936369364693656936669367693686936969370693716937269373693746937569376693776937869379693806938169382693836938469385693866938769388693896939069391693926939369394693956939669397693986939969400694016940269403694046940569406694076940869409694106941169412694136941469415694166941769418694196942069421694226942369424694256942669427694286942969430694316943269433694346943569436694376943869439694406944169442694436944469445694466944769448694496945069451694526945369454694556945669457694586945969460694616946269463694646946569466694676946869469694706947169472694736947469475694766947769478694796948069481694826948369484694856948669487694886948969490694916949269493694946949569496694976949869499695006950169502695036950469505695066950769508695096951069511695126951369514695156951669517695186951969520695216952269523695246952569526695276952869529695306953169532695336953469535695366953769538695396954069541695426954369544695456954669547695486954969550695516955269553695546955569556695576955869559695606956169562695636956469565695666956769568695696957069571695726957369574695756957669577695786957969580695816958269583695846958569586695876958869589695906959169592695936959469595695966959769598695996960069601696026960369604696056960669607696086960969610696116961269613696146961569616696176961869619696206962169622696236962469625696266962769628696296963069631696326963369634696356963669637696386963969640696416964269643696446964569646696476964869649696506965169652696536965469655696566965769658696596966069661696626966369664696656966669667696686966969670696716967269673696746967569676696776967869679696806968169682696836968469685696866968769688696896969069691696926969369694696956969669697696986969969700697016970269703697046970569706697076970869709697106971169712697136971469715697166971769718697196972069721697226972369724697256972669727697286972969730697316973269733697346973569736697376973869739697406974169742697436974469745697466974769748697496975069751697526975369754697556975669757697586975969760697616976269763697646976569766697676976869769697706977169772697736977469775697766977769778697796978069781697826978369784697856978669787697886978969790697916979269793697946979569796697976979869799698006980169802698036980469805698066980769808698096981069811698126981369814698156981669817698186981969820698216982269823698246982569826698276982869829698306983169832698336983469835698366983769838698396984069841698426984369844698456984669847698486984969850698516985269853698546985569856698576985869859698606986169862698636986469865698666986769868698696987069871698726987369874698756987669877698786987969880698816988269883698846988569886698876988869889698906989169892698936989469895698966989769898698996990069901699026990369904699056990669907699086990969910699116991269913699146991569916699176991869919699206992169922699236992469925699266992769928699296993069931699326993369934699356993669937699386993969940699416994269943699446994569946699476994869949699506995169952699536995469955699566995769958699596996069961699626996369964699656996669967699686996969970699716997269973699746997569976699776997869979699806998169982699836998469985699866998769988699896999069991699926999369994699956999669997699986999970000700017000270003700047000570006700077000870009700107001170012700137001470015700167001770018700197002070021700227002370024700257002670027700287002970030700317003270033700347003570036700377003870039700407004170042700437004470045700467004770048700497005070051700527005370054700557005670057700587005970060700617006270063700647006570066700677006870069700707007170072700737007470075700767007770078700797008070081700827008370084700857008670087700887008970090700917009270093700947009570096700977009870099701007010170102701037010470105701067010770108701097011070111701127011370114701157011670117701187011970120701217012270123701247012570126701277012870129701307013170132701337013470135701367013770138701397014070141701427014370144701457014670147701487014970150701517015270153701547015570156701577015870159701607016170162701637016470165701667016770168701697017070171701727017370174701757017670177701787017970180701817018270183701847018570186701877018870189701907019170192701937019470195701967019770198701997020070201702027020370204702057020670207702087020970210702117021270213702147021570216702177021870219702207022170222702237022470225702267022770228702297023070231702327023370234702357023670237702387023970240702417024270243702447024570246702477024870249702507025170252702537025470255702567025770258702597026070261702627026370264702657026670267702687026970270702717027270273702747027570276702777027870279702807028170282702837028470285702867028770288702897029070291702927029370294702957029670297702987029970300703017030270303703047030570306703077030870309703107031170312703137031470315703167031770318703197032070321703227032370324703257032670327703287032970330703317033270333703347033570336703377033870339703407034170342703437034470345703467034770348703497035070351703527035370354703557035670357703587035970360703617036270363703647036570366703677036870369703707037170372703737037470375703767037770378703797038070381703827038370384703857038670387703887038970390703917039270393703947039570396703977039870399704007040170402704037040470405704067040770408704097041070411704127041370414704157041670417704187041970420704217042270423704247042570426704277042870429704307043170432704337043470435704367043770438704397044070441704427044370444704457044670447704487044970450704517045270453704547045570456704577045870459704607046170462704637046470465704667046770468704697047070471704727047370474704757047670477704787047970480704817048270483704847048570486704877048870489704907049170492704937049470495704967049770498704997050070501705027050370504705057050670507705087050970510705117051270513705147051570516705177051870519705207052170522705237052470525705267052770528705297053070531705327053370534705357053670537705387053970540705417054270543705447054570546705477054870549705507055170552705537055470555705567055770558705597056070561705627056370564705657056670567705687056970570705717057270573705747057570576705777057870579705807058170582705837058470585705867058770588705897059070591705927059370594705957059670597705987059970600706017060270603706047060570606706077060870609706107061170612706137061470615706167061770618706197062070621706227062370624706257062670627706287062970630706317063270633706347063570636706377063870639706407064170642706437064470645706467064770648706497065070651706527065370654706557065670657706587065970660706617066270663706647066570666706677066870669706707067170672706737067470675706767067770678706797068070681706827068370684706857068670687706887068970690706917069270693706947069570696706977069870699707007070170702707037070470705707067070770708707097071070711707127071370714707157071670717707187071970720707217072270723707247072570726707277072870729707307073170732707337073470735707367073770738707397074070741707427074370744707457074670747707487074970750707517075270753707547075570756707577075870759707607076170762707637076470765707667076770768707697077070771707727077370774707757077670777707787077970780707817078270783707847078570786707877078870789707907079170792707937079470795707967079770798707997080070801708027080370804708057080670807708087080970810708117081270813708147081570816708177081870819708207082170822708237082470825708267082770828708297083070831708327083370834708357083670837708387083970840708417084270843708447084570846708477084870849708507085170852708537085470855708567085770858708597086070861708627086370864708657086670867708687086970870708717087270873708747087570876708777087870879708807088170882708837088470885708867088770888708897089070891708927089370894708957089670897708987089970900709017090270903709047090570906709077090870909709107091170912709137091470915709167091770918709197092070921709227092370924709257092670927709287092970930709317093270933709347093570936709377093870939709407094170942709437094470945709467094770948709497095070951709527095370954709557095670957709587095970960709617096270963709647096570966709677096870969709707097170972709737097470975709767097770978709797098070981709827098370984709857098670987709887098970990709917099270993709947099570996709977099870999710007100171002710037100471005710067100771008710097101071011710127101371014710157101671017710187101971020710217102271023710247102571026710277102871029710307103171032710337103471035710367103771038710397104071041710427104371044710457104671047710487104971050710517105271053710547105571056710577105871059710607106171062710637106471065710667106771068710697107071071710727107371074710757107671077710787107971080710817108271083710847108571086710877108871089710907109171092710937109471095710967109771098710997110071101711027110371104711057110671107711087110971110711117111271113711147111571116711177111871119711207112171122711237112471125711267112771128711297113071131711327113371134711357113671137711387113971140711417114271143711447114571146711477114871149711507115171152711537115471155711567115771158711597116071161711627116371164711657116671167711687116971170711717117271173711747117571176711777117871179711807118171182711837118471185711867118771188711897119071191711927119371194711957119671197711987119971200712017120271203712047120571206712077120871209712107121171212712137121471215712167121771218712197122071221712227122371224712257122671227712287122971230712317123271233712347123571236712377123871239712407124171242712437124471245712467124771248712497125071251712527125371254712557125671257712587125971260712617126271263712647126571266712677126871269712707127171272712737127471275712767127771278712797128071281712827128371284712857128671287712887128971290712917129271293712947129571296712977129871299713007130171302713037130471305713067130771308713097131071311713127131371314713157131671317713187131971320713217132271323713247132571326713277132871329713307133171332713337133471335713367133771338713397134071341713427134371344713457134671347713487134971350713517135271353713547135571356713577135871359713607136171362713637136471365713667136771368713697137071371713727137371374713757137671377713787137971380713817138271383713847138571386713877138871389713907139171392713937139471395713967139771398713997140071401714027140371404714057140671407714087140971410714117141271413714147141571416714177141871419714207142171422714237142471425714267142771428714297143071431714327143371434714357143671437714387143971440714417144271443714447144571446714477144871449714507145171452714537145471455714567145771458714597146071461714627146371464714657146671467714687146971470714717147271473714747147571476714777147871479714807148171482714837148471485714867148771488714897149071491714927149371494714957149671497714987149971500715017150271503715047150571506715077150871509715107151171512715137151471515715167151771518715197152071521715227152371524715257152671527715287152971530715317153271533715347153571536715377153871539715407154171542715437154471545715467154771548715497155071551715527155371554715557155671557715587155971560715617156271563715647156571566715677156871569715707157171572715737157471575715767157771578715797158071581715827158371584715857158671587715887158971590715917159271593715947159571596715977159871599716007160171602716037160471605716067160771608716097161071611716127161371614716157161671617716187161971620716217162271623716247162571626716277162871629716307163171632716337163471635716367163771638716397164071641716427164371644716457164671647716487164971650716517165271653716547165571656716577165871659716607166171662716637166471665716667166771668716697167071671716727167371674716757167671677716787167971680716817168271683716847168571686716877168871689716907169171692716937169471695716967169771698716997170071701717027170371704717057170671707717087170971710717117171271713717147171571716717177171871719717207172171722717237172471725717267172771728717297173071731717327173371734717357173671737717387173971740717417174271743717447174571746717477174871749717507175171752717537175471755717567175771758717597176071761717627176371764717657176671767717687176971770717717177271773717747177571776717777177871779717807178171782717837178471785717867178771788717897179071791717927179371794717957179671797717987179971800718017180271803718047180571806718077180871809718107181171812718137181471815718167181771818718197182071821718227182371824718257182671827718287182971830718317183271833718347183571836718377183871839718407184171842718437184471845718467184771848718497185071851718527185371854718557185671857718587185971860718617186271863718647186571866718677186871869718707187171872718737187471875718767187771878718797188071881718827188371884718857188671887718887188971890718917189271893718947189571896718977189871899719007190171902719037190471905719067190771908719097191071911719127191371914719157191671917719187191971920719217192271923719247192571926719277192871929719307193171932719337193471935719367193771938719397194071941719427194371944719457194671947719487194971950719517195271953719547195571956719577195871959719607196171962719637196471965719667196771968719697197071971719727197371974719757197671977719787197971980719817198271983719847198571986719877198871989719907199171992719937199471995719967199771998719997200072001720027200372004720057200672007720087200972010720117201272013720147201572016720177201872019720207202172022720237202472025720267202772028720297203072031720327203372034720357203672037720387203972040720417204272043720447204572046720477204872049720507205172052720537205472055720567205772058720597206072061720627206372064720657206672067720687206972070720717207272073720747207572076720777207872079720807208172082720837208472085720867208772088720897209072091720927209372094720957209672097720987209972100721017210272103721047210572106721077210872109721107211172112721137211472115721167211772118721197212072121721227212372124721257212672127721287212972130721317213272133721347213572136721377213872139721407214172142721437214472145721467214772148721497215072151721527215372154721557215672157721587215972160721617216272163721647216572166721677216872169721707217172172721737217472175721767217772178721797218072181721827218372184721857218672187721887218972190721917219272193721947219572196721977219872199722007220172202722037220472205722067220772208722097221072211722127221372214722157221672217722187221972220722217222272223722247222572226722277222872229722307223172232722337223472235722367223772238722397224072241722427224372244722457224672247722487224972250722517225272253722547225572256722577225872259722607226172262722637226472265722667226772268722697227072271722727227372274722757227672277722787227972280722817228272283722847228572286722877228872289722907229172292722937229472295722967229772298722997230072301723027230372304723057230672307723087230972310723117231272313723147231572316723177231872319723207232172322723237232472325723267232772328723297233072331723327233372334723357233672337723387233972340723417234272343723447234572346723477234872349723507235172352723537235472355723567235772358723597236072361723627236372364723657236672367723687236972370723717237272373723747237572376723777237872379723807238172382723837238472385723867238772388723897239072391723927239372394723957239672397723987239972400724017240272403724047240572406724077240872409724107241172412724137241472415724167241772418724197242072421724227242372424724257242672427724287242972430724317243272433724347243572436724377243872439724407244172442724437244472445724467244772448724497245072451724527245372454724557245672457724587245972460724617246272463724647246572466724677246872469724707247172472724737247472475724767247772478724797248072481724827248372484724857248672487724887248972490724917249272493724947249572496724977249872499725007250172502725037250472505725067250772508725097251072511725127251372514725157251672517725187251972520725217252272523725247252572526725277252872529725307253172532725337253472535725367253772538725397254072541725427254372544725457254672547725487254972550725517255272553725547255572556725577255872559725607256172562725637256472565725667256772568725697257072571725727257372574725757257672577725787257972580725817258272583725847258572586725877258872589725907259172592725937259472595725967259772598725997260072601726027260372604726057260672607726087260972610726117261272613726147261572616726177261872619726207262172622726237262472625726267262772628726297263072631726327263372634726357263672637726387263972640726417264272643726447264572646726477264872649726507265172652726537265472655726567265772658726597266072661726627266372664726657266672667726687266972670726717267272673726747267572676726777267872679726807268172682726837268472685726867268772688726897269072691726927269372694726957269672697726987269972700727017270272703727047270572706727077270872709727107271172712727137271472715727167271772718727197272072721727227272372724727257272672727727287272972730727317273272733727347273572736727377273872739727407274172742727437274472745727467274772748727497275072751727527275372754727557275672757727587275972760727617276272763727647276572766727677276872769727707277172772727737277472775727767277772778727797278072781727827278372784727857278672787727887278972790727917279272793727947279572796727977279872799728007280172802728037280472805728067280772808728097281072811728127281372814728157281672817728187281972820728217282272823728247282572826728277282872829728307283172832728337283472835728367283772838728397284072841728427284372844728457284672847728487284972850728517285272853728547285572856728577285872859728607286172862728637286472865728667286772868728697287072871728727287372874728757287672877728787287972880728817288272883728847288572886728877288872889728907289172892728937289472895728967289772898728997290072901729027290372904729057290672907729087290972910729117291272913729147291572916729177291872919729207292172922729237292472925729267292772928729297293072931729327293372934729357293672937729387293972940729417294272943729447294572946729477294872949729507295172952729537295472955729567295772958729597296072961729627296372964729657296672967729687296972970729717297272973729747297572976729777297872979729807298172982729837298472985729867298772988729897299072991729927299372994729957299672997729987299973000730017300273003730047300573006730077300873009730107301173012730137301473015730167301773018730197302073021730227302373024730257302673027730287302973030730317303273033730347303573036730377303873039730407304173042730437304473045730467304773048730497305073051730527305373054730557305673057730587305973060730617306273063730647306573066730677306873069730707307173072730737307473075730767307773078730797308073081730827308373084730857308673087730887308973090730917309273093730947309573096730977309873099731007310173102731037310473105731067310773108731097311073111731127311373114731157311673117731187311973120731217312273123731247312573126731277312873129731307313173132731337313473135731367313773138731397314073141731427314373144731457314673147731487314973150731517315273153731547315573156731577315873159731607316173162731637316473165731667316773168731697317073171731727317373174731757317673177731787317973180731817318273183731847318573186731877318873189731907319173192731937319473195731967319773198731997320073201732027320373204732057320673207732087320973210732117321273213732147321573216732177321873219732207322173222732237322473225732267322773228732297323073231732327323373234732357323673237732387323973240732417324273243732447324573246732477324873249732507325173252732537325473255732567325773258732597326073261732627326373264732657326673267732687326973270732717327273273732747327573276732777327873279732807328173282732837328473285732867328773288732897329073291732927329373294732957329673297732987329973300733017330273303733047330573306733077330873309733107331173312733137331473315733167331773318733197332073321733227332373324733257332673327733287332973330733317333273333733347333573336733377333873339733407334173342733437334473345733467334773348733497335073351733527335373354733557335673357733587335973360733617336273363733647336573366733677336873369733707337173372733737337473375733767337773378733797338073381733827338373384733857338673387733887338973390733917339273393733947339573396733977339873399734007340173402734037340473405734067340773408734097341073411734127341373414734157341673417734187341973420734217342273423734247342573426734277342873429734307343173432734337343473435734367343773438734397344073441734427344373444734457344673447734487344973450734517345273453734547345573456734577345873459734607346173462734637346473465734667346773468734697347073471734727347373474734757347673477734787347973480734817348273483734847348573486734877348873489734907349173492734937349473495734967349773498734997350073501735027350373504735057350673507735087350973510735117351273513735147351573516735177351873519735207352173522735237352473525735267352773528735297353073531735327353373534735357353673537735387353973540735417354273543735447354573546735477354873549735507355173552735537355473555735567355773558735597356073561735627356373564735657356673567735687356973570735717357273573735747357573576735777357873579735807358173582735837358473585735867358773588735897359073591735927359373594735957359673597735987359973600736017360273603736047360573606736077360873609736107361173612736137361473615736167361773618736197362073621736227362373624736257362673627736287362973630736317363273633736347363573636736377363873639736407364173642736437364473645736467364773648736497365073651736527365373654736557365673657736587365973660736617366273663736647366573666736677366873669736707367173672736737367473675736767367773678736797368073681736827368373684736857368673687736887368973690736917369273693736947369573696736977369873699737007370173702737037370473705737067370773708737097371073711737127371373714737157371673717737187371973720737217372273723737247372573726737277372873729737307373173732737337373473735737367373773738737397374073741737427374373744737457374673747737487374973750737517375273753737547375573756737577375873759737607376173762737637376473765737667376773768737697377073771737727377373774737757377673777737787377973780737817378273783737847378573786737877378873789737907379173792737937379473795737967379773798737997380073801738027380373804738057380673807738087380973810738117381273813738147381573816738177381873819738207382173822738237382473825738267382773828738297383073831738327383373834738357383673837738387383973840738417384273843738447384573846738477384873849738507385173852738537385473855738567385773858738597386073861738627386373864738657386673867738687386973870738717387273873738747387573876738777387873879738807388173882738837388473885738867388773888738897389073891738927389373894738957389673897738987389973900739017390273903739047390573906739077390873909739107391173912739137391473915739167391773918739197392073921739227392373924739257392673927739287392973930739317393273933739347393573936739377393873939739407394173942739437394473945739467394773948739497395073951739527395373954739557395673957739587395973960739617396273963739647396573966739677396873969739707397173972739737397473975739767397773978739797398073981739827398373984739857398673987739887398973990739917399273993739947399573996739977399873999740007400174002740037400474005740067400774008740097401074011740127401374014740157401674017740187401974020740217402274023740247402574026740277402874029740307403174032740337403474035740367403774038740397404074041740427404374044740457404674047740487404974050740517405274053740547405574056740577405874059740607406174062740637406474065740667406774068740697407074071740727407374074740757407674077740787407974080740817408274083740847408574086740877408874089740907409174092740937409474095740967409774098740997410074101741027410374104741057410674107741087410974110741117411274113741147411574116741177411874119741207412174122741237412474125741267412774128741297413074131741327413374134741357413674137741387413974140741417414274143741447414574146741477414874149741507415174152741537415474155741567415774158741597416074161741627416374164741657416674167741687416974170741717417274173741747417574176741777417874179741807418174182741837418474185741867418774188741897419074191741927419374194741957419674197741987419974200742017420274203742047420574206742077420874209742107421174212742137421474215742167421774218742197422074221742227422374224742257422674227742287422974230742317423274233742347423574236742377423874239742407424174242742437424474245742467424774248742497425074251742527425374254742557425674257742587425974260742617426274263742647426574266742677426874269742707427174272742737427474275742767427774278742797428074281742827428374284742857428674287742887428974290742917429274293742947429574296742977429874299743007430174302743037430474305743067430774308743097431074311743127431374314743157431674317743187431974320743217432274323743247432574326743277432874329743307433174332743337433474335743367433774338743397434074341743427434374344743457434674347743487434974350743517435274353743547435574356743577435874359743607436174362743637436474365743667436774368743697437074371743727437374374743757437674377743787437974380743817438274383743847438574386743877438874389743907439174392743937439474395743967439774398743997440074401744027440374404744057440674407744087440974410744117441274413744147441574416744177441874419744207442174422744237442474425744267442774428744297443074431744327443374434744357443674437744387443974440744417444274443744447444574446744477444874449744507445174452744537445474455744567445774458744597446074461744627446374464744657446674467744687446974470744717447274473744747447574476744777447874479744807448174482744837448474485744867448774488744897449074491744927449374494744957449674497744987449974500745017450274503745047450574506745077450874509745107451174512745137451474515745167451774518745197452074521745227452374524745257452674527745287452974530745317453274533745347453574536745377453874539745407454174542745437454474545745467454774548745497455074551745527455374554745557455674557745587455974560745617456274563745647456574566745677456874569745707457174572745737457474575745767457774578745797458074581745827458374584745857458674587745887458974590745917459274593745947459574596745977459874599746007460174602746037460474605746067460774608746097461074611746127461374614746157461674617746187461974620746217462274623746247462574626746277462874629746307463174632746337463474635746367463774638746397464074641746427464374644746457464674647746487464974650746517465274653746547465574656746577465874659746607466174662746637466474665746667466774668746697467074671746727467374674746757467674677746787467974680746817468274683746847468574686746877468874689746907469174692746937469474695746967469774698746997470074701747027470374704747057470674707747087470974710747117471274713747147471574716747177471874719747207472174722747237472474725747267472774728747297473074731747327473374734747357473674737747387473974740747417474274743747447474574746747477474874749747507475174752747537475474755747567475774758747597476074761747627476374764747657476674767747687476974770747717477274773747747477574776747777477874779747807478174782747837478474785747867478774788747897479074791747927479374794747957479674797747987479974800748017480274803748047480574806748077480874809748107481174812748137481474815748167481774818748197482074821748227482374824748257482674827748287482974830748317483274833748347483574836748377483874839748407484174842748437484474845748467484774848748497485074851748527485374854748557485674857748587485974860748617486274863748647486574866748677486874869748707487174872748737487474875748767487774878748797488074881748827488374884748857488674887748887488974890748917489274893748947489574896748977489874899749007490174902749037490474905749067490774908749097491074911749127491374914749157491674917749187491974920749217492274923749247492574926749277492874929749307493174932749337493474935749367493774938749397494074941749427494374944749457494674947749487494974950749517495274953749547495574956749577495874959749607496174962749637496474965749667496774968749697497074971749727497374974749757497674977749787497974980749817498274983749847498574986749877498874989749907499174992749937499474995749967499774998749997500075001750027500375004750057500675007750087500975010750117501275013750147501575016750177501875019750207502175022750237502475025750267502775028750297503075031750327503375034750357503675037750387503975040750417504275043750447504575046750477504875049750507505175052750537505475055750567505775058750597506075061750627506375064750657506675067750687506975070750717507275073750747507575076750777507875079750807508175082750837508475085750867508775088750897509075091750927509375094750957509675097750987509975100751017510275103751047510575106751077510875109751107511175112751137511475115751167511775118751197512075121751227512375124751257512675127751287512975130751317513275133751347513575136751377513875139751407514175142751437514475145751467514775148751497515075151751527515375154751557515675157751587515975160751617516275163751647516575166751677516875169751707517175172751737517475175751767517775178751797518075181751827518375184751857518675187751887518975190751917519275193751947519575196751977519875199752007520175202752037520475205752067520775208752097521075211752127521375214752157521675217752187521975220752217522275223752247522575226752277522875229752307523175232752337523475235752367523775238752397524075241752427524375244752457524675247752487524975250752517525275253752547525575256752577525875259752607526175262752637526475265752667526775268752697527075271752727527375274752757527675277752787527975280752817528275283752847528575286752877528875289752907529175292752937529475295752967529775298752997530075301753027530375304753057530675307753087530975310753117531275313753147531575316753177531875319753207532175322753237532475325753267532775328753297533075331753327533375334753357533675337753387533975340753417534275343753447534575346753477534875349753507535175352753537535475355753567535775358753597536075361753627536375364753657536675367753687536975370753717537275373753747537575376753777537875379753807538175382753837538475385753867538775388753897539075391753927539375394753957539675397753987539975400754017540275403754047540575406754077540875409754107541175412754137541475415754167541775418754197542075421754227542375424754257542675427754287542975430754317543275433754347543575436754377543875439754407544175442754437544475445754467544775448754497545075451754527545375454754557545675457754587545975460754617546275463754647546575466754677546875469754707547175472754737547475475754767547775478754797548075481754827548375484754857548675487754887548975490754917549275493754947549575496754977549875499755007550175502755037550475505755067550775508755097551075511755127551375514755157551675517755187551975520755217552275523755247552575526755277552875529755307553175532755337553475535755367553775538755397554075541755427554375544755457554675547755487554975550755517555275553755547555575556755577555875559755607556175562755637556475565755667556775568755697557075571755727557375574755757557675577755787557975580755817558275583755847558575586755877558875589755907559175592755937559475595755967559775598755997560075601756027560375604756057560675607756087560975610756117561275613756147561575616756177561875619756207562175622756237562475625756267562775628756297563075631756327563375634756357563675637756387563975640756417564275643756447564575646756477564875649756507565175652756537565475655756567565775658756597566075661756627566375664756657566675667756687566975670756717567275673756747567575676756777567875679756807568175682756837568475685756867568775688756897569075691756927569375694756957569675697756987569975700757017570275703757047570575706757077570875709757107571175712757137571475715757167571775718757197572075721757227572375724757257572675727757287572975730757317573275733757347573575736757377573875739757407574175742757437574475745757467574775748757497575075751757527575375754757557575675757757587575975760757617576275763757647576575766757677576875769757707577175772757737577475775757767577775778757797578075781757827578375784757857578675787757887578975790757917579275793757947579575796757977579875799758007580175802758037580475805758067580775808758097581075811758127581375814758157581675817758187581975820758217582275823758247582575826758277582875829758307583175832758337583475835758367583775838758397584075841758427584375844758457584675847758487584975850758517585275853758547585575856758577585875859758607586175862758637586475865758667586775868758697587075871758727587375874758757587675877758787587975880758817588275883758847588575886758877588875889758907589175892758937589475895758967589775898758997590075901759027590375904759057590675907759087590975910759117591275913759147591575916759177591875919759207592175922759237592475925759267592775928759297593075931759327593375934759357593675937759387593975940759417594275943759447594575946759477594875949759507595175952759537595475955759567595775958759597596075961759627596375964759657596675967759687596975970759717597275973759747597575976759777597875979759807598175982759837598475985759867598775988759897599075991759927599375994759957599675997759987599976000760017600276003760047600576006760077600876009760107601176012760137601476015760167601776018760197602076021760227602376024760257602676027760287602976030760317603276033760347603576036760377603876039760407604176042760437604476045760467604776048760497605076051760527605376054760557605676057760587605976060760617606276063760647606576066760677606876069760707607176072760737607476075760767607776078760797608076081760827608376084760857608676087760887608976090760917609276093760947609576096760977609876099761007610176102761037610476105761067610776108761097611076111761127611376114761157611676117761187611976120761217612276123761247612576126761277612876129761307613176132761337613476135761367613776138761397614076141761427614376144761457614676147761487614976150761517615276153761547615576156761577615876159761607616176162761637616476165761667616776168761697617076171761727617376174761757617676177761787617976180761817618276183761847618576186761877618876189761907619176192761937619476195761967619776198761997620076201762027620376204762057620676207762087620976210762117621276213762147621576216762177621876219762207622176222762237622476225762267622776228762297623076231762327623376234762357623676237762387623976240762417624276243762447624576246762477624876249762507625176252762537625476255762567625776258762597626076261762627626376264762657626676267762687626976270762717627276273762747627576276762777627876279762807628176282762837628476285762867628776288762897629076291762927629376294762957629676297762987629976300763017630276303763047630576306763077630876309763107631176312763137631476315763167631776318763197632076321763227632376324763257632676327763287632976330763317633276333763347633576336763377633876339763407634176342763437634476345763467634776348763497635076351763527635376354763557635676357763587635976360763617636276363763647636576366763677636876369763707637176372763737637476375763767637776378763797638076381763827638376384763857638676387763887638976390763917639276393763947639576396763977639876399764007640176402764037640476405764067640776408764097641076411764127641376414764157641676417764187641976420764217642276423764247642576426764277642876429764307643176432764337643476435764367643776438764397644076441764427644376444764457644676447764487644976450764517645276453764547645576456764577645876459764607646176462764637646476465764667646776468764697647076471764727647376474764757647676477764787647976480764817648276483764847648576486764877648876489764907649176492764937649476495764967649776498764997650076501765027650376504765057650676507765087650976510765117651276513765147651576516765177651876519765207652176522765237652476525765267652776528765297653076531765327653376534765357653676537765387653976540765417654276543765447654576546765477654876549765507655176552765537655476555765567655776558765597656076561765627656376564765657656676567765687656976570765717657276573765747657576576765777657876579765807658176582765837658476585765867658776588765897659076591765927659376594765957659676597765987659976600766017660276603766047660576606766077660876609766107661176612766137661476615766167661776618766197662076621766227662376624766257662676627766287662976630766317663276633766347663576636766377663876639766407664176642766437664476645766467664776648766497665076651766527665376654766557665676657766587665976660766617666276663766647666576666766677666876669766707667176672766737667476675766767667776678766797668076681766827668376684766857668676687766887668976690766917669276693766947669576696766977669876699767007670176702767037670476705767067670776708767097671076711767127671376714767157671676717767187671976720767217672276723767247672576726767277672876729767307673176732767337673476735767367673776738767397674076741767427674376744767457674676747767487674976750767517675276753767547675576756767577675876759767607676176762767637676476765767667676776768767697677076771767727677376774767757677676777767787677976780767817678276783767847678576786767877678876789767907679176792767937679476795767967679776798767997680076801768027680376804768057680676807768087680976810768117681276813768147681576816768177681876819768207682176822768237682476825768267682776828768297683076831768327683376834768357683676837768387683976840768417684276843768447684576846768477684876849768507685176852768537685476855768567685776858768597686076861768627686376864768657686676867768687686976870768717687276873768747687576876768777687876879768807688176882768837688476885768867688776888768897689076891768927689376894768957689676897768987689976900769017690276903769047690576906769077690876909769107691176912769137691476915769167691776918769197692076921769227692376924769257692676927769287692976930769317693276933769347693576936769377693876939769407694176942769437694476945769467694776948769497695076951769527695376954769557695676957769587695976960769617696276963769647696576966769677696876969769707697176972769737697476975769767697776978769797698076981769827698376984769857698676987769887698976990769917699276993769947699576996769977699876999770007700177002770037700477005770067700777008770097701077011770127701377014770157701677017770187701977020770217702277023770247702577026770277702877029770307703177032770337703477035770367703777038770397704077041770427704377044770457704677047770487704977050770517705277053770547705577056770577705877059770607706177062770637706477065770667706777068770697707077071770727707377074770757707677077770787707977080770817708277083770847708577086770877708877089770907709177092770937709477095770967709777098770997710077101771027710377104771057710677107771087710977110771117711277113771147711577116771177711877119771207712177122771237712477125771267712777128771297713077131771327713377134771357713677137771387713977140771417714277143771447714577146771477714877149771507715177152771537715477155771567715777158771597716077161771627716377164771657716677167771687716977170771717717277173771747717577176771777717877179771807718177182771837718477185771867718777188771897719077191771927719377194771957719677197771987719977200772017720277203772047720577206772077720877209772107721177212772137721477215772167721777218772197722077221772227722377224772257722677227772287722977230772317723277233772347723577236772377723877239772407724177242772437724477245772467724777248772497725077251772527725377254772557725677257772587725977260772617726277263772647726577266772677726877269772707727177272772737727477275772767727777278772797728077281772827728377284772857728677287772887728977290772917729277293772947729577296772977729877299773007730177302773037730477305773067730777308773097731077311773127731377314773157731677317773187731977320773217732277323773247732577326773277732877329773307733177332773337733477335773367733777338773397734077341773427734377344773457734677347773487734977350773517735277353773547735577356773577735877359773607736177362773637736477365773667736777368773697737077371773727737377374773757737677377773787737977380773817738277383773847738577386773877738877389773907739177392773937739477395773967739777398773997740077401774027740377404774057740677407774087740977410774117741277413774147741577416774177741877419774207742177422774237742477425774267742777428774297743077431774327743377434774357743677437774387743977440774417744277443774447744577446774477744877449774507745177452774537745477455774567745777458774597746077461774627746377464774657746677467774687746977470774717747277473774747747577476774777747877479774807748177482774837748477485774867748777488774897749077491774927749377494774957749677497774987749977500775017750277503775047750577506775077750877509775107751177512775137751477515775167751777518775197752077521775227752377524775257752677527775287752977530775317753277533775347753577536775377753877539775407754177542775437754477545775467754777548775497755077551775527755377554775557755677557775587755977560775617756277563775647756577566775677756877569775707757177572775737757477575775767757777578775797758077581775827758377584775857758677587775887758977590775917759277593775947759577596775977759877599776007760177602776037760477605776067760777608776097761077611776127761377614776157761677617776187761977620776217762277623776247762577626776277762877629776307763177632776337763477635776367763777638776397764077641776427764377644776457764677647776487764977650776517765277653776547765577656776577765877659776607766177662776637766477665776667766777668776697767077671776727767377674776757767677677776787767977680776817768277683776847768577686776877768877689776907769177692776937769477695776967769777698776997770077701777027770377704777057770677707777087770977710777117771277713777147771577716777177771877719777207772177722777237772477725777267772777728777297773077731777327773377734777357773677737777387773977740777417774277743777447774577746777477774877749777507775177752777537775477755777567775777758777597776077761777627776377764777657776677767777687776977770777717777277773777747777577776777777777877779777807778177782777837778477785777867778777788777897779077791777927779377794777957779677797777987779977800778017780277803778047780577806778077780877809778107781177812778137781477815778167781777818778197782077821778227782377824778257782677827778287782977830778317783277833778347783577836778377783877839778407784177842778437784477845778467784777848778497785077851778527785377854778557785677857778587785977860778617786277863778647786577866778677786877869778707787177872778737787477875778767787777878778797788077881778827788377884778857788677887778887788977890778917789277893778947789577896778977789877899779007790177902779037790477905779067790777908779097791077911779127791377914779157791677917779187791977920779217792277923779247792577926779277792877929779307793177932779337793477935779367793777938779397794077941779427794377944779457794677947779487794977950779517795277953779547795577956779577795877959779607796177962779637796477965779667796777968779697797077971779727797377974779757797677977779787797977980779817798277983779847798577986779877798877989779907799177992779937799477995779967799777998779997800078001780027800378004780057800678007780087800978010780117801278013780147801578016780177801878019780207802178022780237802478025780267802778028780297803078031780327803378034780357803678037780387803978040780417804278043780447804578046780477804878049780507805178052780537805478055780567805778058780597806078061780627806378064780657806678067780687806978070780717807278073780747807578076780777807878079780807808178082780837808478085780867808778088780897809078091780927809378094780957809678097780987809978100781017810278103781047810578106781077810878109781107811178112781137811478115781167811778118781197812078121781227812378124781257812678127781287812978130781317813278133781347813578136781377813878139781407814178142781437814478145781467814778148781497815078151781527815378154781557815678157781587815978160781617816278163781647816578166781677816878169781707817178172781737817478175781767817778178781797818078181781827818378184781857818678187781887818978190781917819278193781947819578196781977819878199782007820178202782037820478205782067820778208782097821078211782127821378214782157821678217782187821978220782217822278223782247822578226782277822878229782307823178232782337823478235782367823778238782397824078241782427824378244782457824678247782487824978250782517825278253782547825578256782577825878259782607826178262782637826478265782667826778268782697827078271782727827378274782757827678277782787827978280782817828278283782847828578286782877828878289782907829178292782937829478295782967829778298782997830078301783027830378304783057830678307783087830978310783117831278313783147831578316783177831878319783207832178322783237832478325783267832778328783297833078331783327833378334783357833678337783387833978340783417834278343783447834578346783477834878349783507835178352783537835478355783567835778358783597836078361783627836378364783657836678367783687836978370783717837278373783747837578376783777837878379783807838178382783837838478385783867838778388783897839078391783927839378394783957839678397783987839978400784017840278403784047840578406784077840878409784107841178412784137841478415784167841778418784197842078421784227842378424784257842678427784287842978430784317843278433784347843578436784377843878439784407844178442784437844478445784467844778448784497845078451784527845378454784557845678457784587845978460784617846278463784647846578466784677846878469784707847178472784737847478475784767847778478784797848078481784827848378484784857848678487784887848978490784917849278493784947849578496784977849878499785007850178502785037850478505785067850778508785097851078511785127851378514785157851678517785187851978520785217852278523785247852578526785277852878529785307853178532785337853478535785367853778538785397854078541785427854378544785457854678547785487854978550785517855278553785547855578556785577855878559785607856178562785637856478565785667856778568785697857078571785727857378574785757857678577785787857978580785817858278583785847858578586785877858878589785907859178592785937859478595785967859778598785997860078601786027860378604786057860678607786087860978610786117861278613786147861578616786177861878619786207862178622786237862478625786267862778628786297863078631786327863378634786357863678637786387863978640786417864278643786447864578646786477864878649786507865178652786537865478655786567865778658786597866078661786627866378664786657866678667786687866978670786717867278673786747867578676786777867878679786807868178682786837868478685786867868778688786897869078691786927869378694786957869678697786987869978700787017870278703787047870578706787077870878709787107871178712787137871478715787167871778718787197872078721787227872378724787257872678727787287872978730787317873278733787347873578736787377873878739787407874178742787437874478745787467874778748787497875078751787527875378754787557875678757787587875978760787617876278763787647876578766787677876878769787707877178772787737877478775787767877778778787797878078781787827878378784787857878678787787887878978790787917879278793787947879578796787977879878799788007880178802788037880478805788067880778808788097881078811788127881378814788157881678817788187881978820788217882278823788247882578826788277882878829788307883178832788337883478835788367883778838788397884078841788427884378844788457884678847788487884978850788517885278853788547885578856788577885878859788607886178862788637886478865788667886778868788697887078871788727887378874788757887678877788787887978880788817888278883788847888578886788877888878889788907889178892788937889478895788967889778898788997890078901789027890378904789057890678907789087890978910789117891278913789147891578916789177891878919789207892178922789237892478925789267892778928789297893078931789327893378934789357893678937789387893978940789417894278943789447894578946789477894878949789507895178952789537895478955789567895778958789597896078961789627896378964789657896678967789687896978970789717897278973789747897578976789777897878979789807898178982789837898478985789867898778988789897899078991789927899378994789957899678997789987899979000790017900279003790047900579006790077900879009790107901179012790137901479015790167901779018790197902079021790227902379024790257902679027790287902979030790317903279033790347903579036790377903879039790407904179042790437904479045790467904779048790497905079051790527905379054790557905679057790587905979060790617906279063790647906579066790677906879069790707907179072790737907479075790767907779078790797908079081790827908379084790857908679087790887908979090790917909279093790947909579096790977909879099791007910179102791037910479105791067910779108791097911079111791127911379114791157911679117791187911979120791217912279123791247912579126791277912879129791307913179132791337913479135791367913779138791397914079141791427914379144791457914679147791487914979150791517915279153791547915579156791577915879159791607916179162791637916479165791667916779168791697917079171791727917379174791757917679177791787917979180791817918279183791847918579186791877918879189791907919179192791937919479195791967919779198791997920079201792027920379204792057920679207792087920979210792117921279213792147921579216792177921879219792207922179222792237922479225792267922779228792297923079231792327923379234792357923679237792387923979240792417924279243792447924579246792477924879249792507925179252792537925479255792567925779258792597926079261792627926379264792657926679267792687926979270792717927279273792747927579276792777927879279792807928179282792837928479285792867928779288792897929079291792927929379294792957929679297792987929979300793017930279303793047930579306793077930879309793107931179312793137931479315793167931779318793197932079321793227932379324793257932679327793287932979330793317933279333793347933579336793377933879339793407934179342793437934479345793467934779348793497935079351793527935379354793557935679357793587935979360793617936279363793647936579366793677936879369793707937179372793737937479375793767937779378793797938079381793827938379384793857938679387793887938979390793917939279393793947939579396793977939879399794007940179402794037940479405794067940779408794097941079411794127941379414794157941679417794187941979420794217942279423794247942579426794277942879429794307943179432794337943479435794367943779438794397944079441794427944379444794457944679447794487944979450794517945279453794547945579456794577945879459794607946179462794637946479465794667946779468794697947079471794727947379474794757947679477794787947979480794817948279483794847948579486794877948879489794907949179492794937949479495794967949779498794997950079501795027950379504795057950679507795087950979510795117951279513795147951579516795177951879519795207952179522795237952479525795267952779528795297953079531795327953379534795357953679537795387953979540795417954279543795447954579546795477954879549795507955179552795537955479555795567955779558795597956079561795627956379564795657956679567795687956979570795717957279573795747957579576795777957879579795807958179582795837958479585795867958779588795897959079591795927959379594795957959679597795987959979600796017960279603796047960579606796077960879609796107961179612796137961479615796167961779618796197962079621796227962379624796257962679627796287962979630796317963279633796347963579636796377963879639796407964179642796437964479645796467964779648796497965079651796527965379654796557965679657796587965979660796617966279663796647966579666796677966879669796707967179672796737967479675796767967779678796797968079681796827968379684796857968679687796887968979690796917969279693796947969579696796977969879699797007970179702797037970479705797067970779708797097971079711797127971379714797157971679717797187971979720797217972279723797247972579726797277972879729797307973179732797337973479735797367973779738797397974079741797427974379744797457974679747797487974979750797517975279753797547975579756797577975879759797607976179762797637976479765797667976779768797697977079771797727977379774797757977679777797787977979780797817978279783797847978579786797877978879789797907979179792797937979479795797967979779798797997980079801798027980379804798057980679807798087980979810798117981279813798147981579816798177981879819798207982179822798237982479825798267982779828798297983079831798327983379834798357983679837798387983979840798417984279843798447984579846798477984879849798507985179852798537985479855798567985779858798597986079861798627986379864798657986679867798687986979870798717987279873798747987579876798777987879879798807988179882798837988479885798867988779888798897989079891798927989379894798957989679897798987989979900799017990279903799047990579906799077990879909799107991179912799137991479915799167991779918799197992079921799227992379924799257992679927799287992979930799317993279933799347993579936799377993879939799407994179942799437994479945799467994779948799497995079951799527995379954799557995679957799587995979960799617996279963799647996579966799677996879969799707997179972799737997479975799767997779978799797998079981799827998379984799857998679987799887998979990799917999279993799947999579996799977999879999800008000180002800038000480005800068000780008800098001080011800128001380014800158001680017800188001980020800218002280023800248002580026800278002880029800308003180032800338003480035800368003780038800398004080041800428004380044800458004680047800488004980050800518005280053800548005580056800578005880059800608006180062800638006480065
  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. * The url of the texture
  7676. */
  7677. url: string;
  7678. /**
  7679. * Gets or sets the center of the bounding box associated with the cube texture.
  7680. * It must define where the camera used to render the texture was set
  7681. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7682. */
  7683. boundingBoxPosition: Vector3;
  7684. private _boundingBoxSize;
  7685. /**
  7686. * Gets or sets the size of the bounding box associated with the cube texture
  7687. * When defined, the cubemap will switch to local mode
  7688. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7689. * @example https://www.babylonjs-playground.com/#RNASML
  7690. */
  7691. set boundingBoxSize(value: Vector3);
  7692. /**
  7693. * Returns the bounding box size
  7694. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7695. */
  7696. get boundingBoxSize(): Vector3;
  7697. protected _rotationY: number;
  7698. /**
  7699. * Sets texture matrix rotation angle around Y axis in radians.
  7700. */
  7701. set rotationY(value: number);
  7702. /**
  7703. * Gets texture matrix rotation angle around Y axis radians.
  7704. */
  7705. get rotationY(): number;
  7706. /**
  7707. * Are mip maps generated for this texture or not.
  7708. */
  7709. get noMipmap(): boolean;
  7710. private _noMipmap;
  7711. private _files;
  7712. protected _forcedExtension: Nullable<string>;
  7713. private _extensions;
  7714. private _textureMatrix;
  7715. private _format;
  7716. private _createPolynomials;
  7717. /** @hidden */
  7718. _prefiltered: boolean;
  7719. /**
  7720. * Creates a cube texture from an array of image urls
  7721. * @param files defines an array of image urls
  7722. * @param scene defines the hosting scene
  7723. * @param noMipmap specifies if mip maps are not used
  7724. * @returns a cube texture
  7725. */
  7726. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7727. /**
  7728. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7729. * @param url defines the url of the prefiltered texture
  7730. * @param scene defines the scene the texture is attached to
  7731. * @param forcedExtension defines the extension of the file if different from the url
  7732. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7733. * @return the prefiltered texture
  7734. */
  7735. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7736. /**
  7737. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7738. * as prefiltered data.
  7739. * @param rootUrl defines the url of the texture or the root name of the six images
  7740. * @param scene defines the scene the texture is attached to
  7741. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7742. * @param noMipmap defines if mipmaps should be created or not
  7743. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7744. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7745. * @param onError defines a callback triggered in case of error during load
  7746. * @param format defines the internal format to use for the texture once loaded
  7747. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7748. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7749. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7750. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7751. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7752. * @return the cube texture
  7753. */
  7754. 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);
  7755. /**
  7756. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7757. */
  7758. get isPrefiltered(): boolean;
  7759. /**
  7760. * Get the current class name of the texture useful for serialization or dynamic coding.
  7761. * @returns "CubeTexture"
  7762. */
  7763. getClassName(): string;
  7764. /**
  7765. * Update the url (and optional buffer) of this texture if url was null during construction.
  7766. * @param url the url of the texture
  7767. * @param forcedExtension defines the extension to use
  7768. * @param onLoad callback called when the texture is loaded (defaults to null)
  7769. * @param prefiltered Defines whether the updated texture is prefiltered or not
  7770. */
  7771. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  7772. /**
  7773. * Delays loading of the cube texture
  7774. * @param forcedExtension defines the extension to use
  7775. */
  7776. delayLoad(forcedExtension?: string): void;
  7777. /**
  7778. * Returns the reflection texture matrix
  7779. * @returns the reflection texture matrix
  7780. */
  7781. getReflectionTextureMatrix(): Matrix;
  7782. /**
  7783. * Sets the reflection texture matrix
  7784. * @param value Reflection texture matrix
  7785. */
  7786. setReflectionTextureMatrix(value: Matrix): void;
  7787. /**
  7788. * Parses text to create a cube texture
  7789. * @param parsedTexture define the serialized text to read from
  7790. * @param scene defines the hosting scene
  7791. * @param rootUrl defines the root url of the cube texture
  7792. * @returns a cube texture
  7793. */
  7794. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7795. /**
  7796. * Makes a clone, or deep copy, of the cube texture
  7797. * @returns a new cube texture
  7798. */
  7799. clone(): CubeTexture;
  7800. }
  7801. }
  7802. declare module BABYLON {
  7803. /**
  7804. * Manages the defines for the Material
  7805. */
  7806. export class MaterialDefines {
  7807. /** @hidden */
  7808. protected _keys: string[];
  7809. private _isDirty;
  7810. /** @hidden */
  7811. _renderId: number;
  7812. /** @hidden */
  7813. _areLightsDirty: boolean;
  7814. /** @hidden */
  7815. _areLightsDisposed: boolean;
  7816. /** @hidden */
  7817. _areAttributesDirty: boolean;
  7818. /** @hidden */
  7819. _areTexturesDirty: boolean;
  7820. /** @hidden */
  7821. _areFresnelDirty: boolean;
  7822. /** @hidden */
  7823. _areMiscDirty: boolean;
  7824. /** @hidden */
  7825. _areImageProcessingDirty: boolean;
  7826. /** @hidden */
  7827. _normals: boolean;
  7828. /** @hidden */
  7829. _uvs: boolean;
  7830. /** @hidden */
  7831. _needNormals: boolean;
  7832. /** @hidden */
  7833. _needUVs: boolean;
  7834. [id: string]: any;
  7835. /**
  7836. * Specifies if the material needs to be re-calculated
  7837. */
  7838. get isDirty(): boolean;
  7839. /**
  7840. * Marks the material to indicate that it has been re-calculated
  7841. */
  7842. markAsProcessed(): void;
  7843. /**
  7844. * Marks the material to indicate that it needs to be re-calculated
  7845. */
  7846. markAsUnprocessed(): void;
  7847. /**
  7848. * Marks the material to indicate all of its defines need to be re-calculated
  7849. */
  7850. markAllAsDirty(): void;
  7851. /**
  7852. * Marks the material to indicate that image processing needs to be re-calculated
  7853. */
  7854. markAsImageProcessingDirty(): void;
  7855. /**
  7856. * Marks the material to indicate the lights need to be re-calculated
  7857. * @param disposed Defines whether the light is dirty due to dispose or not
  7858. */
  7859. markAsLightDirty(disposed?: boolean): void;
  7860. /**
  7861. * Marks the attribute state as changed
  7862. */
  7863. markAsAttributesDirty(): void;
  7864. /**
  7865. * Marks the texture state as changed
  7866. */
  7867. markAsTexturesDirty(): void;
  7868. /**
  7869. * Marks the fresnel state as changed
  7870. */
  7871. markAsFresnelDirty(): void;
  7872. /**
  7873. * Marks the misc state as changed
  7874. */
  7875. markAsMiscDirty(): void;
  7876. /**
  7877. * Rebuilds the material defines
  7878. */
  7879. rebuild(): void;
  7880. /**
  7881. * Specifies if two material defines are equal
  7882. * @param other - A material define instance to compare to
  7883. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7884. */
  7885. isEqual(other: MaterialDefines): boolean;
  7886. /**
  7887. * Clones this instance's defines to another instance
  7888. * @param other - material defines to clone values to
  7889. */
  7890. cloneTo(other: MaterialDefines): void;
  7891. /**
  7892. * Resets the material define values
  7893. */
  7894. reset(): void;
  7895. /**
  7896. * Converts the material define values to a string
  7897. * @returns - String of material define information
  7898. */
  7899. toString(): string;
  7900. }
  7901. }
  7902. declare module BABYLON {
  7903. /**
  7904. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  7905. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  7906. * 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;
  7907. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  7908. */
  7909. export class ColorCurves {
  7910. private _dirty;
  7911. private _tempColor;
  7912. private _globalCurve;
  7913. private _highlightsCurve;
  7914. private _midtonesCurve;
  7915. private _shadowsCurve;
  7916. private _positiveCurve;
  7917. private _negativeCurve;
  7918. private _globalHue;
  7919. private _globalDensity;
  7920. private _globalSaturation;
  7921. private _globalExposure;
  7922. /**
  7923. * Gets the global Hue value.
  7924. * 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).
  7925. */
  7926. get globalHue(): number;
  7927. /**
  7928. * Sets the global Hue value.
  7929. * 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).
  7930. */
  7931. set globalHue(value: number);
  7932. /**
  7933. * Gets the global Density value.
  7934. * 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.
  7935. * Values less than zero provide a filter of opposite hue.
  7936. */
  7937. get globalDensity(): number;
  7938. /**
  7939. * Sets the global Density value.
  7940. * 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.
  7941. * Values less than zero provide a filter of opposite hue.
  7942. */
  7943. set globalDensity(value: number);
  7944. /**
  7945. * Gets the global Saturation value.
  7946. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7947. */
  7948. get globalSaturation(): number;
  7949. /**
  7950. * Sets the global Saturation value.
  7951. * 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.
  7952. */
  7953. set globalSaturation(value: number);
  7954. /**
  7955. * Gets the global Exposure value.
  7956. * 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.
  7957. */
  7958. get globalExposure(): number;
  7959. /**
  7960. * Sets the global Exposure value.
  7961. * 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.
  7962. */
  7963. set globalExposure(value: number);
  7964. private _highlightsHue;
  7965. private _highlightsDensity;
  7966. private _highlightsSaturation;
  7967. private _highlightsExposure;
  7968. /**
  7969. * Gets the highlights Hue value.
  7970. * 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).
  7971. */
  7972. get highlightsHue(): number;
  7973. /**
  7974. * Sets the highlights Hue value.
  7975. * 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).
  7976. */
  7977. set highlightsHue(value: number);
  7978. /**
  7979. * Gets the highlights Density value.
  7980. * 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.
  7981. * Values less than zero provide a filter of opposite hue.
  7982. */
  7983. get highlightsDensity(): number;
  7984. /**
  7985. * Sets the highlights Density value.
  7986. * 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.
  7987. * Values less than zero provide a filter of opposite hue.
  7988. */
  7989. set highlightsDensity(value: number);
  7990. /**
  7991. * Gets the highlights Saturation value.
  7992. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7993. */
  7994. get highlightsSaturation(): number;
  7995. /**
  7996. * Sets the highlights Saturation value.
  7997. * 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.
  7998. */
  7999. set highlightsSaturation(value: number);
  8000. /**
  8001. * Gets the highlights Exposure value.
  8002. * 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.
  8003. */
  8004. get highlightsExposure(): number;
  8005. /**
  8006. * Sets the highlights Exposure value.
  8007. * 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.
  8008. */
  8009. set highlightsExposure(value: number);
  8010. private _midtonesHue;
  8011. private _midtonesDensity;
  8012. private _midtonesSaturation;
  8013. private _midtonesExposure;
  8014. /**
  8015. * Gets the midtones Hue value.
  8016. * 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).
  8017. */
  8018. get midtonesHue(): number;
  8019. /**
  8020. * Sets the midtones Hue value.
  8021. * 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).
  8022. */
  8023. set midtonesHue(value: number);
  8024. /**
  8025. * Gets the midtones Density value.
  8026. * 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.
  8027. * Values less than zero provide a filter of opposite hue.
  8028. */
  8029. get midtonesDensity(): number;
  8030. /**
  8031. * Sets the midtones Density value.
  8032. * 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.
  8033. * Values less than zero provide a filter of opposite hue.
  8034. */
  8035. set midtonesDensity(value: number);
  8036. /**
  8037. * Gets the midtones Saturation value.
  8038. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8039. */
  8040. get midtonesSaturation(): number;
  8041. /**
  8042. * Sets the midtones Saturation value.
  8043. * 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.
  8044. */
  8045. set midtonesSaturation(value: number);
  8046. /**
  8047. * Gets the midtones Exposure value.
  8048. * 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.
  8049. */
  8050. get midtonesExposure(): number;
  8051. /**
  8052. * Sets the midtones Exposure value.
  8053. * 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.
  8054. */
  8055. set midtonesExposure(value: number);
  8056. private _shadowsHue;
  8057. private _shadowsDensity;
  8058. private _shadowsSaturation;
  8059. private _shadowsExposure;
  8060. /**
  8061. * Gets the shadows Hue value.
  8062. * 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).
  8063. */
  8064. get shadowsHue(): number;
  8065. /**
  8066. * Sets the shadows Hue value.
  8067. * 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).
  8068. */
  8069. set shadowsHue(value: number);
  8070. /**
  8071. * Gets the shadows Density value.
  8072. * 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.
  8073. * Values less than zero provide a filter of opposite hue.
  8074. */
  8075. get shadowsDensity(): number;
  8076. /**
  8077. * Sets the shadows Density value.
  8078. * 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.
  8079. * Values less than zero provide a filter of opposite hue.
  8080. */
  8081. set shadowsDensity(value: number);
  8082. /**
  8083. * Gets the shadows Saturation value.
  8084. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8085. */
  8086. get shadowsSaturation(): number;
  8087. /**
  8088. * Sets the shadows Saturation value.
  8089. * 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.
  8090. */
  8091. set shadowsSaturation(value: number);
  8092. /**
  8093. * Gets the shadows Exposure value.
  8094. * 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.
  8095. */
  8096. get shadowsExposure(): number;
  8097. /**
  8098. * Sets the shadows Exposure value.
  8099. * 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.
  8100. */
  8101. set shadowsExposure(value: number);
  8102. /**
  8103. * Returns the class name
  8104. * @returns The class name
  8105. */
  8106. getClassName(): string;
  8107. /**
  8108. * Binds the color curves to the shader.
  8109. * @param colorCurves The color curve to bind
  8110. * @param effect The effect to bind to
  8111. * @param positiveUniform The positive uniform shader parameter
  8112. * @param neutralUniform The neutral uniform shader parameter
  8113. * @param negativeUniform The negative uniform shader parameter
  8114. */
  8115. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8116. /**
  8117. * Prepare the list of uniforms associated with the ColorCurves effects.
  8118. * @param uniformsList The list of uniforms used in the effect
  8119. */
  8120. static PrepareUniforms(uniformsList: string[]): void;
  8121. /**
  8122. * Returns color grading data based on a hue, density, saturation and exposure value.
  8123. * @param filterHue The hue of the color filter.
  8124. * @param filterDensity The density of the color filter.
  8125. * @param saturation The saturation.
  8126. * @param exposure The exposure.
  8127. * @param result The result data container.
  8128. */
  8129. private getColorGradingDataToRef;
  8130. /**
  8131. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8132. * @param value The input slider value in range [-100,100].
  8133. * @returns Adjusted value.
  8134. */
  8135. private static applyColorGradingSliderNonlinear;
  8136. /**
  8137. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8138. * @param hue The hue (H) input.
  8139. * @param saturation The saturation (S) input.
  8140. * @param brightness The brightness (B) input.
  8141. * @result An RGBA color represented as Vector4.
  8142. */
  8143. private static fromHSBToRef;
  8144. /**
  8145. * Returns a value clamped between min and max
  8146. * @param value The value to clamp
  8147. * @param min The minimum of value
  8148. * @param max The maximum of value
  8149. * @returns The clamped value.
  8150. */
  8151. private static clamp;
  8152. /**
  8153. * Clones the current color curve instance.
  8154. * @return The cloned curves
  8155. */
  8156. clone(): ColorCurves;
  8157. /**
  8158. * Serializes the current color curve instance to a json representation.
  8159. * @return a JSON representation
  8160. */
  8161. serialize(): any;
  8162. /**
  8163. * Parses the color curve from a json representation.
  8164. * @param source the JSON source to parse
  8165. * @return The parsed curves
  8166. */
  8167. static Parse(source: any): ColorCurves;
  8168. }
  8169. }
  8170. declare module BABYLON {
  8171. /**
  8172. * Interface to follow in your material defines to integrate easily the
  8173. * Image proccessing functions.
  8174. * @hidden
  8175. */
  8176. export interface IImageProcessingConfigurationDefines {
  8177. IMAGEPROCESSING: boolean;
  8178. VIGNETTE: boolean;
  8179. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8180. VIGNETTEBLENDMODEOPAQUE: boolean;
  8181. TONEMAPPING: boolean;
  8182. TONEMAPPING_ACES: boolean;
  8183. CONTRAST: boolean;
  8184. EXPOSURE: boolean;
  8185. COLORCURVES: boolean;
  8186. COLORGRADING: boolean;
  8187. COLORGRADING3D: boolean;
  8188. SAMPLER3DGREENDEPTH: boolean;
  8189. SAMPLER3DBGRMAP: boolean;
  8190. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8191. }
  8192. /**
  8193. * @hidden
  8194. */
  8195. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8196. IMAGEPROCESSING: boolean;
  8197. VIGNETTE: boolean;
  8198. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8199. VIGNETTEBLENDMODEOPAQUE: boolean;
  8200. TONEMAPPING: boolean;
  8201. TONEMAPPING_ACES: boolean;
  8202. CONTRAST: boolean;
  8203. COLORCURVES: boolean;
  8204. COLORGRADING: boolean;
  8205. COLORGRADING3D: boolean;
  8206. SAMPLER3DGREENDEPTH: boolean;
  8207. SAMPLER3DBGRMAP: boolean;
  8208. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8209. EXPOSURE: boolean;
  8210. constructor();
  8211. }
  8212. /**
  8213. * This groups together the common properties used for image processing either in direct forward pass
  8214. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8215. * or not.
  8216. */
  8217. export class ImageProcessingConfiguration {
  8218. /**
  8219. * Default tone mapping applied in BabylonJS.
  8220. */
  8221. static readonly TONEMAPPING_STANDARD: number;
  8222. /**
  8223. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8224. * to other engines rendering to increase portability.
  8225. */
  8226. static readonly TONEMAPPING_ACES: number;
  8227. /**
  8228. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8229. */
  8230. colorCurves: Nullable<ColorCurves>;
  8231. private _colorCurvesEnabled;
  8232. /**
  8233. * Gets wether the color curves effect is enabled.
  8234. */
  8235. get colorCurvesEnabled(): boolean;
  8236. /**
  8237. * Sets wether the color curves effect is enabled.
  8238. */
  8239. set colorCurvesEnabled(value: boolean);
  8240. private _colorGradingTexture;
  8241. /**
  8242. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8243. */
  8244. get colorGradingTexture(): Nullable<BaseTexture>;
  8245. /**
  8246. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8247. */
  8248. set colorGradingTexture(value: Nullable<BaseTexture>);
  8249. private _colorGradingEnabled;
  8250. /**
  8251. * Gets wether the color grading effect is enabled.
  8252. */
  8253. get colorGradingEnabled(): boolean;
  8254. /**
  8255. * Sets wether the color grading effect is enabled.
  8256. */
  8257. set colorGradingEnabled(value: boolean);
  8258. private _colorGradingWithGreenDepth;
  8259. /**
  8260. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8261. */
  8262. get colorGradingWithGreenDepth(): boolean;
  8263. /**
  8264. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8265. */
  8266. set colorGradingWithGreenDepth(value: boolean);
  8267. private _colorGradingBGR;
  8268. /**
  8269. * Gets wether the color grading texture contains BGR values.
  8270. */
  8271. get colorGradingBGR(): boolean;
  8272. /**
  8273. * Sets wether the color grading texture contains BGR values.
  8274. */
  8275. set colorGradingBGR(value: boolean);
  8276. /** @hidden */
  8277. _exposure: number;
  8278. /**
  8279. * Gets the Exposure used in the effect.
  8280. */
  8281. get exposure(): number;
  8282. /**
  8283. * Sets the Exposure used in the effect.
  8284. */
  8285. set exposure(value: number);
  8286. private _toneMappingEnabled;
  8287. /**
  8288. * Gets wether the tone mapping effect is enabled.
  8289. */
  8290. get toneMappingEnabled(): boolean;
  8291. /**
  8292. * Sets wether the tone mapping effect is enabled.
  8293. */
  8294. set toneMappingEnabled(value: boolean);
  8295. private _toneMappingType;
  8296. /**
  8297. * Gets the type of tone mapping effect.
  8298. */
  8299. get toneMappingType(): number;
  8300. /**
  8301. * Sets the type of tone mapping effect used in BabylonJS.
  8302. */
  8303. set toneMappingType(value: number);
  8304. protected _contrast: number;
  8305. /**
  8306. * Gets the contrast used in the effect.
  8307. */
  8308. get contrast(): number;
  8309. /**
  8310. * Sets the contrast used in the effect.
  8311. */
  8312. set contrast(value: number);
  8313. /**
  8314. * Vignette stretch size.
  8315. */
  8316. vignetteStretch: number;
  8317. /**
  8318. * Vignette centre X Offset.
  8319. */
  8320. vignetteCentreX: number;
  8321. /**
  8322. * Vignette centre Y Offset.
  8323. */
  8324. vignetteCentreY: number;
  8325. /**
  8326. * Vignette weight or intensity of the vignette effect.
  8327. */
  8328. vignetteWeight: number;
  8329. /**
  8330. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8331. * if vignetteEnabled is set to true.
  8332. */
  8333. vignetteColor: Color4;
  8334. /**
  8335. * Camera field of view used by the Vignette effect.
  8336. */
  8337. vignetteCameraFov: number;
  8338. private _vignetteBlendMode;
  8339. /**
  8340. * Gets the vignette blend mode allowing different kind of effect.
  8341. */
  8342. get vignetteBlendMode(): number;
  8343. /**
  8344. * Sets the vignette blend mode allowing different kind of effect.
  8345. */
  8346. set vignetteBlendMode(value: number);
  8347. private _vignetteEnabled;
  8348. /**
  8349. * Gets wether the vignette effect is enabled.
  8350. */
  8351. get vignetteEnabled(): boolean;
  8352. /**
  8353. * Sets wether the vignette effect is enabled.
  8354. */
  8355. set vignetteEnabled(value: boolean);
  8356. private _applyByPostProcess;
  8357. /**
  8358. * Gets wether the image processing is applied through a post process or not.
  8359. */
  8360. get applyByPostProcess(): boolean;
  8361. /**
  8362. * Sets wether the image processing is applied through a post process or not.
  8363. */
  8364. set applyByPostProcess(value: boolean);
  8365. private _isEnabled;
  8366. /**
  8367. * Gets wether the image processing is enabled or not.
  8368. */
  8369. get isEnabled(): boolean;
  8370. /**
  8371. * Sets wether the image processing is enabled or not.
  8372. */
  8373. set isEnabled(value: boolean);
  8374. /**
  8375. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8376. */
  8377. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8378. /**
  8379. * Method called each time the image processing information changes requires to recompile the effect.
  8380. */
  8381. protected _updateParameters(): void;
  8382. /**
  8383. * Gets the current class name.
  8384. * @return "ImageProcessingConfiguration"
  8385. */
  8386. getClassName(): string;
  8387. /**
  8388. * Prepare the list of uniforms associated with the Image Processing effects.
  8389. * @param uniforms The list of uniforms used in the effect
  8390. * @param defines the list of defines currently in use
  8391. */
  8392. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8393. /**
  8394. * Prepare the list of samplers associated with the Image Processing effects.
  8395. * @param samplersList The list of uniforms used in the effect
  8396. * @param defines the list of defines currently in use
  8397. */
  8398. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8399. /**
  8400. * Prepare the list of defines associated to the shader.
  8401. * @param defines the list of defines to complete
  8402. * @param forPostProcess Define if we are currently in post process mode or not
  8403. */
  8404. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8405. /**
  8406. * Returns true if all the image processing information are ready.
  8407. * @returns True if ready, otherwise, false
  8408. */
  8409. isReady(): boolean;
  8410. /**
  8411. * Binds the image processing to the shader.
  8412. * @param effect The effect to bind to
  8413. * @param overrideAspectRatio Override the aspect ratio of the effect
  8414. */
  8415. bind(effect: Effect, overrideAspectRatio?: number): void;
  8416. /**
  8417. * Clones the current image processing instance.
  8418. * @return The cloned image processing
  8419. */
  8420. clone(): ImageProcessingConfiguration;
  8421. /**
  8422. * Serializes the current image processing instance to a json representation.
  8423. * @return a JSON representation
  8424. */
  8425. serialize(): any;
  8426. /**
  8427. * Parses the image processing from a json representation.
  8428. * @param source the JSON source to parse
  8429. * @return The parsed image processing
  8430. */
  8431. static Parse(source: any): ImageProcessingConfiguration;
  8432. private static _VIGNETTEMODE_MULTIPLY;
  8433. private static _VIGNETTEMODE_OPAQUE;
  8434. /**
  8435. * Used to apply the vignette as a mix with the pixel color.
  8436. */
  8437. static get VIGNETTEMODE_MULTIPLY(): number;
  8438. /**
  8439. * Used to apply the vignette as a replacement of the pixel color.
  8440. */
  8441. static get VIGNETTEMODE_OPAQUE(): number;
  8442. }
  8443. }
  8444. declare module BABYLON {
  8445. /** @hidden */
  8446. export var postprocessVertexShader: {
  8447. name: string;
  8448. shader: string;
  8449. };
  8450. }
  8451. declare module BABYLON {
  8452. interface ThinEngine {
  8453. /**
  8454. * Creates a new render target texture
  8455. * @param size defines the size of the texture
  8456. * @param options defines the options used to create the texture
  8457. * @returns a new render target texture stored in an InternalTexture
  8458. */
  8459. createRenderTargetTexture(size: number | {
  8460. width: number;
  8461. height: number;
  8462. layers?: number;
  8463. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8464. /**
  8465. * Creates a depth stencil texture.
  8466. * This is only available in WebGL 2 or with the depth texture extension available.
  8467. * @param size The size of face edge in the texture.
  8468. * @param options The options defining the texture.
  8469. * @returns The texture
  8470. */
  8471. createDepthStencilTexture(size: number | {
  8472. width: number;
  8473. height: number;
  8474. layers?: number;
  8475. }, options: DepthTextureCreationOptions): InternalTexture;
  8476. /** @hidden */
  8477. _createDepthStencilTexture(size: number | {
  8478. width: number;
  8479. height: number;
  8480. layers?: number;
  8481. }, options: DepthTextureCreationOptions): InternalTexture;
  8482. }
  8483. }
  8484. declare module BABYLON {
  8485. /** Defines supported spaces */
  8486. export enum Space {
  8487. /** Local (object) space */
  8488. LOCAL = 0,
  8489. /** World space */
  8490. WORLD = 1,
  8491. /** Bone space */
  8492. BONE = 2
  8493. }
  8494. /** Defines the 3 main axes */
  8495. export class Axis {
  8496. /** X axis */
  8497. static X: Vector3;
  8498. /** Y axis */
  8499. static Y: Vector3;
  8500. /** Z axis */
  8501. static Z: Vector3;
  8502. }
  8503. }
  8504. declare module BABYLON {
  8505. /**
  8506. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8507. * This is the base of the follow, arc rotate cameras and Free camera
  8508. * @see http://doc.babylonjs.com/features/cameras
  8509. */
  8510. export class TargetCamera extends Camera {
  8511. private static _RigCamTransformMatrix;
  8512. private static _TargetTransformMatrix;
  8513. private static _TargetFocalPoint;
  8514. /**
  8515. * Define the current direction the camera is moving to
  8516. */
  8517. cameraDirection: Vector3;
  8518. /**
  8519. * Define the current rotation the camera is rotating to
  8520. */
  8521. cameraRotation: Vector2;
  8522. /**
  8523. * When set, the up vector of the camera will be updated by the rotation of the camera
  8524. */
  8525. updateUpVectorFromRotation: boolean;
  8526. private _tmpQuaternion;
  8527. /**
  8528. * Define the current rotation of the camera
  8529. */
  8530. rotation: Vector3;
  8531. /**
  8532. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8533. */
  8534. rotationQuaternion: Quaternion;
  8535. /**
  8536. * Define the current speed of the camera
  8537. */
  8538. speed: number;
  8539. /**
  8540. * Add constraint to the camera to prevent it to move freely in all directions and
  8541. * around all axis.
  8542. */
  8543. noRotationConstraint: boolean;
  8544. /**
  8545. * Define the current target of the camera as an object or a position.
  8546. */
  8547. lockedTarget: any;
  8548. /** @hidden */
  8549. _currentTarget: Vector3;
  8550. /** @hidden */
  8551. _initialFocalDistance: number;
  8552. /** @hidden */
  8553. _viewMatrix: Matrix;
  8554. /** @hidden */
  8555. _camMatrix: Matrix;
  8556. /** @hidden */
  8557. _cameraTransformMatrix: Matrix;
  8558. /** @hidden */
  8559. _cameraRotationMatrix: Matrix;
  8560. /** @hidden */
  8561. _referencePoint: Vector3;
  8562. /** @hidden */
  8563. _transformedReferencePoint: Vector3;
  8564. protected _globalCurrentTarget: Vector3;
  8565. protected _globalCurrentUpVector: Vector3;
  8566. /** @hidden */
  8567. _reset: () => void;
  8568. private _defaultUp;
  8569. /**
  8570. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  8571. * This is the base of the follow, arc rotate cameras and Free camera
  8572. * @see http://doc.babylonjs.com/features/cameras
  8573. * @param name Defines the name of the camera in the scene
  8574. * @param position Defines the start position of the camera in the scene
  8575. * @param scene Defines the scene the camera belongs to
  8576. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8577. */
  8578. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8579. /**
  8580. * Gets the position in front of the camera at a given distance.
  8581. * @param distance The distance from the camera we want the position to be
  8582. * @returns the position
  8583. */
  8584. getFrontPosition(distance: number): Vector3;
  8585. /** @hidden */
  8586. _getLockedTargetPosition(): Nullable<Vector3>;
  8587. private _storedPosition;
  8588. private _storedRotation;
  8589. private _storedRotationQuaternion;
  8590. /**
  8591. * Store current camera state of the camera (fov, position, rotation, etc..)
  8592. * @returns the camera
  8593. */
  8594. storeState(): Camera;
  8595. /**
  8596. * Restored camera state. You must call storeState() first
  8597. * @returns whether it was successful or not
  8598. * @hidden
  8599. */
  8600. _restoreStateValues(): boolean;
  8601. /** @hidden */
  8602. _initCache(): void;
  8603. /** @hidden */
  8604. _updateCache(ignoreParentClass?: boolean): void;
  8605. /** @hidden */
  8606. _isSynchronizedViewMatrix(): boolean;
  8607. /** @hidden */
  8608. _computeLocalCameraSpeed(): number;
  8609. /**
  8610. * Defines the target the camera should look at.
  8611. * @param target Defines the new target as a Vector or a mesh
  8612. */
  8613. setTarget(target: Vector3): void;
  8614. /**
  8615. * Return the current target position of the camera. This value is expressed in local space.
  8616. * @returns the target position
  8617. */
  8618. getTarget(): Vector3;
  8619. /** @hidden */
  8620. _decideIfNeedsToMove(): boolean;
  8621. /** @hidden */
  8622. _updatePosition(): void;
  8623. /** @hidden */
  8624. _checkInputs(): void;
  8625. protected _updateCameraRotationMatrix(): void;
  8626. /**
  8627. * 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)
  8628. * @returns the current camera
  8629. */
  8630. private _rotateUpVectorWithCameraRotationMatrix;
  8631. private _cachedRotationZ;
  8632. private _cachedQuaternionRotationZ;
  8633. /** @hidden */
  8634. _getViewMatrix(): Matrix;
  8635. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8636. /**
  8637. * @hidden
  8638. */
  8639. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8640. /**
  8641. * @hidden
  8642. */
  8643. _updateRigCameras(): void;
  8644. private _getRigCamPositionAndTarget;
  8645. /**
  8646. * Gets the current object class name.
  8647. * @return the class name
  8648. */
  8649. getClassName(): string;
  8650. }
  8651. }
  8652. declare module BABYLON {
  8653. /**
  8654. * Gather the list of keyboard event types as constants.
  8655. */
  8656. export class KeyboardEventTypes {
  8657. /**
  8658. * The keydown event is fired when a key becomes active (pressed).
  8659. */
  8660. static readonly KEYDOWN: number;
  8661. /**
  8662. * The keyup event is fired when a key has been released.
  8663. */
  8664. static readonly KEYUP: number;
  8665. }
  8666. /**
  8667. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8668. */
  8669. export class KeyboardInfo {
  8670. /**
  8671. * Defines the type of event (KeyboardEventTypes)
  8672. */
  8673. type: number;
  8674. /**
  8675. * Defines the related dom event
  8676. */
  8677. event: KeyboardEvent;
  8678. /**
  8679. * Instantiates a new keyboard info.
  8680. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8681. * @param type Defines the type of event (KeyboardEventTypes)
  8682. * @param event Defines the related dom event
  8683. */
  8684. constructor(
  8685. /**
  8686. * Defines the type of event (KeyboardEventTypes)
  8687. */
  8688. type: number,
  8689. /**
  8690. * Defines the related dom event
  8691. */
  8692. event: KeyboardEvent);
  8693. }
  8694. /**
  8695. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8696. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8697. */
  8698. export class KeyboardInfoPre extends KeyboardInfo {
  8699. /**
  8700. * Defines the type of event (KeyboardEventTypes)
  8701. */
  8702. type: number;
  8703. /**
  8704. * Defines the related dom event
  8705. */
  8706. event: KeyboardEvent;
  8707. /**
  8708. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8709. */
  8710. skipOnPointerObservable: boolean;
  8711. /**
  8712. * Instantiates a new keyboard pre info.
  8713. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8714. * @param type Defines the type of event (KeyboardEventTypes)
  8715. * @param event Defines the related dom event
  8716. */
  8717. constructor(
  8718. /**
  8719. * Defines the type of event (KeyboardEventTypes)
  8720. */
  8721. type: number,
  8722. /**
  8723. * Defines the related dom event
  8724. */
  8725. event: KeyboardEvent);
  8726. }
  8727. }
  8728. declare module BABYLON {
  8729. /**
  8730. * Manage the keyboard inputs to control the movement of a free camera.
  8731. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8732. */
  8733. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8734. /**
  8735. * Defines the camera the input is attached to.
  8736. */
  8737. camera: FreeCamera;
  8738. /**
  8739. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8740. */
  8741. keysUp: number[];
  8742. /**
  8743. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8744. */
  8745. keysDown: number[];
  8746. /**
  8747. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8748. */
  8749. keysLeft: number[];
  8750. /**
  8751. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8752. */
  8753. keysRight: number[];
  8754. private _keys;
  8755. private _onCanvasBlurObserver;
  8756. private _onKeyboardObserver;
  8757. private _engine;
  8758. private _scene;
  8759. /**
  8760. * Attach the input controls to a specific dom element to get the input from.
  8761. * @param element Defines the element the controls should be listened from
  8762. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8763. */
  8764. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8765. /**
  8766. * Detach the current controls from the specified dom element.
  8767. * @param element Defines the element to stop listening the inputs from
  8768. */
  8769. detachControl(element: Nullable<HTMLElement>): void;
  8770. /**
  8771. * Update the current camera state depending on the inputs that have been used this frame.
  8772. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8773. */
  8774. checkInputs(): void;
  8775. /**
  8776. * Gets the class name of the current intput.
  8777. * @returns the class name
  8778. */
  8779. getClassName(): string;
  8780. /** @hidden */
  8781. _onLostFocus(): void;
  8782. /**
  8783. * Get the friendly name associated with the input class.
  8784. * @returns the input friendly name
  8785. */
  8786. getSimpleName(): string;
  8787. }
  8788. }
  8789. declare module BABYLON {
  8790. /**
  8791. * Interface describing all the common properties and methods a shadow light needs to implement.
  8792. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8793. * as well as binding the different shadow properties to the effects.
  8794. */
  8795. export interface IShadowLight extends Light {
  8796. /**
  8797. * The light id in the scene (used in scene.findLighById for instance)
  8798. */
  8799. id: string;
  8800. /**
  8801. * The position the shdow will be casted from.
  8802. */
  8803. position: Vector3;
  8804. /**
  8805. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8806. */
  8807. direction: Vector3;
  8808. /**
  8809. * The transformed position. Position of the light in world space taking parenting in account.
  8810. */
  8811. transformedPosition: Vector3;
  8812. /**
  8813. * The transformed direction. Direction of the light in world space taking parenting in account.
  8814. */
  8815. transformedDirection: Vector3;
  8816. /**
  8817. * The friendly name of the light in the scene.
  8818. */
  8819. name: string;
  8820. /**
  8821. * Defines the shadow projection clipping minimum z value.
  8822. */
  8823. shadowMinZ: number;
  8824. /**
  8825. * Defines the shadow projection clipping maximum z value.
  8826. */
  8827. shadowMaxZ: number;
  8828. /**
  8829. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8830. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8831. */
  8832. computeTransformedInformation(): boolean;
  8833. /**
  8834. * Gets the scene the light belongs to.
  8835. * @returns The scene
  8836. */
  8837. getScene(): Scene;
  8838. /**
  8839. * Callback defining a custom Projection Matrix Builder.
  8840. * This can be used to override the default projection matrix computation.
  8841. */
  8842. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8843. /**
  8844. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8845. * @param matrix The materix to updated with the projection information
  8846. * @param viewMatrix The transform matrix of the light
  8847. * @param renderList The list of mesh to render in the map
  8848. * @returns The current light
  8849. */
  8850. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8851. /**
  8852. * Gets the current depth scale used in ESM.
  8853. * @returns The scale
  8854. */
  8855. getDepthScale(): number;
  8856. /**
  8857. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8858. * @returns true if a cube texture needs to be use
  8859. */
  8860. needCube(): boolean;
  8861. /**
  8862. * Detects if the projection matrix requires to be recomputed this frame.
  8863. * @returns true if it requires to be recomputed otherwise, false.
  8864. */
  8865. needProjectionMatrixCompute(): boolean;
  8866. /**
  8867. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8868. */
  8869. forceProjectionMatrixCompute(): void;
  8870. /**
  8871. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8872. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8873. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8874. */
  8875. getShadowDirection(faceIndex?: number): Vector3;
  8876. /**
  8877. * Gets the minZ used for shadow according to both the scene and the light.
  8878. * @param activeCamera The camera we are returning the min for
  8879. * @returns the depth min z
  8880. */
  8881. getDepthMinZ(activeCamera: Camera): number;
  8882. /**
  8883. * Gets the maxZ used for shadow according to both the scene and the light.
  8884. * @param activeCamera The camera we are returning the max for
  8885. * @returns the depth max z
  8886. */
  8887. getDepthMaxZ(activeCamera: Camera): number;
  8888. }
  8889. /**
  8890. * Base implementation IShadowLight
  8891. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8892. */
  8893. export abstract class ShadowLight extends Light implements IShadowLight {
  8894. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8895. protected _position: Vector3;
  8896. protected _setPosition(value: Vector3): void;
  8897. /**
  8898. * Sets the position the shadow will be casted from. Also use as the light position for both
  8899. * point and spot lights.
  8900. */
  8901. get position(): Vector3;
  8902. /**
  8903. * Sets the position the shadow will be casted from. Also use as the light position for both
  8904. * point and spot lights.
  8905. */
  8906. set position(value: Vector3);
  8907. protected _direction: Vector3;
  8908. protected _setDirection(value: Vector3): void;
  8909. /**
  8910. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8911. * Also use as the light direction on spot and directional lights.
  8912. */
  8913. get direction(): Vector3;
  8914. /**
  8915. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8916. * Also use as the light direction on spot and directional lights.
  8917. */
  8918. set direction(value: Vector3);
  8919. protected _shadowMinZ: number;
  8920. /**
  8921. * Gets the shadow projection clipping minimum z value.
  8922. */
  8923. get shadowMinZ(): number;
  8924. /**
  8925. * Sets the shadow projection clipping minimum z value.
  8926. */
  8927. set shadowMinZ(value: number);
  8928. protected _shadowMaxZ: number;
  8929. /**
  8930. * Sets the shadow projection clipping maximum z value.
  8931. */
  8932. get shadowMaxZ(): number;
  8933. /**
  8934. * Gets the shadow projection clipping maximum z value.
  8935. */
  8936. set shadowMaxZ(value: number);
  8937. /**
  8938. * Callback defining a custom Projection Matrix Builder.
  8939. * This can be used to override the default projection matrix computation.
  8940. */
  8941. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8942. /**
  8943. * The transformed position. Position of the light in world space taking parenting in account.
  8944. */
  8945. transformedPosition: Vector3;
  8946. /**
  8947. * The transformed direction. Direction of the light in world space taking parenting in account.
  8948. */
  8949. transformedDirection: Vector3;
  8950. private _needProjectionMatrixCompute;
  8951. /**
  8952. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8953. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8954. */
  8955. computeTransformedInformation(): boolean;
  8956. /**
  8957. * Return the depth scale used for the shadow map.
  8958. * @returns the depth scale.
  8959. */
  8960. getDepthScale(): number;
  8961. /**
  8962. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8963. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8964. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8965. */
  8966. getShadowDirection(faceIndex?: number): Vector3;
  8967. /**
  8968. * Returns the ShadowLight absolute position in the World.
  8969. * @returns the position vector in world space
  8970. */
  8971. getAbsolutePosition(): Vector3;
  8972. /**
  8973. * Sets the ShadowLight direction toward the passed target.
  8974. * @param target The point to target in local space
  8975. * @returns the updated ShadowLight direction
  8976. */
  8977. setDirectionToTarget(target: Vector3): Vector3;
  8978. /**
  8979. * Returns the light rotation in euler definition.
  8980. * @returns the x y z rotation in local space.
  8981. */
  8982. getRotation(): Vector3;
  8983. /**
  8984. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8985. * @returns true if a cube texture needs to be use
  8986. */
  8987. needCube(): boolean;
  8988. /**
  8989. * Detects if the projection matrix requires to be recomputed this frame.
  8990. * @returns true if it requires to be recomputed otherwise, false.
  8991. */
  8992. needProjectionMatrixCompute(): boolean;
  8993. /**
  8994. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8995. */
  8996. forceProjectionMatrixCompute(): void;
  8997. /** @hidden */
  8998. _initCache(): void;
  8999. /** @hidden */
  9000. _isSynchronized(): boolean;
  9001. /**
  9002. * Computes the world matrix of the node
  9003. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9004. * @returns the world matrix
  9005. */
  9006. computeWorldMatrix(force?: boolean): Matrix;
  9007. /**
  9008. * Gets the minZ used for shadow according to both the scene and the light.
  9009. * @param activeCamera The camera we are returning the min for
  9010. * @returns the depth min z
  9011. */
  9012. getDepthMinZ(activeCamera: Camera): number;
  9013. /**
  9014. * Gets the maxZ used for shadow according to both the scene and the light.
  9015. * @param activeCamera The camera we are returning the max for
  9016. * @returns the depth max z
  9017. */
  9018. getDepthMaxZ(activeCamera: Camera): number;
  9019. /**
  9020. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9021. * @param matrix The materix to updated with the projection information
  9022. * @param viewMatrix The transform matrix of the light
  9023. * @param renderList The list of mesh to render in the map
  9024. * @returns The current light
  9025. */
  9026. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9027. }
  9028. }
  9029. declare module BABYLON {
  9030. /**
  9031. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  9032. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  9033. */
  9034. export class EffectFallbacks implements IEffectFallbacks {
  9035. private _defines;
  9036. private _currentRank;
  9037. private _maxRank;
  9038. private _mesh;
  9039. /**
  9040. * Removes the fallback from the bound mesh.
  9041. */
  9042. unBindMesh(): void;
  9043. /**
  9044. * Adds a fallback on the specified property.
  9045. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9046. * @param define The name of the define in the shader
  9047. */
  9048. addFallback(rank: number, define: string): void;
  9049. /**
  9050. * Sets the mesh to use CPU skinning when needing to fallback.
  9051. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9052. * @param mesh The mesh to use the fallbacks.
  9053. */
  9054. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  9055. /**
  9056. * Checks to see if more fallbacks are still availible.
  9057. */
  9058. get hasMoreFallbacks(): boolean;
  9059. /**
  9060. * Removes the defines that should be removed when falling back.
  9061. * @param currentDefines defines the current define statements for the shader.
  9062. * @param effect defines the current effect we try to compile
  9063. * @returns The resulting defines with defines of the current rank removed.
  9064. */
  9065. reduce(currentDefines: string, effect: Effect): string;
  9066. }
  9067. }
  9068. declare module BABYLON {
  9069. /**
  9070. * "Static Class" containing the most commonly used helper while dealing with material for
  9071. * rendering purpose.
  9072. *
  9073. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  9074. *
  9075. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  9076. */
  9077. export class MaterialHelper {
  9078. /**
  9079. * Bind the current view position to an effect.
  9080. * @param effect The effect to be bound
  9081. * @param scene The scene the eyes position is used from
  9082. */
  9083. static BindEyePosition(effect: Effect, scene: Scene): void;
  9084. /**
  9085. * Helps preparing the defines values about the UVs in used in the effect.
  9086. * UVs are shared as much as we can accross channels in the shaders.
  9087. * @param texture The texture we are preparing the UVs for
  9088. * @param defines The defines to update
  9089. * @param key The channel key "diffuse", "specular"... used in the shader
  9090. */
  9091. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  9092. /**
  9093. * Binds a texture matrix value to its corrsponding uniform
  9094. * @param texture The texture to bind the matrix for
  9095. * @param uniformBuffer The uniform buffer receivin the data
  9096. * @param key The channel key "diffuse", "specular"... used in the shader
  9097. */
  9098. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9099. /**
  9100. * Gets the current status of the fog (should it be enabled?)
  9101. * @param mesh defines the mesh to evaluate for fog support
  9102. * @param scene defines the hosting scene
  9103. * @returns true if fog must be enabled
  9104. */
  9105. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  9106. /**
  9107. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9108. * @param mesh defines the current mesh
  9109. * @param scene defines the current scene
  9110. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9111. * @param pointsCloud defines if point cloud rendering has to be turned on
  9112. * @param fogEnabled defines if fog has to be turned on
  9113. * @param alphaTest defines if alpha testing has to be turned on
  9114. * @param defines defines the current list of defines
  9115. */
  9116. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9117. /**
  9118. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9119. * @param scene defines the current scene
  9120. * @param engine defines the current engine
  9121. * @param defines specifies the list of active defines
  9122. * @param useInstances defines if instances have to be turned on
  9123. * @param useClipPlane defines if clip plane have to be turned on
  9124. */
  9125. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9126. /**
  9127. * Prepares the defines for bones
  9128. * @param mesh The mesh containing the geometry data we will draw
  9129. * @param defines The defines to update
  9130. */
  9131. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  9132. /**
  9133. * Prepares the defines for morph targets
  9134. * @param mesh The mesh containing the geometry data we will draw
  9135. * @param defines The defines to update
  9136. */
  9137. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  9138. /**
  9139. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9140. * @param mesh The mesh containing the geometry data we will draw
  9141. * @param defines The defines to update
  9142. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9143. * @param useBones Precise whether bones should be used or not (override mesh info)
  9144. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9145. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9146. * @returns false if defines are considered not dirty and have not been checked
  9147. */
  9148. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9149. /**
  9150. * Prepares the defines related to multiview
  9151. * @param scene The scene we are intending to draw
  9152. * @param defines The defines to update
  9153. */
  9154. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  9155. /**
  9156. * Prepares the defines related to the light information passed in parameter
  9157. * @param scene The scene we are intending to draw
  9158. * @param mesh The mesh the effect is compiling for
  9159. * @param light The light the effect is compiling for
  9160. * @param lightIndex The index of the light
  9161. * @param defines The defines to update
  9162. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9163. * @param state Defines the current state regarding what is needed (normals, etc...)
  9164. */
  9165. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  9166. needNormals: boolean;
  9167. needRebuild: boolean;
  9168. shadowEnabled: boolean;
  9169. specularEnabled: boolean;
  9170. lightmapMode: boolean;
  9171. }): void;
  9172. /**
  9173. * Prepares the defines related to the light information passed in parameter
  9174. * @param scene The scene we are intending to draw
  9175. * @param mesh The mesh the effect is compiling for
  9176. * @param defines The defines to update
  9177. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9178. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9179. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9180. * @returns true if normals will be required for the rest of the effect
  9181. */
  9182. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9183. /**
  9184. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  9185. * @param lightIndex defines the light index
  9186. * @param uniformsList The uniform list
  9187. * @param samplersList The sampler list
  9188. * @param projectedLightTexture defines if projected texture must be used
  9189. * @param uniformBuffersList defines an optional list of uniform buffers
  9190. */
  9191. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  9192. /**
  9193. * Prepares the uniforms and samplers list to be used in the effect
  9194. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9195. * @param samplersList The sampler list
  9196. * @param defines The defines helping in the list generation
  9197. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9198. */
  9199. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9200. /**
  9201. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9202. * @param defines The defines to update while falling back
  9203. * @param fallbacks The authorized effect fallbacks
  9204. * @param maxSimultaneousLights The maximum number of lights allowed
  9205. * @param rank the current rank of the Effect
  9206. * @returns The newly affected rank
  9207. */
  9208. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9209. private static _TmpMorphInfluencers;
  9210. /**
  9211. * Prepares the list of attributes required for morph targets according to the effect defines.
  9212. * @param attribs The current list of supported attribs
  9213. * @param mesh The mesh to prepare the morph targets attributes for
  9214. * @param influencers The number of influencers
  9215. */
  9216. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  9217. /**
  9218. * Prepares the list of attributes required for morph targets according to the effect defines.
  9219. * @param attribs The current list of supported attribs
  9220. * @param mesh The mesh to prepare the morph targets attributes for
  9221. * @param defines The current Defines of the effect
  9222. */
  9223. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9224. /**
  9225. * Prepares the list of attributes required for bones according to the effect defines.
  9226. * @param attribs The current list of supported attribs
  9227. * @param mesh The mesh to prepare the bones attributes for
  9228. * @param defines The current Defines of the effect
  9229. * @param fallbacks The current efffect fallback strategy
  9230. */
  9231. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9232. /**
  9233. * Check and prepare the list of attributes required for instances according to the effect defines.
  9234. * @param attribs The current list of supported attribs
  9235. * @param defines The current MaterialDefines of the effect
  9236. */
  9237. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  9238. /**
  9239. * Add the list of attributes required for instances to the attribs array.
  9240. * @param attribs The current list of supported attribs
  9241. */
  9242. static PushAttributesForInstances(attribs: string[]): void;
  9243. /**
  9244. * Binds the light information to the effect.
  9245. * @param light The light containing the generator
  9246. * @param effect The effect we are binding the data to
  9247. * @param lightIndex The light index in the effect used to render
  9248. */
  9249. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9250. /**
  9251. * Binds the lights information from the scene to the effect for the given mesh.
  9252. * @param light Light to bind
  9253. * @param lightIndex Light index
  9254. * @param scene The scene where the light belongs to
  9255. * @param effect The effect we are binding the data to
  9256. * @param useSpecular Defines if specular is supported
  9257. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9258. */
  9259. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  9260. /**
  9261. * Binds the lights information from the scene to the effect for the given mesh.
  9262. * @param scene The scene the lights belongs to
  9263. * @param mesh The mesh we are binding the information to render
  9264. * @param effect The effect we are binding the data to
  9265. * @param defines The generated defines for the effect
  9266. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9267. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9268. */
  9269. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  9270. private static _tempFogColor;
  9271. /**
  9272. * Binds the fog information from the scene to the effect for the given mesh.
  9273. * @param scene The scene the lights belongs to
  9274. * @param mesh The mesh we are binding the information to render
  9275. * @param effect The effect we are binding the data to
  9276. * @param linearSpace Defines if the fog effect is applied in linear space
  9277. */
  9278. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9279. /**
  9280. * Binds the bones information from the mesh to the effect.
  9281. * @param mesh The mesh we are binding the information to render
  9282. * @param effect The effect we are binding the data to
  9283. */
  9284. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9285. /**
  9286. * Binds the morph targets information from the mesh to the effect.
  9287. * @param abstractMesh The mesh we are binding the information to render
  9288. * @param effect The effect we are binding the data to
  9289. */
  9290. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9291. /**
  9292. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9293. * @param defines The generated defines used in the effect
  9294. * @param effect The effect we are binding the data to
  9295. * @param scene The scene we are willing to render with logarithmic scale for
  9296. */
  9297. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9298. /**
  9299. * Binds the clip plane information from the scene to the effect.
  9300. * @param scene The scene the clip plane information are extracted from
  9301. * @param effect The effect we are binding the data to
  9302. */
  9303. static BindClipPlane(effect: Effect, scene: Scene): void;
  9304. }
  9305. }
  9306. declare module BABYLON {
  9307. /** @hidden */
  9308. export var packingFunctions: {
  9309. name: string;
  9310. shader: string;
  9311. };
  9312. }
  9313. declare module BABYLON {
  9314. /** @hidden */
  9315. export var clipPlaneFragmentDeclaration: {
  9316. name: string;
  9317. shader: string;
  9318. };
  9319. }
  9320. declare module BABYLON {
  9321. /** @hidden */
  9322. export var clipPlaneFragment: {
  9323. name: string;
  9324. shader: string;
  9325. };
  9326. }
  9327. declare module BABYLON {
  9328. /** @hidden */
  9329. export var shadowMapPixelShader: {
  9330. name: string;
  9331. shader: string;
  9332. };
  9333. }
  9334. declare module BABYLON {
  9335. /** @hidden */
  9336. export var bonesDeclaration: {
  9337. name: string;
  9338. shader: string;
  9339. };
  9340. }
  9341. declare module BABYLON {
  9342. /** @hidden */
  9343. export var morphTargetsVertexGlobalDeclaration: {
  9344. name: string;
  9345. shader: string;
  9346. };
  9347. }
  9348. declare module BABYLON {
  9349. /** @hidden */
  9350. export var morphTargetsVertexDeclaration: {
  9351. name: string;
  9352. shader: string;
  9353. };
  9354. }
  9355. declare module BABYLON {
  9356. /** @hidden */
  9357. export var instancesDeclaration: {
  9358. name: string;
  9359. shader: string;
  9360. };
  9361. }
  9362. declare module BABYLON {
  9363. /** @hidden */
  9364. export var helperFunctions: {
  9365. name: string;
  9366. shader: string;
  9367. };
  9368. }
  9369. declare module BABYLON {
  9370. /** @hidden */
  9371. export var clipPlaneVertexDeclaration: {
  9372. name: string;
  9373. shader: string;
  9374. };
  9375. }
  9376. declare module BABYLON {
  9377. /** @hidden */
  9378. export var morphTargetsVertex: {
  9379. name: string;
  9380. shader: string;
  9381. };
  9382. }
  9383. declare module BABYLON {
  9384. /** @hidden */
  9385. export var instancesVertex: {
  9386. name: string;
  9387. shader: string;
  9388. };
  9389. }
  9390. declare module BABYLON {
  9391. /** @hidden */
  9392. export var bonesVertex: {
  9393. name: string;
  9394. shader: string;
  9395. };
  9396. }
  9397. declare module BABYLON {
  9398. /** @hidden */
  9399. export var clipPlaneVertex: {
  9400. name: string;
  9401. shader: string;
  9402. };
  9403. }
  9404. declare module BABYLON {
  9405. /** @hidden */
  9406. export var shadowMapVertexShader: {
  9407. name: string;
  9408. shader: string;
  9409. };
  9410. }
  9411. declare module BABYLON {
  9412. /** @hidden */
  9413. export var depthBoxBlurPixelShader: {
  9414. name: string;
  9415. shader: string;
  9416. };
  9417. }
  9418. declare module BABYLON {
  9419. /**
  9420. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9421. */
  9422. export interface ICustomShaderOptions {
  9423. /**
  9424. * Gets or sets the custom shader name to use
  9425. */
  9426. shaderName: string;
  9427. /**
  9428. * The list of attribute names used in the shader
  9429. */
  9430. attributes?: string[];
  9431. /**
  9432. * The list of unifrom names used in the shader
  9433. */
  9434. uniforms?: string[];
  9435. /**
  9436. * The list of sampler names used in the shader
  9437. */
  9438. samplers?: string[];
  9439. /**
  9440. * The list of defines used in the shader
  9441. */
  9442. defines?: string[];
  9443. }
  9444. /**
  9445. * Interface to implement to create a shadow generator compatible with BJS.
  9446. */
  9447. export interface IShadowGenerator {
  9448. /**
  9449. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9450. * @returns The render target texture if present otherwise, null
  9451. */
  9452. getShadowMap(): Nullable<RenderTargetTexture>;
  9453. /**
  9454. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9455. * @param subMesh The submesh we want to render in the shadow map
  9456. * @param useInstances Defines wether will draw in the map using instances
  9457. * @returns true if ready otherwise, false
  9458. */
  9459. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9460. /**
  9461. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9462. * @param defines Defines of the material we want to update
  9463. * @param lightIndex Index of the light in the enabled light list of the material
  9464. */
  9465. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9466. /**
  9467. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9468. * defined in the generator but impacting the effect).
  9469. * It implies the unifroms available on the materials are the standard BJS ones.
  9470. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9471. * @param effect The effect we are binfing the information for
  9472. */
  9473. bindShadowLight(lightIndex: string, effect: Effect): void;
  9474. /**
  9475. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9476. * (eq to shadow prjection matrix * light transform matrix)
  9477. * @returns The transform matrix used to create the shadow map
  9478. */
  9479. getTransformMatrix(): Matrix;
  9480. /**
  9481. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9482. * Cube and 2D textures for instance.
  9483. */
  9484. recreateShadowMap(): void;
  9485. /**
  9486. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9487. * @param onCompiled Callback triggered at the and of the effects compilation
  9488. * @param options Sets of optional options forcing the compilation with different modes
  9489. */
  9490. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  9491. useInstances: boolean;
  9492. }>): void;
  9493. /**
  9494. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9495. * @param options Sets of optional options forcing the compilation with different modes
  9496. * @returns A promise that resolves when the compilation completes
  9497. */
  9498. forceCompilationAsync(options?: Partial<{
  9499. useInstances: boolean;
  9500. }>): Promise<void>;
  9501. /**
  9502. * Serializes the shadow generator setup to a json object.
  9503. * @returns The serialized JSON object
  9504. */
  9505. serialize(): any;
  9506. /**
  9507. * Disposes the Shadow map and related Textures and effects.
  9508. */
  9509. dispose(): void;
  9510. }
  9511. /**
  9512. * Default implementation IShadowGenerator.
  9513. * This is the main object responsible of generating shadows in the framework.
  9514. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9515. */
  9516. export class ShadowGenerator implements IShadowGenerator {
  9517. /**
  9518. * Name of the shadow generator class
  9519. */
  9520. static CLASSNAME: string;
  9521. /**
  9522. * Shadow generator mode None: no filtering applied.
  9523. */
  9524. static readonly FILTER_NONE: number;
  9525. /**
  9526. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9527. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9528. */
  9529. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9530. /**
  9531. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9532. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9533. */
  9534. static readonly FILTER_POISSONSAMPLING: number;
  9535. /**
  9536. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9537. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9538. */
  9539. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9540. /**
  9541. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9542. * edge artifacts on steep falloff.
  9543. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9544. */
  9545. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9546. /**
  9547. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9548. * edge artifacts on steep falloff.
  9549. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9550. */
  9551. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9552. /**
  9553. * Shadow generator mode PCF: Percentage Closer Filtering
  9554. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9555. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9556. */
  9557. static readonly FILTER_PCF: number;
  9558. /**
  9559. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9560. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9561. * Contact Hardening
  9562. */
  9563. static readonly FILTER_PCSS: number;
  9564. /**
  9565. * Reserved for PCF and PCSS
  9566. * Highest Quality.
  9567. *
  9568. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9569. *
  9570. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9571. */
  9572. static readonly QUALITY_HIGH: number;
  9573. /**
  9574. * Reserved for PCF and PCSS
  9575. * Good tradeoff for quality/perf cross devices
  9576. *
  9577. * Execute PCF on a 3*3 kernel.
  9578. *
  9579. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9580. */
  9581. static readonly QUALITY_MEDIUM: number;
  9582. /**
  9583. * Reserved for PCF and PCSS
  9584. * The lowest quality but the fastest.
  9585. *
  9586. * Execute PCF on a 1*1 kernel.
  9587. *
  9588. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9589. */
  9590. static readonly QUALITY_LOW: number;
  9591. /** Gets or sets the custom shader name to use */
  9592. customShaderOptions: ICustomShaderOptions;
  9593. /**
  9594. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9595. */
  9596. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9597. /**
  9598. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  9599. */
  9600. onAfterShadowMapRenderObservable: Observable<Effect>;
  9601. /**
  9602. * Observable triggered before a mesh is rendered in the shadow map.
  9603. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  9604. */
  9605. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  9606. /**
  9607. * Observable triggered after a mesh is rendered in the shadow map.
  9608. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  9609. */
  9610. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  9611. protected _bias: number;
  9612. /**
  9613. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9614. */
  9615. get bias(): number;
  9616. /**
  9617. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9618. */
  9619. set bias(bias: number);
  9620. protected _normalBias: number;
  9621. /**
  9622. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9623. */
  9624. get normalBias(): number;
  9625. /**
  9626. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9627. */
  9628. set normalBias(normalBias: number);
  9629. protected _blurBoxOffset: number;
  9630. /**
  9631. * Gets the blur box offset: offset applied during the blur pass.
  9632. * Only useful if useKernelBlur = false
  9633. */
  9634. get blurBoxOffset(): number;
  9635. /**
  9636. * Sets the blur box offset: offset applied during the blur pass.
  9637. * Only useful if useKernelBlur = false
  9638. */
  9639. set blurBoxOffset(value: number);
  9640. protected _blurScale: number;
  9641. /**
  9642. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9643. * 2 means half of the size.
  9644. */
  9645. get blurScale(): number;
  9646. /**
  9647. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9648. * 2 means half of the size.
  9649. */
  9650. set blurScale(value: number);
  9651. protected _blurKernel: number;
  9652. /**
  9653. * Gets the blur kernel: kernel size of the blur pass.
  9654. * Only useful if useKernelBlur = true
  9655. */
  9656. get blurKernel(): number;
  9657. /**
  9658. * Sets the blur kernel: kernel size of the blur pass.
  9659. * Only useful if useKernelBlur = true
  9660. */
  9661. set blurKernel(value: number);
  9662. protected _useKernelBlur: boolean;
  9663. /**
  9664. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9665. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9666. */
  9667. get useKernelBlur(): boolean;
  9668. /**
  9669. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9670. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9671. */
  9672. set useKernelBlur(value: boolean);
  9673. protected _depthScale: number;
  9674. /**
  9675. * Gets the depth scale used in ESM mode.
  9676. */
  9677. get depthScale(): number;
  9678. /**
  9679. * Sets the depth scale used in ESM mode.
  9680. * This can override the scale stored on the light.
  9681. */
  9682. set depthScale(value: number);
  9683. protected _validateFilter(filter: number): number;
  9684. protected _filter: number;
  9685. /**
  9686. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9687. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9688. */
  9689. get filter(): number;
  9690. /**
  9691. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  9692. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9693. */
  9694. set filter(value: number);
  9695. /**
  9696. * Gets if the current filter is set to Poisson Sampling.
  9697. */
  9698. get usePoissonSampling(): boolean;
  9699. /**
  9700. * Sets the current filter to Poisson Sampling.
  9701. */
  9702. set usePoissonSampling(value: boolean);
  9703. /**
  9704. * Gets if the current filter is set to ESM.
  9705. */
  9706. get useExponentialShadowMap(): boolean;
  9707. /**
  9708. * Sets the current filter is to ESM.
  9709. */
  9710. set useExponentialShadowMap(value: boolean);
  9711. /**
  9712. * Gets if the current filter is set to filtered ESM.
  9713. */
  9714. get useBlurExponentialShadowMap(): boolean;
  9715. /**
  9716. * Gets if the current filter is set to filtered ESM.
  9717. */
  9718. set useBlurExponentialShadowMap(value: boolean);
  9719. /**
  9720. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9721. * exponential to prevent steep falloff artifacts).
  9722. */
  9723. get useCloseExponentialShadowMap(): boolean;
  9724. /**
  9725. * Sets the current filter to "close ESM" (using the inverse of the
  9726. * exponential to prevent steep falloff artifacts).
  9727. */
  9728. set useCloseExponentialShadowMap(value: boolean);
  9729. /**
  9730. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9731. * exponential to prevent steep falloff artifacts).
  9732. */
  9733. get useBlurCloseExponentialShadowMap(): boolean;
  9734. /**
  9735. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9736. * exponential to prevent steep falloff artifacts).
  9737. */
  9738. set useBlurCloseExponentialShadowMap(value: boolean);
  9739. /**
  9740. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9741. */
  9742. get usePercentageCloserFiltering(): boolean;
  9743. /**
  9744. * Sets the current filter to "PCF" (percentage closer filtering).
  9745. */
  9746. set usePercentageCloserFiltering(value: boolean);
  9747. protected _filteringQuality: number;
  9748. /**
  9749. * Gets the PCF or PCSS Quality.
  9750. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9751. */
  9752. get filteringQuality(): number;
  9753. /**
  9754. * Sets the PCF or PCSS Quality.
  9755. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9756. */
  9757. set filteringQuality(filteringQuality: number);
  9758. /**
  9759. * Gets if the current filter is set to "PCSS" (contact hardening).
  9760. */
  9761. get useContactHardeningShadow(): boolean;
  9762. /**
  9763. * Sets the current filter to "PCSS" (contact hardening).
  9764. */
  9765. set useContactHardeningShadow(value: boolean);
  9766. protected _contactHardeningLightSizeUVRatio: number;
  9767. /**
  9768. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9769. * Using a ratio helps keeping shape stability independently of the map size.
  9770. *
  9771. * It does not account for the light projection as it was having too much
  9772. * instability during the light setup or during light position changes.
  9773. *
  9774. * Only valid if useContactHardeningShadow is true.
  9775. */
  9776. get contactHardeningLightSizeUVRatio(): number;
  9777. /**
  9778. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9779. * Using a ratio helps keeping shape stability independently of the map size.
  9780. *
  9781. * It does not account for the light projection as it was having too much
  9782. * instability during the light setup or during light position changes.
  9783. *
  9784. * Only valid if useContactHardeningShadow is true.
  9785. */
  9786. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  9787. protected _darkness: number;
  9788. /** Gets or sets the actual darkness of a shadow */
  9789. get darkness(): number;
  9790. set darkness(value: number);
  9791. /**
  9792. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  9793. * 0 means strongest and 1 would means no shadow.
  9794. * @returns the darkness.
  9795. */
  9796. getDarkness(): number;
  9797. /**
  9798. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  9799. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  9800. * @returns the shadow generator allowing fluent coding.
  9801. */
  9802. setDarkness(darkness: number): ShadowGenerator;
  9803. protected _transparencyShadow: boolean;
  9804. /** Gets or sets the ability to have transparent shadow */
  9805. get transparencyShadow(): boolean;
  9806. set transparencyShadow(value: boolean);
  9807. /**
  9808. * Sets the ability to have transparent shadow (boolean).
  9809. * @param transparent True if transparent else False
  9810. * @returns the shadow generator allowing fluent coding
  9811. */
  9812. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  9813. protected _shadowMap: Nullable<RenderTargetTexture>;
  9814. protected _shadowMap2: Nullable<RenderTargetTexture>;
  9815. /**
  9816. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9817. * @returns The render target texture if present otherwise, null
  9818. */
  9819. getShadowMap(): Nullable<RenderTargetTexture>;
  9820. /**
  9821. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9822. * @returns The render target texture if the shadow map is present otherwise, null
  9823. */
  9824. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9825. /**
  9826. * Gets the class name of that object
  9827. * @returns "ShadowGenerator"
  9828. */
  9829. getClassName(): string;
  9830. /**
  9831. * Helper function to add a mesh and its descendants to the list of shadow casters.
  9832. * @param mesh Mesh to add
  9833. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  9834. * @returns the Shadow Generator itself
  9835. */
  9836. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9837. /**
  9838. * Helper function to remove a mesh and its descendants from the list of shadow casters
  9839. * @param mesh Mesh to remove
  9840. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  9841. * @returns the Shadow Generator itself
  9842. */
  9843. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9844. /**
  9845. * Controls the extent to which the shadows fade out at the edge of the frustum
  9846. */
  9847. frustumEdgeFalloff: number;
  9848. protected _light: IShadowLight;
  9849. /**
  9850. * Returns the associated light object.
  9851. * @returns the light generating the shadow
  9852. */
  9853. getLight(): IShadowLight;
  9854. /**
  9855. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  9856. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  9857. * It might on the other hand introduce peter panning.
  9858. */
  9859. forceBackFacesOnly: boolean;
  9860. protected _scene: Scene;
  9861. protected _lightDirection: Vector3;
  9862. protected _effect: Effect;
  9863. protected _viewMatrix: Matrix;
  9864. protected _projectionMatrix: Matrix;
  9865. protected _transformMatrix: Matrix;
  9866. protected _cachedPosition: Vector3;
  9867. protected _cachedDirection: Vector3;
  9868. protected _cachedDefines: string;
  9869. protected _currentRenderID: number;
  9870. protected _boxBlurPostprocess: Nullable<PostProcess>;
  9871. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  9872. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  9873. protected _blurPostProcesses: PostProcess[];
  9874. protected _mapSize: number;
  9875. protected _currentFaceIndex: number;
  9876. protected _currentFaceIndexCache: number;
  9877. protected _textureType: number;
  9878. protected _defaultTextureMatrix: Matrix;
  9879. protected _storedUniqueId: Nullable<number>;
  9880. /** @hidden */
  9881. static _SceneComponentInitialization: (scene: Scene) => void;
  9882. /**
  9883. * Creates a ShadowGenerator object.
  9884. * A ShadowGenerator is the required tool to use the shadows.
  9885. * Each light casting shadows needs to use its own ShadowGenerator.
  9886. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  9887. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  9888. * @param light The light object generating the shadows.
  9889. * @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.
  9890. */
  9891. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  9892. protected _initializeGenerator(): void;
  9893. protected _createTargetRenderTexture(): void;
  9894. protected _initializeShadowMap(): void;
  9895. protected _initializeBlurRTTAndPostProcesses(): void;
  9896. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  9897. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect): void;
  9898. protected _renderSubMeshForShadowMap(subMesh: SubMesh): void;
  9899. protected _applyFilterValues(): void;
  9900. /**
  9901. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9902. * @param onCompiled Callback triggered at the and of the effects compilation
  9903. * @param options Sets of optional options forcing the compilation with different modes
  9904. */
  9905. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  9906. useInstances: boolean;
  9907. }>): void;
  9908. /**
  9909. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9910. * @param options Sets of optional options forcing the compilation with different modes
  9911. * @returns A promise that resolves when the compilation completes
  9912. */
  9913. forceCompilationAsync(options?: Partial<{
  9914. useInstances: boolean;
  9915. }>): Promise<void>;
  9916. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  9917. /**
  9918. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9919. * @param subMesh The submesh we want to render in the shadow map
  9920. * @param useInstances Defines wether will draw in the map using instances
  9921. * @returns true if ready otherwise, false
  9922. */
  9923. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9924. /**
  9925. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9926. * @param defines Defines of the material we want to update
  9927. * @param lightIndex Index of the light in the enabled light list of the material
  9928. */
  9929. prepareDefines(defines: any, lightIndex: number): void;
  9930. /**
  9931. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9932. * defined in the generator but impacting the effect).
  9933. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9934. * @param effect The effect we are binfing the information for
  9935. */
  9936. bindShadowLight(lightIndex: string, effect: Effect): void;
  9937. /**
  9938. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9939. * (eq to shadow prjection matrix * light transform matrix)
  9940. * @returns The transform matrix used to create the shadow map
  9941. */
  9942. getTransformMatrix(): Matrix;
  9943. /**
  9944. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9945. * Cube and 2D textures for instance.
  9946. */
  9947. recreateShadowMap(): void;
  9948. protected _disposeBlurPostProcesses(): void;
  9949. protected _disposeRTTandPostProcesses(): void;
  9950. /**
  9951. * Disposes the ShadowGenerator.
  9952. * Returns nothing.
  9953. */
  9954. dispose(): void;
  9955. /**
  9956. * Serializes the shadow generator setup to a json object.
  9957. * @returns The serialized JSON object
  9958. */
  9959. serialize(): any;
  9960. /**
  9961. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  9962. * @param parsedShadowGenerator The JSON object to parse
  9963. * @param scene The scene to create the shadow map for
  9964. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  9965. * @returns The parsed shadow generator
  9966. */
  9967. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  9968. }
  9969. }
  9970. declare module BABYLON {
  9971. /**
  9972. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  9973. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  9974. * 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.
  9975. */
  9976. export abstract class Light extends Node {
  9977. /**
  9978. * Falloff Default: light is falling off following the material specification:
  9979. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  9980. */
  9981. static readonly FALLOFF_DEFAULT: number;
  9982. /**
  9983. * Falloff Physical: light is falling off following the inverse squared distance law.
  9984. */
  9985. static readonly FALLOFF_PHYSICAL: number;
  9986. /**
  9987. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  9988. * to enhance interoperability with other engines.
  9989. */
  9990. static readonly FALLOFF_GLTF: number;
  9991. /**
  9992. * Falloff Standard: light is falling off like in the standard material
  9993. * to enhance interoperability with other materials.
  9994. */
  9995. static readonly FALLOFF_STANDARD: number;
  9996. /**
  9997. * If every light affecting the material is in this lightmapMode,
  9998. * material.lightmapTexture adds or multiplies
  9999. * (depends on material.useLightmapAsShadowmap)
  10000. * after every other light calculations.
  10001. */
  10002. static readonly LIGHTMAP_DEFAULT: number;
  10003. /**
  10004. * material.lightmapTexture as only diffuse lighting from this light
  10005. * adds only specular lighting from this light
  10006. * adds dynamic shadows
  10007. */
  10008. static readonly LIGHTMAP_SPECULAR: number;
  10009. /**
  10010. * material.lightmapTexture as only lighting
  10011. * no light calculation from this light
  10012. * only adds dynamic shadows from this light
  10013. */
  10014. static readonly LIGHTMAP_SHADOWSONLY: number;
  10015. /**
  10016. * Each light type uses the default quantity according to its type:
  10017. * point/spot lights use luminous intensity
  10018. * directional lights use illuminance
  10019. */
  10020. static readonly INTENSITYMODE_AUTOMATIC: number;
  10021. /**
  10022. * lumen (lm)
  10023. */
  10024. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  10025. /**
  10026. * candela (lm/sr)
  10027. */
  10028. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  10029. /**
  10030. * lux (lm/m^2)
  10031. */
  10032. static readonly INTENSITYMODE_ILLUMINANCE: number;
  10033. /**
  10034. * nit (cd/m^2)
  10035. */
  10036. static readonly INTENSITYMODE_LUMINANCE: number;
  10037. /**
  10038. * Light type const id of the point light.
  10039. */
  10040. static readonly LIGHTTYPEID_POINTLIGHT: number;
  10041. /**
  10042. * Light type const id of the directional light.
  10043. */
  10044. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  10045. /**
  10046. * Light type const id of the spot light.
  10047. */
  10048. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  10049. /**
  10050. * Light type const id of the hemispheric light.
  10051. */
  10052. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  10053. /**
  10054. * Diffuse gives the basic color to an object.
  10055. */
  10056. diffuse: Color3;
  10057. /**
  10058. * Specular produces a highlight color on an object.
  10059. * Note: This is note affecting PBR materials.
  10060. */
  10061. specular: Color3;
  10062. /**
  10063. * Defines the falloff type for this light. This lets overrriding how punctual light are
  10064. * falling off base on range or angle.
  10065. * This can be set to any values in Light.FALLOFF_x.
  10066. *
  10067. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  10068. * other types of materials.
  10069. */
  10070. falloffType: number;
  10071. /**
  10072. * Strength of the light.
  10073. * Note: By default it is define in the framework own unit.
  10074. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  10075. */
  10076. intensity: number;
  10077. private _range;
  10078. protected _inverseSquaredRange: number;
  10079. /**
  10080. * Defines how far from the source the light is impacting in scene units.
  10081. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10082. */
  10083. get range(): number;
  10084. /**
  10085. * Defines how far from the source the light is impacting in scene units.
  10086. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10087. */
  10088. set range(value: number);
  10089. /**
  10090. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  10091. * of light.
  10092. */
  10093. private _photometricScale;
  10094. private _intensityMode;
  10095. /**
  10096. * Gets the photometric scale used to interpret the intensity.
  10097. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10098. */
  10099. get intensityMode(): number;
  10100. /**
  10101. * Sets the photometric scale used to interpret the intensity.
  10102. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10103. */
  10104. set intensityMode(value: number);
  10105. private _radius;
  10106. /**
  10107. * Gets the light radius used by PBR Materials to simulate soft area lights.
  10108. */
  10109. get radius(): number;
  10110. /**
  10111. * sets the light radius used by PBR Materials to simulate soft area lights.
  10112. */
  10113. set radius(value: number);
  10114. private _renderPriority;
  10115. /**
  10116. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  10117. * exceeding the number allowed of the materials.
  10118. */
  10119. renderPriority: number;
  10120. private _shadowEnabled;
  10121. /**
  10122. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10123. * the current shadow generator.
  10124. */
  10125. get shadowEnabled(): boolean;
  10126. /**
  10127. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10128. * the current shadow generator.
  10129. */
  10130. set shadowEnabled(value: boolean);
  10131. private _includedOnlyMeshes;
  10132. /**
  10133. * Gets the only meshes impacted by this light.
  10134. */
  10135. get includedOnlyMeshes(): AbstractMesh[];
  10136. /**
  10137. * Sets the only meshes impacted by this light.
  10138. */
  10139. set includedOnlyMeshes(value: AbstractMesh[]);
  10140. private _excludedMeshes;
  10141. /**
  10142. * Gets the meshes not impacted by this light.
  10143. */
  10144. get excludedMeshes(): AbstractMesh[];
  10145. /**
  10146. * Sets the meshes not impacted by this light.
  10147. */
  10148. set excludedMeshes(value: AbstractMesh[]);
  10149. private _excludeWithLayerMask;
  10150. /**
  10151. * Gets the layer id use to find what meshes are not impacted by the light.
  10152. * Inactive if 0
  10153. */
  10154. get excludeWithLayerMask(): number;
  10155. /**
  10156. * Sets the layer id use to find what meshes are not impacted by the light.
  10157. * Inactive if 0
  10158. */
  10159. set excludeWithLayerMask(value: number);
  10160. private _includeOnlyWithLayerMask;
  10161. /**
  10162. * Gets the layer id use to find what meshes are impacted by the light.
  10163. * Inactive if 0
  10164. */
  10165. get includeOnlyWithLayerMask(): number;
  10166. /**
  10167. * Sets the layer id use to find what meshes are impacted by the light.
  10168. * Inactive if 0
  10169. */
  10170. set includeOnlyWithLayerMask(value: number);
  10171. private _lightmapMode;
  10172. /**
  10173. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10174. */
  10175. get lightmapMode(): number;
  10176. /**
  10177. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10178. */
  10179. set lightmapMode(value: number);
  10180. /**
  10181. * Shadow generator associted to the light.
  10182. * @hidden Internal use only.
  10183. */
  10184. _shadowGenerator: Nullable<IShadowGenerator>;
  10185. /**
  10186. * @hidden Internal use only.
  10187. */
  10188. _excludedMeshesIds: string[];
  10189. /**
  10190. * @hidden Internal use only.
  10191. */
  10192. _includedOnlyMeshesIds: string[];
  10193. /**
  10194. * The current light unifom buffer.
  10195. * @hidden Internal use only.
  10196. */
  10197. _uniformBuffer: UniformBuffer;
  10198. /** @hidden */
  10199. _renderId: number;
  10200. /**
  10201. * Creates a Light object in the scene.
  10202. * Documentation : https://doc.babylonjs.com/babylon101/lights
  10203. * @param name The firendly name of the light
  10204. * @param scene The scene the light belongs too
  10205. */
  10206. constructor(name: string, scene: Scene);
  10207. protected abstract _buildUniformLayout(): void;
  10208. /**
  10209. * Sets the passed Effect "effect" with the Light information.
  10210. * @param effect The effect to update
  10211. * @param lightIndex The index of the light in the effect to update
  10212. * @returns The light
  10213. */
  10214. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  10215. /**
  10216. * Sets the passed Effect "effect" with the Light textures.
  10217. * @param effect The effect to update
  10218. * @param lightIndex The index of the light in the effect to update
  10219. * @returns The light
  10220. */
  10221. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  10222. /**
  10223. * Binds the lights information from the scene to the effect for the given mesh.
  10224. * @param lightIndex Light index
  10225. * @param scene The scene where the light belongs to
  10226. * @param effect The effect we are binding the data to
  10227. * @param useSpecular Defines if specular is supported
  10228. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  10229. */
  10230. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  10231. /**
  10232. * Sets the passed Effect "effect" with the Light information.
  10233. * @param effect The effect to update
  10234. * @param lightDataUniformName The uniform used to store light data (position or direction)
  10235. * @returns The light
  10236. */
  10237. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  10238. /**
  10239. * Returns the string "Light".
  10240. * @returns the class name
  10241. */
  10242. getClassName(): string;
  10243. /** @hidden */
  10244. readonly _isLight: boolean;
  10245. /**
  10246. * Converts the light information to a readable string for debug purpose.
  10247. * @param fullDetails Supports for multiple levels of logging within scene loading
  10248. * @returns the human readable light info
  10249. */
  10250. toString(fullDetails?: boolean): string;
  10251. /** @hidden */
  10252. protected _syncParentEnabledState(): void;
  10253. /**
  10254. * Set the enabled state of this node.
  10255. * @param value - the new enabled state
  10256. */
  10257. setEnabled(value: boolean): void;
  10258. /**
  10259. * Returns the Light associated shadow generator if any.
  10260. * @return the associated shadow generator.
  10261. */
  10262. getShadowGenerator(): Nullable<IShadowGenerator>;
  10263. /**
  10264. * Returns a Vector3, the absolute light position in the World.
  10265. * @returns the world space position of the light
  10266. */
  10267. getAbsolutePosition(): Vector3;
  10268. /**
  10269. * Specifies if the light will affect the passed mesh.
  10270. * @param mesh The mesh to test against the light
  10271. * @return true the mesh is affected otherwise, false.
  10272. */
  10273. canAffectMesh(mesh: AbstractMesh): boolean;
  10274. /**
  10275. * Sort function to order lights for rendering.
  10276. * @param a First Light object to compare to second.
  10277. * @param b Second Light object to compare first.
  10278. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  10279. */
  10280. static CompareLightsPriority(a: Light, b: Light): number;
  10281. /**
  10282. * Releases resources associated with this node.
  10283. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10284. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10285. */
  10286. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10287. /**
  10288. * Returns the light type ID (integer).
  10289. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10290. */
  10291. getTypeID(): number;
  10292. /**
  10293. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  10294. * @returns the scaled intensity in intensity mode unit
  10295. */
  10296. getScaledIntensity(): number;
  10297. /**
  10298. * Returns a new Light object, named "name", from the current one.
  10299. * @param name The name of the cloned light
  10300. * @returns the new created light
  10301. */
  10302. clone(name: string): Nullable<Light>;
  10303. /**
  10304. * Serializes the current light into a Serialization object.
  10305. * @returns the serialized object.
  10306. */
  10307. serialize(): any;
  10308. /**
  10309. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  10310. * This new light is named "name" and added to the passed scene.
  10311. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  10312. * @param name The friendly name of the light
  10313. * @param scene The scene the new light will belong to
  10314. * @returns the constructor function
  10315. */
  10316. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  10317. /**
  10318. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  10319. * @param parsedLight The JSON representation of the light
  10320. * @param scene The scene to create the parsed light in
  10321. * @returns the created light after parsing
  10322. */
  10323. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  10324. private _hookArrayForExcluded;
  10325. private _hookArrayForIncludedOnly;
  10326. private _resyncMeshes;
  10327. /**
  10328. * Forces the meshes to update their light related information in their rendering used effects
  10329. * @hidden Internal Use Only
  10330. */
  10331. _markMeshesAsLightDirty(): void;
  10332. /**
  10333. * Recomputes the cached photometric scale if needed.
  10334. */
  10335. private _computePhotometricScale;
  10336. /**
  10337. * Returns the Photometric Scale according to the light type and intensity mode.
  10338. */
  10339. private _getPhotometricScale;
  10340. /**
  10341. * Reorder the light in the scene according to their defined priority.
  10342. * @hidden Internal Use Only
  10343. */
  10344. _reorderLightsInScene(): void;
  10345. /**
  10346. * Prepares the list of defines specific to the light type.
  10347. * @param defines the list of defines
  10348. * @param lightIndex defines the index of the light for the effect
  10349. */
  10350. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  10351. }
  10352. }
  10353. declare module BABYLON {
  10354. /**
  10355. * Interface used to define Action
  10356. */
  10357. export interface IAction {
  10358. /**
  10359. * Trigger for the action
  10360. */
  10361. trigger: number;
  10362. /** Options of the trigger */
  10363. triggerOptions: any;
  10364. /**
  10365. * Gets the trigger parameters
  10366. * @returns the trigger parameters
  10367. */
  10368. getTriggerParameter(): any;
  10369. /**
  10370. * Internal only - executes current action event
  10371. * @hidden
  10372. */
  10373. _executeCurrent(evt?: ActionEvent): void;
  10374. /**
  10375. * Serialize placeholder for child classes
  10376. * @param parent of child
  10377. * @returns the serialized object
  10378. */
  10379. serialize(parent: any): any;
  10380. /**
  10381. * Internal only
  10382. * @hidden
  10383. */
  10384. _prepare(): void;
  10385. /**
  10386. * Internal only - manager for action
  10387. * @hidden
  10388. */
  10389. _actionManager: AbstractActionManager;
  10390. /**
  10391. * Adds action to chain of actions, may be a DoNothingAction
  10392. * @param action defines the next action to execute
  10393. * @returns The action passed in
  10394. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10395. */
  10396. then(action: IAction): IAction;
  10397. }
  10398. /**
  10399. * The action to be carried out following a trigger
  10400. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10401. */
  10402. export class Action implements IAction {
  10403. /** the trigger, with or without parameters, for the action */
  10404. triggerOptions: any;
  10405. /**
  10406. * Trigger for the action
  10407. */
  10408. trigger: number;
  10409. /**
  10410. * Internal only - manager for action
  10411. * @hidden
  10412. */
  10413. _actionManager: ActionManager;
  10414. private _nextActiveAction;
  10415. private _child;
  10416. private _condition?;
  10417. private _triggerParameter;
  10418. /**
  10419. * An event triggered prior to action being executed.
  10420. */
  10421. onBeforeExecuteObservable: Observable<Action>;
  10422. /**
  10423. * Creates a new Action
  10424. * @param triggerOptions the trigger, with or without parameters, for the action
  10425. * @param condition an optional determinant of action
  10426. */
  10427. constructor(
  10428. /** the trigger, with or without parameters, for the action */
  10429. triggerOptions: any, condition?: Condition);
  10430. /**
  10431. * Internal only
  10432. * @hidden
  10433. */
  10434. _prepare(): void;
  10435. /**
  10436. * Gets the trigger parameters
  10437. * @returns the trigger parameters
  10438. */
  10439. getTriggerParameter(): any;
  10440. /**
  10441. * Internal only - executes current action event
  10442. * @hidden
  10443. */
  10444. _executeCurrent(evt?: ActionEvent): void;
  10445. /**
  10446. * Execute placeholder for child classes
  10447. * @param evt optional action event
  10448. */
  10449. execute(evt?: ActionEvent): void;
  10450. /**
  10451. * Skips to next active action
  10452. */
  10453. skipToNextActiveAction(): void;
  10454. /**
  10455. * Adds action to chain of actions, may be a DoNothingAction
  10456. * @param action defines the next action to execute
  10457. * @returns The action passed in
  10458. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10459. */
  10460. then(action: Action): Action;
  10461. /**
  10462. * Internal only
  10463. * @hidden
  10464. */
  10465. _getProperty(propertyPath: string): string;
  10466. /**
  10467. * Internal only
  10468. * @hidden
  10469. */
  10470. _getEffectiveTarget(target: any, propertyPath: string): any;
  10471. /**
  10472. * Serialize placeholder for child classes
  10473. * @param parent of child
  10474. * @returns the serialized object
  10475. */
  10476. serialize(parent: any): any;
  10477. /**
  10478. * Internal only called by serialize
  10479. * @hidden
  10480. */
  10481. protected _serialize(serializedAction: any, parent?: any): any;
  10482. /**
  10483. * Internal only
  10484. * @hidden
  10485. */
  10486. static _SerializeValueAsString: (value: any) => string;
  10487. /**
  10488. * Internal only
  10489. * @hidden
  10490. */
  10491. static _GetTargetProperty: (target: Node | Scene) => {
  10492. name: string;
  10493. targetType: string;
  10494. value: string;
  10495. };
  10496. }
  10497. }
  10498. declare module BABYLON {
  10499. /**
  10500. * A Condition applied to an Action
  10501. */
  10502. export class Condition {
  10503. /**
  10504. * Internal only - manager for action
  10505. * @hidden
  10506. */
  10507. _actionManager: ActionManager;
  10508. /**
  10509. * Internal only
  10510. * @hidden
  10511. */
  10512. _evaluationId: number;
  10513. /**
  10514. * Internal only
  10515. * @hidden
  10516. */
  10517. _currentResult: boolean;
  10518. /**
  10519. * Creates a new Condition
  10520. * @param actionManager the manager of the action the condition is applied to
  10521. */
  10522. constructor(actionManager: ActionManager);
  10523. /**
  10524. * Check if the current condition is valid
  10525. * @returns a boolean
  10526. */
  10527. isValid(): boolean;
  10528. /**
  10529. * Internal only
  10530. * @hidden
  10531. */
  10532. _getProperty(propertyPath: string): string;
  10533. /**
  10534. * Internal only
  10535. * @hidden
  10536. */
  10537. _getEffectiveTarget(target: any, propertyPath: string): any;
  10538. /**
  10539. * Serialize placeholder for child classes
  10540. * @returns the serialized object
  10541. */
  10542. serialize(): any;
  10543. /**
  10544. * Internal only
  10545. * @hidden
  10546. */
  10547. protected _serialize(serializedCondition: any): any;
  10548. }
  10549. /**
  10550. * Defines specific conditional operators as extensions of Condition
  10551. */
  10552. export class ValueCondition extends Condition {
  10553. /** path to specify the property of the target the conditional operator uses */
  10554. propertyPath: string;
  10555. /** the value compared by the conditional operator against the current value of the property */
  10556. value: any;
  10557. /** the conditional operator, default ValueCondition.IsEqual */
  10558. operator: number;
  10559. /**
  10560. * Internal only
  10561. * @hidden
  10562. */
  10563. private static _IsEqual;
  10564. /**
  10565. * Internal only
  10566. * @hidden
  10567. */
  10568. private static _IsDifferent;
  10569. /**
  10570. * Internal only
  10571. * @hidden
  10572. */
  10573. private static _IsGreater;
  10574. /**
  10575. * Internal only
  10576. * @hidden
  10577. */
  10578. private static _IsLesser;
  10579. /**
  10580. * returns the number for IsEqual
  10581. */
  10582. static get IsEqual(): number;
  10583. /**
  10584. * Returns the number for IsDifferent
  10585. */
  10586. static get IsDifferent(): number;
  10587. /**
  10588. * Returns the number for IsGreater
  10589. */
  10590. static get IsGreater(): number;
  10591. /**
  10592. * Returns the number for IsLesser
  10593. */
  10594. static get IsLesser(): number;
  10595. /**
  10596. * Internal only The action manager for the condition
  10597. * @hidden
  10598. */
  10599. _actionManager: ActionManager;
  10600. /**
  10601. * Internal only
  10602. * @hidden
  10603. */
  10604. private _target;
  10605. /**
  10606. * Internal only
  10607. * @hidden
  10608. */
  10609. private _effectiveTarget;
  10610. /**
  10611. * Internal only
  10612. * @hidden
  10613. */
  10614. private _property;
  10615. /**
  10616. * Creates a new ValueCondition
  10617. * @param actionManager manager for the action the condition applies to
  10618. * @param target for the action
  10619. * @param propertyPath path to specify the property of the target the conditional operator uses
  10620. * @param value the value compared by the conditional operator against the current value of the property
  10621. * @param operator the conditional operator, default ValueCondition.IsEqual
  10622. */
  10623. constructor(actionManager: ActionManager, target: any,
  10624. /** path to specify the property of the target the conditional operator uses */
  10625. propertyPath: string,
  10626. /** the value compared by the conditional operator against the current value of the property */
  10627. value: any,
  10628. /** the conditional operator, default ValueCondition.IsEqual */
  10629. operator?: number);
  10630. /**
  10631. * Compares the given value with the property value for the specified conditional operator
  10632. * @returns the result of the comparison
  10633. */
  10634. isValid(): boolean;
  10635. /**
  10636. * Serialize the ValueCondition into a JSON compatible object
  10637. * @returns serialization object
  10638. */
  10639. serialize(): any;
  10640. /**
  10641. * Gets the name of the conditional operator for the ValueCondition
  10642. * @param operator the conditional operator
  10643. * @returns the name
  10644. */
  10645. static GetOperatorName(operator: number): string;
  10646. }
  10647. /**
  10648. * Defines a predicate condition as an extension of Condition
  10649. */
  10650. export class PredicateCondition extends Condition {
  10651. /** defines the predicate function used to validate the condition */
  10652. predicate: () => boolean;
  10653. /**
  10654. * Internal only - manager for action
  10655. * @hidden
  10656. */
  10657. _actionManager: ActionManager;
  10658. /**
  10659. * Creates a new PredicateCondition
  10660. * @param actionManager manager for the action the condition applies to
  10661. * @param predicate defines the predicate function used to validate the condition
  10662. */
  10663. constructor(actionManager: ActionManager,
  10664. /** defines the predicate function used to validate the condition */
  10665. predicate: () => boolean);
  10666. /**
  10667. * @returns the validity of the predicate condition
  10668. */
  10669. isValid(): boolean;
  10670. }
  10671. /**
  10672. * Defines a state condition as an extension of Condition
  10673. */
  10674. export class StateCondition extends Condition {
  10675. /** Value to compare with target state */
  10676. value: string;
  10677. /**
  10678. * Internal only - manager for action
  10679. * @hidden
  10680. */
  10681. _actionManager: ActionManager;
  10682. /**
  10683. * Internal only
  10684. * @hidden
  10685. */
  10686. private _target;
  10687. /**
  10688. * Creates a new StateCondition
  10689. * @param actionManager manager for the action the condition applies to
  10690. * @param target of the condition
  10691. * @param value to compare with target state
  10692. */
  10693. constructor(actionManager: ActionManager, target: any,
  10694. /** Value to compare with target state */
  10695. value: string);
  10696. /**
  10697. * Gets a boolean indicating if the current condition is met
  10698. * @returns the validity of the state
  10699. */
  10700. isValid(): boolean;
  10701. /**
  10702. * Serialize the StateCondition into a JSON compatible object
  10703. * @returns serialization object
  10704. */
  10705. serialize(): any;
  10706. }
  10707. }
  10708. declare module BABYLON {
  10709. /**
  10710. * This defines an action responsible to toggle a boolean once triggered.
  10711. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10712. */
  10713. export class SwitchBooleanAction extends Action {
  10714. /**
  10715. * The path to the boolean property in the target object
  10716. */
  10717. propertyPath: string;
  10718. private _target;
  10719. private _effectiveTarget;
  10720. private _property;
  10721. /**
  10722. * Instantiate the action
  10723. * @param triggerOptions defines the trigger options
  10724. * @param target defines the object containing the boolean
  10725. * @param propertyPath defines the path to the boolean property in the target object
  10726. * @param condition defines the trigger related conditions
  10727. */
  10728. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10729. /** @hidden */
  10730. _prepare(): void;
  10731. /**
  10732. * Execute the action toggle the boolean value.
  10733. */
  10734. execute(): void;
  10735. /**
  10736. * Serializes the actions and its related information.
  10737. * @param parent defines the object to serialize in
  10738. * @returns the serialized object
  10739. */
  10740. serialize(parent: any): any;
  10741. }
  10742. /**
  10743. * This defines an action responsible to set a the state field of the target
  10744. * to a desired value once triggered.
  10745. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10746. */
  10747. export class SetStateAction extends Action {
  10748. /**
  10749. * The value to store in the state field.
  10750. */
  10751. value: string;
  10752. private _target;
  10753. /**
  10754. * Instantiate the action
  10755. * @param triggerOptions defines the trigger options
  10756. * @param target defines the object containing the state property
  10757. * @param value defines the value to store in the state field
  10758. * @param condition defines the trigger related conditions
  10759. */
  10760. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10761. /**
  10762. * Execute the action and store the value on the target state property.
  10763. */
  10764. execute(): void;
  10765. /**
  10766. * Serializes the actions and its related information.
  10767. * @param parent defines the object to serialize in
  10768. * @returns the serialized object
  10769. */
  10770. serialize(parent: any): any;
  10771. }
  10772. /**
  10773. * This defines an action responsible to set a property of the target
  10774. * to a desired value once triggered.
  10775. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10776. */
  10777. export class SetValueAction extends Action {
  10778. /**
  10779. * The path of the property to set in the target.
  10780. */
  10781. propertyPath: string;
  10782. /**
  10783. * The value to set in the property
  10784. */
  10785. value: any;
  10786. private _target;
  10787. private _effectiveTarget;
  10788. private _property;
  10789. /**
  10790. * Instantiate the action
  10791. * @param triggerOptions defines the trigger options
  10792. * @param target defines the object containing the property
  10793. * @param propertyPath defines the path of the property to set in the target
  10794. * @param value defines the value to set in the property
  10795. * @param condition defines the trigger related conditions
  10796. */
  10797. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10798. /** @hidden */
  10799. _prepare(): void;
  10800. /**
  10801. * Execute the action and set the targetted property to the desired value.
  10802. */
  10803. execute(): void;
  10804. /**
  10805. * Serializes the actions and its related information.
  10806. * @param parent defines the object to serialize in
  10807. * @returns the serialized object
  10808. */
  10809. serialize(parent: any): any;
  10810. }
  10811. /**
  10812. * This defines an action responsible to increment the target value
  10813. * to a desired value once triggered.
  10814. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10815. */
  10816. export class IncrementValueAction extends Action {
  10817. /**
  10818. * The path of the property to increment in the target.
  10819. */
  10820. propertyPath: string;
  10821. /**
  10822. * The value we should increment the property by.
  10823. */
  10824. value: any;
  10825. private _target;
  10826. private _effectiveTarget;
  10827. private _property;
  10828. /**
  10829. * Instantiate the action
  10830. * @param triggerOptions defines the trigger options
  10831. * @param target defines the object containing the property
  10832. * @param propertyPath defines the path of the property to increment in the target
  10833. * @param value defines the value value we should increment the property by
  10834. * @param condition defines the trigger related conditions
  10835. */
  10836. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10837. /** @hidden */
  10838. _prepare(): void;
  10839. /**
  10840. * Execute the action and increment the target of the value amount.
  10841. */
  10842. execute(): void;
  10843. /**
  10844. * Serializes the actions and its related information.
  10845. * @param parent defines the object to serialize in
  10846. * @returns the serialized object
  10847. */
  10848. serialize(parent: any): any;
  10849. }
  10850. /**
  10851. * This defines an action responsible to start an animation once triggered.
  10852. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10853. */
  10854. export class PlayAnimationAction extends Action {
  10855. /**
  10856. * Where the animation should start (animation frame)
  10857. */
  10858. from: number;
  10859. /**
  10860. * Where the animation should stop (animation frame)
  10861. */
  10862. to: number;
  10863. /**
  10864. * Define if the animation should loop or stop after the first play.
  10865. */
  10866. loop?: boolean;
  10867. private _target;
  10868. /**
  10869. * Instantiate the action
  10870. * @param triggerOptions defines the trigger options
  10871. * @param target defines the target animation or animation name
  10872. * @param from defines from where the animation should start (animation frame)
  10873. * @param end defines where the animation should stop (animation frame)
  10874. * @param loop defines if the animation should loop or stop after the first play
  10875. * @param condition defines the trigger related conditions
  10876. */
  10877. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10878. /** @hidden */
  10879. _prepare(): void;
  10880. /**
  10881. * Execute the action and play the animation.
  10882. */
  10883. execute(): void;
  10884. /**
  10885. * Serializes the actions and its related information.
  10886. * @param parent defines the object to serialize in
  10887. * @returns the serialized object
  10888. */
  10889. serialize(parent: any): any;
  10890. }
  10891. /**
  10892. * This defines an action responsible to stop an animation once triggered.
  10893. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10894. */
  10895. export class StopAnimationAction extends Action {
  10896. private _target;
  10897. /**
  10898. * Instantiate the action
  10899. * @param triggerOptions defines the trigger options
  10900. * @param target defines the target animation or animation name
  10901. * @param condition defines the trigger related conditions
  10902. */
  10903. constructor(triggerOptions: any, target: any, condition?: Condition);
  10904. /** @hidden */
  10905. _prepare(): void;
  10906. /**
  10907. * Execute the action and stop the animation.
  10908. */
  10909. execute(): void;
  10910. /**
  10911. * Serializes the actions and its related information.
  10912. * @param parent defines the object to serialize in
  10913. * @returns the serialized object
  10914. */
  10915. serialize(parent: any): any;
  10916. }
  10917. /**
  10918. * This defines an action responsible that does nothing once triggered.
  10919. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10920. */
  10921. export class DoNothingAction extends Action {
  10922. /**
  10923. * Instantiate the action
  10924. * @param triggerOptions defines the trigger options
  10925. * @param condition defines the trigger related conditions
  10926. */
  10927. constructor(triggerOptions?: any, condition?: Condition);
  10928. /**
  10929. * Execute the action and do nothing.
  10930. */
  10931. execute(): void;
  10932. /**
  10933. * Serializes the actions and its related information.
  10934. * @param parent defines the object to serialize in
  10935. * @returns the serialized object
  10936. */
  10937. serialize(parent: any): any;
  10938. }
  10939. /**
  10940. * This defines an action responsible to trigger several actions once triggered.
  10941. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10942. */
  10943. export class CombineAction extends Action {
  10944. /**
  10945. * The list of aggregated animations to run.
  10946. */
  10947. children: Action[];
  10948. /**
  10949. * Instantiate the action
  10950. * @param triggerOptions defines the trigger options
  10951. * @param children defines the list of aggregated animations to run
  10952. * @param condition defines the trigger related conditions
  10953. */
  10954. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10955. /** @hidden */
  10956. _prepare(): void;
  10957. /**
  10958. * Execute the action and executes all the aggregated actions.
  10959. */
  10960. execute(evt: ActionEvent): void;
  10961. /**
  10962. * Serializes the actions and its related information.
  10963. * @param parent defines the object to serialize in
  10964. * @returns the serialized object
  10965. */
  10966. serialize(parent: any): any;
  10967. }
  10968. /**
  10969. * This defines an action responsible to run code (external event) once triggered.
  10970. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10971. */
  10972. export class ExecuteCodeAction extends Action {
  10973. /**
  10974. * The callback function to run.
  10975. */
  10976. func: (evt: ActionEvent) => void;
  10977. /**
  10978. * Instantiate the action
  10979. * @param triggerOptions defines the trigger options
  10980. * @param func defines the callback function to run
  10981. * @param condition defines the trigger related conditions
  10982. */
  10983. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10984. /**
  10985. * Execute the action and run the attached code.
  10986. */
  10987. execute(evt: ActionEvent): void;
  10988. }
  10989. /**
  10990. * This defines an action responsible to set the parent property of the target once triggered.
  10991. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10992. */
  10993. export class SetParentAction extends Action {
  10994. private _parent;
  10995. private _target;
  10996. /**
  10997. * Instantiate the action
  10998. * @param triggerOptions defines the trigger options
  10999. * @param target defines the target containing the parent property
  11000. * @param parent defines from where the animation should start (animation frame)
  11001. * @param condition defines the trigger related conditions
  11002. */
  11003. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  11004. /** @hidden */
  11005. _prepare(): void;
  11006. /**
  11007. * Execute the action and set the parent property.
  11008. */
  11009. execute(): void;
  11010. /**
  11011. * Serializes the actions and its related information.
  11012. * @param parent defines the object to serialize in
  11013. * @returns the serialized object
  11014. */
  11015. serialize(parent: any): any;
  11016. }
  11017. }
  11018. declare module BABYLON {
  11019. /**
  11020. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  11021. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  11022. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11023. */
  11024. export class ActionManager extends AbstractActionManager {
  11025. /**
  11026. * Nothing
  11027. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11028. */
  11029. static readonly NothingTrigger: number;
  11030. /**
  11031. * On pick
  11032. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11033. */
  11034. static readonly OnPickTrigger: number;
  11035. /**
  11036. * On left pick
  11037. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11038. */
  11039. static readonly OnLeftPickTrigger: number;
  11040. /**
  11041. * On right pick
  11042. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11043. */
  11044. static readonly OnRightPickTrigger: number;
  11045. /**
  11046. * On center pick
  11047. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11048. */
  11049. static readonly OnCenterPickTrigger: number;
  11050. /**
  11051. * On pick down
  11052. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11053. */
  11054. static readonly OnPickDownTrigger: number;
  11055. /**
  11056. * On double pick
  11057. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11058. */
  11059. static readonly OnDoublePickTrigger: number;
  11060. /**
  11061. * On pick up
  11062. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11063. */
  11064. static readonly OnPickUpTrigger: number;
  11065. /**
  11066. * On pick out.
  11067. * This trigger will only be raised if you also declared a OnPickDown
  11068. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11069. */
  11070. static readonly OnPickOutTrigger: number;
  11071. /**
  11072. * On long press
  11073. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11074. */
  11075. static readonly OnLongPressTrigger: number;
  11076. /**
  11077. * On pointer over
  11078. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11079. */
  11080. static readonly OnPointerOverTrigger: number;
  11081. /**
  11082. * On pointer out
  11083. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11084. */
  11085. static readonly OnPointerOutTrigger: number;
  11086. /**
  11087. * On every frame
  11088. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11089. */
  11090. static readonly OnEveryFrameTrigger: number;
  11091. /**
  11092. * On intersection enter
  11093. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11094. */
  11095. static readonly OnIntersectionEnterTrigger: number;
  11096. /**
  11097. * On intersection exit
  11098. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11099. */
  11100. static readonly OnIntersectionExitTrigger: number;
  11101. /**
  11102. * On key down
  11103. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11104. */
  11105. static readonly OnKeyDownTrigger: number;
  11106. /**
  11107. * On key up
  11108. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11109. */
  11110. static readonly OnKeyUpTrigger: number;
  11111. private _scene;
  11112. /**
  11113. * Creates a new action manager
  11114. * @param scene defines the hosting scene
  11115. */
  11116. constructor(scene: Scene);
  11117. /**
  11118. * Releases all associated resources
  11119. */
  11120. dispose(): void;
  11121. /**
  11122. * Gets hosting scene
  11123. * @returns the hosting scene
  11124. */
  11125. getScene(): Scene;
  11126. /**
  11127. * Does this action manager handles actions of any of the given triggers
  11128. * @param triggers defines the triggers to be tested
  11129. * @return a boolean indicating whether one (or more) of the triggers is handled
  11130. */
  11131. hasSpecificTriggers(triggers: number[]): boolean;
  11132. /**
  11133. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  11134. * speed.
  11135. * @param triggerA defines the trigger to be tested
  11136. * @param triggerB defines the trigger to be tested
  11137. * @return a boolean indicating whether one (or more) of the triggers is handled
  11138. */
  11139. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  11140. /**
  11141. * Does this action manager handles actions of a given trigger
  11142. * @param trigger defines the trigger to be tested
  11143. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  11144. * @return whether the trigger is handled
  11145. */
  11146. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  11147. /**
  11148. * Does this action manager has pointer triggers
  11149. */
  11150. get hasPointerTriggers(): boolean;
  11151. /**
  11152. * Does this action manager has pick triggers
  11153. */
  11154. get hasPickTriggers(): boolean;
  11155. /**
  11156. * Registers an action to this action manager
  11157. * @param action defines the action to be registered
  11158. * @return the action amended (prepared) after registration
  11159. */
  11160. registerAction(action: IAction): Nullable<IAction>;
  11161. /**
  11162. * Unregisters an action to this action manager
  11163. * @param action defines the action to be unregistered
  11164. * @return a boolean indicating whether the action has been unregistered
  11165. */
  11166. unregisterAction(action: IAction): Boolean;
  11167. /**
  11168. * Process a specific trigger
  11169. * @param trigger defines the trigger to process
  11170. * @param evt defines the event details to be processed
  11171. */
  11172. processTrigger(trigger: number, evt?: IActionEvent): void;
  11173. /** @hidden */
  11174. _getEffectiveTarget(target: any, propertyPath: string): any;
  11175. /** @hidden */
  11176. _getProperty(propertyPath: string): string;
  11177. /**
  11178. * Serialize this manager to a JSON object
  11179. * @param name defines the property name to store this manager
  11180. * @returns a JSON representation of this manager
  11181. */
  11182. serialize(name: string): any;
  11183. /**
  11184. * Creates a new ActionManager from a JSON data
  11185. * @param parsedActions defines the JSON data to read from
  11186. * @param object defines the hosting mesh
  11187. * @param scene defines the hosting scene
  11188. */
  11189. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  11190. /**
  11191. * Get a trigger name by index
  11192. * @param trigger defines the trigger index
  11193. * @returns a trigger name
  11194. */
  11195. static GetTriggerName(trigger: number): string;
  11196. }
  11197. }
  11198. declare module BABYLON {
  11199. /**
  11200. * Class representing a ray with position and direction
  11201. */
  11202. export class Ray {
  11203. /** origin point */
  11204. origin: Vector3;
  11205. /** direction */
  11206. direction: Vector3;
  11207. /** length of the ray */
  11208. length: number;
  11209. private static readonly TmpVector3;
  11210. private _tmpRay;
  11211. /**
  11212. * Creates a new ray
  11213. * @param origin origin point
  11214. * @param direction direction
  11215. * @param length length of the ray
  11216. */
  11217. constructor(
  11218. /** origin point */
  11219. origin: Vector3,
  11220. /** direction */
  11221. direction: Vector3,
  11222. /** length of the ray */
  11223. length?: number);
  11224. /**
  11225. * Checks if the ray intersects a box
  11226. * @param minimum bound of the box
  11227. * @param maximum bound of the box
  11228. * @param intersectionTreshold extra extend to be added to the box in all direction
  11229. * @returns if the box was hit
  11230. */
  11231. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  11232. /**
  11233. * Checks if the ray intersects a box
  11234. * @param box the bounding box to check
  11235. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  11236. * @returns if the box was hit
  11237. */
  11238. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  11239. /**
  11240. * If the ray hits a sphere
  11241. * @param sphere the bounding sphere to check
  11242. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  11243. * @returns true if it hits the sphere
  11244. */
  11245. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  11246. /**
  11247. * If the ray hits a triange
  11248. * @param vertex0 triangle vertex
  11249. * @param vertex1 triangle vertex
  11250. * @param vertex2 triangle vertex
  11251. * @returns intersection information if hit
  11252. */
  11253. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  11254. /**
  11255. * Checks if ray intersects a plane
  11256. * @param plane the plane to check
  11257. * @returns the distance away it was hit
  11258. */
  11259. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  11260. /**
  11261. * Calculate the intercept of a ray on a given axis
  11262. * @param axis to check 'x' | 'y' | 'z'
  11263. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  11264. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  11265. */
  11266. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  11267. /**
  11268. * Checks if ray intersects a mesh
  11269. * @param mesh the mesh to check
  11270. * @param fastCheck if only the bounding box should checked
  11271. * @returns picking info of the intersecton
  11272. */
  11273. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  11274. /**
  11275. * Checks if ray intersects a mesh
  11276. * @param meshes the meshes to check
  11277. * @param fastCheck if only the bounding box should checked
  11278. * @param results array to store result in
  11279. * @returns Array of picking infos
  11280. */
  11281. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  11282. private _comparePickingInfo;
  11283. private static smallnum;
  11284. private static rayl;
  11285. /**
  11286. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  11287. * @param sega the first point of the segment to test the intersection against
  11288. * @param segb the second point of the segment to test the intersection against
  11289. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  11290. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  11291. */
  11292. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  11293. /**
  11294. * Update the ray from viewport position
  11295. * @param x position
  11296. * @param y y position
  11297. * @param viewportWidth viewport width
  11298. * @param viewportHeight viewport height
  11299. * @param world world matrix
  11300. * @param view view matrix
  11301. * @param projection projection matrix
  11302. * @returns this ray updated
  11303. */
  11304. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11305. /**
  11306. * Creates a ray with origin and direction of 0,0,0
  11307. * @returns the new ray
  11308. */
  11309. static Zero(): Ray;
  11310. /**
  11311. * Creates a new ray from screen space and viewport
  11312. * @param x position
  11313. * @param y y position
  11314. * @param viewportWidth viewport width
  11315. * @param viewportHeight viewport height
  11316. * @param world world matrix
  11317. * @param view view matrix
  11318. * @param projection projection matrix
  11319. * @returns new ray
  11320. */
  11321. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11322. /**
  11323. * 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
  11324. * transformed to the given world matrix.
  11325. * @param origin The origin point
  11326. * @param end The end point
  11327. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11328. * @returns the new ray
  11329. */
  11330. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  11331. /**
  11332. * Transforms a ray by a matrix
  11333. * @param ray ray to transform
  11334. * @param matrix matrix to apply
  11335. * @returns the resulting new ray
  11336. */
  11337. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11338. /**
  11339. * Transforms a ray by a matrix
  11340. * @param ray ray to transform
  11341. * @param matrix matrix to apply
  11342. * @param result ray to store result in
  11343. */
  11344. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11345. /**
  11346. * Unproject a ray from screen space to object space
  11347. * @param sourceX defines the screen space x coordinate to use
  11348. * @param sourceY defines the screen space y coordinate to use
  11349. * @param viewportWidth defines the current width of the viewport
  11350. * @param viewportHeight defines the current height of the viewport
  11351. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11352. * @param view defines the view matrix to use
  11353. * @param projection defines the projection matrix to use
  11354. */
  11355. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11356. }
  11357. /**
  11358. * Type used to define predicate used to select faces when a mesh intersection is detected
  11359. */
  11360. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11361. interface Scene {
  11362. /** @hidden */
  11363. _tempPickingRay: Nullable<Ray>;
  11364. /** @hidden */
  11365. _cachedRayForTransform: Ray;
  11366. /** @hidden */
  11367. _pickWithRayInverseMatrix: Matrix;
  11368. /** @hidden */
  11369. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11370. /** @hidden */
  11371. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11372. }
  11373. }
  11374. declare module BABYLON {
  11375. /**
  11376. * Groups all the scene component constants in one place to ease maintenance.
  11377. * @hidden
  11378. */
  11379. export class SceneComponentConstants {
  11380. static readonly NAME_EFFECTLAYER: string;
  11381. static readonly NAME_LAYER: string;
  11382. static readonly NAME_LENSFLARESYSTEM: string;
  11383. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11384. static readonly NAME_PARTICLESYSTEM: string;
  11385. static readonly NAME_GAMEPAD: string;
  11386. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11387. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11388. static readonly NAME_DEPTHRENDERER: string;
  11389. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11390. static readonly NAME_SPRITE: string;
  11391. static readonly NAME_OUTLINERENDERER: string;
  11392. static readonly NAME_PROCEDURALTEXTURE: string;
  11393. static readonly NAME_SHADOWGENERATOR: string;
  11394. static readonly NAME_OCTREE: string;
  11395. static readonly NAME_PHYSICSENGINE: string;
  11396. static readonly NAME_AUDIO: string;
  11397. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11398. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11399. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11400. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11401. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11402. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11403. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11404. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11405. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11406. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11407. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11408. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11409. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11410. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11411. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11412. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11413. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11414. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11415. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11416. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11417. static readonly STEP_AFTERRENDER_AUDIO: number;
  11418. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11419. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11420. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11421. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11422. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11423. static readonly STEP_POINTERMOVE_SPRITE: number;
  11424. static readonly STEP_POINTERDOWN_SPRITE: number;
  11425. static readonly STEP_POINTERUP_SPRITE: number;
  11426. }
  11427. /**
  11428. * This represents a scene component.
  11429. *
  11430. * This is used to decouple the dependency the scene is having on the different workloads like
  11431. * layers, post processes...
  11432. */
  11433. export interface ISceneComponent {
  11434. /**
  11435. * The name of the component. Each component must have a unique name.
  11436. */
  11437. name: string;
  11438. /**
  11439. * The scene the component belongs to.
  11440. */
  11441. scene: Scene;
  11442. /**
  11443. * Register the component to one instance of a scene.
  11444. */
  11445. register(): void;
  11446. /**
  11447. * Rebuilds the elements related to this component in case of
  11448. * context lost for instance.
  11449. */
  11450. rebuild(): void;
  11451. /**
  11452. * Disposes the component and the associated ressources.
  11453. */
  11454. dispose(): void;
  11455. }
  11456. /**
  11457. * This represents a SERIALIZABLE scene component.
  11458. *
  11459. * This extends Scene Component to add Serialization methods on top.
  11460. */
  11461. export interface ISceneSerializableComponent extends ISceneComponent {
  11462. /**
  11463. * Adds all the elements from the container to the scene
  11464. * @param container the container holding the elements
  11465. */
  11466. addFromContainer(container: AbstractScene): void;
  11467. /**
  11468. * Removes all the elements in the container from the scene
  11469. * @param container contains the elements to remove
  11470. * @param dispose if the removed element should be disposed (default: false)
  11471. */
  11472. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11473. /**
  11474. * Serializes the component data to the specified json object
  11475. * @param serializationObject The object to serialize to
  11476. */
  11477. serialize(serializationObject: any): void;
  11478. }
  11479. /**
  11480. * Strong typing of a Mesh related stage step action
  11481. */
  11482. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11483. /**
  11484. * Strong typing of a Evaluate Sub Mesh related stage step action
  11485. */
  11486. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11487. /**
  11488. * Strong typing of a Active Mesh related stage step action
  11489. */
  11490. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11491. /**
  11492. * Strong typing of a Camera related stage step action
  11493. */
  11494. export type CameraStageAction = (camera: Camera) => void;
  11495. /**
  11496. * Strong typing of a Camera Frame buffer related stage step action
  11497. */
  11498. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11499. /**
  11500. * Strong typing of a Render Target related stage step action
  11501. */
  11502. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11503. /**
  11504. * Strong typing of a RenderingGroup related stage step action
  11505. */
  11506. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11507. /**
  11508. * Strong typing of a Mesh Render related stage step action
  11509. */
  11510. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11511. /**
  11512. * Strong typing of a simple stage step action
  11513. */
  11514. export type SimpleStageAction = () => void;
  11515. /**
  11516. * Strong typing of a render target action.
  11517. */
  11518. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11519. /**
  11520. * Strong typing of a pointer move action.
  11521. */
  11522. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  11523. /**
  11524. * Strong typing of a pointer up/down action.
  11525. */
  11526. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11527. /**
  11528. * Representation of a stage in the scene (Basically a list of ordered steps)
  11529. * @hidden
  11530. */
  11531. export class Stage<T extends Function> extends Array<{
  11532. index: number;
  11533. component: ISceneComponent;
  11534. action: T;
  11535. }> {
  11536. /**
  11537. * Hide ctor from the rest of the world.
  11538. * @param items The items to add.
  11539. */
  11540. private constructor();
  11541. /**
  11542. * Creates a new Stage.
  11543. * @returns A new instance of a Stage
  11544. */
  11545. static Create<T extends Function>(): Stage<T>;
  11546. /**
  11547. * Registers a step in an ordered way in the targeted stage.
  11548. * @param index Defines the position to register the step in
  11549. * @param component Defines the component attached to the step
  11550. * @param action Defines the action to launch during the step
  11551. */
  11552. registerStep(index: number, component: ISceneComponent, action: T): void;
  11553. /**
  11554. * Clears all the steps from the stage.
  11555. */
  11556. clear(): void;
  11557. }
  11558. }
  11559. declare module BABYLON {
  11560. interface Scene {
  11561. /** @hidden */
  11562. _pointerOverSprite: Nullable<Sprite>;
  11563. /** @hidden */
  11564. _pickedDownSprite: Nullable<Sprite>;
  11565. /** @hidden */
  11566. _tempSpritePickingRay: Nullable<Ray>;
  11567. /**
  11568. * All of the sprite managers added to this scene
  11569. * @see http://doc.babylonjs.com/babylon101/sprites
  11570. */
  11571. spriteManagers: Array<ISpriteManager>;
  11572. /**
  11573. * An event triggered when sprites rendering is about to start
  11574. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11575. */
  11576. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11577. /**
  11578. * An event triggered when sprites rendering is done
  11579. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11580. */
  11581. onAfterSpritesRenderingObservable: Observable<Scene>;
  11582. /** @hidden */
  11583. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11584. /** Launch a ray to try to pick a sprite in the scene
  11585. * @param x position on screen
  11586. * @param y position on screen
  11587. * @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
  11588. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11589. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11590. * @returns a PickingInfo
  11591. */
  11592. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11593. /** Use the given ray to pick a sprite in the scene
  11594. * @param ray The ray (in world space) to use to pick meshes
  11595. * @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
  11596. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11597. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11598. * @returns a PickingInfo
  11599. */
  11600. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11601. /** @hidden */
  11602. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11603. /** Launch a ray to try to pick sprites in the scene
  11604. * @param x position on screen
  11605. * @param y position on screen
  11606. * @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
  11607. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11608. * @returns a PickingInfo array
  11609. */
  11610. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11611. /** Use the given ray to pick sprites in the scene
  11612. * @param ray The ray (in world space) to use to pick meshes
  11613. * @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
  11614. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11615. * @returns a PickingInfo array
  11616. */
  11617. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11618. /**
  11619. * Force the sprite under the pointer
  11620. * @param sprite defines the sprite to use
  11621. */
  11622. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11623. /**
  11624. * Gets the sprite under the pointer
  11625. * @returns a Sprite or null if no sprite is under the pointer
  11626. */
  11627. getPointerOverSprite(): Nullable<Sprite>;
  11628. }
  11629. /**
  11630. * Defines the sprite scene component responsible to manage sprites
  11631. * in a given scene.
  11632. */
  11633. export class SpriteSceneComponent implements ISceneComponent {
  11634. /**
  11635. * The component name helpfull to identify the component in the list of scene components.
  11636. */
  11637. readonly name: string;
  11638. /**
  11639. * The scene the component belongs to.
  11640. */
  11641. scene: Scene;
  11642. /** @hidden */
  11643. private _spritePredicate;
  11644. /**
  11645. * Creates a new instance of the component for the given scene
  11646. * @param scene Defines the scene to register the component in
  11647. */
  11648. constructor(scene: Scene);
  11649. /**
  11650. * Registers the component in a given scene
  11651. */
  11652. register(): void;
  11653. /**
  11654. * Rebuilds the elements related to this component in case of
  11655. * context lost for instance.
  11656. */
  11657. rebuild(): void;
  11658. /**
  11659. * Disposes the component and the associated ressources.
  11660. */
  11661. dispose(): void;
  11662. private _pickSpriteButKeepRay;
  11663. private _pointerMove;
  11664. private _pointerDown;
  11665. private _pointerUp;
  11666. }
  11667. }
  11668. declare module BABYLON {
  11669. /** @hidden */
  11670. export var fogFragmentDeclaration: {
  11671. name: string;
  11672. shader: string;
  11673. };
  11674. }
  11675. declare module BABYLON {
  11676. /** @hidden */
  11677. export var fogFragment: {
  11678. name: string;
  11679. shader: string;
  11680. };
  11681. }
  11682. declare module BABYLON {
  11683. /** @hidden */
  11684. export var spritesPixelShader: {
  11685. name: string;
  11686. shader: string;
  11687. };
  11688. }
  11689. declare module BABYLON {
  11690. /** @hidden */
  11691. export var fogVertexDeclaration: {
  11692. name: string;
  11693. shader: string;
  11694. };
  11695. }
  11696. declare module BABYLON {
  11697. /** @hidden */
  11698. export var spritesVertexShader: {
  11699. name: string;
  11700. shader: string;
  11701. };
  11702. }
  11703. declare module BABYLON {
  11704. /**
  11705. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11706. */
  11707. export interface ISpriteManager extends IDisposable {
  11708. /**
  11709. * Restricts the camera to viewing objects with the same layerMask.
  11710. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11711. */
  11712. layerMask: number;
  11713. /**
  11714. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11715. */
  11716. isPickable: boolean;
  11717. /**
  11718. * Specifies the rendering group id for this mesh (0 by default)
  11719. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11720. */
  11721. renderingGroupId: number;
  11722. /**
  11723. * Defines the list of sprites managed by the manager.
  11724. */
  11725. sprites: Array<Sprite>;
  11726. /**
  11727. * Tests the intersection of a sprite with a specific ray.
  11728. * @param ray The ray we are sending to test the collision
  11729. * @param camera The camera space we are sending rays in
  11730. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11731. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11732. * @returns picking info or null.
  11733. */
  11734. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11735. /**
  11736. * Intersects the sprites with a ray
  11737. * @param ray defines the ray to intersect with
  11738. * @param camera defines the current active camera
  11739. * @param predicate defines a predicate used to select candidate sprites
  11740. * @returns null if no hit or a PickingInfo array
  11741. */
  11742. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11743. /**
  11744. * Renders the list of sprites on screen.
  11745. */
  11746. render(): void;
  11747. }
  11748. /**
  11749. * Class used to manage multiple sprites on the same spritesheet
  11750. * @see http://doc.babylonjs.com/babylon101/sprites
  11751. */
  11752. export class SpriteManager implements ISpriteManager {
  11753. /** defines the manager's name */
  11754. name: string;
  11755. /** Gets the list of sprites */
  11756. sprites: Sprite[];
  11757. /** Gets or sets the rendering group id (0 by default) */
  11758. renderingGroupId: number;
  11759. /** Gets or sets camera layer mask */
  11760. layerMask: number;
  11761. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11762. fogEnabled: boolean;
  11763. /** Gets or sets a boolean indicating if the sprites are pickable */
  11764. isPickable: boolean;
  11765. /** Defines the default width of a cell in the spritesheet */
  11766. cellWidth: number;
  11767. /** Defines the default height of a cell in the spritesheet */
  11768. cellHeight: number;
  11769. /** Associative array from JSON sprite data file */
  11770. private _cellData;
  11771. /** Array of sprite names from JSON sprite data file */
  11772. private _spriteMap;
  11773. /** True when packed cell data from JSON file is ready*/
  11774. private _packedAndReady;
  11775. /**
  11776. * An event triggered when the manager is disposed.
  11777. */
  11778. onDisposeObservable: Observable<SpriteManager>;
  11779. private _onDisposeObserver;
  11780. /**
  11781. * Callback called when the manager is disposed
  11782. */
  11783. set onDispose(callback: () => void);
  11784. private _capacity;
  11785. private _fromPacked;
  11786. private _spriteTexture;
  11787. private _epsilon;
  11788. private _scene;
  11789. private _vertexData;
  11790. private _buffer;
  11791. private _vertexBuffers;
  11792. private _indexBuffer;
  11793. private _effectBase;
  11794. private _effectFog;
  11795. /**
  11796. * Gets or sets the spritesheet texture
  11797. */
  11798. get texture(): Texture;
  11799. set texture(value: Texture);
  11800. /**
  11801. * Creates a new sprite manager
  11802. * @param name defines the manager's name
  11803. * @param imgUrl defines the sprite sheet url
  11804. * @param capacity defines the maximum allowed number of sprites
  11805. * @param cellSize defines the size of a sprite cell
  11806. * @param scene defines the hosting scene
  11807. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11808. * @param samplingMode defines the smapling mode to use with spritesheet
  11809. * @param fromPacked set to false; do not alter
  11810. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11811. */
  11812. constructor(
  11813. /** defines the manager's name */
  11814. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  11815. private _makePacked;
  11816. private _appendSpriteVertex;
  11817. /**
  11818. * Intersects the sprites with a ray
  11819. * @param ray defines the ray to intersect with
  11820. * @param camera defines the current active camera
  11821. * @param predicate defines a predicate used to select candidate sprites
  11822. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11823. * @returns null if no hit or a PickingInfo
  11824. */
  11825. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11826. /**
  11827. * Intersects the sprites with a ray
  11828. * @param ray defines the ray to intersect with
  11829. * @param camera defines the current active camera
  11830. * @param predicate defines a predicate used to select candidate sprites
  11831. * @returns null if no hit or a PickingInfo array
  11832. */
  11833. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11834. /**
  11835. * Render all child sprites
  11836. */
  11837. render(): void;
  11838. /**
  11839. * Release associated resources
  11840. */
  11841. dispose(): void;
  11842. }
  11843. }
  11844. declare module BABYLON {
  11845. /**
  11846. * Class used to represent a sprite
  11847. * @see http://doc.babylonjs.com/babylon101/sprites
  11848. */
  11849. export class Sprite {
  11850. /** defines the name */
  11851. name: string;
  11852. /** Gets or sets the current world position */
  11853. position: Vector3;
  11854. /** Gets or sets the main color */
  11855. color: Color4;
  11856. /** Gets or sets the width */
  11857. width: number;
  11858. /** Gets or sets the height */
  11859. height: number;
  11860. /** Gets or sets rotation angle */
  11861. angle: number;
  11862. /** Gets or sets the cell index in the sprite sheet */
  11863. cellIndex: number;
  11864. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  11865. cellRef: string;
  11866. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  11867. invertU: number;
  11868. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  11869. invertV: number;
  11870. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  11871. disposeWhenFinishedAnimating: boolean;
  11872. /** Gets the list of attached animations */
  11873. animations: Animation[];
  11874. /** Gets or sets a boolean indicating if the sprite can be picked */
  11875. isPickable: boolean;
  11876. /**
  11877. * Gets or sets the associated action manager
  11878. */
  11879. actionManager: Nullable<ActionManager>;
  11880. private _animationStarted;
  11881. private _loopAnimation;
  11882. private _fromIndex;
  11883. private _toIndex;
  11884. private _delay;
  11885. private _direction;
  11886. private _manager;
  11887. private _time;
  11888. private _onAnimationEnd;
  11889. /**
  11890. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  11891. */
  11892. isVisible: boolean;
  11893. /**
  11894. * Gets or sets the sprite size
  11895. */
  11896. get size(): number;
  11897. set size(value: number);
  11898. /**
  11899. * Creates a new Sprite
  11900. * @param name defines the name
  11901. * @param manager defines the manager
  11902. */
  11903. constructor(
  11904. /** defines the name */
  11905. name: string, manager: ISpriteManager);
  11906. /**
  11907. * Starts an animation
  11908. * @param from defines the initial key
  11909. * @param to defines the end key
  11910. * @param loop defines if the animation must loop
  11911. * @param delay defines the start delay (in ms)
  11912. * @param onAnimationEnd defines a callback to call when animation ends
  11913. */
  11914. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  11915. /** Stops current animation (if any) */
  11916. stopAnimation(): void;
  11917. /** @hidden */
  11918. _animate(deltaTime: number): void;
  11919. /** Release associated resources */
  11920. dispose(): void;
  11921. }
  11922. }
  11923. declare module BABYLON {
  11924. /**
  11925. * Information about the result of picking within a scene
  11926. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  11927. */
  11928. export class PickingInfo {
  11929. /** @hidden */
  11930. _pickingUnavailable: boolean;
  11931. /**
  11932. * If the pick collided with an object
  11933. */
  11934. hit: boolean;
  11935. /**
  11936. * Distance away where the pick collided
  11937. */
  11938. distance: number;
  11939. /**
  11940. * The location of pick collision
  11941. */
  11942. pickedPoint: Nullable<Vector3>;
  11943. /**
  11944. * The mesh corresponding the the pick collision
  11945. */
  11946. pickedMesh: Nullable<AbstractMesh>;
  11947. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  11948. bu: number;
  11949. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  11950. bv: number;
  11951. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  11952. faceId: number;
  11953. /** Id of the the submesh that was picked */
  11954. subMeshId: number;
  11955. /** If a sprite was picked, this will be the sprite the pick collided with */
  11956. pickedSprite: Nullable<Sprite>;
  11957. /**
  11958. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  11959. */
  11960. originMesh: Nullable<AbstractMesh>;
  11961. /**
  11962. * The ray that was used to perform the picking.
  11963. */
  11964. ray: Nullable<Ray>;
  11965. /**
  11966. * Gets the normal correspodning to the face the pick collided with
  11967. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  11968. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  11969. * @returns The normal correspodning to the face the pick collided with
  11970. */
  11971. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  11972. /**
  11973. * Gets the texture coordinates of where the pick occured
  11974. * @returns the vector containing the coordnates of the texture
  11975. */
  11976. getTextureCoordinates(): Nullable<Vector2>;
  11977. }
  11978. }
  11979. declare module BABYLON {
  11980. /**
  11981. * Gather the list of pointer event types as constants.
  11982. */
  11983. export class PointerEventTypes {
  11984. /**
  11985. * 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.
  11986. */
  11987. static readonly POINTERDOWN: number;
  11988. /**
  11989. * The pointerup event is fired when a pointer is no longer active.
  11990. */
  11991. static readonly POINTERUP: number;
  11992. /**
  11993. * The pointermove event is fired when a pointer changes coordinates.
  11994. */
  11995. static readonly POINTERMOVE: number;
  11996. /**
  11997. * The pointerwheel event is fired when a mouse wheel has been rotated.
  11998. */
  11999. static readonly POINTERWHEEL: number;
  12000. /**
  12001. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  12002. */
  12003. static readonly POINTERPICK: number;
  12004. /**
  12005. * The pointertap event is fired when a the object has been touched and released without drag.
  12006. */
  12007. static readonly POINTERTAP: number;
  12008. /**
  12009. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  12010. */
  12011. static readonly POINTERDOUBLETAP: number;
  12012. }
  12013. /**
  12014. * Base class of pointer info types.
  12015. */
  12016. export class PointerInfoBase {
  12017. /**
  12018. * Defines the type of event (PointerEventTypes)
  12019. */
  12020. type: number;
  12021. /**
  12022. * Defines the related dom event
  12023. */
  12024. event: PointerEvent | MouseWheelEvent;
  12025. /**
  12026. * Instantiates the base class of pointers info.
  12027. * @param type Defines the type of event (PointerEventTypes)
  12028. * @param event Defines the related dom event
  12029. */
  12030. constructor(
  12031. /**
  12032. * Defines the type of event (PointerEventTypes)
  12033. */
  12034. type: number,
  12035. /**
  12036. * Defines the related dom event
  12037. */
  12038. event: PointerEvent | MouseWheelEvent);
  12039. }
  12040. /**
  12041. * This class is used to store pointer related info for the onPrePointerObservable event.
  12042. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  12043. */
  12044. export class PointerInfoPre extends PointerInfoBase {
  12045. /**
  12046. * Ray from a pointer if availible (eg. 6dof controller)
  12047. */
  12048. ray: Nullable<Ray>;
  12049. /**
  12050. * Defines the local position of the pointer on the canvas.
  12051. */
  12052. localPosition: Vector2;
  12053. /**
  12054. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  12055. */
  12056. skipOnPointerObservable: boolean;
  12057. /**
  12058. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  12059. * @param type Defines the type of event (PointerEventTypes)
  12060. * @param event Defines the related dom event
  12061. * @param localX Defines the local x coordinates of the pointer when the event occured
  12062. * @param localY Defines the local y coordinates of the pointer when the event occured
  12063. */
  12064. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  12065. }
  12066. /**
  12067. * This type contains all the data related to a pointer event in Babylon.js.
  12068. * 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.
  12069. */
  12070. export class PointerInfo extends PointerInfoBase {
  12071. /**
  12072. * Defines the picking info associated to the info (if any)\
  12073. */
  12074. pickInfo: Nullable<PickingInfo>;
  12075. /**
  12076. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  12077. * @param type Defines the type of event (PointerEventTypes)
  12078. * @param event Defines the related dom event
  12079. * @param pickInfo Defines the picking info associated to the info (if any)\
  12080. */
  12081. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  12082. /**
  12083. * Defines the picking info associated to the info (if any)\
  12084. */
  12085. pickInfo: Nullable<PickingInfo>);
  12086. }
  12087. /**
  12088. * Data relating to a touch event on the screen.
  12089. */
  12090. export interface PointerTouch {
  12091. /**
  12092. * X coordinate of touch.
  12093. */
  12094. x: number;
  12095. /**
  12096. * Y coordinate of touch.
  12097. */
  12098. y: number;
  12099. /**
  12100. * Id of touch. Unique for each finger.
  12101. */
  12102. pointerId: number;
  12103. /**
  12104. * Event type passed from DOM.
  12105. */
  12106. type: any;
  12107. }
  12108. }
  12109. declare module BABYLON {
  12110. /**
  12111. * Manage the mouse inputs to control the movement of a free camera.
  12112. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12113. */
  12114. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  12115. /**
  12116. * Define if touch is enabled in the mouse input
  12117. */
  12118. touchEnabled: boolean;
  12119. /**
  12120. * Defines the camera the input is attached to.
  12121. */
  12122. camera: FreeCamera;
  12123. /**
  12124. * Defines the buttons associated with the input to handle camera move.
  12125. */
  12126. buttons: number[];
  12127. /**
  12128. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  12129. */
  12130. angularSensibility: number;
  12131. private _pointerInput;
  12132. private _onMouseMove;
  12133. private _observer;
  12134. private previousPosition;
  12135. /**
  12136. * Observable for when a pointer move event occurs containing the move offset
  12137. */
  12138. onPointerMovedObservable: Observable<{
  12139. offsetX: number;
  12140. offsetY: number;
  12141. }>;
  12142. /**
  12143. * @hidden
  12144. * If the camera should be rotated automatically based on pointer movement
  12145. */
  12146. _allowCameraRotation: boolean;
  12147. /**
  12148. * Manage the mouse inputs to control the movement of a free camera.
  12149. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12150. * @param touchEnabled Defines if touch is enabled or not
  12151. */
  12152. constructor(
  12153. /**
  12154. * Define if touch is enabled in the mouse input
  12155. */
  12156. touchEnabled?: boolean);
  12157. /**
  12158. * Attach the input controls to a specific dom element to get the input from.
  12159. * @param element Defines the element the controls should be listened from
  12160. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12161. */
  12162. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12163. /**
  12164. * Called on JS contextmenu event.
  12165. * Override this method to provide functionality.
  12166. */
  12167. protected onContextMenu(evt: PointerEvent): void;
  12168. /**
  12169. * Detach the current controls from the specified dom element.
  12170. * @param element Defines the element to stop listening the inputs from
  12171. */
  12172. detachControl(element: Nullable<HTMLElement>): void;
  12173. /**
  12174. * Gets the class name of the current intput.
  12175. * @returns the class name
  12176. */
  12177. getClassName(): string;
  12178. /**
  12179. * Get the friendly name associated with the input class.
  12180. * @returns the input friendly name
  12181. */
  12182. getSimpleName(): string;
  12183. }
  12184. }
  12185. declare module BABYLON {
  12186. /**
  12187. * Manage the touch inputs to control the movement of a free camera.
  12188. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12189. */
  12190. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  12191. /**
  12192. * Defines the camera the input is attached to.
  12193. */
  12194. camera: FreeCamera;
  12195. /**
  12196. * Defines the touch sensibility for rotation.
  12197. * The higher the faster.
  12198. */
  12199. touchAngularSensibility: number;
  12200. /**
  12201. * Defines the touch sensibility for move.
  12202. * The higher the faster.
  12203. */
  12204. touchMoveSensibility: number;
  12205. private _offsetX;
  12206. private _offsetY;
  12207. private _pointerPressed;
  12208. private _pointerInput;
  12209. private _observer;
  12210. private _onLostFocus;
  12211. /**
  12212. * Attach the input controls to a specific dom element to get the input from.
  12213. * @param element Defines the element the controls should be listened from
  12214. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12215. */
  12216. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12217. /**
  12218. * Detach the current controls from the specified dom element.
  12219. * @param element Defines the element to stop listening the inputs from
  12220. */
  12221. detachControl(element: Nullable<HTMLElement>): void;
  12222. /**
  12223. * Update the current camera state depending on the inputs that have been used this frame.
  12224. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12225. */
  12226. checkInputs(): void;
  12227. /**
  12228. * Gets the class name of the current intput.
  12229. * @returns the class name
  12230. */
  12231. getClassName(): string;
  12232. /**
  12233. * Get the friendly name associated with the input class.
  12234. * @returns the input friendly name
  12235. */
  12236. getSimpleName(): string;
  12237. }
  12238. }
  12239. declare module BABYLON {
  12240. /**
  12241. * Default Inputs manager for the FreeCamera.
  12242. * It groups all the default supported inputs for ease of use.
  12243. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12244. */
  12245. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  12246. /**
  12247. * @hidden
  12248. */
  12249. _mouseInput: Nullable<FreeCameraMouseInput>;
  12250. /**
  12251. * Instantiates a new FreeCameraInputsManager.
  12252. * @param camera Defines the camera the inputs belong to
  12253. */
  12254. constructor(camera: FreeCamera);
  12255. /**
  12256. * Add keyboard input support to the input manager.
  12257. * @returns the current input manager
  12258. */
  12259. addKeyboard(): FreeCameraInputsManager;
  12260. /**
  12261. * Add mouse input support to the input manager.
  12262. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  12263. * @returns the current input manager
  12264. */
  12265. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  12266. /**
  12267. * Removes the mouse input support from the manager
  12268. * @returns the current input manager
  12269. */
  12270. removeMouse(): FreeCameraInputsManager;
  12271. /**
  12272. * Add touch input support to the input manager.
  12273. * @returns the current input manager
  12274. */
  12275. addTouch(): FreeCameraInputsManager;
  12276. /**
  12277. * Remove all attached input methods from a camera
  12278. */
  12279. clear(): void;
  12280. }
  12281. }
  12282. declare module BABYLON {
  12283. /**
  12284. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12285. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  12286. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12287. */
  12288. export class FreeCamera extends TargetCamera {
  12289. /**
  12290. * Define the collision ellipsoid of the camera.
  12291. * This is helpful to simulate a camera body like the player body around the camera
  12292. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  12293. */
  12294. ellipsoid: Vector3;
  12295. /**
  12296. * Define an offset for the position of the ellipsoid around the camera.
  12297. * This can be helpful to determine the center of the body near the gravity center of the body
  12298. * instead of its head.
  12299. */
  12300. ellipsoidOffset: Vector3;
  12301. /**
  12302. * Enable or disable collisions of the camera with the rest of the scene objects.
  12303. */
  12304. checkCollisions: boolean;
  12305. /**
  12306. * Enable or disable gravity on the camera.
  12307. */
  12308. applyGravity: boolean;
  12309. /**
  12310. * Define the input manager associated to the camera.
  12311. */
  12312. inputs: FreeCameraInputsManager;
  12313. /**
  12314. * Gets the input sensibility for a mouse input. (default is 2000.0)
  12315. * Higher values reduce sensitivity.
  12316. */
  12317. get angularSensibility(): number;
  12318. /**
  12319. * Sets the input sensibility for a mouse input. (default is 2000.0)
  12320. * Higher values reduce sensitivity.
  12321. */
  12322. set angularSensibility(value: number);
  12323. /**
  12324. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  12325. */
  12326. get keysUp(): number[];
  12327. set keysUp(value: number[]);
  12328. /**
  12329. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  12330. */
  12331. get keysDown(): number[];
  12332. set keysDown(value: number[]);
  12333. /**
  12334. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  12335. */
  12336. get keysLeft(): number[];
  12337. set keysLeft(value: number[]);
  12338. /**
  12339. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  12340. */
  12341. get keysRight(): number[];
  12342. set keysRight(value: number[]);
  12343. /**
  12344. * Event raised when the camera collide with a mesh in the scene.
  12345. */
  12346. onCollide: (collidedMesh: AbstractMesh) => void;
  12347. private _collider;
  12348. private _needMoveForGravity;
  12349. private _oldPosition;
  12350. private _diffPosition;
  12351. private _newPosition;
  12352. /** @hidden */
  12353. _localDirection: Vector3;
  12354. /** @hidden */
  12355. _transformedDirection: Vector3;
  12356. /**
  12357. * Instantiates a Free Camera.
  12358. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12359. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  12360. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12361. * @param name Define the name of the camera in the scene
  12362. * @param position Define the start position of the camera in the scene
  12363. * @param scene Define the scene the camera belongs to
  12364. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  12365. */
  12366. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  12367. /**
  12368. * Attached controls to the current camera.
  12369. * @param element Defines the element the controls should be listened from
  12370. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12371. */
  12372. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12373. /**
  12374. * Detach the current controls from the camera.
  12375. * The camera will stop reacting to inputs.
  12376. * @param element Defines the element to stop listening the inputs from
  12377. */
  12378. detachControl(element: HTMLElement): void;
  12379. private _collisionMask;
  12380. /**
  12381. * Define a collision mask to limit the list of object the camera can collide with
  12382. */
  12383. get collisionMask(): number;
  12384. set collisionMask(mask: number);
  12385. /** @hidden */
  12386. _collideWithWorld(displacement: Vector3): void;
  12387. private _onCollisionPositionChange;
  12388. /** @hidden */
  12389. _checkInputs(): void;
  12390. /** @hidden */
  12391. _decideIfNeedsToMove(): boolean;
  12392. /** @hidden */
  12393. _updatePosition(): void;
  12394. /**
  12395. * Destroy the camera and release the current resources hold by it.
  12396. */
  12397. dispose(): void;
  12398. /**
  12399. * Gets the current object class name.
  12400. * @return the class name
  12401. */
  12402. getClassName(): string;
  12403. }
  12404. }
  12405. declare module BABYLON {
  12406. /**
  12407. * Represents a gamepad control stick position
  12408. */
  12409. export class StickValues {
  12410. /**
  12411. * The x component of the control stick
  12412. */
  12413. x: number;
  12414. /**
  12415. * The y component of the control stick
  12416. */
  12417. y: number;
  12418. /**
  12419. * Initializes the gamepad x and y control stick values
  12420. * @param x The x component of the gamepad control stick value
  12421. * @param y The y component of the gamepad control stick value
  12422. */
  12423. constructor(
  12424. /**
  12425. * The x component of the control stick
  12426. */
  12427. x: number,
  12428. /**
  12429. * The y component of the control stick
  12430. */
  12431. y: number);
  12432. }
  12433. /**
  12434. * An interface which manages callbacks for gamepad button changes
  12435. */
  12436. export interface GamepadButtonChanges {
  12437. /**
  12438. * Called when a gamepad has been changed
  12439. */
  12440. changed: boolean;
  12441. /**
  12442. * Called when a gamepad press event has been triggered
  12443. */
  12444. pressChanged: boolean;
  12445. /**
  12446. * Called when a touch event has been triggered
  12447. */
  12448. touchChanged: boolean;
  12449. /**
  12450. * Called when a value has changed
  12451. */
  12452. valueChanged: boolean;
  12453. }
  12454. /**
  12455. * Represents a gamepad
  12456. */
  12457. export class Gamepad {
  12458. /**
  12459. * The id of the gamepad
  12460. */
  12461. id: string;
  12462. /**
  12463. * The index of the gamepad
  12464. */
  12465. index: number;
  12466. /**
  12467. * The browser gamepad
  12468. */
  12469. browserGamepad: any;
  12470. /**
  12471. * Specifies what type of gamepad this represents
  12472. */
  12473. type: number;
  12474. private _leftStick;
  12475. private _rightStick;
  12476. /** @hidden */
  12477. _isConnected: boolean;
  12478. private _leftStickAxisX;
  12479. private _leftStickAxisY;
  12480. private _rightStickAxisX;
  12481. private _rightStickAxisY;
  12482. /**
  12483. * Triggered when the left control stick has been changed
  12484. */
  12485. private _onleftstickchanged;
  12486. /**
  12487. * Triggered when the right control stick has been changed
  12488. */
  12489. private _onrightstickchanged;
  12490. /**
  12491. * Represents a gamepad controller
  12492. */
  12493. static GAMEPAD: number;
  12494. /**
  12495. * Represents a generic controller
  12496. */
  12497. static GENERIC: number;
  12498. /**
  12499. * Represents an XBox controller
  12500. */
  12501. static XBOX: number;
  12502. /**
  12503. * Represents a pose-enabled controller
  12504. */
  12505. static POSE_ENABLED: number;
  12506. /**
  12507. * Represents an Dual Shock controller
  12508. */
  12509. static DUALSHOCK: number;
  12510. /**
  12511. * Specifies whether the left control stick should be Y-inverted
  12512. */
  12513. protected _invertLeftStickY: boolean;
  12514. /**
  12515. * Specifies if the gamepad has been connected
  12516. */
  12517. get isConnected(): boolean;
  12518. /**
  12519. * Initializes the gamepad
  12520. * @param id The id of the gamepad
  12521. * @param index The index of the gamepad
  12522. * @param browserGamepad The browser gamepad
  12523. * @param leftStickX The x component of the left joystick
  12524. * @param leftStickY The y component of the left joystick
  12525. * @param rightStickX The x component of the right joystick
  12526. * @param rightStickY The y component of the right joystick
  12527. */
  12528. constructor(
  12529. /**
  12530. * The id of the gamepad
  12531. */
  12532. id: string,
  12533. /**
  12534. * The index of the gamepad
  12535. */
  12536. index: number,
  12537. /**
  12538. * The browser gamepad
  12539. */
  12540. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12541. /**
  12542. * Callback triggered when the left joystick has changed
  12543. * @param callback
  12544. */
  12545. onleftstickchanged(callback: (values: StickValues) => void): void;
  12546. /**
  12547. * Callback triggered when the right joystick has changed
  12548. * @param callback
  12549. */
  12550. onrightstickchanged(callback: (values: StickValues) => void): void;
  12551. /**
  12552. * Gets the left joystick
  12553. */
  12554. get leftStick(): StickValues;
  12555. /**
  12556. * Sets the left joystick values
  12557. */
  12558. set leftStick(newValues: StickValues);
  12559. /**
  12560. * Gets the right joystick
  12561. */
  12562. get rightStick(): StickValues;
  12563. /**
  12564. * Sets the right joystick value
  12565. */
  12566. set rightStick(newValues: StickValues);
  12567. /**
  12568. * Updates the gamepad joystick positions
  12569. */
  12570. update(): void;
  12571. /**
  12572. * Disposes the gamepad
  12573. */
  12574. dispose(): void;
  12575. }
  12576. /**
  12577. * Represents a generic gamepad
  12578. */
  12579. export class GenericPad extends Gamepad {
  12580. private _buttons;
  12581. private _onbuttondown;
  12582. private _onbuttonup;
  12583. /**
  12584. * Observable triggered when a button has been pressed
  12585. */
  12586. onButtonDownObservable: Observable<number>;
  12587. /**
  12588. * Observable triggered when a button has been released
  12589. */
  12590. onButtonUpObservable: Observable<number>;
  12591. /**
  12592. * Callback triggered when a button has been pressed
  12593. * @param callback Called when a button has been pressed
  12594. */
  12595. onbuttondown(callback: (buttonPressed: number) => void): void;
  12596. /**
  12597. * Callback triggered when a button has been released
  12598. * @param callback Called when a button has been released
  12599. */
  12600. onbuttonup(callback: (buttonReleased: number) => void): void;
  12601. /**
  12602. * Initializes the generic gamepad
  12603. * @param id The id of the generic gamepad
  12604. * @param index The index of the generic gamepad
  12605. * @param browserGamepad The browser gamepad
  12606. */
  12607. constructor(id: string, index: number, browserGamepad: any);
  12608. private _setButtonValue;
  12609. /**
  12610. * Updates the generic gamepad
  12611. */
  12612. update(): void;
  12613. /**
  12614. * Disposes the generic gamepad
  12615. */
  12616. dispose(): void;
  12617. }
  12618. }
  12619. declare module BABYLON {
  12620. interface Engine {
  12621. /**
  12622. * Creates a raw texture
  12623. * @param data defines the data to store in the texture
  12624. * @param width defines the width of the texture
  12625. * @param height defines the height of the texture
  12626. * @param format defines the format of the data
  12627. * @param generateMipMaps defines if the engine should generate the mip levels
  12628. * @param invertY defines if data must be stored with Y axis inverted
  12629. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  12630. * @param compression defines the compression used (null by default)
  12631. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12632. * @returns the raw texture inside an InternalTexture
  12633. */
  12634. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  12635. /**
  12636. * Update a raw texture
  12637. * @param texture defines the texture to update
  12638. * @param data defines the data to store in the texture
  12639. * @param format defines the format of the data
  12640. * @param invertY defines if data must be stored with Y axis inverted
  12641. */
  12642. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12643. /**
  12644. * Update a raw texture
  12645. * @param texture defines the texture to update
  12646. * @param data defines the data to store in the texture
  12647. * @param format defines the format of the data
  12648. * @param invertY defines if data must be stored with Y axis inverted
  12649. * @param compression defines the compression used (null by default)
  12650. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12651. */
  12652. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  12653. /**
  12654. * Creates a new raw cube texture
  12655. * @param data defines the array of data to use to create each face
  12656. * @param size defines the size of the textures
  12657. * @param format defines the format of the data
  12658. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12659. * @param generateMipMaps defines if the engine should generate the mip levels
  12660. * @param invertY defines if data must be stored with Y axis inverted
  12661. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12662. * @param compression defines the compression used (null by default)
  12663. * @returns the cube texture as an InternalTexture
  12664. */
  12665. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  12666. /**
  12667. * Update a raw cube texture
  12668. * @param texture defines the texture to udpdate
  12669. * @param data defines the data to store
  12670. * @param format defines the data format
  12671. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12672. * @param invertY defines if data must be stored with Y axis inverted
  12673. */
  12674. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  12675. /**
  12676. * Update a raw cube texture
  12677. * @param texture defines the texture to udpdate
  12678. * @param data defines the data to store
  12679. * @param format defines the data format
  12680. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12681. * @param invertY defines if data must be stored with Y axis inverted
  12682. * @param compression defines the compression used (null by default)
  12683. */
  12684. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  12685. /**
  12686. * Update a raw cube texture
  12687. * @param texture defines the texture to udpdate
  12688. * @param data defines the data to store
  12689. * @param format defines the data format
  12690. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12691. * @param invertY defines if data must be stored with Y axis inverted
  12692. * @param compression defines the compression used (null by default)
  12693. * @param level defines which level of the texture to update
  12694. */
  12695. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  12696. /**
  12697. * Creates a new raw cube texture from a specified url
  12698. * @param url defines the url where the data is located
  12699. * @param scene defines the current scene
  12700. * @param size defines the size of the textures
  12701. * @param format defines the format of the data
  12702. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12703. * @param noMipmap defines if the engine should avoid generating the mip levels
  12704. * @param callback defines a callback used to extract texture data from loaded data
  12705. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12706. * @param onLoad defines a callback called when texture is loaded
  12707. * @param onError defines a callback called if there is an error
  12708. * @returns the cube texture as an InternalTexture
  12709. */
  12710. 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;
  12711. /**
  12712. * Creates a new raw cube texture from a specified url
  12713. * @param url defines the url where the data is located
  12714. * @param scene defines the current scene
  12715. * @param size defines the size of the textures
  12716. * @param format defines the format of the data
  12717. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12718. * @param noMipmap defines if the engine should avoid generating the mip levels
  12719. * @param callback defines a callback used to extract texture data from loaded data
  12720. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12721. * @param onLoad defines a callback called when texture is loaded
  12722. * @param onError defines a callback called if there is an error
  12723. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12724. * @param invertY defines if data must be stored with Y axis inverted
  12725. * @returns the cube texture as an InternalTexture
  12726. */
  12727. 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;
  12728. /**
  12729. * Creates a new raw 3D texture
  12730. * @param data defines the data used to create the texture
  12731. * @param width defines the width of the texture
  12732. * @param height defines the height of the texture
  12733. * @param depth defines the depth of the texture
  12734. * @param format defines the format of the texture
  12735. * @param generateMipMaps defines if the engine must generate mip levels
  12736. * @param invertY defines if data must be stored with Y axis inverted
  12737. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12738. * @param compression defines the compressed used (can be null)
  12739. * @param textureType defines the compressed used (can be null)
  12740. * @returns a new raw 3D texture (stored in an InternalTexture)
  12741. */
  12742. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  12743. /**
  12744. * Update a raw 3D texture
  12745. * @param texture defines the texture to update
  12746. * @param data defines the data to store
  12747. * @param format defines the data format
  12748. * @param invertY defines if data must be stored with Y axis inverted
  12749. */
  12750. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12751. /**
  12752. * Update a raw 3D texture
  12753. * @param texture defines the texture to update
  12754. * @param data defines the data to store
  12755. * @param format defines the data format
  12756. * @param invertY defines if data must be stored with Y axis inverted
  12757. * @param compression defines the used compression (can be null)
  12758. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  12759. */
  12760. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  12761. /**
  12762. * Creates a new raw 2D array texture
  12763. * @param data defines the data used to create the texture
  12764. * @param width defines the width of the texture
  12765. * @param height defines the height of the texture
  12766. * @param depth defines the number of layers of the texture
  12767. * @param format defines the format of the texture
  12768. * @param generateMipMaps defines if the engine must generate mip levels
  12769. * @param invertY defines if data must be stored with Y axis inverted
  12770. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12771. * @param compression defines the compressed used (can be null)
  12772. * @param textureType defines the compressed used (can be null)
  12773. * @returns a new raw 2D array texture (stored in an InternalTexture)
  12774. */
  12775. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  12776. /**
  12777. * Update a raw 2D array texture
  12778. * @param texture defines the texture to update
  12779. * @param data defines the data to store
  12780. * @param format defines the data format
  12781. * @param invertY defines if data must be stored with Y axis inverted
  12782. */
  12783. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12784. /**
  12785. * Update a raw 2D array texture
  12786. * @param texture defines the texture to update
  12787. * @param data defines the data to store
  12788. * @param format defines the data format
  12789. * @param invertY defines if data must be stored with Y axis inverted
  12790. * @param compression defines the used compression (can be null)
  12791. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  12792. */
  12793. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  12794. }
  12795. }
  12796. declare module BABYLON {
  12797. /**
  12798. * Raw texture can help creating a texture directly from an array of data.
  12799. * This can be super useful if you either get the data from an uncompressed source or
  12800. * if you wish to create your texture pixel by pixel.
  12801. */
  12802. export class RawTexture extends Texture {
  12803. /**
  12804. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12805. */
  12806. format: number;
  12807. private _engine;
  12808. /**
  12809. * Instantiates a new RawTexture.
  12810. * Raw texture can help creating a texture directly from an array of data.
  12811. * This can be super useful if you either get the data from an uncompressed source or
  12812. * if you wish to create your texture pixel by pixel.
  12813. * @param data define the array of data to use to create the texture
  12814. * @param width define the width of the texture
  12815. * @param height define the height of the texture
  12816. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12817. * @param scene define the scene the texture belongs to
  12818. * @param generateMipMaps define whether mip maps should be generated or not
  12819. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12820. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12821. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12822. */
  12823. constructor(data: ArrayBufferView, width: number, height: number,
  12824. /**
  12825. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12826. */
  12827. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  12828. /**
  12829. * Updates the texture underlying data.
  12830. * @param data Define the new data of the texture
  12831. */
  12832. update(data: ArrayBufferView): void;
  12833. /**
  12834. * Creates a luminance texture from some data.
  12835. * @param data Define the texture data
  12836. * @param width Define the width of the texture
  12837. * @param height Define the height of the texture
  12838. * @param scene Define the scene the texture belongs to
  12839. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12840. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12841. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12842. * @returns the luminance texture
  12843. */
  12844. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12845. /**
  12846. * Creates a luminance alpha texture from some data.
  12847. * @param data Define the texture data
  12848. * @param width Define the width of the texture
  12849. * @param height Define the height of the texture
  12850. * @param scene Define the scene the texture belongs to
  12851. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12852. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12853. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12854. * @returns the luminance alpha texture
  12855. */
  12856. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12857. /**
  12858. * Creates an alpha texture from some data.
  12859. * @param data Define the texture data
  12860. * @param width Define the width of the texture
  12861. * @param height Define the height of the texture
  12862. * @param scene Define the scene the texture belongs to
  12863. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12864. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12865. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12866. * @returns the alpha texture
  12867. */
  12868. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12869. /**
  12870. * Creates a RGB texture from some data.
  12871. * @param data Define the texture data
  12872. * @param width Define the width of the texture
  12873. * @param height Define the height of the texture
  12874. * @param scene Define the scene the texture belongs to
  12875. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12876. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12877. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12878. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12879. * @returns the RGB alpha texture
  12880. */
  12881. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12882. /**
  12883. * Creates a RGBA texture from some data.
  12884. * @param data Define the texture data
  12885. * @param width Define the width of the texture
  12886. * @param height Define the height of the texture
  12887. * @param scene Define the scene the texture belongs to
  12888. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12889. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12890. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12891. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12892. * @returns the RGBA texture
  12893. */
  12894. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12895. /**
  12896. * Creates a R texture from some data.
  12897. * @param data Define the texture data
  12898. * @param width Define the width of the texture
  12899. * @param height Define the height of the texture
  12900. * @param scene Define the scene the texture belongs to
  12901. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12902. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12903. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12904. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12905. * @returns the R texture
  12906. */
  12907. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12908. }
  12909. }
  12910. declare module BABYLON {
  12911. /**
  12912. * Interface for the size containing width and height
  12913. */
  12914. export interface ISize {
  12915. /**
  12916. * Width
  12917. */
  12918. width: number;
  12919. /**
  12920. * Heighht
  12921. */
  12922. height: number;
  12923. }
  12924. /**
  12925. * Size containing widht and height
  12926. */
  12927. export class Size implements ISize {
  12928. /**
  12929. * Width
  12930. */
  12931. width: number;
  12932. /**
  12933. * Height
  12934. */
  12935. height: number;
  12936. /**
  12937. * Creates a Size object from the given width and height (floats).
  12938. * @param width width of the new size
  12939. * @param height height of the new size
  12940. */
  12941. constructor(width: number, height: number);
  12942. /**
  12943. * Returns a string with the Size width and height
  12944. * @returns a string with the Size width and height
  12945. */
  12946. toString(): string;
  12947. /**
  12948. * "Size"
  12949. * @returns the string "Size"
  12950. */
  12951. getClassName(): string;
  12952. /**
  12953. * Returns the Size hash code.
  12954. * @returns a hash code for a unique width and height
  12955. */
  12956. getHashCode(): number;
  12957. /**
  12958. * Updates the current size from the given one.
  12959. * @param src the given size
  12960. */
  12961. copyFrom(src: Size): void;
  12962. /**
  12963. * Updates in place the current Size from the given floats.
  12964. * @param width width of the new size
  12965. * @param height height of the new size
  12966. * @returns the updated Size.
  12967. */
  12968. copyFromFloats(width: number, height: number): Size;
  12969. /**
  12970. * Updates in place the current Size from the given floats.
  12971. * @param width width to set
  12972. * @param height height to set
  12973. * @returns the updated Size.
  12974. */
  12975. set(width: number, height: number): Size;
  12976. /**
  12977. * Multiplies the width and height by numbers
  12978. * @param w factor to multiple the width by
  12979. * @param h factor to multiple the height by
  12980. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  12981. */
  12982. multiplyByFloats(w: number, h: number): Size;
  12983. /**
  12984. * Clones the size
  12985. * @returns a new Size copied from the given one.
  12986. */
  12987. clone(): Size;
  12988. /**
  12989. * True if the current Size and the given one width and height are strictly equal.
  12990. * @param other the other size to compare against
  12991. * @returns True if the current Size and the given one width and height are strictly equal.
  12992. */
  12993. equals(other: Size): boolean;
  12994. /**
  12995. * The surface of the Size : width * height (float).
  12996. */
  12997. get surface(): number;
  12998. /**
  12999. * Create a new size of zero
  13000. * @returns a new Size set to (0.0, 0.0)
  13001. */
  13002. static Zero(): Size;
  13003. /**
  13004. * Sums the width and height of two sizes
  13005. * @param otherSize size to add to this size
  13006. * @returns a new Size set as the addition result of the current Size and the given one.
  13007. */
  13008. add(otherSize: Size): Size;
  13009. /**
  13010. * Subtracts the width and height of two
  13011. * @param otherSize size to subtract to this size
  13012. * @returns a new Size set as the subtraction result of the given one from the current Size.
  13013. */
  13014. subtract(otherSize: Size): Size;
  13015. /**
  13016. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  13017. * @param start starting size to lerp between
  13018. * @param end end size to lerp between
  13019. * @param amount amount to lerp between the start and end values
  13020. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  13021. */
  13022. static Lerp(start: Size, end: Size, amount: number): Size;
  13023. }
  13024. }
  13025. declare module BABYLON {
  13026. /**
  13027. * Defines a runtime animation
  13028. */
  13029. export class RuntimeAnimation {
  13030. private _events;
  13031. /**
  13032. * The current frame of the runtime animation
  13033. */
  13034. private _currentFrame;
  13035. /**
  13036. * The animation used by the runtime animation
  13037. */
  13038. private _animation;
  13039. /**
  13040. * The target of the runtime animation
  13041. */
  13042. private _target;
  13043. /**
  13044. * The initiating animatable
  13045. */
  13046. private _host;
  13047. /**
  13048. * The original value of the runtime animation
  13049. */
  13050. private _originalValue;
  13051. /**
  13052. * The original blend value of the runtime animation
  13053. */
  13054. private _originalBlendValue;
  13055. /**
  13056. * The offsets cache of the runtime animation
  13057. */
  13058. private _offsetsCache;
  13059. /**
  13060. * The high limits cache of the runtime animation
  13061. */
  13062. private _highLimitsCache;
  13063. /**
  13064. * Specifies if the runtime animation has been stopped
  13065. */
  13066. private _stopped;
  13067. /**
  13068. * The blending factor of the runtime animation
  13069. */
  13070. private _blendingFactor;
  13071. /**
  13072. * The BabylonJS scene
  13073. */
  13074. private _scene;
  13075. /**
  13076. * The current value of the runtime animation
  13077. */
  13078. private _currentValue;
  13079. /** @hidden */
  13080. _animationState: _IAnimationState;
  13081. /**
  13082. * The active target of the runtime animation
  13083. */
  13084. private _activeTargets;
  13085. private _currentActiveTarget;
  13086. private _directTarget;
  13087. /**
  13088. * The target path of the runtime animation
  13089. */
  13090. private _targetPath;
  13091. /**
  13092. * The weight of the runtime animation
  13093. */
  13094. private _weight;
  13095. /**
  13096. * The ratio offset of the runtime animation
  13097. */
  13098. private _ratioOffset;
  13099. /**
  13100. * The previous delay of the runtime animation
  13101. */
  13102. private _previousDelay;
  13103. /**
  13104. * The previous ratio of the runtime animation
  13105. */
  13106. private _previousRatio;
  13107. private _enableBlending;
  13108. private _keys;
  13109. private _minFrame;
  13110. private _maxFrame;
  13111. private _minValue;
  13112. private _maxValue;
  13113. private _targetIsArray;
  13114. /**
  13115. * Gets the current frame of the runtime animation
  13116. */
  13117. get currentFrame(): number;
  13118. /**
  13119. * Gets the weight of the runtime animation
  13120. */
  13121. get weight(): number;
  13122. /**
  13123. * Gets the current value of the runtime animation
  13124. */
  13125. get currentValue(): any;
  13126. /**
  13127. * Gets the target path of the runtime animation
  13128. */
  13129. get targetPath(): string;
  13130. /**
  13131. * Gets the actual target of the runtime animation
  13132. */
  13133. get target(): any;
  13134. /** @hidden */
  13135. _onLoop: () => void;
  13136. /**
  13137. * Create a new RuntimeAnimation object
  13138. * @param target defines the target of the animation
  13139. * @param animation defines the source animation object
  13140. * @param scene defines the hosting scene
  13141. * @param host defines the initiating Animatable
  13142. */
  13143. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  13144. private _preparePath;
  13145. /**
  13146. * Gets the animation from the runtime animation
  13147. */
  13148. get animation(): Animation;
  13149. /**
  13150. * Resets the runtime animation to the beginning
  13151. * @param restoreOriginal defines whether to restore the target property to the original value
  13152. */
  13153. reset(restoreOriginal?: boolean): void;
  13154. /**
  13155. * Specifies if the runtime animation is stopped
  13156. * @returns Boolean specifying if the runtime animation is stopped
  13157. */
  13158. isStopped(): boolean;
  13159. /**
  13160. * Disposes of the runtime animation
  13161. */
  13162. dispose(): void;
  13163. /**
  13164. * Apply the interpolated value to the target
  13165. * @param currentValue defines the value computed by the animation
  13166. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  13167. */
  13168. setValue(currentValue: any, weight: number): void;
  13169. private _getOriginalValues;
  13170. private _setValue;
  13171. /**
  13172. * Gets the loop pmode of the runtime animation
  13173. * @returns Loop Mode
  13174. */
  13175. private _getCorrectLoopMode;
  13176. /**
  13177. * Move the current animation to a given frame
  13178. * @param frame defines the frame to move to
  13179. */
  13180. goToFrame(frame: number): void;
  13181. /**
  13182. * @hidden Internal use only
  13183. */
  13184. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  13185. /**
  13186. * Execute the current animation
  13187. * @param delay defines the delay to add to the current frame
  13188. * @param from defines the lower bound of the animation range
  13189. * @param to defines the upper bound of the animation range
  13190. * @param loop defines if the current animation must loop
  13191. * @param speedRatio defines the current speed ratio
  13192. * @param weight defines the weight of the animation (default is -1 so no weight)
  13193. * @param onLoop optional callback called when animation loops
  13194. * @returns a boolean indicating if the animation is running
  13195. */
  13196. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  13197. }
  13198. }
  13199. declare module BABYLON {
  13200. /**
  13201. * Class used to store an actual running animation
  13202. */
  13203. export class Animatable {
  13204. /** defines the target object */
  13205. target: any;
  13206. /** defines the starting frame number (default is 0) */
  13207. fromFrame: number;
  13208. /** defines the ending frame number (default is 100) */
  13209. toFrame: number;
  13210. /** defines if the animation must loop (default is false) */
  13211. loopAnimation: boolean;
  13212. /** defines a callback to call when animation ends if it is not looping */
  13213. onAnimationEnd?: (() => void) | null | undefined;
  13214. /** defines a callback to call when animation loops */
  13215. onAnimationLoop?: (() => void) | null | undefined;
  13216. private _localDelayOffset;
  13217. private _pausedDelay;
  13218. private _runtimeAnimations;
  13219. private _paused;
  13220. private _scene;
  13221. private _speedRatio;
  13222. private _weight;
  13223. private _syncRoot;
  13224. /**
  13225. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  13226. * This will only apply for non looping animation (default is true)
  13227. */
  13228. disposeOnEnd: boolean;
  13229. /**
  13230. * Gets a boolean indicating if the animation has started
  13231. */
  13232. animationStarted: boolean;
  13233. /**
  13234. * Observer raised when the animation ends
  13235. */
  13236. onAnimationEndObservable: Observable<Animatable>;
  13237. /**
  13238. * Observer raised when the animation loops
  13239. */
  13240. onAnimationLoopObservable: Observable<Animatable>;
  13241. /**
  13242. * Gets the root Animatable used to synchronize and normalize animations
  13243. */
  13244. get syncRoot(): Nullable<Animatable>;
  13245. /**
  13246. * Gets the current frame of the first RuntimeAnimation
  13247. * Used to synchronize Animatables
  13248. */
  13249. get masterFrame(): number;
  13250. /**
  13251. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  13252. */
  13253. get weight(): number;
  13254. set weight(value: number);
  13255. /**
  13256. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  13257. */
  13258. get speedRatio(): number;
  13259. set speedRatio(value: number);
  13260. /**
  13261. * Creates a new Animatable
  13262. * @param scene defines the hosting scene
  13263. * @param target defines the target object
  13264. * @param fromFrame defines the starting frame number (default is 0)
  13265. * @param toFrame defines the ending frame number (default is 100)
  13266. * @param loopAnimation defines if the animation must loop (default is false)
  13267. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  13268. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  13269. * @param animations defines a group of animation to add to the new Animatable
  13270. * @param onAnimationLoop defines a callback to call when animation loops
  13271. */
  13272. constructor(scene: Scene,
  13273. /** defines the target object */
  13274. target: any,
  13275. /** defines the starting frame number (default is 0) */
  13276. fromFrame?: number,
  13277. /** defines the ending frame number (default is 100) */
  13278. toFrame?: number,
  13279. /** defines if the animation must loop (default is false) */
  13280. loopAnimation?: boolean, speedRatio?: number,
  13281. /** defines a callback to call when animation ends if it is not looping */
  13282. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  13283. /** defines a callback to call when animation loops */
  13284. onAnimationLoop?: (() => void) | null | undefined);
  13285. /**
  13286. * Synchronize and normalize current Animatable with a source Animatable
  13287. * This is useful when using animation weights and when animations are not of the same length
  13288. * @param root defines the root Animatable to synchronize with
  13289. * @returns the current Animatable
  13290. */
  13291. syncWith(root: Animatable): Animatable;
  13292. /**
  13293. * Gets the list of runtime animations
  13294. * @returns an array of RuntimeAnimation
  13295. */
  13296. getAnimations(): RuntimeAnimation[];
  13297. /**
  13298. * Adds more animations to the current animatable
  13299. * @param target defines the target of the animations
  13300. * @param animations defines the new animations to add
  13301. */
  13302. appendAnimations(target: any, animations: Animation[]): void;
  13303. /**
  13304. * Gets the source animation for a specific property
  13305. * @param property defines the propertyu to look for
  13306. * @returns null or the source animation for the given property
  13307. */
  13308. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  13309. /**
  13310. * Gets the runtime animation for a specific property
  13311. * @param property defines the propertyu to look for
  13312. * @returns null or the runtime animation for the given property
  13313. */
  13314. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  13315. /**
  13316. * Resets the animatable to its original state
  13317. */
  13318. reset(): void;
  13319. /**
  13320. * Allows the animatable to blend with current running animations
  13321. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13322. * @param blendingSpeed defines the blending speed to use
  13323. */
  13324. enableBlending(blendingSpeed: number): void;
  13325. /**
  13326. * Disable animation blending
  13327. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13328. */
  13329. disableBlending(): void;
  13330. /**
  13331. * Jump directly to a given frame
  13332. * @param frame defines the frame to jump to
  13333. */
  13334. goToFrame(frame: number): void;
  13335. /**
  13336. * Pause the animation
  13337. */
  13338. pause(): void;
  13339. /**
  13340. * Restart the animation
  13341. */
  13342. restart(): void;
  13343. private _raiseOnAnimationEnd;
  13344. /**
  13345. * Stop and delete the current animation
  13346. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  13347. * @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)
  13348. */
  13349. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  13350. /**
  13351. * Wait asynchronously for the animation to end
  13352. * @returns a promise which will be fullfilled when the animation ends
  13353. */
  13354. waitAsync(): Promise<Animatable>;
  13355. /** @hidden */
  13356. _animate(delay: number): boolean;
  13357. }
  13358. interface Scene {
  13359. /** @hidden */
  13360. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  13361. /** @hidden */
  13362. _processLateAnimationBindingsForMatrices(holder: {
  13363. totalWeight: number;
  13364. animations: RuntimeAnimation[];
  13365. originalValue: Matrix;
  13366. }): any;
  13367. /** @hidden */
  13368. _processLateAnimationBindingsForQuaternions(holder: {
  13369. totalWeight: number;
  13370. animations: RuntimeAnimation[];
  13371. originalValue: Quaternion;
  13372. }, refQuaternion: Quaternion): Quaternion;
  13373. /** @hidden */
  13374. _processLateAnimationBindings(): void;
  13375. /**
  13376. * Will start the animation sequence of a given target
  13377. * @param target defines the target
  13378. * @param from defines from which frame should animation start
  13379. * @param to defines until which frame should animation run.
  13380. * @param weight defines the weight to apply to the animation (1.0 by default)
  13381. * @param loop defines if the animation loops
  13382. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13383. * @param onAnimationEnd defines the function to be executed when the animation ends
  13384. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13385. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13386. * @param onAnimationLoop defines the callback to call when an animation loops
  13387. * @returns the animatable object created for this animation
  13388. */
  13389. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13390. /**
  13391. * Will start the animation sequence of a given target
  13392. * @param target defines the target
  13393. * @param from defines from which frame should animation start
  13394. * @param to defines until which frame should animation run.
  13395. * @param loop defines if the animation loops
  13396. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13397. * @param onAnimationEnd defines the function to be executed when the animation ends
  13398. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13399. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13400. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  13401. * @param onAnimationLoop defines the callback to call when an animation loops
  13402. * @returns the animatable object created for this animation
  13403. */
  13404. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13405. /**
  13406. * Will start the animation sequence of a given target and its hierarchy
  13407. * @param target defines the target
  13408. * @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.
  13409. * @param from defines from which frame should animation start
  13410. * @param to defines until which frame should animation run.
  13411. * @param loop defines if the animation loops
  13412. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13413. * @param onAnimationEnd defines the function to be executed when the animation ends
  13414. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13415. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13416. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13417. * @param onAnimationLoop defines the callback to call when an animation loops
  13418. * @returns the list of created animatables
  13419. */
  13420. 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[];
  13421. /**
  13422. * Begin a new animation on a given node
  13423. * @param target defines the target where the animation will take place
  13424. * @param animations defines the list of animations to start
  13425. * @param from defines the initial value
  13426. * @param to defines the final value
  13427. * @param loop defines if you want animation to loop (off by default)
  13428. * @param speedRatio defines the speed ratio to apply to all animations
  13429. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13430. * @param onAnimationLoop defines the callback to call when an animation loops
  13431. * @returns the list of created animatables
  13432. */
  13433. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  13434. /**
  13435. * Begin a new animation on a given node and its hierarchy
  13436. * @param target defines the root node where the animation will take place
  13437. * @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.
  13438. * @param animations defines the list of animations to start
  13439. * @param from defines the initial value
  13440. * @param to defines the final value
  13441. * @param loop defines if you want animation to loop (off by default)
  13442. * @param speedRatio defines the speed ratio to apply to all animations
  13443. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13444. * @param onAnimationLoop defines the callback to call when an animation loops
  13445. * @returns the list of animatables created for all nodes
  13446. */
  13447. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  13448. /**
  13449. * Gets the animatable associated with a specific target
  13450. * @param target defines the target of the animatable
  13451. * @returns the required animatable if found
  13452. */
  13453. getAnimatableByTarget(target: any): Nullable<Animatable>;
  13454. /**
  13455. * Gets all animatables associated with a given target
  13456. * @param target defines the target to look animatables for
  13457. * @returns an array of Animatables
  13458. */
  13459. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  13460. /**
  13461. * Stops and removes all animations that have been applied to the scene
  13462. */
  13463. stopAllAnimations(): void;
  13464. /**
  13465. * Gets the current delta time used by animation engine
  13466. */
  13467. deltaTime: number;
  13468. }
  13469. interface Bone {
  13470. /**
  13471. * Copy an animation range from another bone
  13472. * @param source defines the source bone
  13473. * @param rangeName defines the range name to copy
  13474. * @param frameOffset defines the frame offset
  13475. * @param rescaleAsRequired defines if rescaling must be applied if required
  13476. * @param skelDimensionsRatio defines the scaling ratio
  13477. * @returns true if operation was successful
  13478. */
  13479. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  13480. }
  13481. }
  13482. declare module BABYLON {
  13483. /**
  13484. * Class used to override all child animations of a given target
  13485. */
  13486. export class AnimationPropertiesOverride {
  13487. /**
  13488. * Gets or sets a value indicating if animation blending must be used
  13489. */
  13490. enableBlending: boolean;
  13491. /**
  13492. * Gets or sets the blending speed to use when enableBlending is true
  13493. */
  13494. blendingSpeed: number;
  13495. /**
  13496. * Gets or sets the default loop mode to use
  13497. */
  13498. loopMode: number;
  13499. }
  13500. }
  13501. declare module BABYLON {
  13502. /**
  13503. * Class used to handle skinning animations
  13504. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13505. */
  13506. export class Skeleton implements IAnimatable {
  13507. /** defines the skeleton name */
  13508. name: string;
  13509. /** defines the skeleton Id */
  13510. id: string;
  13511. /**
  13512. * Defines the list of child bones
  13513. */
  13514. bones: Bone[];
  13515. /**
  13516. * Defines an estimate of the dimension of the skeleton at rest
  13517. */
  13518. dimensionsAtRest: Vector3;
  13519. /**
  13520. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  13521. */
  13522. needInitialSkinMatrix: boolean;
  13523. /**
  13524. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  13525. */
  13526. overrideMesh: Nullable<AbstractMesh>;
  13527. /**
  13528. * Gets the list of animations attached to this skeleton
  13529. */
  13530. animations: Array<Animation>;
  13531. private _scene;
  13532. private _isDirty;
  13533. private _transformMatrices;
  13534. private _transformMatrixTexture;
  13535. private _meshesWithPoseMatrix;
  13536. private _animatables;
  13537. private _identity;
  13538. private _synchronizedWithMesh;
  13539. private _ranges;
  13540. private _lastAbsoluteTransformsUpdateId;
  13541. private _canUseTextureForBones;
  13542. private _uniqueId;
  13543. /** @hidden */
  13544. _numBonesWithLinkedTransformNode: number;
  13545. /** @hidden */
  13546. _hasWaitingData: Nullable<boolean>;
  13547. /**
  13548. * Specifies if the skeleton should be serialized
  13549. */
  13550. doNotSerialize: boolean;
  13551. private _useTextureToStoreBoneMatrices;
  13552. /**
  13553. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  13554. * Please note that this option is not available if the hardware does not support it
  13555. */
  13556. get useTextureToStoreBoneMatrices(): boolean;
  13557. set useTextureToStoreBoneMatrices(value: boolean);
  13558. private _animationPropertiesOverride;
  13559. /**
  13560. * Gets or sets the animation properties override
  13561. */
  13562. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  13563. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  13564. /**
  13565. * List of inspectable custom properties (used by the Inspector)
  13566. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  13567. */
  13568. inspectableCustomProperties: IInspectable[];
  13569. /**
  13570. * An observable triggered before computing the skeleton's matrices
  13571. */
  13572. onBeforeComputeObservable: Observable<Skeleton>;
  13573. /**
  13574. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  13575. */
  13576. get isUsingTextureForMatrices(): boolean;
  13577. /**
  13578. * Gets the unique ID of this skeleton
  13579. */
  13580. get uniqueId(): number;
  13581. /**
  13582. * Creates a new skeleton
  13583. * @param name defines the skeleton name
  13584. * @param id defines the skeleton Id
  13585. * @param scene defines the hosting scene
  13586. */
  13587. constructor(
  13588. /** defines the skeleton name */
  13589. name: string,
  13590. /** defines the skeleton Id */
  13591. id: string, scene: Scene);
  13592. /**
  13593. * Gets the current object class name.
  13594. * @return the class name
  13595. */
  13596. getClassName(): string;
  13597. /**
  13598. * Returns an array containing the root bones
  13599. * @returns an array containing the root bones
  13600. */
  13601. getChildren(): Array<Bone>;
  13602. /**
  13603. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  13604. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13605. * @returns a Float32Array containing matrices data
  13606. */
  13607. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  13608. /**
  13609. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  13610. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13611. * @returns a raw texture containing the data
  13612. */
  13613. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  13614. /**
  13615. * Gets the current hosting scene
  13616. * @returns a scene object
  13617. */
  13618. getScene(): Scene;
  13619. /**
  13620. * Gets a string representing the current skeleton data
  13621. * @param fullDetails defines a boolean indicating if we want a verbose version
  13622. * @returns a string representing the current skeleton data
  13623. */
  13624. toString(fullDetails?: boolean): string;
  13625. /**
  13626. * Get bone's index searching by name
  13627. * @param name defines bone's name to search for
  13628. * @return the indice of the bone. Returns -1 if not found
  13629. */
  13630. getBoneIndexByName(name: string): number;
  13631. /**
  13632. * Creater a new animation range
  13633. * @param name defines the name of the range
  13634. * @param from defines the start key
  13635. * @param to defines the end key
  13636. */
  13637. createAnimationRange(name: string, from: number, to: number): void;
  13638. /**
  13639. * Delete a specific animation range
  13640. * @param name defines the name of the range
  13641. * @param deleteFrames defines if frames must be removed as well
  13642. */
  13643. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  13644. /**
  13645. * Gets a specific animation range
  13646. * @param name defines the name of the range to look for
  13647. * @returns the requested animation range or null if not found
  13648. */
  13649. getAnimationRange(name: string): Nullable<AnimationRange>;
  13650. /**
  13651. * Gets the list of all animation ranges defined on this skeleton
  13652. * @returns an array
  13653. */
  13654. getAnimationRanges(): Nullable<AnimationRange>[];
  13655. /**
  13656. * Copy animation range from a source skeleton.
  13657. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  13658. * @param source defines the source skeleton
  13659. * @param name defines the name of the range to copy
  13660. * @param rescaleAsRequired defines if rescaling must be applied if required
  13661. * @returns true if operation was successful
  13662. */
  13663. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  13664. /**
  13665. * Forces the skeleton to go to rest pose
  13666. */
  13667. returnToRest(): void;
  13668. private _getHighestAnimationFrame;
  13669. /**
  13670. * Begin a specific animation range
  13671. * @param name defines the name of the range to start
  13672. * @param loop defines if looping must be turned on (false by default)
  13673. * @param speedRatio defines the speed ratio to apply (1 by default)
  13674. * @param onAnimationEnd defines a callback which will be called when animation will end
  13675. * @returns a new animatable
  13676. */
  13677. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  13678. /** @hidden */
  13679. _markAsDirty(): void;
  13680. /** @hidden */
  13681. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13682. /** @hidden */
  13683. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13684. private _computeTransformMatrices;
  13685. /**
  13686. * Build all resources required to render a skeleton
  13687. */
  13688. prepare(): void;
  13689. /**
  13690. * Gets the list of animatables currently running for this skeleton
  13691. * @returns an array of animatables
  13692. */
  13693. getAnimatables(): IAnimatable[];
  13694. /**
  13695. * Clone the current skeleton
  13696. * @param name defines the name of the new skeleton
  13697. * @param id defines the id of the new skeleton
  13698. * @returns the new skeleton
  13699. */
  13700. clone(name: string, id?: string): Skeleton;
  13701. /**
  13702. * Enable animation blending for this skeleton
  13703. * @param blendingSpeed defines the blending speed to apply
  13704. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13705. */
  13706. enableBlending(blendingSpeed?: number): void;
  13707. /**
  13708. * Releases all resources associated with the current skeleton
  13709. */
  13710. dispose(): void;
  13711. /**
  13712. * Serialize the skeleton in a JSON object
  13713. * @returns a JSON object
  13714. */
  13715. serialize(): any;
  13716. /**
  13717. * Creates a new skeleton from serialized data
  13718. * @param parsedSkeleton defines the serialized data
  13719. * @param scene defines the hosting scene
  13720. * @returns a new skeleton
  13721. */
  13722. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  13723. /**
  13724. * Compute all node absolute transforms
  13725. * @param forceUpdate defines if computation must be done even if cache is up to date
  13726. */
  13727. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  13728. /**
  13729. * Gets the root pose matrix
  13730. * @returns a matrix
  13731. */
  13732. getPoseMatrix(): Nullable<Matrix>;
  13733. /**
  13734. * Sorts bones per internal index
  13735. */
  13736. sortBones(): void;
  13737. private _sortBones;
  13738. }
  13739. }
  13740. declare module BABYLON {
  13741. /**
  13742. * Class used to store bone information
  13743. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13744. */
  13745. export class Bone extends Node {
  13746. /**
  13747. * defines the bone name
  13748. */
  13749. name: string;
  13750. private static _tmpVecs;
  13751. private static _tmpQuat;
  13752. private static _tmpMats;
  13753. /**
  13754. * Gets the list of child bones
  13755. */
  13756. children: Bone[];
  13757. /** Gets the animations associated with this bone */
  13758. animations: Animation[];
  13759. /**
  13760. * Gets or sets bone length
  13761. */
  13762. length: number;
  13763. /**
  13764. * @hidden Internal only
  13765. * Set this value to map this bone to a different index in the transform matrices
  13766. * Set this value to -1 to exclude the bone from the transform matrices
  13767. */
  13768. _index: Nullable<number>;
  13769. private _skeleton;
  13770. private _localMatrix;
  13771. private _restPose;
  13772. private _baseMatrix;
  13773. private _absoluteTransform;
  13774. private _invertedAbsoluteTransform;
  13775. private _parent;
  13776. private _scalingDeterminant;
  13777. private _worldTransform;
  13778. private _localScaling;
  13779. private _localRotation;
  13780. private _localPosition;
  13781. private _needToDecompose;
  13782. private _needToCompose;
  13783. /** @hidden */
  13784. _linkedTransformNode: Nullable<TransformNode>;
  13785. /** @hidden */
  13786. _waitingTransformNodeId: Nullable<string>;
  13787. /** @hidden */
  13788. get _matrix(): Matrix;
  13789. /** @hidden */
  13790. set _matrix(value: Matrix);
  13791. /**
  13792. * Create a new bone
  13793. * @param name defines the bone name
  13794. * @param skeleton defines the parent skeleton
  13795. * @param parentBone defines the parent (can be null if the bone is the root)
  13796. * @param localMatrix defines the local matrix
  13797. * @param restPose defines the rest pose matrix
  13798. * @param baseMatrix defines the base matrix
  13799. * @param index defines index of the bone in the hiearchy
  13800. */
  13801. constructor(
  13802. /**
  13803. * defines the bone name
  13804. */
  13805. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  13806. /**
  13807. * Gets the current object class name.
  13808. * @return the class name
  13809. */
  13810. getClassName(): string;
  13811. /**
  13812. * Gets the parent skeleton
  13813. * @returns a skeleton
  13814. */
  13815. getSkeleton(): Skeleton;
  13816. /**
  13817. * Gets parent bone
  13818. * @returns a bone or null if the bone is the root of the bone hierarchy
  13819. */
  13820. getParent(): Nullable<Bone>;
  13821. /**
  13822. * Returns an array containing the root bones
  13823. * @returns an array containing the root bones
  13824. */
  13825. getChildren(): Array<Bone>;
  13826. /**
  13827. * Gets the node index in matrix array generated for rendering
  13828. * @returns the node index
  13829. */
  13830. getIndex(): number;
  13831. /**
  13832. * Sets the parent bone
  13833. * @param parent defines the parent (can be null if the bone is the root)
  13834. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13835. */
  13836. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  13837. /**
  13838. * Gets the local matrix
  13839. * @returns a matrix
  13840. */
  13841. getLocalMatrix(): Matrix;
  13842. /**
  13843. * Gets the base matrix (initial matrix which remains unchanged)
  13844. * @returns a matrix
  13845. */
  13846. getBaseMatrix(): Matrix;
  13847. /**
  13848. * Gets the rest pose matrix
  13849. * @returns a matrix
  13850. */
  13851. getRestPose(): Matrix;
  13852. /**
  13853. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  13854. */
  13855. getWorldMatrix(): Matrix;
  13856. /**
  13857. * Sets the local matrix to rest pose matrix
  13858. */
  13859. returnToRest(): void;
  13860. /**
  13861. * Gets the inverse of the absolute transform matrix.
  13862. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  13863. * @returns a matrix
  13864. */
  13865. getInvertedAbsoluteTransform(): Matrix;
  13866. /**
  13867. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  13868. * @returns a matrix
  13869. */
  13870. getAbsoluteTransform(): Matrix;
  13871. /**
  13872. * Links with the given transform node.
  13873. * The local matrix of this bone is copied from the transform node every frame.
  13874. * @param transformNode defines the transform node to link to
  13875. */
  13876. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  13877. /**
  13878. * Gets the node used to drive the bone's transformation
  13879. * @returns a transform node or null
  13880. */
  13881. getTransformNode(): Nullable<TransformNode>;
  13882. /** Gets or sets current position (in local space) */
  13883. get position(): Vector3;
  13884. set position(newPosition: Vector3);
  13885. /** Gets or sets current rotation (in local space) */
  13886. get rotation(): Vector3;
  13887. set rotation(newRotation: Vector3);
  13888. /** Gets or sets current rotation quaternion (in local space) */
  13889. get rotationQuaternion(): Quaternion;
  13890. set rotationQuaternion(newRotation: Quaternion);
  13891. /** Gets or sets current scaling (in local space) */
  13892. get scaling(): Vector3;
  13893. set scaling(newScaling: Vector3);
  13894. /**
  13895. * Gets the animation properties override
  13896. */
  13897. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  13898. private _decompose;
  13899. private _compose;
  13900. /**
  13901. * Update the base and local matrices
  13902. * @param matrix defines the new base or local matrix
  13903. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13904. * @param updateLocalMatrix defines if the local matrix should be updated
  13905. */
  13906. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  13907. /** @hidden */
  13908. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  13909. /**
  13910. * Flag the bone as dirty (Forcing it to update everything)
  13911. */
  13912. markAsDirty(): void;
  13913. /** @hidden */
  13914. _markAsDirtyAndCompose(): void;
  13915. private _markAsDirtyAndDecompose;
  13916. /**
  13917. * Translate the bone in local or world space
  13918. * @param vec The amount to translate the bone
  13919. * @param space The space that the translation is in
  13920. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13921. */
  13922. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13923. /**
  13924. * Set the postion of the bone in local or world space
  13925. * @param position The position to set the bone
  13926. * @param space The space that the position is in
  13927. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13928. */
  13929. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13930. /**
  13931. * Set the absolute position of the bone (world space)
  13932. * @param position The position to set the bone
  13933. * @param mesh The mesh that this bone is attached to
  13934. */
  13935. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  13936. /**
  13937. * Scale the bone on the x, y and z axes (in local space)
  13938. * @param x The amount to scale the bone on the x axis
  13939. * @param y The amount to scale the bone on the y axis
  13940. * @param z The amount to scale the bone on the z axis
  13941. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  13942. */
  13943. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  13944. /**
  13945. * Set the bone scaling in local space
  13946. * @param scale defines the scaling vector
  13947. */
  13948. setScale(scale: Vector3): void;
  13949. /**
  13950. * Gets the current scaling in local space
  13951. * @returns the current scaling vector
  13952. */
  13953. getScale(): Vector3;
  13954. /**
  13955. * Gets the current scaling in local space and stores it in a target vector
  13956. * @param result defines the target vector
  13957. */
  13958. getScaleToRef(result: Vector3): void;
  13959. /**
  13960. * Set the yaw, pitch, and roll of the bone in local or world space
  13961. * @param yaw The rotation of the bone on the y axis
  13962. * @param pitch The rotation of the bone on the x axis
  13963. * @param roll The rotation of the bone on the z axis
  13964. * @param space The space that the axes of rotation are in
  13965. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13966. */
  13967. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  13968. /**
  13969. * Add a rotation to the bone on an axis in local or world space
  13970. * @param axis The axis to rotate the bone on
  13971. * @param amount The amount to rotate the bone
  13972. * @param space The space that the axis is in
  13973. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13974. */
  13975. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  13976. /**
  13977. * Set the rotation of the bone to a particular axis angle in local or world space
  13978. * @param axis The axis to rotate the bone on
  13979. * @param angle The angle that the bone should be rotated to
  13980. * @param space The space that the axis is in
  13981. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13982. */
  13983. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  13984. /**
  13985. * Set the euler rotation of the bone in local of world space
  13986. * @param rotation The euler rotation that the bone should be set to
  13987. * @param space The space that the rotation is in
  13988. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13989. */
  13990. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13991. /**
  13992. * Set the quaternion rotation of the bone in local of world space
  13993. * @param quat The quaternion rotation that the bone should be set to
  13994. * @param space The space that the rotation is in
  13995. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13996. */
  13997. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  13998. /**
  13999. * Set the rotation matrix of the bone in local of world space
  14000. * @param rotMat The rotation matrix that the bone should be set to
  14001. * @param space The space that the rotation is in
  14002. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14003. */
  14004. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  14005. private _rotateWithMatrix;
  14006. private _getNegativeRotationToRef;
  14007. /**
  14008. * Get the position of the bone in local or world space
  14009. * @param space The space that the returned position is in
  14010. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14011. * @returns The position of the bone
  14012. */
  14013. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14014. /**
  14015. * Copy the position of the bone to a vector3 in local or world space
  14016. * @param space The space that the returned position is in
  14017. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14018. * @param result The vector3 to copy the position to
  14019. */
  14020. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  14021. /**
  14022. * Get the absolute position of the bone (world space)
  14023. * @param mesh The mesh that this bone is attached to
  14024. * @returns The absolute position of the bone
  14025. */
  14026. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  14027. /**
  14028. * Copy the absolute position of the bone (world space) to the result param
  14029. * @param mesh The mesh that this bone is attached to
  14030. * @param result The vector3 to copy the absolute position to
  14031. */
  14032. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  14033. /**
  14034. * Compute the absolute transforms of this bone and its children
  14035. */
  14036. computeAbsoluteTransforms(): void;
  14037. /**
  14038. * Get the world direction from an axis that is in the local space of the bone
  14039. * @param localAxis The local direction that is used to compute the world direction
  14040. * @param mesh The mesh that this bone is attached to
  14041. * @returns The world direction
  14042. */
  14043. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14044. /**
  14045. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  14046. * @param localAxis The local direction that is used to compute the world direction
  14047. * @param mesh The mesh that this bone is attached to
  14048. * @param result The vector3 that the world direction will be copied to
  14049. */
  14050. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14051. /**
  14052. * Get the euler rotation of the bone in local or world space
  14053. * @param space The space that the rotation should be in
  14054. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14055. * @returns The euler rotation
  14056. */
  14057. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14058. /**
  14059. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  14060. * @param space The space that the rotation should be in
  14061. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14062. * @param result The vector3 that the rotation should be copied to
  14063. */
  14064. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14065. /**
  14066. * Get the quaternion rotation of the bone in either local or world space
  14067. * @param space The space that the rotation should be in
  14068. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14069. * @returns The quaternion rotation
  14070. */
  14071. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  14072. /**
  14073. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  14074. * @param space The space that the rotation should be in
  14075. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14076. * @param result The quaternion that the rotation should be copied to
  14077. */
  14078. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  14079. /**
  14080. * Get the rotation matrix of the bone in local or world space
  14081. * @param space The space that the rotation should be in
  14082. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14083. * @returns The rotation matrix
  14084. */
  14085. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  14086. /**
  14087. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  14088. * @param space The space that the rotation should be in
  14089. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14090. * @param result The quaternion that the rotation should be copied to
  14091. */
  14092. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  14093. /**
  14094. * Get the world position of a point that is in the local space of the bone
  14095. * @param position The local position
  14096. * @param mesh The mesh that this bone is attached to
  14097. * @returns The world position
  14098. */
  14099. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14100. /**
  14101. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  14102. * @param position The local position
  14103. * @param mesh The mesh that this bone is attached to
  14104. * @param result The vector3 that the world position should be copied to
  14105. */
  14106. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14107. /**
  14108. * Get the local position of a point that is in world space
  14109. * @param position The world position
  14110. * @param mesh The mesh that this bone is attached to
  14111. * @returns The local position
  14112. */
  14113. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14114. /**
  14115. * Get the local position of a point that is in world space and copy it to the result param
  14116. * @param position The world position
  14117. * @param mesh The mesh that this bone is attached to
  14118. * @param result The vector3 that the local position should be copied to
  14119. */
  14120. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14121. }
  14122. }
  14123. declare module BABYLON {
  14124. /**
  14125. * 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.
  14126. * @see https://doc.babylonjs.com/how_to/transformnode
  14127. */
  14128. export class TransformNode extends Node {
  14129. /**
  14130. * Object will not rotate to face the camera
  14131. */
  14132. static BILLBOARDMODE_NONE: number;
  14133. /**
  14134. * Object will rotate to face the camera but only on the x axis
  14135. */
  14136. static BILLBOARDMODE_X: number;
  14137. /**
  14138. * Object will rotate to face the camera but only on the y axis
  14139. */
  14140. static BILLBOARDMODE_Y: number;
  14141. /**
  14142. * Object will rotate to face the camera but only on the z axis
  14143. */
  14144. static BILLBOARDMODE_Z: number;
  14145. /**
  14146. * Object will rotate to face the camera
  14147. */
  14148. static BILLBOARDMODE_ALL: number;
  14149. /**
  14150. * Object will rotate to face the camera's position instead of orientation
  14151. */
  14152. static BILLBOARDMODE_USE_POSITION: number;
  14153. private _forward;
  14154. private _forwardInverted;
  14155. private _up;
  14156. private _right;
  14157. private _rightInverted;
  14158. private _position;
  14159. private _rotation;
  14160. private _rotationQuaternion;
  14161. protected _scaling: Vector3;
  14162. protected _isDirty: boolean;
  14163. private _transformToBoneReferal;
  14164. private _isAbsoluteSynced;
  14165. private _billboardMode;
  14166. /**
  14167. * Gets or sets the billboard mode. Default is 0.
  14168. *
  14169. * | Value | Type | Description |
  14170. * | --- | --- | --- |
  14171. * | 0 | BILLBOARDMODE_NONE | |
  14172. * | 1 | BILLBOARDMODE_X | |
  14173. * | 2 | BILLBOARDMODE_Y | |
  14174. * | 4 | BILLBOARDMODE_Z | |
  14175. * | 7 | BILLBOARDMODE_ALL | |
  14176. *
  14177. */
  14178. get billboardMode(): number;
  14179. set billboardMode(value: number);
  14180. private _preserveParentRotationForBillboard;
  14181. /**
  14182. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  14183. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  14184. */
  14185. get preserveParentRotationForBillboard(): boolean;
  14186. set preserveParentRotationForBillboard(value: boolean);
  14187. /**
  14188. * 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
  14189. */
  14190. scalingDeterminant: number;
  14191. private _infiniteDistance;
  14192. /**
  14193. * Gets or sets the distance of the object to max, often used by skybox
  14194. */
  14195. get infiniteDistance(): boolean;
  14196. set infiniteDistance(value: boolean);
  14197. /**
  14198. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  14199. * By default the system will update normals to compensate
  14200. */
  14201. ignoreNonUniformScaling: boolean;
  14202. /**
  14203. * 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
  14204. */
  14205. reIntegrateRotationIntoRotationQuaternion: boolean;
  14206. /** @hidden */
  14207. _poseMatrix: Nullable<Matrix>;
  14208. /** @hidden */
  14209. _localMatrix: Matrix;
  14210. private _usePivotMatrix;
  14211. private _absolutePosition;
  14212. private _absoluteScaling;
  14213. private _absoluteRotationQuaternion;
  14214. private _pivotMatrix;
  14215. private _pivotMatrixInverse;
  14216. protected _postMultiplyPivotMatrix: boolean;
  14217. protected _isWorldMatrixFrozen: boolean;
  14218. /** @hidden */
  14219. _indexInSceneTransformNodesArray: number;
  14220. /**
  14221. * An event triggered after the world matrix is updated
  14222. */
  14223. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  14224. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  14225. /**
  14226. * Gets a string identifying the name of the class
  14227. * @returns "TransformNode" string
  14228. */
  14229. getClassName(): string;
  14230. /**
  14231. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  14232. */
  14233. get position(): Vector3;
  14234. set position(newPosition: Vector3);
  14235. /**
  14236. * 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)).
  14237. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  14238. */
  14239. get rotation(): Vector3;
  14240. set rotation(newRotation: Vector3);
  14241. /**
  14242. * 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)).
  14243. */
  14244. get scaling(): Vector3;
  14245. set scaling(newScaling: Vector3);
  14246. /**
  14247. * 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).
  14248. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  14249. */
  14250. get rotationQuaternion(): Nullable<Quaternion>;
  14251. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  14252. /**
  14253. * The forward direction of that transform in world space.
  14254. */
  14255. get forward(): Vector3;
  14256. /**
  14257. * The up direction of that transform in world space.
  14258. */
  14259. get up(): Vector3;
  14260. /**
  14261. * The right direction of that transform in world space.
  14262. */
  14263. get right(): Vector3;
  14264. /**
  14265. * Copies the parameter passed Matrix into the mesh Pose matrix.
  14266. * @param matrix the matrix to copy the pose from
  14267. * @returns this TransformNode.
  14268. */
  14269. updatePoseMatrix(matrix: Matrix): TransformNode;
  14270. /**
  14271. * Returns the mesh Pose matrix.
  14272. * @returns the pose matrix
  14273. */
  14274. getPoseMatrix(): Matrix;
  14275. /** @hidden */
  14276. _isSynchronized(): boolean;
  14277. /** @hidden */
  14278. _initCache(): void;
  14279. /**
  14280. * Flag the transform node as dirty (Forcing it to update everything)
  14281. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  14282. * @returns this transform node
  14283. */
  14284. markAsDirty(property: string): TransformNode;
  14285. /**
  14286. * Returns the current mesh absolute position.
  14287. * Returns a Vector3.
  14288. */
  14289. get absolutePosition(): Vector3;
  14290. /**
  14291. * Returns the current mesh absolute scaling.
  14292. * Returns a Vector3.
  14293. */
  14294. get absoluteScaling(): Vector3;
  14295. /**
  14296. * Returns the current mesh absolute rotation.
  14297. * Returns a Quaternion.
  14298. */
  14299. get absoluteRotationQuaternion(): Quaternion;
  14300. /**
  14301. * Sets a new matrix to apply before all other transformation
  14302. * @param matrix defines the transform matrix
  14303. * @returns the current TransformNode
  14304. */
  14305. setPreTransformMatrix(matrix: Matrix): TransformNode;
  14306. /**
  14307. * Sets a new pivot matrix to the current node
  14308. * @param matrix defines the new pivot matrix to use
  14309. * @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
  14310. * @returns the current TransformNode
  14311. */
  14312. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  14313. /**
  14314. * Returns the mesh pivot matrix.
  14315. * Default : Identity.
  14316. * @returns the matrix
  14317. */
  14318. getPivotMatrix(): Matrix;
  14319. /**
  14320. * Instantiate (when possible) or clone that node with its hierarchy
  14321. * @param newParent defines the new parent to use for the instance (or clone)
  14322. * @param options defines options to configure how copy is done
  14323. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  14324. * @returns an instance (or a clone) of the current node with its hiearchy
  14325. */
  14326. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  14327. doNotInstantiate: boolean;
  14328. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  14329. /**
  14330. * Prevents the World matrix to be computed any longer
  14331. * @param newWorldMatrix defines an optional matrix to use as world matrix
  14332. * @returns the TransformNode.
  14333. */
  14334. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  14335. /**
  14336. * Allows back the World matrix computation.
  14337. * @returns the TransformNode.
  14338. */
  14339. unfreezeWorldMatrix(): this;
  14340. /**
  14341. * True if the World matrix has been frozen.
  14342. */
  14343. get isWorldMatrixFrozen(): boolean;
  14344. /**
  14345. * Retuns the mesh absolute position in the World.
  14346. * @returns a Vector3.
  14347. */
  14348. getAbsolutePosition(): Vector3;
  14349. /**
  14350. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  14351. * @param absolutePosition the absolute position to set
  14352. * @returns the TransformNode.
  14353. */
  14354. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  14355. /**
  14356. * Sets the mesh position in its local space.
  14357. * @param vector3 the position to set in localspace
  14358. * @returns the TransformNode.
  14359. */
  14360. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  14361. /**
  14362. * Returns the mesh position in the local space from the current World matrix values.
  14363. * @returns a new Vector3.
  14364. */
  14365. getPositionExpressedInLocalSpace(): Vector3;
  14366. /**
  14367. * Translates the mesh along the passed Vector3 in its local space.
  14368. * @param vector3 the distance to translate in localspace
  14369. * @returns the TransformNode.
  14370. */
  14371. locallyTranslate(vector3: Vector3): TransformNode;
  14372. private static _lookAtVectorCache;
  14373. /**
  14374. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  14375. * @param targetPoint the position (must be in same space as current mesh) to look at
  14376. * @param yawCor optional yaw (y-axis) correction in radians
  14377. * @param pitchCor optional pitch (x-axis) correction in radians
  14378. * @param rollCor optional roll (z-axis) correction in radians
  14379. * @param space the choosen space of the target
  14380. * @returns the TransformNode.
  14381. */
  14382. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  14383. /**
  14384. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14385. * This Vector3 is expressed in the World space.
  14386. * @param localAxis axis to rotate
  14387. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14388. */
  14389. getDirection(localAxis: Vector3): Vector3;
  14390. /**
  14391. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  14392. * localAxis is expressed in the mesh local space.
  14393. * result is computed in the Wordl space from the mesh World matrix.
  14394. * @param localAxis axis to rotate
  14395. * @param result the resulting transformnode
  14396. * @returns this TransformNode.
  14397. */
  14398. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  14399. /**
  14400. * Sets this transform node rotation to the given local axis.
  14401. * @param localAxis the axis in local space
  14402. * @param yawCor optional yaw (y-axis) correction in radians
  14403. * @param pitchCor optional pitch (x-axis) correction in radians
  14404. * @param rollCor optional roll (z-axis) correction in radians
  14405. * @returns this TransformNode
  14406. */
  14407. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  14408. /**
  14409. * Sets a new pivot point to the current node
  14410. * @param point defines the new pivot point to use
  14411. * @param space defines if the point is in world or local space (local by default)
  14412. * @returns the current TransformNode
  14413. */
  14414. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  14415. /**
  14416. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  14417. * @returns the pivot point
  14418. */
  14419. getPivotPoint(): Vector3;
  14420. /**
  14421. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  14422. * @param result the vector3 to store the result
  14423. * @returns this TransformNode.
  14424. */
  14425. getPivotPointToRef(result: Vector3): TransformNode;
  14426. /**
  14427. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  14428. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  14429. */
  14430. getAbsolutePivotPoint(): Vector3;
  14431. /**
  14432. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  14433. * @param result vector3 to store the result
  14434. * @returns this TransformNode.
  14435. */
  14436. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  14437. /**
  14438. * Defines the passed node as the parent of the current node.
  14439. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  14440. * @see https://doc.babylonjs.com/how_to/parenting
  14441. * @param node the node ot set as the parent
  14442. * @returns this TransformNode.
  14443. */
  14444. setParent(node: Nullable<Node>): TransformNode;
  14445. private _nonUniformScaling;
  14446. /**
  14447. * True if the scaling property of this object is non uniform eg. (1,2,1)
  14448. */
  14449. get nonUniformScaling(): boolean;
  14450. /** @hidden */
  14451. _updateNonUniformScalingState(value: boolean): boolean;
  14452. /**
  14453. * Attach the current TransformNode to another TransformNode associated with a bone
  14454. * @param bone Bone affecting the TransformNode
  14455. * @param affectedTransformNode TransformNode associated with the bone
  14456. * @returns this object
  14457. */
  14458. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  14459. /**
  14460. * Detach the transform node if its associated with a bone
  14461. * @returns this object
  14462. */
  14463. detachFromBone(): TransformNode;
  14464. private static _rotationAxisCache;
  14465. /**
  14466. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  14467. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14468. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14469. * The passed axis is also normalized.
  14470. * @param axis the axis to rotate around
  14471. * @param amount the amount to rotate in radians
  14472. * @param space Space to rotate in (Default: local)
  14473. * @returns the TransformNode.
  14474. */
  14475. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  14476. /**
  14477. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  14478. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14479. * The passed axis is also normalized. .
  14480. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  14481. * @param point the point to rotate around
  14482. * @param axis the axis to rotate around
  14483. * @param amount the amount to rotate in radians
  14484. * @returns the TransformNode
  14485. */
  14486. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  14487. /**
  14488. * Translates the mesh along the axis vector for the passed distance in the given space.
  14489. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14490. * @param axis the axis to translate in
  14491. * @param distance the distance to translate
  14492. * @param space Space to rotate in (Default: local)
  14493. * @returns the TransformNode.
  14494. */
  14495. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  14496. /**
  14497. * Adds a rotation step to the mesh current rotation.
  14498. * x, y, z are Euler angles expressed in radians.
  14499. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14500. * This means this rotation is made in the mesh local space only.
  14501. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14502. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14503. * ```javascript
  14504. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14505. * ```
  14506. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14507. * 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.
  14508. * @param x Rotation to add
  14509. * @param y Rotation to add
  14510. * @param z Rotation to add
  14511. * @returns the TransformNode.
  14512. */
  14513. addRotation(x: number, y: number, z: number): TransformNode;
  14514. /**
  14515. * @hidden
  14516. */
  14517. protected _getEffectiveParent(): Nullable<Node>;
  14518. /**
  14519. * Computes the world matrix of the node
  14520. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14521. * @returns the world matrix
  14522. */
  14523. computeWorldMatrix(force?: boolean): Matrix;
  14524. /**
  14525. * Resets this nodeTransform's local matrix to Matrix.Identity().
  14526. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  14527. */
  14528. resetLocalMatrix(independentOfChildren?: boolean): void;
  14529. protected _afterComputeWorldMatrix(): void;
  14530. /**
  14531. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14532. * @param func callback function to add
  14533. *
  14534. * @returns the TransformNode.
  14535. */
  14536. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14537. /**
  14538. * Removes a registered callback function.
  14539. * @param func callback function to remove
  14540. * @returns the TransformNode.
  14541. */
  14542. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14543. /**
  14544. * Gets the position of the current mesh in camera space
  14545. * @param camera defines the camera to use
  14546. * @returns a position
  14547. */
  14548. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14549. /**
  14550. * Returns the distance from the mesh to the active camera
  14551. * @param camera defines the camera to use
  14552. * @returns the distance
  14553. */
  14554. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14555. /**
  14556. * Clone the current transform node
  14557. * @param name Name of the new clone
  14558. * @param newParent New parent for the clone
  14559. * @param doNotCloneChildren Do not clone children hierarchy
  14560. * @returns the new transform node
  14561. */
  14562. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14563. /**
  14564. * Serializes the objects information.
  14565. * @param currentSerializationObject defines the object to serialize in
  14566. * @returns the serialized object
  14567. */
  14568. serialize(currentSerializationObject?: any): any;
  14569. /**
  14570. * Returns a new TransformNode object parsed from the source provided.
  14571. * @param parsedTransformNode is the source.
  14572. * @param scene the scne the object belongs to
  14573. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14574. * @returns a new TransformNode object parsed from the source provided.
  14575. */
  14576. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14577. /**
  14578. * Get all child-transformNodes of this node
  14579. * @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
  14580. * @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
  14581. * @returns an array of TransformNode
  14582. */
  14583. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14584. /**
  14585. * Releases resources associated with this transform node.
  14586. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14587. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14588. */
  14589. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14590. /**
  14591. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14592. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14593. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14594. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14595. * @returns the current mesh
  14596. */
  14597. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14598. private _syncAbsoluteScalingAndRotation;
  14599. }
  14600. }
  14601. declare module BABYLON {
  14602. /**
  14603. * Defines the types of pose enabled controllers that are supported
  14604. */
  14605. export enum PoseEnabledControllerType {
  14606. /**
  14607. * HTC Vive
  14608. */
  14609. VIVE = 0,
  14610. /**
  14611. * Oculus Rift
  14612. */
  14613. OCULUS = 1,
  14614. /**
  14615. * Windows mixed reality
  14616. */
  14617. WINDOWS = 2,
  14618. /**
  14619. * Samsung gear VR
  14620. */
  14621. GEAR_VR = 3,
  14622. /**
  14623. * Google Daydream
  14624. */
  14625. DAYDREAM = 4,
  14626. /**
  14627. * Generic
  14628. */
  14629. GENERIC = 5
  14630. }
  14631. /**
  14632. * Defines the MutableGamepadButton interface for the state of a gamepad button
  14633. */
  14634. export interface MutableGamepadButton {
  14635. /**
  14636. * Value of the button/trigger
  14637. */
  14638. value: number;
  14639. /**
  14640. * If the button/trigger is currently touched
  14641. */
  14642. touched: boolean;
  14643. /**
  14644. * If the button/trigger is currently pressed
  14645. */
  14646. pressed: boolean;
  14647. }
  14648. /**
  14649. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  14650. * @hidden
  14651. */
  14652. export interface ExtendedGamepadButton extends GamepadButton {
  14653. /**
  14654. * If the button/trigger is currently pressed
  14655. */
  14656. readonly pressed: boolean;
  14657. /**
  14658. * If the button/trigger is currently touched
  14659. */
  14660. readonly touched: boolean;
  14661. /**
  14662. * Value of the button/trigger
  14663. */
  14664. readonly value: number;
  14665. }
  14666. /** @hidden */
  14667. export interface _GamePadFactory {
  14668. /**
  14669. * Returns whether or not the current gamepad can be created for this type of controller.
  14670. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  14671. * @returns true if it can be created, otherwise false
  14672. */
  14673. canCreate(gamepadInfo: any): boolean;
  14674. /**
  14675. * Creates a new instance of the Gamepad.
  14676. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  14677. * @returns the new gamepad instance
  14678. */
  14679. create(gamepadInfo: any): Gamepad;
  14680. }
  14681. /**
  14682. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14683. */
  14684. export class PoseEnabledControllerHelper {
  14685. /** @hidden */
  14686. static _ControllerFactories: _GamePadFactory[];
  14687. /** @hidden */
  14688. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  14689. /**
  14690. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14691. * @param vrGamepad the gamepad to initialized
  14692. * @returns a vr controller of the type the gamepad identified as
  14693. */
  14694. static InitiateController(vrGamepad: any): Gamepad;
  14695. }
  14696. /**
  14697. * Defines the PoseEnabledController object that contains state of a vr capable controller
  14698. */
  14699. export class PoseEnabledController extends Gamepad implements PoseControlled {
  14700. /**
  14701. * If the controller is used in a webXR session
  14702. */
  14703. isXR: boolean;
  14704. private _deviceRoomPosition;
  14705. private _deviceRoomRotationQuaternion;
  14706. /**
  14707. * The device position in babylon space
  14708. */
  14709. devicePosition: Vector3;
  14710. /**
  14711. * The device rotation in babylon space
  14712. */
  14713. deviceRotationQuaternion: Quaternion;
  14714. /**
  14715. * The scale factor of the device in babylon space
  14716. */
  14717. deviceScaleFactor: number;
  14718. /**
  14719. * (Likely devicePosition should be used instead) The device position in its room space
  14720. */
  14721. position: Vector3;
  14722. /**
  14723. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  14724. */
  14725. rotationQuaternion: Quaternion;
  14726. /**
  14727. * The type of controller (Eg. Windows mixed reality)
  14728. */
  14729. controllerType: PoseEnabledControllerType;
  14730. protected _calculatedPosition: Vector3;
  14731. private _calculatedRotation;
  14732. /**
  14733. * The raw pose from the device
  14734. */
  14735. rawPose: DevicePose;
  14736. private _trackPosition;
  14737. private _maxRotationDistFromHeadset;
  14738. private _draggedRoomRotation;
  14739. /**
  14740. * @hidden
  14741. */
  14742. _disableTrackPosition(fixedPosition: Vector3): void;
  14743. /**
  14744. * Internal, the mesh attached to the controller
  14745. * @hidden
  14746. */
  14747. _mesh: Nullable<AbstractMesh>;
  14748. private _poseControlledCamera;
  14749. private _leftHandSystemQuaternion;
  14750. /**
  14751. * Internal, matrix used to convert room space to babylon space
  14752. * @hidden
  14753. */
  14754. _deviceToWorld: Matrix;
  14755. /**
  14756. * Node to be used when casting a ray from the controller
  14757. * @hidden
  14758. */
  14759. _pointingPoseNode: Nullable<TransformNode>;
  14760. /**
  14761. * Name of the child mesh that can be used to cast a ray from the controller
  14762. */
  14763. static readonly POINTING_POSE: string;
  14764. /**
  14765. * Creates a new PoseEnabledController from a gamepad
  14766. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  14767. */
  14768. constructor(browserGamepad: any);
  14769. private _workingMatrix;
  14770. /**
  14771. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  14772. */
  14773. update(): void;
  14774. /**
  14775. * Updates only the pose device and mesh without doing any button event checking
  14776. */
  14777. protected _updatePoseAndMesh(): void;
  14778. /**
  14779. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  14780. * @param poseData raw pose fromthe device
  14781. */
  14782. updateFromDevice(poseData: DevicePose): void;
  14783. /**
  14784. * @hidden
  14785. */
  14786. _meshAttachedObservable: Observable<AbstractMesh>;
  14787. /**
  14788. * Attaches a mesh to the controller
  14789. * @param mesh the mesh to be attached
  14790. */
  14791. attachToMesh(mesh: AbstractMesh): void;
  14792. /**
  14793. * Attaches the controllers mesh to a camera
  14794. * @param camera the camera the mesh should be attached to
  14795. */
  14796. attachToPoseControlledCamera(camera: TargetCamera): void;
  14797. /**
  14798. * Disposes of the controller
  14799. */
  14800. dispose(): void;
  14801. /**
  14802. * The mesh that is attached to the controller
  14803. */
  14804. get mesh(): Nullable<AbstractMesh>;
  14805. /**
  14806. * Gets the ray of the controller in the direction the controller is pointing
  14807. * @param length the length the resulting ray should be
  14808. * @returns a ray in the direction the controller is pointing
  14809. */
  14810. getForwardRay(length?: number): Ray;
  14811. }
  14812. }
  14813. declare module BABYLON {
  14814. /**
  14815. * Defines the WebVRController object that represents controllers tracked in 3D space
  14816. */
  14817. export abstract class WebVRController extends PoseEnabledController {
  14818. /**
  14819. * Internal, the default controller model for the controller
  14820. */
  14821. protected _defaultModel: Nullable<AbstractMesh>;
  14822. /**
  14823. * Fired when the trigger state has changed
  14824. */
  14825. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  14826. /**
  14827. * Fired when the main button state has changed
  14828. */
  14829. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14830. /**
  14831. * Fired when the secondary button state has changed
  14832. */
  14833. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14834. /**
  14835. * Fired when the pad state has changed
  14836. */
  14837. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  14838. /**
  14839. * Fired when controllers stick values have changed
  14840. */
  14841. onPadValuesChangedObservable: Observable<StickValues>;
  14842. /**
  14843. * Array of button availible on the controller
  14844. */
  14845. protected _buttons: Array<MutableGamepadButton>;
  14846. private _onButtonStateChange;
  14847. /**
  14848. * Fired when a controller button's state has changed
  14849. * @param callback the callback containing the button that was modified
  14850. */
  14851. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  14852. /**
  14853. * X and Y axis corresponding to the controllers joystick
  14854. */
  14855. pad: StickValues;
  14856. /**
  14857. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  14858. */
  14859. hand: string;
  14860. /**
  14861. * The default controller model for the controller
  14862. */
  14863. get defaultModel(): Nullable<AbstractMesh>;
  14864. /**
  14865. * Creates a new WebVRController from a gamepad
  14866. * @param vrGamepad the gamepad that the WebVRController should be created from
  14867. */
  14868. constructor(vrGamepad: any);
  14869. /**
  14870. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  14871. */
  14872. update(): void;
  14873. /**
  14874. * Function to be called when a button is modified
  14875. */
  14876. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  14877. /**
  14878. * Loads a mesh and attaches it to the controller
  14879. * @param scene the scene the mesh should be added to
  14880. * @param meshLoaded callback for when the mesh has been loaded
  14881. */
  14882. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  14883. private _setButtonValue;
  14884. private _changes;
  14885. private _checkChanges;
  14886. /**
  14887. * Disposes of th webVRCOntroller
  14888. */
  14889. dispose(): void;
  14890. }
  14891. }
  14892. declare module BABYLON {
  14893. /**
  14894. * The HemisphericLight simulates the ambient environment light,
  14895. * so the passed direction is the light reflection direction, not the incoming direction.
  14896. */
  14897. export class HemisphericLight extends Light {
  14898. /**
  14899. * The groundColor is the light in the opposite direction to the one specified during creation.
  14900. * 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.
  14901. */
  14902. groundColor: Color3;
  14903. /**
  14904. * The light reflection direction, not the incoming direction.
  14905. */
  14906. direction: Vector3;
  14907. /**
  14908. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  14909. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  14910. * The HemisphericLight can't cast shadows.
  14911. * Documentation : https://doc.babylonjs.com/babylon101/lights
  14912. * @param name The friendly name of the light
  14913. * @param direction The direction of the light reflection
  14914. * @param scene The scene the light belongs to
  14915. */
  14916. constructor(name: string, direction: Vector3, scene: Scene);
  14917. protected _buildUniformLayout(): void;
  14918. /**
  14919. * Returns the string "HemisphericLight".
  14920. * @return The class name
  14921. */
  14922. getClassName(): string;
  14923. /**
  14924. * Sets the HemisphericLight direction towards the passed target (Vector3).
  14925. * Returns the updated direction.
  14926. * @param target The target the direction should point to
  14927. * @return The computed direction
  14928. */
  14929. setDirectionToTarget(target: Vector3): Vector3;
  14930. /**
  14931. * Returns the shadow generator associated to the light.
  14932. * @returns Always null for hemispheric lights because it does not support shadows.
  14933. */
  14934. getShadowGenerator(): Nullable<IShadowGenerator>;
  14935. /**
  14936. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  14937. * @param effect The effect to update
  14938. * @param lightIndex The index of the light in the effect to update
  14939. * @returns The hemispheric light
  14940. */
  14941. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  14942. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  14943. /**
  14944. * Computes the world matrix of the node
  14945. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14946. * @param useWasUpdatedFlag defines a reserved property
  14947. * @returns the world matrix
  14948. */
  14949. computeWorldMatrix(): Matrix;
  14950. /**
  14951. * Returns the integer 3.
  14952. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  14953. */
  14954. getTypeID(): number;
  14955. /**
  14956. * Prepares the list of defines specific to the light type.
  14957. * @param defines the list of defines
  14958. * @param lightIndex defines the index of the light for the effect
  14959. */
  14960. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  14961. }
  14962. }
  14963. declare module BABYLON {
  14964. /** @hidden */
  14965. export var vrMultiviewToSingleviewPixelShader: {
  14966. name: string;
  14967. shader: string;
  14968. };
  14969. }
  14970. declare module BABYLON {
  14971. /**
  14972. * Renders to multiple views with a single draw call
  14973. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  14974. */
  14975. export class MultiviewRenderTarget extends RenderTargetTexture {
  14976. /**
  14977. * Creates a multiview render target
  14978. * @param scene scene used with the render target
  14979. * @param size the size of the render target (used for each view)
  14980. */
  14981. constructor(scene: Scene, size?: number | {
  14982. width: number;
  14983. height: number;
  14984. } | {
  14985. ratio: number;
  14986. });
  14987. /**
  14988. * @hidden
  14989. * @param faceIndex the face index, if its a cube texture
  14990. */
  14991. _bindFrameBuffer(faceIndex?: number): void;
  14992. /**
  14993. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  14994. * @returns the view count
  14995. */
  14996. getViewCount(): number;
  14997. }
  14998. }
  14999. declare module BABYLON {
  15000. /**
  15001. * Represents a camera frustum
  15002. */
  15003. export class Frustum {
  15004. /**
  15005. * Gets the planes representing the frustum
  15006. * @param transform matrix to be applied to the returned planes
  15007. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  15008. */
  15009. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  15010. /**
  15011. * Gets the near frustum plane transformed by the transform matrix
  15012. * @param transform transformation matrix to be applied to the resulting frustum plane
  15013. * @param frustumPlane the resuling frustum plane
  15014. */
  15015. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15016. /**
  15017. * Gets the far frustum plane transformed by the transform matrix
  15018. * @param transform transformation matrix to be applied to the resulting frustum plane
  15019. * @param frustumPlane the resuling frustum plane
  15020. */
  15021. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15022. /**
  15023. * Gets the left frustum plane transformed by the transform matrix
  15024. * @param transform transformation matrix to be applied to the resulting frustum plane
  15025. * @param frustumPlane the resuling frustum plane
  15026. */
  15027. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15028. /**
  15029. * Gets the right frustum plane transformed by the transform matrix
  15030. * @param transform transformation matrix to be applied to the resulting frustum plane
  15031. * @param frustumPlane the resuling frustum plane
  15032. */
  15033. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15034. /**
  15035. * Gets the top frustum plane transformed by the transform matrix
  15036. * @param transform transformation matrix to be applied to the resulting frustum plane
  15037. * @param frustumPlane the resuling frustum plane
  15038. */
  15039. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15040. /**
  15041. * Gets the bottom frustum plane transformed by the transform matrix
  15042. * @param transform transformation matrix to be applied to the resulting frustum plane
  15043. * @param frustumPlane the resuling frustum plane
  15044. */
  15045. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15046. /**
  15047. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  15048. * @param transform transformation matrix to be applied to the resulting frustum planes
  15049. * @param frustumPlanes the resuling frustum planes
  15050. */
  15051. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  15052. }
  15053. }
  15054. declare module BABYLON {
  15055. interface Engine {
  15056. /**
  15057. * Creates a new multiview render target
  15058. * @param width defines the width of the texture
  15059. * @param height defines the height of the texture
  15060. * @returns the created multiview texture
  15061. */
  15062. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  15063. /**
  15064. * Binds a multiview framebuffer to be drawn to
  15065. * @param multiviewTexture texture to bind
  15066. */
  15067. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  15068. }
  15069. interface Camera {
  15070. /**
  15071. * @hidden
  15072. * 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)
  15073. */
  15074. _useMultiviewToSingleView: boolean;
  15075. /**
  15076. * @hidden
  15077. * 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)
  15078. */
  15079. _multiviewTexture: Nullable<RenderTargetTexture>;
  15080. /**
  15081. * @hidden
  15082. * ensures the multiview texture of the camera exists and has the specified width/height
  15083. * @param width height to set on the multiview texture
  15084. * @param height width to set on the multiview texture
  15085. */
  15086. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  15087. }
  15088. interface Scene {
  15089. /** @hidden */
  15090. _transformMatrixR: Matrix;
  15091. /** @hidden */
  15092. _multiviewSceneUbo: Nullable<UniformBuffer>;
  15093. /** @hidden */
  15094. _createMultiviewUbo(): void;
  15095. /** @hidden */
  15096. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  15097. /** @hidden */
  15098. _renderMultiviewToSingleView(camera: Camera): void;
  15099. }
  15100. }
  15101. declare module BABYLON {
  15102. /**
  15103. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  15104. * This will not be used for webXR as it supports displaying texture arrays directly
  15105. */
  15106. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  15107. /**
  15108. * Initializes a VRMultiviewToSingleview
  15109. * @param name name of the post process
  15110. * @param camera camera to be applied to
  15111. * @param scaleFactor scaling factor to the size of the output texture
  15112. */
  15113. constructor(name: string, camera: Camera, scaleFactor: number);
  15114. }
  15115. }
  15116. declare module BABYLON {
  15117. /**
  15118. * Interface used to define additional presentation attributes
  15119. */
  15120. export interface IVRPresentationAttributes {
  15121. /**
  15122. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  15123. */
  15124. highRefreshRate: boolean;
  15125. /**
  15126. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  15127. */
  15128. foveationLevel: number;
  15129. }
  15130. interface Engine {
  15131. /** @hidden */
  15132. _vrDisplay: any;
  15133. /** @hidden */
  15134. _vrSupported: boolean;
  15135. /** @hidden */
  15136. _oldSize: Size;
  15137. /** @hidden */
  15138. _oldHardwareScaleFactor: number;
  15139. /** @hidden */
  15140. _vrExclusivePointerMode: boolean;
  15141. /** @hidden */
  15142. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  15143. /** @hidden */
  15144. _onVRDisplayPointerRestricted: () => void;
  15145. /** @hidden */
  15146. _onVRDisplayPointerUnrestricted: () => void;
  15147. /** @hidden */
  15148. _onVrDisplayConnect: Nullable<(display: any) => void>;
  15149. /** @hidden */
  15150. _onVrDisplayDisconnect: Nullable<() => void>;
  15151. /** @hidden */
  15152. _onVrDisplayPresentChange: Nullable<() => void>;
  15153. /**
  15154. * Observable signaled when VR display mode changes
  15155. */
  15156. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  15157. /**
  15158. * Observable signaled when VR request present is complete
  15159. */
  15160. onVRRequestPresentComplete: Observable<boolean>;
  15161. /**
  15162. * Observable signaled when VR request present starts
  15163. */
  15164. onVRRequestPresentStart: Observable<Engine>;
  15165. /**
  15166. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  15167. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  15168. */
  15169. isInVRExclusivePointerMode: boolean;
  15170. /**
  15171. * Gets a boolean indicating if a webVR device was detected
  15172. * @returns true if a webVR device was detected
  15173. */
  15174. isVRDevicePresent(): boolean;
  15175. /**
  15176. * Gets the current webVR device
  15177. * @returns the current webVR device (or null)
  15178. */
  15179. getVRDevice(): any;
  15180. /**
  15181. * Initializes a webVR display and starts listening to display change events
  15182. * The onVRDisplayChangedObservable will be notified upon these changes
  15183. * @returns A promise containing a VRDisplay and if vr is supported
  15184. */
  15185. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  15186. /** @hidden */
  15187. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  15188. /**
  15189. * Gets or sets the presentation attributes used to configure VR rendering
  15190. */
  15191. vrPresentationAttributes?: IVRPresentationAttributes;
  15192. /**
  15193. * Call this function to switch to webVR mode
  15194. * Will do nothing if webVR is not supported or if there is no webVR device
  15195. * @param options the webvr options provided to the camera. mainly used for multiview
  15196. * @see http://doc.babylonjs.com/how_to/webvr_camera
  15197. */
  15198. enableVR(options: WebVROptions): void;
  15199. /** @hidden */
  15200. _onVRFullScreenTriggered(): void;
  15201. }
  15202. }
  15203. declare module BABYLON {
  15204. /**
  15205. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  15206. * IMPORTANT!! The data is right-hand data.
  15207. * @export
  15208. * @interface DevicePose
  15209. */
  15210. export interface DevicePose {
  15211. /**
  15212. * The position of the device, values in array are [x,y,z].
  15213. */
  15214. readonly position: Nullable<Float32Array>;
  15215. /**
  15216. * The linearVelocity of the device, values in array are [x,y,z].
  15217. */
  15218. readonly linearVelocity: Nullable<Float32Array>;
  15219. /**
  15220. * The linearAcceleration of the device, values in array are [x,y,z].
  15221. */
  15222. readonly linearAcceleration: Nullable<Float32Array>;
  15223. /**
  15224. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  15225. */
  15226. readonly orientation: Nullable<Float32Array>;
  15227. /**
  15228. * The angularVelocity of the device, values in array are [x,y,z].
  15229. */
  15230. readonly angularVelocity: Nullable<Float32Array>;
  15231. /**
  15232. * The angularAcceleration of the device, values in array are [x,y,z].
  15233. */
  15234. readonly angularAcceleration: Nullable<Float32Array>;
  15235. }
  15236. /**
  15237. * Interface representing a pose controlled object in Babylon.
  15238. * A pose controlled object has both regular pose values as well as pose values
  15239. * from an external device such as a VR head mounted display
  15240. */
  15241. export interface PoseControlled {
  15242. /**
  15243. * The position of the object in babylon space.
  15244. */
  15245. position: Vector3;
  15246. /**
  15247. * The rotation quaternion of the object in babylon space.
  15248. */
  15249. rotationQuaternion: Quaternion;
  15250. /**
  15251. * The position of the device in babylon space.
  15252. */
  15253. devicePosition?: Vector3;
  15254. /**
  15255. * The rotation quaternion of the device in babylon space.
  15256. */
  15257. deviceRotationQuaternion: Quaternion;
  15258. /**
  15259. * The raw pose coming from the device.
  15260. */
  15261. rawPose: Nullable<DevicePose>;
  15262. /**
  15263. * The scale of the device to be used when translating from device space to babylon space.
  15264. */
  15265. deviceScaleFactor: number;
  15266. /**
  15267. * Updates the poseControlled values based on the input device pose.
  15268. * @param poseData the pose data to update the object with
  15269. */
  15270. updateFromDevice(poseData: DevicePose): void;
  15271. }
  15272. /**
  15273. * Set of options to customize the webVRCamera
  15274. */
  15275. export interface WebVROptions {
  15276. /**
  15277. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  15278. */
  15279. trackPosition?: boolean;
  15280. /**
  15281. * Sets the scale of the vrDevice in babylon space. (default: 1)
  15282. */
  15283. positionScale?: number;
  15284. /**
  15285. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  15286. */
  15287. displayName?: string;
  15288. /**
  15289. * Should the native controller meshes be initialized. (default: true)
  15290. */
  15291. controllerMeshes?: boolean;
  15292. /**
  15293. * Creating a default HemiLight only on controllers. (default: true)
  15294. */
  15295. defaultLightingOnControllers?: boolean;
  15296. /**
  15297. * If you don't want to use the default VR button of the helper. (default: false)
  15298. */
  15299. useCustomVRButton?: boolean;
  15300. /**
  15301. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  15302. */
  15303. customVRButton?: HTMLButtonElement;
  15304. /**
  15305. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  15306. */
  15307. rayLength?: number;
  15308. /**
  15309. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  15310. */
  15311. defaultHeight?: number;
  15312. /**
  15313. * If multiview should be used if availible (default: false)
  15314. */
  15315. useMultiview?: boolean;
  15316. }
  15317. /**
  15318. * This represents a WebVR camera.
  15319. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  15320. * @example http://doc.babylonjs.com/how_to/webvr_camera
  15321. */
  15322. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  15323. private webVROptions;
  15324. /**
  15325. * @hidden
  15326. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  15327. */
  15328. _vrDevice: any;
  15329. /**
  15330. * The rawPose of the vrDevice.
  15331. */
  15332. rawPose: Nullable<DevicePose>;
  15333. private _onVREnabled;
  15334. private _specsVersion;
  15335. private _attached;
  15336. private _frameData;
  15337. protected _descendants: Array<Node>;
  15338. private _deviceRoomPosition;
  15339. /** @hidden */
  15340. _deviceRoomRotationQuaternion: Quaternion;
  15341. private _standingMatrix;
  15342. /**
  15343. * Represents device position in babylon space.
  15344. */
  15345. devicePosition: Vector3;
  15346. /**
  15347. * Represents device rotation in babylon space.
  15348. */
  15349. deviceRotationQuaternion: Quaternion;
  15350. /**
  15351. * The scale of the device to be used when translating from device space to babylon space.
  15352. */
  15353. deviceScaleFactor: number;
  15354. private _deviceToWorld;
  15355. private _worldToDevice;
  15356. /**
  15357. * References to the webVR controllers for the vrDevice.
  15358. */
  15359. controllers: Array<WebVRController>;
  15360. /**
  15361. * Emits an event when a controller is attached.
  15362. */
  15363. onControllersAttachedObservable: Observable<WebVRController[]>;
  15364. /**
  15365. * Emits an event when a controller's mesh has been loaded;
  15366. */
  15367. onControllerMeshLoadedObservable: Observable<WebVRController>;
  15368. /**
  15369. * Emits an event when the HMD's pose has been updated.
  15370. */
  15371. onPoseUpdatedFromDeviceObservable: Observable<any>;
  15372. private _poseSet;
  15373. /**
  15374. * If the rig cameras be used as parent instead of this camera.
  15375. */
  15376. rigParenting: boolean;
  15377. private _lightOnControllers;
  15378. private _defaultHeight?;
  15379. /**
  15380. * Instantiates a WebVRFreeCamera.
  15381. * @param name The name of the WebVRFreeCamera
  15382. * @param position The starting anchor position for the camera
  15383. * @param scene The scene the camera belongs to
  15384. * @param webVROptions a set of customizable options for the webVRCamera
  15385. */
  15386. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  15387. /**
  15388. * Gets the device distance from the ground in meters.
  15389. * @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.
  15390. */
  15391. deviceDistanceToRoomGround(): number;
  15392. /**
  15393. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15394. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  15395. */
  15396. useStandingMatrix(callback?: (bool: boolean) => void): void;
  15397. /**
  15398. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15399. * @returns A promise with a boolean set to if the standing matrix is supported.
  15400. */
  15401. useStandingMatrixAsync(): Promise<boolean>;
  15402. /**
  15403. * Disposes the camera
  15404. */
  15405. dispose(): void;
  15406. /**
  15407. * Gets a vrController by name.
  15408. * @param name The name of the controller to retreive
  15409. * @returns the controller matching the name specified or null if not found
  15410. */
  15411. getControllerByName(name: string): Nullable<WebVRController>;
  15412. private _leftController;
  15413. /**
  15414. * The controller corresponding to the users left hand.
  15415. */
  15416. get leftController(): Nullable<WebVRController>;
  15417. private _rightController;
  15418. /**
  15419. * The controller corresponding to the users right hand.
  15420. */
  15421. get rightController(): Nullable<WebVRController>;
  15422. /**
  15423. * Casts a ray forward from the vrCamera's gaze.
  15424. * @param length Length of the ray (default: 100)
  15425. * @returns the ray corresponding to the gaze
  15426. */
  15427. getForwardRay(length?: number): Ray;
  15428. /**
  15429. * @hidden
  15430. * Updates the camera based on device's frame data
  15431. */
  15432. _checkInputs(): void;
  15433. /**
  15434. * Updates the poseControlled values based on the input device pose.
  15435. * @param poseData Pose coming from the device
  15436. */
  15437. updateFromDevice(poseData: DevicePose): void;
  15438. private _htmlElementAttached;
  15439. private _detachIfAttached;
  15440. /**
  15441. * WebVR's attach control will start broadcasting frames to the device.
  15442. * Note that in certain browsers (chrome for example) this function must be called
  15443. * within a user-interaction callback. Example:
  15444. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  15445. *
  15446. * @param element html element to attach the vrDevice to
  15447. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  15448. */
  15449. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  15450. /**
  15451. * Detaches the camera from the html element and disables VR
  15452. *
  15453. * @param element html element to detach from
  15454. */
  15455. detachControl(element: HTMLElement): void;
  15456. /**
  15457. * @returns the name of this class
  15458. */
  15459. getClassName(): string;
  15460. /**
  15461. * Calls resetPose on the vrDisplay
  15462. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  15463. */
  15464. resetToCurrentRotation(): void;
  15465. /**
  15466. * @hidden
  15467. * Updates the rig cameras (left and right eye)
  15468. */
  15469. _updateRigCameras(): void;
  15470. private _workingVector;
  15471. private _oneVector;
  15472. private _workingMatrix;
  15473. private updateCacheCalled;
  15474. private _correctPositionIfNotTrackPosition;
  15475. /**
  15476. * @hidden
  15477. * Updates the cached values of the camera
  15478. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  15479. */
  15480. _updateCache(ignoreParentClass?: boolean): void;
  15481. /**
  15482. * @hidden
  15483. * Get current device position in babylon world
  15484. */
  15485. _computeDevicePosition(): void;
  15486. /**
  15487. * Updates the current device position and rotation in the babylon world
  15488. */
  15489. update(): void;
  15490. /**
  15491. * @hidden
  15492. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  15493. * @returns an identity matrix
  15494. */
  15495. _getViewMatrix(): Matrix;
  15496. private _tmpMatrix;
  15497. /**
  15498. * This function is called by the two RIG cameras.
  15499. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  15500. * @hidden
  15501. */
  15502. _getWebVRViewMatrix(): Matrix;
  15503. /** @hidden */
  15504. _getWebVRProjectionMatrix(): Matrix;
  15505. private _onGamepadConnectedObserver;
  15506. private _onGamepadDisconnectedObserver;
  15507. private _updateCacheWhenTrackingDisabledObserver;
  15508. /**
  15509. * Initializes the controllers and their meshes
  15510. */
  15511. initControllers(): void;
  15512. }
  15513. }
  15514. declare module BABYLON {
  15515. /**
  15516. * Size options for a post process
  15517. */
  15518. export type PostProcessOptions = {
  15519. width: number;
  15520. height: number;
  15521. };
  15522. /**
  15523. * PostProcess can be used to apply a shader to a texture after it has been rendered
  15524. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  15525. */
  15526. export class PostProcess {
  15527. /** Name of the PostProcess. */
  15528. name: string;
  15529. /**
  15530. * Gets or sets the unique id of the post process
  15531. */
  15532. uniqueId: number;
  15533. /**
  15534. * Width of the texture to apply the post process on
  15535. */
  15536. width: number;
  15537. /**
  15538. * Height of the texture to apply the post process on
  15539. */
  15540. height: number;
  15541. /**
  15542. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  15543. * @hidden
  15544. */
  15545. _outputTexture: Nullable<InternalTexture>;
  15546. /**
  15547. * Sampling mode used by the shader
  15548. * See https://doc.babylonjs.com/classes/3.1/texture
  15549. */
  15550. renderTargetSamplingMode: number;
  15551. /**
  15552. * Clear color to use when screen clearing
  15553. */
  15554. clearColor: Color4;
  15555. /**
  15556. * If the buffer needs to be cleared before applying the post process. (default: true)
  15557. * Should be set to false if shader will overwrite all previous pixels.
  15558. */
  15559. autoClear: boolean;
  15560. /**
  15561. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  15562. */
  15563. alphaMode: number;
  15564. /**
  15565. * Sets the setAlphaBlendConstants of the babylon engine
  15566. */
  15567. alphaConstants: Color4;
  15568. /**
  15569. * Animations to be used for the post processing
  15570. */
  15571. animations: Animation[];
  15572. /**
  15573. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  15574. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  15575. */
  15576. enablePixelPerfectMode: boolean;
  15577. /**
  15578. * Force the postprocess to be applied without taking in account viewport
  15579. */
  15580. forceFullscreenViewport: boolean;
  15581. /**
  15582. * List of inspectable custom properties (used by the Inspector)
  15583. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15584. */
  15585. inspectableCustomProperties: IInspectable[];
  15586. /**
  15587. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  15588. *
  15589. * | Value | Type | Description |
  15590. * | ----- | ----------------------------------- | ----------- |
  15591. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  15592. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  15593. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  15594. *
  15595. */
  15596. scaleMode: number;
  15597. /**
  15598. * Force textures to be a power of two (default: false)
  15599. */
  15600. alwaysForcePOT: boolean;
  15601. private _samples;
  15602. /**
  15603. * Number of sample textures (default: 1)
  15604. */
  15605. get samples(): number;
  15606. set samples(n: number);
  15607. /**
  15608. * Modify the scale of the post process to be the same as the viewport (default: false)
  15609. */
  15610. adaptScaleToCurrentViewport: boolean;
  15611. private _camera;
  15612. private _scene;
  15613. private _engine;
  15614. private _options;
  15615. private _reusable;
  15616. private _textureType;
  15617. private _textureFormat;
  15618. /**
  15619. * Smart array of input and output textures for the post process.
  15620. * @hidden
  15621. */
  15622. _textures: SmartArray<InternalTexture>;
  15623. /**
  15624. * The index in _textures that corresponds to the output texture.
  15625. * @hidden
  15626. */
  15627. _currentRenderTextureInd: number;
  15628. private _effect;
  15629. private _samplers;
  15630. private _fragmentUrl;
  15631. private _vertexUrl;
  15632. private _parameters;
  15633. private _scaleRatio;
  15634. protected _indexParameters: any;
  15635. private _shareOutputWithPostProcess;
  15636. private _texelSize;
  15637. private _forcedOutputTexture;
  15638. /**
  15639. * Returns the fragment url or shader name used in the post process.
  15640. * @returns the fragment url or name in the shader store.
  15641. */
  15642. getEffectName(): string;
  15643. /**
  15644. * An event triggered when the postprocess is activated.
  15645. */
  15646. onActivateObservable: Observable<Camera>;
  15647. private _onActivateObserver;
  15648. /**
  15649. * A function that is added to the onActivateObservable
  15650. */
  15651. set onActivate(callback: Nullable<(camera: Camera) => void>);
  15652. /**
  15653. * An event triggered when the postprocess changes its size.
  15654. */
  15655. onSizeChangedObservable: Observable<PostProcess>;
  15656. private _onSizeChangedObserver;
  15657. /**
  15658. * A function that is added to the onSizeChangedObservable
  15659. */
  15660. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  15661. /**
  15662. * An event triggered when the postprocess applies its effect.
  15663. */
  15664. onApplyObservable: Observable<Effect>;
  15665. private _onApplyObserver;
  15666. /**
  15667. * A function that is added to the onApplyObservable
  15668. */
  15669. set onApply(callback: (effect: Effect) => void);
  15670. /**
  15671. * An event triggered before rendering the postprocess
  15672. */
  15673. onBeforeRenderObservable: Observable<Effect>;
  15674. private _onBeforeRenderObserver;
  15675. /**
  15676. * A function that is added to the onBeforeRenderObservable
  15677. */
  15678. set onBeforeRender(callback: (effect: Effect) => void);
  15679. /**
  15680. * An event triggered after rendering the postprocess
  15681. */
  15682. onAfterRenderObservable: Observable<Effect>;
  15683. private _onAfterRenderObserver;
  15684. /**
  15685. * A function that is added to the onAfterRenderObservable
  15686. */
  15687. set onAfterRender(callback: (efect: Effect) => void);
  15688. /**
  15689. * 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
  15690. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  15691. */
  15692. get inputTexture(): InternalTexture;
  15693. set inputTexture(value: InternalTexture);
  15694. /**
  15695. * Gets the camera which post process is applied to.
  15696. * @returns The camera the post process is applied to.
  15697. */
  15698. getCamera(): Camera;
  15699. /**
  15700. * Gets the texel size of the postprocess.
  15701. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  15702. */
  15703. get texelSize(): Vector2;
  15704. /**
  15705. * Creates a new instance PostProcess
  15706. * @param name The name of the PostProcess.
  15707. * @param fragmentUrl The url of the fragment shader to be used.
  15708. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  15709. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  15710. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15711. * @param camera The camera to apply the render pass to.
  15712. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15713. * @param engine The engine which the post process will be applied. (default: current engine)
  15714. * @param reusable If the post process can be reused on the same frame. (default: false)
  15715. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  15716. * @param textureType Type of textures used when performing the post process. (default: 0)
  15717. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  15718. * @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
  15719. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  15720. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  15721. */
  15722. constructor(
  15723. /** Name of the PostProcess. */
  15724. 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);
  15725. /**
  15726. * Gets a string idenfifying the name of the class
  15727. * @returns "PostProcess" string
  15728. */
  15729. getClassName(): string;
  15730. /**
  15731. * Gets the engine which this post process belongs to.
  15732. * @returns The engine the post process was enabled with.
  15733. */
  15734. getEngine(): Engine;
  15735. /**
  15736. * The effect that is created when initializing the post process.
  15737. * @returns The created effect corresponding the the postprocess.
  15738. */
  15739. getEffect(): Effect;
  15740. /**
  15741. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  15742. * @param postProcess The post process to share the output with.
  15743. * @returns This post process.
  15744. */
  15745. shareOutputWith(postProcess: PostProcess): PostProcess;
  15746. /**
  15747. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  15748. * This should be called if the post process that shares output with this post process is disabled/disposed.
  15749. */
  15750. useOwnOutput(): void;
  15751. /**
  15752. * Updates the effect with the current post process compile time values and recompiles the shader.
  15753. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15754. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15755. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15756. * @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
  15757. * @param onCompiled Called when the shader has been compiled.
  15758. * @param onError Called if there is an error when compiling a shader.
  15759. */
  15760. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15761. /**
  15762. * The post process is reusable if it can be used multiple times within one frame.
  15763. * @returns If the post process is reusable
  15764. */
  15765. isReusable(): boolean;
  15766. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  15767. markTextureDirty(): void;
  15768. /**
  15769. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  15770. * 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.
  15771. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  15772. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  15773. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  15774. * @returns The target texture that was bound to be written to.
  15775. */
  15776. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  15777. /**
  15778. * If the post process is supported.
  15779. */
  15780. get isSupported(): boolean;
  15781. /**
  15782. * The aspect ratio of the output texture.
  15783. */
  15784. get aspectRatio(): number;
  15785. /**
  15786. * Get a value indicating if the post-process is ready to be used
  15787. * @returns true if the post-process is ready (shader is compiled)
  15788. */
  15789. isReady(): boolean;
  15790. /**
  15791. * Binds all textures and uniforms to the shader, this will be run on every pass.
  15792. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  15793. */
  15794. apply(): Nullable<Effect>;
  15795. private _disposeTextures;
  15796. /**
  15797. * Disposes the post process.
  15798. * @param camera The camera to dispose the post process on.
  15799. */
  15800. dispose(camera?: Camera): void;
  15801. }
  15802. }
  15803. declare module BABYLON {
  15804. /** @hidden */
  15805. export var kernelBlurVaryingDeclaration: {
  15806. name: string;
  15807. shader: string;
  15808. };
  15809. }
  15810. declare module BABYLON {
  15811. /** @hidden */
  15812. export var kernelBlurFragment: {
  15813. name: string;
  15814. shader: string;
  15815. };
  15816. }
  15817. declare module BABYLON {
  15818. /** @hidden */
  15819. export var kernelBlurFragment2: {
  15820. name: string;
  15821. shader: string;
  15822. };
  15823. }
  15824. declare module BABYLON {
  15825. /** @hidden */
  15826. export var kernelBlurPixelShader: {
  15827. name: string;
  15828. shader: string;
  15829. };
  15830. }
  15831. declare module BABYLON {
  15832. /** @hidden */
  15833. export var kernelBlurVertex: {
  15834. name: string;
  15835. shader: string;
  15836. };
  15837. }
  15838. declare module BABYLON {
  15839. /** @hidden */
  15840. export var kernelBlurVertexShader: {
  15841. name: string;
  15842. shader: string;
  15843. };
  15844. }
  15845. declare module BABYLON {
  15846. /**
  15847. * The Blur Post Process which blurs an image based on a kernel and direction.
  15848. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  15849. */
  15850. export class BlurPostProcess extends PostProcess {
  15851. /** The direction in which to blur the image. */
  15852. direction: Vector2;
  15853. private blockCompilation;
  15854. protected _kernel: number;
  15855. protected _idealKernel: number;
  15856. protected _packedFloat: boolean;
  15857. private _staticDefines;
  15858. /**
  15859. * Sets the length in pixels of the blur sample region
  15860. */
  15861. set kernel(v: number);
  15862. /**
  15863. * Gets the length in pixels of the blur sample region
  15864. */
  15865. get kernel(): number;
  15866. /**
  15867. * Sets wether or not the blur needs to unpack/repack floats
  15868. */
  15869. set packedFloat(v: boolean);
  15870. /**
  15871. * Gets wether or not the blur is unpacking/repacking floats
  15872. */
  15873. get packedFloat(): boolean;
  15874. /**
  15875. * Creates a new instance BlurPostProcess
  15876. * @param name The name of the effect.
  15877. * @param direction The direction in which to blur the image.
  15878. * @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.
  15879. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15880. * @param camera The camera to apply the render pass to.
  15881. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15882. * @param engine The engine which the post process will be applied. (default: current engine)
  15883. * @param reusable If the post process can be reused on the same frame. (default: false)
  15884. * @param textureType Type of textures used when performing the post process. (default: 0)
  15885. * @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)
  15886. */
  15887. constructor(name: string,
  15888. /** The direction in which to blur the image. */
  15889. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  15890. /**
  15891. * Updates the effect with the current post process compile time values and recompiles the shader.
  15892. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15893. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15894. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15895. * @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
  15896. * @param onCompiled Called when the shader has been compiled.
  15897. * @param onError Called if there is an error when compiling a shader.
  15898. */
  15899. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15900. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15901. /**
  15902. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  15903. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  15904. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  15905. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  15906. * The gaps between physical kernels are compensated for in the weighting of the samples
  15907. * @param idealKernel Ideal blur kernel.
  15908. * @return Nearest best kernel.
  15909. */
  15910. protected _nearestBestKernel(idealKernel: number): number;
  15911. /**
  15912. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  15913. * @param x The point on the Gaussian distribution to sample.
  15914. * @return the value of the Gaussian function at x.
  15915. */
  15916. protected _gaussianWeight(x: number): number;
  15917. /**
  15918. * Generates a string that can be used as a floating point number in GLSL.
  15919. * @param x Value to print.
  15920. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  15921. * @return GLSL float string.
  15922. */
  15923. protected _glslFloat(x: number, decimalFigures?: number): string;
  15924. }
  15925. }
  15926. declare module BABYLON {
  15927. /**
  15928. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15929. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15930. * You can then easily use it as a reflectionTexture on a flat surface.
  15931. * In case the surface is not a plane, please consider relying on reflection probes.
  15932. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15933. */
  15934. export class MirrorTexture extends RenderTargetTexture {
  15935. private scene;
  15936. /**
  15937. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  15938. * 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.
  15939. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15940. */
  15941. mirrorPlane: Plane;
  15942. /**
  15943. * Define the blur ratio used to blur the reflection if needed.
  15944. */
  15945. set blurRatio(value: number);
  15946. get blurRatio(): number;
  15947. /**
  15948. * Define the adaptive blur kernel used to blur the reflection if needed.
  15949. * This will autocompute the closest best match for the `blurKernel`
  15950. */
  15951. set adaptiveBlurKernel(value: number);
  15952. /**
  15953. * Define the blur kernel used to blur the reflection if needed.
  15954. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15955. */
  15956. set blurKernel(value: number);
  15957. /**
  15958. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  15959. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15960. */
  15961. set blurKernelX(value: number);
  15962. get blurKernelX(): number;
  15963. /**
  15964. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  15965. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15966. */
  15967. set blurKernelY(value: number);
  15968. get blurKernelY(): number;
  15969. private _autoComputeBlurKernel;
  15970. protected _onRatioRescale(): void;
  15971. private _updateGammaSpace;
  15972. private _imageProcessingConfigChangeObserver;
  15973. private _transformMatrix;
  15974. private _mirrorMatrix;
  15975. private _savedViewMatrix;
  15976. private _blurX;
  15977. private _blurY;
  15978. private _adaptiveBlurKernel;
  15979. private _blurKernelX;
  15980. private _blurKernelY;
  15981. private _blurRatio;
  15982. /**
  15983. * Instantiates a Mirror Texture.
  15984. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15985. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15986. * You can then easily use it as a reflectionTexture on a flat surface.
  15987. * In case the surface is not a plane, please consider relying on reflection probes.
  15988. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15989. * @param name
  15990. * @param size
  15991. * @param scene
  15992. * @param generateMipMaps
  15993. * @param type
  15994. * @param samplingMode
  15995. * @param generateDepthBuffer
  15996. */
  15997. constructor(name: string, size: number | {
  15998. width: number;
  15999. height: number;
  16000. } | {
  16001. ratio: number;
  16002. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  16003. private _preparePostProcesses;
  16004. /**
  16005. * Clone the mirror texture.
  16006. * @returns the cloned texture
  16007. */
  16008. clone(): MirrorTexture;
  16009. /**
  16010. * Serialize the texture to a JSON representation you could use in Parse later on
  16011. * @returns the serialized JSON representation
  16012. */
  16013. serialize(): any;
  16014. /**
  16015. * Dispose the texture and release its associated resources.
  16016. */
  16017. dispose(): void;
  16018. }
  16019. }
  16020. declare module BABYLON {
  16021. /**
  16022. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  16023. * @see http://doc.babylonjs.com/babylon101/materials#texture
  16024. */
  16025. export class Texture extends BaseTexture {
  16026. /**
  16027. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  16028. */
  16029. static SerializeBuffers: boolean;
  16030. /** @hidden */
  16031. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  16032. /** @hidden */
  16033. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  16034. /** @hidden */
  16035. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  16036. /** nearest is mag = nearest and min = nearest and mip = linear */
  16037. static readonly NEAREST_SAMPLINGMODE: number;
  16038. /** nearest is mag = nearest and min = nearest and mip = linear */
  16039. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  16040. /** Bilinear is mag = linear and min = linear and mip = nearest */
  16041. static readonly BILINEAR_SAMPLINGMODE: number;
  16042. /** Bilinear is mag = linear and min = linear and mip = nearest */
  16043. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  16044. /** Trilinear is mag = linear and min = linear and mip = linear */
  16045. static readonly TRILINEAR_SAMPLINGMODE: number;
  16046. /** Trilinear is mag = linear and min = linear and mip = linear */
  16047. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  16048. /** mag = nearest and min = nearest and mip = nearest */
  16049. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  16050. /** mag = nearest and min = linear and mip = nearest */
  16051. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  16052. /** mag = nearest and min = linear and mip = linear */
  16053. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  16054. /** mag = nearest and min = linear and mip = none */
  16055. static readonly NEAREST_LINEAR: number;
  16056. /** mag = nearest and min = nearest and mip = none */
  16057. static readonly NEAREST_NEAREST: number;
  16058. /** mag = linear and min = nearest and mip = nearest */
  16059. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  16060. /** mag = linear and min = nearest and mip = linear */
  16061. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  16062. /** mag = linear and min = linear and mip = none */
  16063. static readonly LINEAR_LINEAR: number;
  16064. /** mag = linear and min = nearest and mip = none */
  16065. static readonly LINEAR_NEAREST: number;
  16066. /** Explicit coordinates mode */
  16067. static readonly EXPLICIT_MODE: number;
  16068. /** Spherical coordinates mode */
  16069. static readonly SPHERICAL_MODE: number;
  16070. /** Planar coordinates mode */
  16071. static readonly PLANAR_MODE: number;
  16072. /** Cubic coordinates mode */
  16073. static readonly CUBIC_MODE: number;
  16074. /** Projection coordinates mode */
  16075. static readonly PROJECTION_MODE: number;
  16076. /** Inverse Cubic coordinates mode */
  16077. static readonly SKYBOX_MODE: number;
  16078. /** Inverse Cubic coordinates mode */
  16079. static readonly INVCUBIC_MODE: number;
  16080. /** Equirectangular coordinates mode */
  16081. static readonly EQUIRECTANGULAR_MODE: number;
  16082. /** Equirectangular Fixed coordinates mode */
  16083. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  16084. /** Equirectangular Fixed Mirrored coordinates mode */
  16085. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  16086. /** Texture is not repeating outside of 0..1 UVs */
  16087. static readonly CLAMP_ADDRESSMODE: number;
  16088. /** Texture is repeating outside of 0..1 UVs */
  16089. static readonly WRAP_ADDRESSMODE: number;
  16090. /** Texture is repeating and mirrored */
  16091. static readonly MIRROR_ADDRESSMODE: number;
  16092. /**
  16093. * 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
  16094. */
  16095. static UseSerializedUrlIfAny: boolean;
  16096. /**
  16097. * Define the url of the texture.
  16098. */
  16099. url: Nullable<string>;
  16100. /**
  16101. * Define an offset on the texture to offset the u coordinates of the UVs
  16102. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  16103. */
  16104. uOffset: number;
  16105. /**
  16106. * Define an offset on the texture to offset the v coordinates of the UVs
  16107. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  16108. */
  16109. vOffset: number;
  16110. /**
  16111. * Define an offset on the texture to scale the u coordinates of the UVs
  16112. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  16113. */
  16114. uScale: number;
  16115. /**
  16116. * Define an offset on the texture to scale the v coordinates of the UVs
  16117. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  16118. */
  16119. vScale: number;
  16120. /**
  16121. * Define an offset on the texture to rotate around the u coordinates of the UVs
  16122. * @see http://doc.babylonjs.com/how_to/more_materials
  16123. */
  16124. uAng: number;
  16125. /**
  16126. * Define an offset on the texture to rotate around the v coordinates of the UVs
  16127. * @see http://doc.babylonjs.com/how_to/more_materials
  16128. */
  16129. vAng: number;
  16130. /**
  16131. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  16132. * @see http://doc.babylonjs.com/how_to/more_materials
  16133. */
  16134. wAng: number;
  16135. /**
  16136. * Defines the center of rotation (U)
  16137. */
  16138. uRotationCenter: number;
  16139. /**
  16140. * Defines the center of rotation (V)
  16141. */
  16142. vRotationCenter: number;
  16143. /**
  16144. * Defines the center of rotation (W)
  16145. */
  16146. wRotationCenter: number;
  16147. /**
  16148. * Are mip maps generated for this texture or not.
  16149. */
  16150. get noMipmap(): boolean;
  16151. /**
  16152. * List of inspectable custom properties (used by the Inspector)
  16153. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  16154. */
  16155. inspectableCustomProperties: Nullable<IInspectable[]>;
  16156. private _noMipmap;
  16157. /** @hidden */
  16158. _invertY: boolean;
  16159. private _rowGenerationMatrix;
  16160. private _cachedTextureMatrix;
  16161. private _projectionModeMatrix;
  16162. private _t0;
  16163. private _t1;
  16164. private _t2;
  16165. private _cachedUOffset;
  16166. private _cachedVOffset;
  16167. private _cachedUScale;
  16168. private _cachedVScale;
  16169. private _cachedUAng;
  16170. private _cachedVAng;
  16171. private _cachedWAng;
  16172. private _cachedProjectionMatrixId;
  16173. private _cachedCoordinatesMode;
  16174. /** @hidden */
  16175. protected _initialSamplingMode: number;
  16176. /** @hidden */
  16177. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  16178. private _deleteBuffer;
  16179. protected _format: Nullable<number>;
  16180. private _delayedOnLoad;
  16181. private _delayedOnError;
  16182. private _mimeType?;
  16183. /**
  16184. * Observable triggered once the texture has been loaded.
  16185. */
  16186. onLoadObservable: Observable<Texture>;
  16187. protected _isBlocking: boolean;
  16188. /**
  16189. * Is the texture preventing material to render while loading.
  16190. * If false, a default texture will be used instead of the loading one during the preparation step.
  16191. */
  16192. set isBlocking(value: boolean);
  16193. get isBlocking(): boolean;
  16194. /**
  16195. * Get the current sampling mode associated with the texture.
  16196. */
  16197. get samplingMode(): number;
  16198. /**
  16199. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  16200. */
  16201. get invertY(): boolean;
  16202. /**
  16203. * Instantiates a new texture.
  16204. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  16205. * @see http://doc.babylonjs.com/babylon101/materials#texture
  16206. * @param url defines the url of the picture to load as a texture
  16207. * @param scene defines the scene or engine the texture will belong to
  16208. * @param noMipmap defines if the texture will require mip maps or not
  16209. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  16210. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16211. * @param onLoad defines a callback triggered when the texture has been loaded
  16212. * @param onError defines a callback triggered when an error occurred during the loading session
  16213. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  16214. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  16215. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16216. * @param mimeType defines an optional mime type information
  16217. */
  16218. 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);
  16219. /**
  16220. * Update the url (and optional buffer) of this texture if url was null during construction.
  16221. * @param url the url of the texture
  16222. * @param buffer the buffer of the texture (defaults to null)
  16223. * @param onLoad callback called when the texture is loaded (defaults to null)
  16224. */
  16225. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  16226. /**
  16227. * Finish the loading sequence of a texture flagged as delayed load.
  16228. * @hidden
  16229. */
  16230. delayLoad(): void;
  16231. private _prepareRowForTextureGeneration;
  16232. /**
  16233. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  16234. * @returns the transform matrix of the texture.
  16235. */
  16236. getTextureMatrix(uBase?: number): Matrix;
  16237. /**
  16238. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  16239. * @returns The reflection texture transform
  16240. */
  16241. getReflectionTextureMatrix(): Matrix;
  16242. /**
  16243. * Clones the texture.
  16244. * @returns the cloned texture
  16245. */
  16246. clone(): Texture;
  16247. /**
  16248. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  16249. * @returns The JSON representation of the texture
  16250. */
  16251. serialize(): any;
  16252. /**
  16253. * Get the current class name of the texture useful for serialization or dynamic coding.
  16254. * @returns "Texture"
  16255. */
  16256. getClassName(): string;
  16257. /**
  16258. * Dispose the texture and release its associated resources.
  16259. */
  16260. dispose(): void;
  16261. /**
  16262. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  16263. * @param parsedTexture Define the JSON representation of the texture
  16264. * @param scene Define the scene the parsed texture should be instantiated in
  16265. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  16266. * @returns The parsed texture if successful
  16267. */
  16268. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  16269. /**
  16270. * Creates a texture from its base 64 representation.
  16271. * @param data Define the base64 payload without the data: prefix
  16272. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  16273. * @param scene Define the scene the texture should belong to
  16274. * @param noMipmap Forces the texture to not create mip map information if true
  16275. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16276. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16277. * @param onLoad define a callback triggered when the texture has been loaded
  16278. * @param onError define a callback triggered when an error occurred during the loading session
  16279. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16280. * @returns the created texture
  16281. */
  16282. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  16283. /**
  16284. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  16285. * @param data Define the base64 payload without the data: prefix
  16286. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  16287. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  16288. * @param scene Define the scene the texture should belong to
  16289. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  16290. * @param noMipmap Forces the texture to not create mip map information if true
  16291. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16292. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16293. * @param onLoad define a callback triggered when the texture has been loaded
  16294. * @param onError define a callback triggered when an error occurred during the loading session
  16295. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16296. * @returns the created texture
  16297. */
  16298. 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;
  16299. }
  16300. }
  16301. declare module BABYLON {
  16302. /**
  16303. * PostProcessManager is used to manage one or more post processes or post process pipelines
  16304. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  16305. */
  16306. export class PostProcessManager {
  16307. private _scene;
  16308. private _indexBuffer;
  16309. private _vertexBuffers;
  16310. /**
  16311. * Creates a new instance PostProcess
  16312. * @param scene The scene that the post process is associated with.
  16313. */
  16314. constructor(scene: Scene);
  16315. private _prepareBuffers;
  16316. private _buildIndexBuffer;
  16317. /**
  16318. * Rebuilds the vertex buffers of the manager.
  16319. * @hidden
  16320. */
  16321. _rebuild(): void;
  16322. /**
  16323. * Prepares a frame to be run through a post process.
  16324. * @param sourceTexture The input texture to the post procesess. (default: null)
  16325. * @param postProcesses An array of post processes to be run. (default: null)
  16326. * @returns True if the post processes were able to be run.
  16327. * @hidden
  16328. */
  16329. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  16330. /**
  16331. * Manually render a set of post processes to a texture.
  16332. * @param postProcesses An array of post processes to be run.
  16333. * @param targetTexture The target texture to render to.
  16334. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  16335. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  16336. * @param lodLevel defines which lod of the texture to render to
  16337. */
  16338. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  16339. /**
  16340. * Finalize the result of the output of the postprocesses.
  16341. * @param doNotPresent If true the result will not be displayed to the screen.
  16342. * @param targetTexture The target texture to render to.
  16343. * @param faceIndex The index of the face to bind the target texture to.
  16344. * @param postProcesses The array of post processes to render.
  16345. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  16346. * @hidden
  16347. */
  16348. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  16349. /**
  16350. * Disposes of the post process manager.
  16351. */
  16352. dispose(): void;
  16353. }
  16354. }
  16355. declare module BABYLON {
  16356. /** Interface used by value gradients (color, factor, ...) */
  16357. export interface IValueGradient {
  16358. /**
  16359. * Gets or sets the gradient value (between 0 and 1)
  16360. */
  16361. gradient: number;
  16362. }
  16363. /** Class used to store color4 gradient */
  16364. export class ColorGradient implements IValueGradient {
  16365. /**
  16366. * Gets or sets the gradient value (between 0 and 1)
  16367. */
  16368. gradient: number;
  16369. /**
  16370. * Gets or sets first associated color
  16371. */
  16372. color1: Color4;
  16373. /**
  16374. * Gets or sets second associated color
  16375. */
  16376. color2?: Color4;
  16377. /**
  16378. * Will get a color picked randomly between color1 and color2.
  16379. * If color2 is undefined then color1 will be used
  16380. * @param result defines the target Color4 to store the result in
  16381. */
  16382. getColorToRef(result: Color4): void;
  16383. }
  16384. /** Class used to store color 3 gradient */
  16385. export class Color3Gradient implements IValueGradient {
  16386. /**
  16387. * Gets or sets the gradient value (between 0 and 1)
  16388. */
  16389. gradient: number;
  16390. /**
  16391. * Gets or sets the associated color
  16392. */
  16393. color: Color3;
  16394. }
  16395. /** Class used to store factor gradient */
  16396. export class FactorGradient implements IValueGradient {
  16397. /**
  16398. * Gets or sets the gradient value (between 0 and 1)
  16399. */
  16400. gradient: number;
  16401. /**
  16402. * Gets or sets first associated factor
  16403. */
  16404. factor1: number;
  16405. /**
  16406. * Gets or sets second associated factor
  16407. */
  16408. factor2?: number;
  16409. /**
  16410. * Will get a number picked randomly between factor1 and factor2.
  16411. * If factor2 is undefined then factor1 will be used
  16412. * @returns the picked number
  16413. */
  16414. getFactor(): number;
  16415. }
  16416. /**
  16417. * Helper used to simplify some generic gradient tasks
  16418. */
  16419. export class GradientHelper {
  16420. /**
  16421. * Gets the current gradient from an array of IValueGradient
  16422. * @param ratio defines the current ratio to get
  16423. * @param gradients defines the array of IValueGradient
  16424. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  16425. */
  16426. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  16427. }
  16428. }
  16429. declare module BABYLON {
  16430. interface ThinEngine {
  16431. /**
  16432. * Creates a dynamic texture
  16433. * @param width defines the width of the texture
  16434. * @param height defines the height of the texture
  16435. * @param generateMipMaps defines if the engine should generate the mip levels
  16436. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  16437. * @returns the dynamic texture inside an InternalTexture
  16438. */
  16439. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  16440. /**
  16441. * Update the content of a dynamic texture
  16442. * @param texture defines the texture to update
  16443. * @param canvas defines the canvas containing the source
  16444. * @param invertY defines if data must be stored with Y axis inverted
  16445. * @param premulAlpha defines if alpha is stored as premultiplied
  16446. * @param format defines the format of the data
  16447. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  16448. */
  16449. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  16450. }
  16451. }
  16452. declare module BABYLON {
  16453. /**
  16454. * Helper class used to generate a canvas to manipulate images
  16455. */
  16456. export class CanvasGenerator {
  16457. /**
  16458. * Create a new canvas (or offscreen canvas depending on the context)
  16459. * @param width defines the expected width
  16460. * @param height defines the expected height
  16461. * @return a new canvas or offscreen canvas
  16462. */
  16463. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  16464. }
  16465. }
  16466. declare module BABYLON {
  16467. /**
  16468. * A class extending Texture allowing drawing on a texture
  16469. * @see http://doc.babylonjs.com/how_to/dynamictexture
  16470. */
  16471. export class DynamicTexture extends Texture {
  16472. private _generateMipMaps;
  16473. private _canvas;
  16474. private _context;
  16475. private _engine;
  16476. /**
  16477. * Creates a DynamicTexture
  16478. * @param name defines the name of the texture
  16479. * @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
  16480. * @param scene defines the scene where you want the texture
  16481. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  16482. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  16483. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  16484. */
  16485. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  16486. /**
  16487. * Get the current class name of the texture useful for serialization or dynamic coding.
  16488. * @returns "DynamicTexture"
  16489. */
  16490. getClassName(): string;
  16491. /**
  16492. * Gets the current state of canRescale
  16493. */
  16494. get canRescale(): boolean;
  16495. private _recreate;
  16496. /**
  16497. * Scales the texture
  16498. * @param ratio the scale factor to apply to both width and height
  16499. */
  16500. scale(ratio: number): void;
  16501. /**
  16502. * Resizes the texture
  16503. * @param width the new width
  16504. * @param height the new height
  16505. */
  16506. scaleTo(width: number, height: number): void;
  16507. /**
  16508. * Gets the context of the canvas used by the texture
  16509. * @returns the canvas context of the dynamic texture
  16510. */
  16511. getContext(): CanvasRenderingContext2D;
  16512. /**
  16513. * Clears the texture
  16514. */
  16515. clear(): void;
  16516. /**
  16517. * Updates the texture
  16518. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  16519. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  16520. */
  16521. update(invertY?: boolean, premulAlpha?: boolean): void;
  16522. /**
  16523. * Draws text onto the texture
  16524. * @param text defines the text to be drawn
  16525. * @param x defines the placement of the text from the left
  16526. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  16527. * @param font defines the font to be used with font-style, font-size, font-name
  16528. * @param color defines the color used for the text
  16529. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  16530. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  16531. * @param update defines whether texture is immediately update (default is true)
  16532. */
  16533. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  16534. /**
  16535. * Clones the texture
  16536. * @returns the clone of the texture.
  16537. */
  16538. clone(): DynamicTexture;
  16539. /**
  16540. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  16541. * @returns a serialized dynamic texture object
  16542. */
  16543. serialize(): any;
  16544. /** @hidden */
  16545. _rebuild(): void;
  16546. }
  16547. }
  16548. declare module BABYLON {
  16549. interface AbstractScene {
  16550. /**
  16551. * The list of procedural textures added to the scene
  16552. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16553. */
  16554. proceduralTextures: Array<ProceduralTexture>;
  16555. }
  16556. /**
  16557. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  16558. * in a given scene.
  16559. */
  16560. export class ProceduralTextureSceneComponent implements ISceneComponent {
  16561. /**
  16562. * The component name helpfull to identify the component in the list of scene components.
  16563. */
  16564. readonly name: string;
  16565. /**
  16566. * The scene the component belongs to.
  16567. */
  16568. scene: Scene;
  16569. /**
  16570. * Creates a new instance of the component for the given scene
  16571. * @param scene Defines the scene to register the component in
  16572. */
  16573. constructor(scene: Scene);
  16574. /**
  16575. * Registers the component in a given scene
  16576. */
  16577. register(): void;
  16578. /**
  16579. * Rebuilds the elements related to this component in case of
  16580. * context lost for instance.
  16581. */
  16582. rebuild(): void;
  16583. /**
  16584. * Disposes the component and the associated ressources.
  16585. */
  16586. dispose(): void;
  16587. private _beforeClear;
  16588. }
  16589. }
  16590. declare module BABYLON {
  16591. interface ThinEngine {
  16592. /**
  16593. * Creates a new render target cube texture
  16594. * @param size defines the size of the texture
  16595. * @param options defines the options used to create the texture
  16596. * @returns a new render target cube texture stored in an InternalTexture
  16597. */
  16598. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  16599. }
  16600. }
  16601. declare module BABYLON {
  16602. /** @hidden */
  16603. export var proceduralVertexShader: {
  16604. name: string;
  16605. shader: string;
  16606. };
  16607. }
  16608. declare module BABYLON {
  16609. /**
  16610. * 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.
  16611. * This is the base class of any Procedural texture and contains most of the shareable code.
  16612. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16613. */
  16614. export class ProceduralTexture extends Texture {
  16615. isCube: boolean;
  16616. /**
  16617. * Define if the texture is enabled or not (disabled texture will not render)
  16618. */
  16619. isEnabled: boolean;
  16620. /**
  16621. * Define if the texture must be cleared before rendering (default is true)
  16622. */
  16623. autoClear: boolean;
  16624. /**
  16625. * Callback called when the texture is generated
  16626. */
  16627. onGenerated: () => void;
  16628. /**
  16629. * Event raised when the texture is generated
  16630. */
  16631. onGeneratedObservable: Observable<ProceduralTexture>;
  16632. /** @hidden */
  16633. _generateMipMaps: boolean;
  16634. /** @hidden **/
  16635. _effect: Effect;
  16636. /** @hidden */
  16637. _textures: {
  16638. [key: string]: Texture;
  16639. };
  16640. private _size;
  16641. private _currentRefreshId;
  16642. private _frameId;
  16643. private _refreshRate;
  16644. private _vertexBuffers;
  16645. private _indexBuffer;
  16646. private _uniforms;
  16647. private _samplers;
  16648. private _fragment;
  16649. private _floats;
  16650. private _ints;
  16651. private _floatsArrays;
  16652. private _colors3;
  16653. private _colors4;
  16654. private _vectors2;
  16655. private _vectors3;
  16656. private _matrices;
  16657. private _fallbackTexture;
  16658. private _fallbackTextureUsed;
  16659. private _engine;
  16660. private _cachedDefines;
  16661. private _contentUpdateId;
  16662. private _contentData;
  16663. /**
  16664. * Instantiates a new procedural texture.
  16665. * 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.
  16666. * This is the base class of any Procedural texture and contains most of the shareable code.
  16667. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16668. * @param name Define the name of the texture
  16669. * @param size Define the size of the texture to create
  16670. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  16671. * @param scene Define the scene the texture belongs to
  16672. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  16673. * @param generateMipMaps Define if the texture should creates mip maps or not
  16674. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  16675. */
  16676. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  16677. /**
  16678. * The effect that is created when initializing the post process.
  16679. * @returns The created effect corresponding the the postprocess.
  16680. */
  16681. getEffect(): Effect;
  16682. /**
  16683. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  16684. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  16685. */
  16686. getContent(): Nullable<ArrayBufferView>;
  16687. private _createIndexBuffer;
  16688. /** @hidden */
  16689. _rebuild(): void;
  16690. /**
  16691. * Resets the texture in order to recreate its associated resources.
  16692. * This can be called in case of context loss
  16693. */
  16694. reset(): void;
  16695. protected _getDefines(): string;
  16696. /**
  16697. * Is the texture ready to be used ? (rendered at least once)
  16698. * @returns true if ready, otherwise, false.
  16699. */
  16700. isReady(): boolean;
  16701. /**
  16702. * Resets the refresh counter of the texture and start bak from scratch.
  16703. * Could be useful to regenerate the texture if it is setup to render only once.
  16704. */
  16705. resetRefreshCounter(): void;
  16706. /**
  16707. * Set the fragment shader to use in order to render the texture.
  16708. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  16709. */
  16710. setFragment(fragment: any): void;
  16711. /**
  16712. * Define the refresh rate of the texture or the rendering frequency.
  16713. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  16714. */
  16715. get refreshRate(): number;
  16716. set refreshRate(value: number);
  16717. /** @hidden */
  16718. _shouldRender(): boolean;
  16719. /**
  16720. * Get the size the texture is rendering at.
  16721. * @returns the size (texture is always squared)
  16722. */
  16723. getRenderSize(): number;
  16724. /**
  16725. * Resize the texture to new value.
  16726. * @param size Define the new size the texture should have
  16727. * @param generateMipMaps Define whether the new texture should create mip maps
  16728. */
  16729. resize(size: number, generateMipMaps: boolean): void;
  16730. private _checkUniform;
  16731. /**
  16732. * Set a texture in the shader program used to render.
  16733. * @param name Define the name of the uniform samplers as defined in the shader
  16734. * @param texture Define the texture to bind to this sampler
  16735. * @return the texture itself allowing "fluent" like uniform updates
  16736. */
  16737. setTexture(name: string, texture: Texture): ProceduralTexture;
  16738. /**
  16739. * Set a float in the shader.
  16740. * @param name Define the name of the uniform as defined in the shader
  16741. * @param value Define the value to give to the uniform
  16742. * @return the texture itself allowing "fluent" like uniform updates
  16743. */
  16744. setFloat(name: string, value: number): ProceduralTexture;
  16745. /**
  16746. * Set a int in the shader.
  16747. * @param name Define the name of the uniform as defined in the shader
  16748. * @param value Define the value to give to the uniform
  16749. * @return the texture itself allowing "fluent" like uniform updates
  16750. */
  16751. setInt(name: string, value: number): ProceduralTexture;
  16752. /**
  16753. * Set an array of floats in the shader.
  16754. * @param name Define the name of the uniform as defined in the shader
  16755. * @param value Define the value to give to the uniform
  16756. * @return the texture itself allowing "fluent" like uniform updates
  16757. */
  16758. setFloats(name: string, value: number[]): ProceduralTexture;
  16759. /**
  16760. * Set a vec3 in the shader from a Color3.
  16761. * @param name Define the name of the uniform as defined in the shader
  16762. * @param value Define the value to give to the uniform
  16763. * @return the texture itself allowing "fluent" like uniform updates
  16764. */
  16765. setColor3(name: string, value: Color3): ProceduralTexture;
  16766. /**
  16767. * Set a vec4 in the shader from a Color4.
  16768. * @param name Define the name of the uniform as defined in the shader
  16769. * @param value Define the value to give to the uniform
  16770. * @return the texture itself allowing "fluent" like uniform updates
  16771. */
  16772. setColor4(name: string, value: Color4): ProceduralTexture;
  16773. /**
  16774. * Set a vec2 in the shader from a Vector2.
  16775. * @param name Define the name of the uniform as defined in the shader
  16776. * @param value Define the value to give to the uniform
  16777. * @return the texture itself allowing "fluent" like uniform updates
  16778. */
  16779. setVector2(name: string, value: Vector2): ProceduralTexture;
  16780. /**
  16781. * Set a vec3 in the shader from a Vector3.
  16782. * @param name Define the name of the uniform as defined in the shader
  16783. * @param value Define the value to give to the uniform
  16784. * @return the texture itself allowing "fluent" like uniform updates
  16785. */
  16786. setVector3(name: string, value: Vector3): ProceduralTexture;
  16787. /**
  16788. * Set a mat4 in the shader from a MAtrix.
  16789. * @param name Define the name of the uniform as defined in the shader
  16790. * @param value Define the value to give to the uniform
  16791. * @return the texture itself allowing "fluent" like uniform updates
  16792. */
  16793. setMatrix(name: string, value: Matrix): ProceduralTexture;
  16794. /**
  16795. * Render the texture to its associated render target.
  16796. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  16797. */
  16798. render(useCameraPostProcess?: boolean): void;
  16799. /**
  16800. * Clone the texture.
  16801. * @returns the cloned texture
  16802. */
  16803. clone(): ProceduralTexture;
  16804. /**
  16805. * Dispose the texture and release its asoociated resources.
  16806. */
  16807. dispose(): void;
  16808. }
  16809. }
  16810. declare module BABYLON {
  16811. /**
  16812. * This represents the base class for particle system in Babylon.
  16813. * 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.
  16814. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  16815. * @example https://doc.babylonjs.com/babylon101/particles
  16816. */
  16817. export class BaseParticleSystem {
  16818. /**
  16819. * Source color is added to the destination color without alpha affecting the result
  16820. */
  16821. static BLENDMODE_ONEONE: number;
  16822. /**
  16823. * Blend current color and particle color using particle’s alpha
  16824. */
  16825. static BLENDMODE_STANDARD: number;
  16826. /**
  16827. * Add current color and particle color multiplied by particle’s alpha
  16828. */
  16829. static BLENDMODE_ADD: number;
  16830. /**
  16831. * Multiply current color with particle color
  16832. */
  16833. static BLENDMODE_MULTIPLY: number;
  16834. /**
  16835. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  16836. */
  16837. static BLENDMODE_MULTIPLYADD: number;
  16838. /**
  16839. * List of animations used by the particle system.
  16840. */
  16841. animations: Animation[];
  16842. /**
  16843. * The id of the Particle system.
  16844. */
  16845. id: string;
  16846. /**
  16847. * The friendly name of the Particle system.
  16848. */
  16849. name: string;
  16850. /**
  16851. * The rendering group used by the Particle system to chose when to render.
  16852. */
  16853. renderingGroupId: number;
  16854. /**
  16855. * The emitter represents the Mesh or position we are attaching the particle system to.
  16856. */
  16857. emitter: Nullable<AbstractMesh | Vector3>;
  16858. /**
  16859. * The maximum number of particles to emit per frame
  16860. */
  16861. emitRate: number;
  16862. /**
  16863. * If you want to launch only a few particles at once, that can be done, as well.
  16864. */
  16865. manualEmitCount: number;
  16866. /**
  16867. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  16868. */
  16869. updateSpeed: number;
  16870. /**
  16871. * The amount of time the particle system is running (depends of the overall update speed).
  16872. */
  16873. targetStopDuration: number;
  16874. /**
  16875. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  16876. */
  16877. disposeOnStop: boolean;
  16878. /**
  16879. * Minimum power of emitting particles.
  16880. */
  16881. minEmitPower: number;
  16882. /**
  16883. * Maximum power of emitting particles.
  16884. */
  16885. maxEmitPower: number;
  16886. /**
  16887. * Minimum life time of emitting particles.
  16888. */
  16889. minLifeTime: number;
  16890. /**
  16891. * Maximum life time of emitting particles.
  16892. */
  16893. maxLifeTime: number;
  16894. /**
  16895. * Minimum Size of emitting particles.
  16896. */
  16897. minSize: number;
  16898. /**
  16899. * Maximum Size of emitting particles.
  16900. */
  16901. maxSize: number;
  16902. /**
  16903. * Minimum scale of emitting particles on X axis.
  16904. */
  16905. minScaleX: number;
  16906. /**
  16907. * Maximum scale of emitting particles on X axis.
  16908. */
  16909. maxScaleX: number;
  16910. /**
  16911. * Minimum scale of emitting particles on Y axis.
  16912. */
  16913. minScaleY: number;
  16914. /**
  16915. * Maximum scale of emitting particles on Y axis.
  16916. */
  16917. maxScaleY: number;
  16918. /**
  16919. * Gets or sets the minimal initial rotation in radians.
  16920. */
  16921. minInitialRotation: number;
  16922. /**
  16923. * Gets or sets the maximal initial rotation in radians.
  16924. */
  16925. maxInitialRotation: number;
  16926. /**
  16927. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  16928. */
  16929. minAngularSpeed: number;
  16930. /**
  16931. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  16932. */
  16933. maxAngularSpeed: number;
  16934. /**
  16935. * The texture used to render each particle. (this can be a spritesheet)
  16936. */
  16937. particleTexture: Nullable<Texture>;
  16938. /**
  16939. * The layer mask we are rendering the particles through.
  16940. */
  16941. layerMask: number;
  16942. /**
  16943. * This can help using your own shader to render the particle system.
  16944. * The according effect will be created
  16945. */
  16946. customShader: any;
  16947. /**
  16948. * By default particle system starts as soon as they are created. This prevents the
  16949. * automatic start to happen and let you decide when to start emitting particles.
  16950. */
  16951. preventAutoStart: boolean;
  16952. private _noiseTexture;
  16953. /**
  16954. * Gets or sets a texture used to add random noise to particle positions
  16955. */
  16956. get noiseTexture(): Nullable<ProceduralTexture>;
  16957. set noiseTexture(value: Nullable<ProceduralTexture>);
  16958. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  16959. noiseStrength: Vector3;
  16960. /**
  16961. * Callback triggered when the particle animation is ending.
  16962. */
  16963. onAnimationEnd: Nullable<() => void>;
  16964. /**
  16965. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  16966. */
  16967. blendMode: number;
  16968. /**
  16969. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  16970. * to override the particles.
  16971. */
  16972. forceDepthWrite: boolean;
  16973. /** 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 */
  16974. preWarmCycles: number;
  16975. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  16976. preWarmStepOffset: number;
  16977. /**
  16978. * 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)
  16979. */
  16980. spriteCellChangeSpeed: number;
  16981. /**
  16982. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  16983. */
  16984. startSpriteCellID: number;
  16985. /**
  16986. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  16987. */
  16988. endSpriteCellID: number;
  16989. /**
  16990. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  16991. */
  16992. spriteCellWidth: number;
  16993. /**
  16994. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  16995. */
  16996. spriteCellHeight: number;
  16997. /**
  16998. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  16999. */
  17000. spriteRandomStartCell: boolean;
  17001. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  17002. translationPivot: Vector2;
  17003. /** @hidden */
  17004. protected _isAnimationSheetEnabled: boolean;
  17005. /**
  17006. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  17007. */
  17008. beginAnimationOnStart: boolean;
  17009. /**
  17010. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  17011. */
  17012. beginAnimationFrom: number;
  17013. /**
  17014. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  17015. */
  17016. beginAnimationTo: number;
  17017. /**
  17018. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  17019. */
  17020. beginAnimationLoop: boolean;
  17021. /**
  17022. * Gets or sets a world offset applied to all particles
  17023. */
  17024. worldOffset: Vector3;
  17025. /**
  17026. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  17027. */
  17028. get isAnimationSheetEnabled(): boolean;
  17029. set isAnimationSheetEnabled(value: boolean);
  17030. /**
  17031. * Get hosting scene
  17032. * @returns the scene
  17033. */
  17034. getScene(): Scene;
  17035. /**
  17036. * You can use gravity if you want to give an orientation to your particles.
  17037. */
  17038. gravity: Vector3;
  17039. protected _colorGradients: Nullable<Array<ColorGradient>>;
  17040. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  17041. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  17042. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  17043. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  17044. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  17045. protected _dragGradients: Nullable<Array<FactorGradient>>;
  17046. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  17047. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  17048. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  17049. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  17050. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  17051. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  17052. /**
  17053. * Defines the delay in milliseconds before starting the system (0 by default)
  17054. */
  17055. startDelay: number;
  17056. /**
  17057. * Gets the current list of drag gradients.
  17058. * You must use addDragGradient and removeDragGradient to udpate this list
  17059. * @returns the list of drag gradients
  17060. */
  17061. getDragGradients(): Nullable<Array<FactorGradient>>;
  17062. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  17063. limitVelocityDamping: number;
  17064. /**
  17065. * Gets the current list of limit velocity gradients.
  17066. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  17067. * @returns the list of limit velocity gradients
  17068. */
  17069. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  17070. /**
  17071. * Gets the current list of color gradients.
  17072. * You must use addColorGradient and removeColorGradient to udpate this list
  17073. * @returns the list of color gradients
  17074. */
  17075. getColorGradients(): Nullable<Array<ColorGradient>>;
  17076. /**
  17077. * Gets the current list of size gradients.
  17078. * You must use addSizeGradient and removeSizeGradient to udpate this list
  17079. * @returns the list of size gradients
  17080. */
  17081. getSizeGradients(): Nullable<Array<FactorGradient>>;
  17082. /**
  17083. * Gets the current list of color remap gradients.
  17084. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  17085. * @returns the list of color remap gradients
  17086. */
  17087. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  17088. /**
  17089. * Gets the current list of alpha remap gradients.
  17090. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  17091. * @returns the list of alpha remap gradients
  17092. */
  17093. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  17094. /**
  17095. * Gets the current list of life time gradients.
  17096. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  17097. * @returns the list of life time gradients
  17098. */
  17099. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  17100. /**
  17101. * Gets the current list of angular speed gradients.
  17102. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  17103. * @returns the list of angular speed gradients
  17104. */
  17105. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  17106. /**
  17107. * Gets the current list of velocity gradients.
  17108. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  17109. * @returns the list of velocity gradients
  17110. */
  17111. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  17112. /**
  17113. * Gets the current list of start size gradients.
  17114. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  17115. * @returns the list of start size gradients
  17116. */
  17117. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  17118. /**
  17119. * Gets the current list of emit rate gradients.
  17120. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  17121. * @returns the list of emit rate gradients
  17122. */
  17123. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  17124. /**
  17125. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17126. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17127. */
  17128. get direction1(): Vector3;
  17129. set direction1(value: Vector3);
  17130. /**
  17131. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17132. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17133. */
  17134. get direction2(): Vector3;
  17135. set direction2(value: Vector3);
  17136. /**
  17137. * 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.
  17138. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17139. */
  17140. get minEmitBox(): Vector3;
  17141. set minEmitBox(value: Vector3);
  17142. /**
  17143. * 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.
  17144. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17145. */
  17146. get maxEmitBox(): Vector3;
  17147. set maxEmitBox(value: Vector3);
  17148. /**
  17149. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  17150. */
  17151. color1: Color4;
  17152. /**
  17153. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  17154. */
  17155. color2: Color4;
  17156. /**
  17157. * Color the particle will have at the end of its lifetime
  17158. */
  17159. colorDead: Color4;
  17160. /**
  17161. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  17162. */
  17163. textureMask: Color4;
  17164. /**
  17165. * The particle emitter type defines the emitter used by the particle system.
  17166. * It can be for example box, sphere, or cone...
  17167. */
  17168. particleEmitterType: IParticleEmitterType;
  17169. /** @hidden */
  17170. _isSubEmitter: boolean;
  17171. /**
  17172. * Gets or sets the billboard mode to use when isBillboardBased = true.
  17173. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  17174. */
  17175. billboardMode: number;
  17176. protected _isBillboardBased: boolean;
  17177. /**
  17178. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  17179. */
  17180. get isBillboardBased(): boolean;
  17181. set isBillboardBased(value: boolean);
  17182. /**
  17183. * The scene the particle system belongs to.
  17184. */
  17185. protected _scene: Scene;
  17186. /**
  17187. * Local cache of defines for image processing.
  17188. */
  17189. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  17190. /**
  17191. * Default configuration related to image processing available in the standard Material.
  17192. */
  17193. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  17194. /**
  17195. * Gets the image processing configuration used either in this material.
  17196. */
  17197. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  17198. /**
  17199. * Sets the Default image processing configuration used either in the this material.
  17200. *
  17201. * If sets to null, the scene one is in use.
  17202. */
  17203. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  17204. /**
  17205. * Attaches a new image processing configuration to the Standard Material.
  17206. * @param configuration
  17207. */
  17208. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  17209. /** @hidden */
  17210. protected _reset(): void;
  17211. /** @hidden */
  17212. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  17213. /**
  17214. * Instantiates a particle system.
  17215. * 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.
  17216. * @param name The name of the particle system
  17217. */
  17218. constructor(name: string);
  17219. /**
  17220. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  17221. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17222. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17223. * @returns the emitter
  17224. */
  17225. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  17226. /**
  17227. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  17228. * @param radius The radius of the hemisphere to emit from
  17229. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17230. * @returns the emitter
  17231. */
  17232. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  17233. /**
  17234. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  17235. * @param radius The radius of the sphere to emit from
  17236. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17237. * @returns the emitter
  17238. */
  17239. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  17240. /**
  17241. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  17242. * @param radius The radius of the sphere to emit from
  17243. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  17244. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  17245. * @returns the emitter
  17246. */
  17247. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  17248. /**
  17249. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  17250. * @param radius The radius of the emission cylinder
  17251. * @param height The height of the emission cylinder
  17252. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  17253. * @param directionRandomizer How much to randomize the particle direction [0-1]
  17254. * @returns the emitter
  17255. */
  17256. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  17257. /**
  17258. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  17259. * @param radius The radius of the cylinder to emit from
  17260. * @param height The height of the emission cylinder
  17261. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17262. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  17263. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  17264. * @returns the emitter
  17265. */
  17266. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  17267. /**
  17268. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  17269. * @param radius The radius of the cone to emit from
  17270. * @param angle The base angle of the cone
  17271. * @returns the emitter
  17272. */
  17273. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  17274. /**
  17275. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  17276. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17277. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17278. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17279. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17280. * @returns the emitter
  17281. */
  17282. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  17283. }
  17284. }
  17285. declare module BABYLON {
  17286. /**
  17287. * Type of sub emitter
  17288. */
  17289. export enum SubEmitterType {
  17290. /**
  17291. * Attached to the particle over it's lifetime
  17292. */
  17293. ATTACHED = 0,
  17294. /**
  17295. * Created when the particle dies
  17296. */
  17297. END = 1
  17298. }
  17299. /**
  17300. * Sub emitter class used to emit particles from an existing particle
  17301. */
  17302. export class SubEmitter {
  17303. /**
  17304. * the particle system to be used by the sub emitter
  17305. */
  17306. particleSystem: ParticleSystem;
  17307. /**
  17308. * Type of the submitter (Default: END)
  17309. */
  17310. type: SubEmitterType;
  17311. /**
  17312. * 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)
  17313. * Note: This only is supported when using an emitter of type Mesh
  17314. */
  17315. inheritDirection: boolean;
  17316. /**
  17317. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  17318. */
  17319. inheritedVelocityAmount: number;
  17320. /**
  17321. * Creates a sub emitter
  17322. * @param particleSystem the particle system to be used by the sub emitter
  17323. */
  17324. constructor(
  17325. /**
  17326. * the particle system to be used by the sub emitter
  17327. */
  17328. particleSystem: ParticleSystem);
  17329. /**
  17330. * Clones the sub emitter
  17331. * @returns the cloned sub emitter
  17332. */
  17333. clone(): SubEmitter;
  17334. /**
  17335. * Serialize current object to a JSON object
  17336. * @returns the serialized object
  17337. */
  17338. serialize(): any;
  17339. /** @hidden */
  17340. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  17341. /**
  17342. * Creates a new SubEmitter from a serialized JSON version
  17343. * @param serializationObject defines the JSON object to read from
  17344. * @param scene defines the hosting scene
  17345. * @param rootUrl defines the rootUrl for data loading
  17346. * @returns a new SubEmitter
  17347. */
  17348. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  17349. /** Release associated resources */
  17350. dispose(): void;
  17351. }
  17352. }
  17353. declare module BABYLON {
  17354. /** @hidden */
  17355. export var imageProcessingDeclaration: {
  17356. name: string;
  17357. shader: string;
  17358. };
  17359. }
  17360. declare module BABYLON {
  17361. /** @hidden */
  17362. export var imageProcessingFunctions: {
  17363. name: string;
  17364. shader: string;
  17365. };
  17366. }
  17367. declare module BABYLON {
  17368. /** @hidden */
  17369. export var particlesPixelShader: {
  17370. name: string;
  17371. shader: string;
  17372. };
  17373. }
  17374. declare module BABYLON {
  17375. /** @hidden */
  17376. export var particlesVertexShader: {
  17377. name: string;
  17378. shader: string;
  17379. };
  17380. }
  17381. declare module BABYLON {
  17382. /**
  17383. * This represents a particle system in Babylon.
  17384. * 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.
  17385. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  17386. * @example https://doc.babylonjs.com/babylon101/particles
  17387. */
  17388. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  17389. /**
  17390. * Billboard mode will only apply to Y axis
  17391. */
  17392. static readonly BILLBOARDMODE_Y: number;
  17393. /**
  17394. * Billboard mode will apply to all axes
  17395. */
  17396. static readonly BILLBOARDMODE_ALL: number;
  17397. /**
  17398. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  17399. */
  17400. static readonly BILLBOARDMODE_STRETCHED: number;
  17401. /**
  17402. * This function can be defined to provide custom update for active particles.
  17403. * This function will be called instead of regular update (age, position, color, etc.).
  17404. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  17405. */
  17406. updateFunction: (particles: Particle[]) => void;
  17407. private _emitterWorldMatrix;
  17408. /**
  17409. * This function can be defined to specify initial direction for every new particle.
  17410. * It by default use the emitterType defined function
  17411. */
  17412. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  17413. /**
  17414. * This function can be defined to specify initial position for every new particle.
  17415. * It by default use the emitterType defined function
  17416. */
  17417. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  17418. /**
  17419. * @hidden
  17420. */
  17421. _inheritedVelocityOffset: Vector3;
  17422. /**
  17423. * An event triggered when the system is disposed
  17424. */
  17425. onDisposeObservable: Observable<ParticleSystem>;
  17426. private _onDisposeObserver;
  17427. /**
  17428. * Sets a callback that will be triggered when the system is disposed
  17429. */
  17430. set onDispose(callback: () => void);
  17431. private _particles;
  17432. private _epsilon;
  17433. private _capacity;
  17434. private _stockParticles;
  17435. private _newPartsExcess;
  17436. private _vertexData;
  17437. private _vertexBuffer;
  17438. private _vertexBuffers;
  17439. private _spriteBuffer;
  17440. private _indexBuffer;
  17441. private _effect;
  17442. private _customEffect;
  17443. private _cachedDefines;
  17444. private _scaledColorStep;
  17445. private _colorDiff;
  17446. private _scaledDirection;
  17447. private _scaledGravity;
  17448. private _currentRenderId;
  17449. private _alive;
  17450. private _useInstancing;
  17451. private _started;
  17452. private _stopped;
  17453. private _actualFrame;
  17454. private _scaledUpdateSpeed;
  17455. private _vertexBufferSize;
  17456. /** @hidden */
  17457. _currentEmitRateGradient: Nullable<FactorGradient>;
  17458. /** @hidden */
  17459. _currentEmitRate1: number;
  17460. /** @hidden */
  17461. _currentEmitRate2: number;
  17462. /** @hidden */
  17463. _currentStartSizeGradient: Nullable<FactorGradient>;
  17464. /** @hidden */
  17465. _currentStartSize1: number;
  17466. /** @hidden */
  17467. _currentStartSize2: number;
  17468. private readonly _rawTextureWidth;
  17469. private _rampGradientsTexture;
  17470. private _useRampGradients;
  17471. /** Gets or sets a boolean indicating that ramp gradients must be used
  17472. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  17473. */
  17474. get useRampGradients(): boolean;
  17475. set useRampGradients(value: boolean);
  17476. /**
  17477. * 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.
  17478. * 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: [])
  17479. */
  17480. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  17481. private _subEmitters;
  17482. /**
  17483. * @hidden
  17484. * If the particle systems emitter should be disposed when the particle system is disposed
  17485. */
  17486. _disposeEmitterOnDispose: boolean;
  17487. /**
  17488. * The current active Sub-systems, this property is used by the root particle system only.
  17489. */
  17490. activeSubSystems: Array<ParticleSystem>;
  17491. private _rootParticleSystem;
  17492. /**
  17493. * Gets the current list of active particles
  17494. */
  17495. get particles(): Particle[];
  17496. /**
  17497. * Returns the string "ParticleSystem"
  17498. * @returns a string containing the class name
  17499. */
  17500. getClassName(): string;
  17501. /**
  17502. * Instantiates a particle system.
  17503. * 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.
  17504. * @param name The name of the particle system
  17505. * @param capacity The max number of particles alive at the same time
  17506. * @param scene The scene the particle system belongs to
  17507. * @param customEffect a custom effect used to change the way particles are rendered by default
  17508. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  17509. * @param epsilon Offset used to render the particles
  17510. */
  17511. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  17512. private _addFactorGradient;
  17513. private _removeFactorGradient;
  17514. /**
  17515. * Adds a new life time gradient
  17516. * @param gradient defines the gradient to use (between 0 and 1)
  17517. * @param factor defines the life time factor to affect to the specified gradient
  17518. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17519. * @returns the current particle system
  17520. */
  17521. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17522. /**
  17523. * Remove a specific life time gradient
  17524. * @param gradient defines the gradient to remove
  17525. * @returns the current particle system
  17526. */
  17527. removeLifeTimeGradient(gradient: number): IParticleSystem;
  17528. /**
  17529. * Adds a new size gradient
  17530. * @param gradient defines the gradient to use (between 0 and 1)
  17531. * @param factor defines the size factor to affect to the specified gradient
  17532. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17533. * @returns the current particle system
  17534. */
  17535. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17536. /**
  17537. * Remove a specific size gradient
  17538. * @param gradient defines the gradient to remove
  17539. * @returns the current particle system
  17540. */
  17541. removeSizeGradient(gradient: number): IParticleSystem;
  17542. /**
  17543. * Adds a new color remap gradient
  17544. * @param gradient defines the gradient to use (between 0 and 1)
  17545. * @param min defines the color remap minimal range
  17546. * @param max defines the color remap maximal range
  17547. * @returns the current particle system
  17548. */
  17549. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17550. /**
  17551. * Remove a specific color remap gradient
  17552. * @param gradient defines the gradient to remove
  17553. * @returns the current particle system
  17554. */
  17555. removeColorRemapGradient(gradient: number): IParticleSystem;
  17556. /**
  17557. * Adds a new alpha remap gradient
  17558. * @param gradient defines the gradient to use (between 0 and 1)
  17559. * @param min defines the alpha remap minimal range
  17560. * @param max defines the alpha remap maximal range
  17561. * @returns the current particle system
  17562. */
  17563. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17564. /**
  17565. * Remove a specific alpha remap gradient
  17566. * @param gradient defines the gradient to remove
  17567. * @returns the current particle system
  17568. */
  17569. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  17570. /**
  17571. * Adds a new angular speed gradient
  17572. * @param gradient defines the gradient to use (between 0 and 1)
  17573. * @param factor defines the angular speed to affect to the specified gradient
  17574. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17575. * @returns the current particle system
  17576. */
  17577. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17578. /**
  17579. * Remove a specific angular speed gradient
  17580. * @param gradient defines the gradient to remove
  17581. * @returns the current particle system
  17582. */
  17583. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  17584. /**
  17585. * Adds a new velocity gradient
  17586. * @param gradient defines the gradient to use (between 0 and 1)
  17587. * @param factor defines the velocity to affect to the specified gradient
  17588. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17589. * @returns the current particle system
  17590. */
  17591. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17592. /**
  17593. * Remove a specific velocity gradient
  17594. * @param gradient defines the gradient to remove
  17595. * @returns the current particle system
  17596. */
  17597. removeVelocityGradient(gradient: number): IParticleSystem;
  17598. /**
  17599. * Adds a new limit velocity gradient
  17600. * @param gradient defines the gradient to use (between 0 and 1)
  17601. * @param factor defines the limit velocity value to affect to the specified gradient
  17602. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17603. * @returns the current particle system
  17604. */
  17605. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17606. /**
  17607. * Remove a specific limit velocity gradient
  17608. * @param gradient defines the gradient to remove
  17609. * @returns the current particle system
  17610. */
  17611. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  17612. /**
  17613. * Adds a new drag gradient
  17614. * @param gradient defines the gradient to use (between 0 and 1)
  17615. * @param factor defines the drag value to affect to the specified gradient
  17616. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17617. * @returns the current particle system
  17618. */
  17619. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17620. /**
  17621. * Remove a specific drag gradient
  17622. * @param gradient defines the gradient to remove
  17623. * @returns the current particle system
  17624. */
  17625. removeDragGradient(gradient: number): IParticleSystem;
  17626. /**
  17627. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  17628. * @param gradient defines the gradient to use (between 0 and 1)
  17629. * @param factor defines the emit rate value to affect to the specified gradient
  17630. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17631. * @returns the current particle system
  17632. */
  17633. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17634. /**
  17635. * Remove a specific emit rate gradient
  17636. * @param gradient defines the gradient to remove
  17637. * @returns the current particle system
  17638. */
  17639. removeEmitRateGradient(gradient: number): IParticleSystem;
  17640. /**
  17641. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  17642. * @param gradient defines the gradient to use (between 0 and 1)
  17643. * @param factor defines the start size value to affect to the specified gradient
  17644. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17645. * @returns the current particle system
  17646. */
  17647. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17648. /**
  17649. * Remove a specific start size gradient
  17650. * @param gradient defines the gradient to remove
  17651. * @returns the current particle system
  17652. */
  17653. removeStartSizeGradient(gradient: number): IParticleSystem;
  17654. private _createRampGradientTexture;
  17655. /**
  17656. * Gets the current list of ramp gradients.
  17657. * You must use addRampGradient and removeRampGradient to udpate this list
  17658. * @returns the list of ramp gradients
  17659. */
  17660. getRampGradients(): Nullable<Array<Color3Gradient>>;
  17661. /**
  17662. * Adds a new ramp gradient used to remap particle colors
  17663. * @param gradient defines the gradient to use (between 0 and 1)
  17664. * @param color defines the color to affect to the specified gradient
  17665. * @returns the current particle system
  17666. */
  17667. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  17668. /**
  17669. * Remove a specific ramp gradient
  17670. * @param gradient defines the gradient to remove
  17671. * @returns the current particle system
  17672. */
  17673. removeRampGradient(gradient: number): ParticleSystem;
  17674. /**
  17675. * Adds a new color gradient
  17676. * @param gradient defines the gradient to use (between 0 and 1)
  17677. * @param color1 defines the color to affect to the specified gradient
  17678. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  17679. * @returns this particle system
  17680. */
  17681. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  17682. /**
  17683. * Remove a specific color gradient
  17684. * @param gradient defines the gradient to remove
  17685. * @returns this particle system
  17686. */
  17687. removeColorGradient(gradient: number): IParticleSystem;
  17688. private _fetchR;
  17689. protected _reset(): void;
  17690. private _resetEffect;
  17691. private _createVertexBuffers;
  17692. private _createIndexBuffer;
  17693. /**
  17694. * Gets the maximum number of particles active at the same time.
  17695. * @returns The max number of active particles.
  17696. */
  17697. getCapacity(): number;
  17698. /**
  17699. * Gets whether there are still active particles in the system.
  17700. * @returns True if it is alive, otherwise false.
  17701. */
  17702. isAlive(): boolean;
  17703. /**
  17704. * Gets if the system has been started. (Note: this will still be true after stop is called)
  17705. * @returns True if it has been started, otherwise false.
  17706. */
  17707. isStarted(): boolean;
  17708. private _prepareSubEmitterInternalArray;
  17709. /**
  17710. * Starts the particle system and begins to emit
  17711. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  17712. */
  17713. start(delay?: number): void;
  17714. /**
  17715. * Stops the particle system.
  17716. * @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.
  17717. */
  17718. stop(stopSubEmitters?: boolean): void;
  17719. /**
  17720. * Remove all active particles
  17721. */
  17722. reset(): void;
  17723. /**
  17724. * @hidden (for internal use only)
  17725. */
  17726. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  17727. /**
  17728. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  17729. * Its lifetime will start back at 0.
  17730. */
  17731. recycleParticle: (particle: Particle) => void;
  17732. private _stopSubEmitters;
  17733. private _createParticle;
  17734. private _removeFromRoot;
  17735. private _emitFromParticle;
  17736. private _update;
  17737. /** @hidden */
  17738. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  17739. /** @hidden */
  17740. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  17741. /** @hidden */
  17742. private _getEffect;
  17743. /**
  17744. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  17745. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  17746. */
  17747. animate(preWarmOnly?: boolean): void;
  17748. private _appendParticleVertices;
  17749. /**
  17750. * Rebuilds the particle system.
  17751. */
  17752. rebuild(): void;
  17753. /**
  17754. * Is this system ready to be used/rendered
  17755. * @return true if the system is ready
  17756. */
  17757. isReady(): boolean;
  17758. private _render;
  17759. /**
  17760. * Renders the particle system in its current state.
  17761. * @returns the current number of particles
  17762. */
  17763. render(): number;
  17764. /**
  17765. * Disposes the particle system and free the associated resources
  17766. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  17767. */
  17768. dispose(disposeTexture?: boolean): void;
  17769. /**
  17770. * Clones the particle system.
  17771. * @param name The name of the cloned object
  17772. * @param newEmitter The new emitter to use
  17773. * @returns the cloned particle system
  17774. */
  17775. clone(name: string, newEmitter: any): ParticleSystem;
  17776. /**
  17777. * Serializes the particle system to a JSON object.
  17778. * @returns the JSON object
  17779. */
  17780. serialize(): any;
  17781. /** @hidden */
  17782. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  17783. /** @hidden */
  17784. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  17785. /**
  17786. * Parses a JSON object to create a particle system.
  17787. * @param parsedParticleSystem The JSON object to parse
  17788. * @param scene The scene to create the particle system in
  17789. * @param rootUrl The root url to use to load external dependencies like texture
  17790. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  17791. * @returns the Parsed particle system
  17792. */
  17793. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  17794. }
  17795. }
  17796. declare module BABYLON {
  17797. /**
  17798. * A particle represents one of the element emitted by a particle system.
  17799. * This is mainly define by its coordinates, direction, velocity and age.
  17800. */
  17801. export class Particle {
  17802. /**
  17803. * The particle system the particle belongs to.
  17804. */
  17805. particleSystem: ParticleSystem;
  17806. private static _Count;
  17807. /**
  17808. * Unique ID of the particle
  17809. */
  17810. id: number;
  17811. /**
  17812. * The world position of the particle in the scene.
  17813. */
  17814. position: Vector3;
  17815. /**
  17816. * The world direction of the particle in the scene.
  17817. */
  17818. direction: Vector3;
  17819. /**
  17820. * The color of the particle.
  17821. */
  17822. color: Color4;
  17823. /**
  17824. * The color change of the particle per step.
  17825. */
  17826. colorStep: Color4;
  17827. /**
  17828. * Defines how long will the life of the particle be.
  17829. */
  17830. lifeTime: number;
  17831. /**
  17832. * The current age of the particle.
  17833. */
  17834. age: number;
  17835. /**
  17836. * The current size of the particle.
  17837. */
  17838. size: number;
  17839. /**
  17840. * The current scale of the particle.
  17841. */
  17842. scale: Vector2;
  17843. /**
  17844. * The current angle of the particle.
  17845. */
  17846. angle: number;
  17847. /**
  17848. * Defines how fast is the angle changing.
  17849. */
  17850. angularSpeed: number;
  17851. /**
  17852. * Defines the cell index used by the particle to be rendered from a sprite.
  17853. */
  17854. cellIndex: number;
  17855. /**
  17856. * The information required to support color remapping
  17857. */
  17858. remapData: Vector4;
  17859. /** @hidden */
  17860. _randomCellOffset?: number;
  17861. /** @hidden */
  17862. _initialDirection: Nullable<Vector3>;
  17863. /** @hidden */
  17864. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  17865. /** @hidden */
  17866. _initialStartSpriteCellID: number;
  17867. /** @hidden */
  17868. _initialEndSpriteCellID: number;
  17869. /** @hidden */
  17870. _currentColorGradient: Nullable<ColorGradient>;
  17871. /** @hidden */
  17872. _currentColor1: Color4;
  17873. /** @hidden */
  17874. _currentColor2: Color4;
  17875. /** @hidden */
  17876. _currentSizeGradient: Nullable<FactorGradient>;
  17877. /** @hidden */
  17878. _currentSize1: number;
  17879. /** @hidden */
  17880. _currentSize2: number;
  17881. /** @hidden */
  17882. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  17883. /** @hidden */
  17884. _currentAngularSpeed1: number;
  17885. /** @hidden */
  17886. _currentAngularSpeed2: number;
  17887. /** @hidden */
  17888. _currentVelocityGradient: Nullable<FactorGradient>;
  17889. /** @hidden */
  17890. _currentVelocity1: number;
  17891. /** @hidden */
  17892. _currentVelocity2: number;
  17893. /** @hidden */
  17894. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  17895. /** @hidden */
  17896. _currentLimitVelocity1: number;
  17897. /** @hidden */
  17898. _currentLimitVelocity2: number;
  17899. /** @hidden */
  17900. _currentDragGradient: Nullable<FactorGradient>;
  17901. /** @hidden */
  17902. _currentDrag1: number;
  17903. /** @hidden */
  17904. _currentDrag2: number;
  17905. /** @hidden */
  17906. _randomNoiseCoordinates1: Vector3;
  17907. /** @hidden */
  17908. _randomNoiseCoordinates2: Vector3;
  17909. /**
  17910. * Creates a new instance Particle
  17911. * @param particleSystem the particle system the particle belongs to
  17912. */
  17913. constructor(
  17914. /**
  17915. * The particle system the particle belongs to.
  17916. */
  17917. particleSystem: ParticleSystem);
  17918. private updateCellInfoFromSystem;
  17919. /**
  17920. * Defines how the sprite cell index is updated for the particle
  17921. */
  17922. updateCellIndex(): void;
  17923. /** @hidden */
  17924. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  17925. /** @hidden */
  17926. _inheritParticleInfoToSubEmitters(): void;
  17927. /** @hidden */
  17928. _reset(): void;
  17929. /**
  17930. * Copy the properties of particle to another one.
  17931. * @param other the particle to copy the information to.
  17932. */
  17933. copyTo(other: Particle): void;
  17934. }
  17935. }
  17936. declare module BABYLON {
  17937. /**
  17938. * Particle emitter represents a volume emitting particles.
  17939. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  17940. */
  17941. export interface IParticleEmitterType {
  17942. /**
  17943. * Called by the particle System when the direction is computed for the created particle.
  17944. * @param worldMatrix is the world matrix of the particle system
  17945. * @param directionToUpdate is the direction vector to update with the result
  17946. * @param particle is the particle we are computed the direction for
  17947. */
  17948. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17949. /**
  17950. * Called by the particle System when the position is computed for the created particle.
  17951. * @param worldMatrix is the world matrix of the particle system
  17952. * @param positionToUpdate is the position vector to update with the result
  17953. * @param particle is the particle we are computed the position for
  17954. */
  17955. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17956. /**
  17957. * Clones the current emitter and returns a copy of it
  17958. * @returns the new emitter
  17959. */
  17960. clone(): IParticleEmitterType;
  17961. /**
  17962. * Called by the GPUParticleSystem to setup the update shader
  17963. * @param effect defines the update shader
  17964. */
  17965. applyToShader(effect: Effect): void;
  17966. /**
  17967. * Returns a string to use to update the GPU particles update shader
  17968. * @returns the effect defines string
  17969. */
  17970. getEffectDefines(): string;
  17971. /**
  17972. * Returns a string representing the class name
  17973. * @returns a string containing the class name
  17974. */
  17975. getClassName(): string;
  17976. /**
  17977. * Serializes the particle system to a JSON object.
  17978. * @returns the JSON object
  17979. */
  17980. serialize(): any;
  17981. /**
  17982. * Parse properties from a JSON object
  17983. * @param serializationObject defines the JSON object
  17984. * @param scene defines the hosting scene
  17985. */
  17986. parse(serializationObject: any, scene: Scene): void;
  17987. }
  17988. }
  17989. declare module BABYLON {
  17990. /**
  17991. * Particle emitter emitting particles from the inside of a box.
  17992. * It emits the particles randomly between 2 given directions.
  17993. */
  17994. export class BoxParticleEmitter implements IParticleEmitterType {
  17995. /**
  17996. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17997. */
  17998. direction1: Vector3;
  17999. /**
  18000. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18001. */
  18002. direction2: Vector3;
  18003. /**
  18004. * 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.
  18005. */
  18006. minEmitBox: Vector3;
  18007. /**
  18008. * 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.
  18009. */
  18010. maxEmitBox: Vector3;
  18011. /**
  18012. * Creates a new instance BoxParticleEmitter
  18013. */
  18014. constructor();
  18015. /**
  18016. * Called by the particle System when the direction is computed for the created particle.
  18017. * @param worldMatrix is the world matrix of the particle system
  18018. * @param directionToUpdate is the direction vector to update with the result
  18019. * @param particle is the particle we are computed the direction for
  18020. */
  18021. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18022. /**
  18023. * Called by the particle System when the position is computed for the created particle.
  18024. * @param worldMatrix is the world matrix of the particle system
  18025. * @param positionToUpdate is the position vector to update with the result
  18026. * @param particle is the particle we are computed the position for
  18027. */
  18028. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18029. /**
  18030. * Clones the current emitter and returns a copy of it
  18031. * @returns the new emitter
  18032. */
  18033. clone(): BoxParticleEmitter;
  18034. /**
  18035. * Called by the GPUParticleSystem to setup the update shader
  18036. * @param effect defines the update shader
  18037. */
  18038. applyToShader(effect: Effect): void;
  18039. /**
  18040. * Returns a string to use to update the GPU particles update shader
  18041. * @returns a string containng the defines string
  18042. */
  18043. getEffectDefines(): string;
  18044. /**
  18045. * Returns the string "BoxParticleEmitter"
  18046. * @returns a string containing the class name
  18047. */
  18048. getClassName(): string;
  18049. /**
  18050. * Serializes the particle system to a JSON object.
  18051. * @returns the JSON object
  18052. */
  18053. serialize(): any;
  18054. /**
  18055. * Parse properties from a JSON object
  18056. * @param serializationObject defines the JSON object
  18057. */
  18058. parse(serializationObject: any): void;
  18059. }
  18060. }
  18061. declare module BABYLON {
  18062. /**
  18063. * Particle emitter emitting particles from the inside of a cone.
  18064. * It emits the particles alongside the cone volume from the base to the particle.
  18065. * The emission direction might be randomized.
  18066. */
  18067. export class ConeParticleEmitter implements IParticleEmitterType {
  18068. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  18069. directionRandomizer: number;
  18070. private _radius;
  18071. private _angle;
  18072. private _height;
  18073. /**
  18074. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  18075. */
  18076. radiusRange: number;
  18077. /**
  18078. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  18079. */
  18080. heightRange: number;
  18081. /**
  18082. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  18083. */
  18084. emitFromSpawnPointOnly: boolean;
  18085. /**
  18086. * Gets or sets the radius of the emission cone
  18087. */
  18088. get radius(): number;
  18089. set radius(value: number);
  18090. /**
  18091. * Gets or sets the angle of the emission cone
  18092. */
  18093. get angle(): number;
  18094. set angle(value: number);
  18095. private _buildHeight;
  18096. /**
  18097. * Creates a new instance ConeParticleEmitter
  18098. * @param radius the radius of the emission cone (1 by default)
  18099. * @param angle the cone base angle (PI by default)
  18100. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  18101. */
  18102. constructor(radius?: number, angle?: number,
  18103. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  18104. directionRandomizer?: number);
  18105. /**
  18106. * Called by the particle System when the direction is computed for the created particle.
  18107. * @param worldMatrix is the world matrix of the particle system
  18108. * @param directionToUpdate is the direction vector to update with the result
  18109. * @param particle is the particle we are computed the direction for
  18110. */
  18111. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18112. /**
  18113. * Called by the particle System when the position is computed for the created particle.
  18114. * @param worldMatrix is the world matrix of the particle system
  18115. * @param positionToUpdate is the position vector to update with the result
  18116. * @param particle is the particle we are computed the position for
  18117. */
  18118. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18119. /**
  18120. * Clones the current emitter and returns a copy of it
  18121. * @returns the new emitter
  18122. */
  18123. clone(): ConeParticleEmitter;
  18124. /**
  18125. * Called by the GPUParticleSystem to setup the update shader
  18126. * @param effect defines the update shader
  18127. */
  18128. applyToShader(effect: Effect): void;
  18129. /**
  18130. * Returns a string to use to update the GPU particles update shader
  18131. * @returns a string containng the defines string
  18132. */
  18133. getEffectDefines(): string;
  18134. /**
  18135. * Returns the string "ConeParticleEmitter"
  18136. * @returns a string containing the class name
  18137. */
  18138. getClassName(): string;
  18139. /**
  18140. * Serializes the particle system to a JSON object.
  18141. * @returns the JSON object
  18142. */
  18143. serialize(): any;
  18144. /**
  18145. * Parse properties from a JSON object
  18146. * @param serializationObject defines the JSON object
  18147. */
  18148. parse(serializationObject: any): void;
  18149. }
  18150. }
  18151. declare module BABYLON {
  18152. /**
  18153. * Particle emitter emitting particles from the inside of a cylinder.
  18154. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  18155. */
  18156. export class CylinderParticleEmitter implements IParticleEmitterType {
  18157. /**
  18158. * The radius of the emission cylinder.
  18159. */
  18160. radius: number;
  18161. /**
  18162. * The height of the emission cylinder.
  18163. */
  18164. height: number;
  18165. /**
  18166. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18167. */
  18168. radiusRange: number;
  18169. /**
  18170. * How much to randomize the particle direction [0-1].
  18171. */
  18172. directionRandomizer: number;
  18173. /**
  18174. * Creates a new instance CylinderParticleEmitter
  18175. * @param radius the radius of the emission cylinder (1 by default)
  18176. * @param height the height of the emission cylinder (1 by default)
  18177. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18178. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18179. */
  18180. constructor(
  18181. /**
  18182. * The radius of the emission cylinder.
  18183. */
  18184. radius?: number,
  18185. /**
  18186. * The height of the emission cylinder.
  18187. */
  18188. height?: number,
  18189. /**
  18190. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18191. */
  18192. radiusRange?: number,
  18193. /**
  18194. * How much to randomize the particle direction [0-1].
  18195. */
  18196. directionRandomizer?: number);
  18197. /**
  18198. * Called by the particle System when the direction is computed for the created particle.
  18199. * @param worldMatrix is the world matrix of the particle system
  18200. * @param directionToUpdate is the direction vector to update with the result
  18201. * @param particle is the particle we are computed the direction for
  18202. */
  18203. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18204. /**
  18205. * Called by the particle System when the position is computed for the created particle.
  18206. * @param worldMatrix is the world matrix of the particle system
  18207. * @param positionToUpdate is the position vector to update with the result
  18208. * @param particle is the particle we are computed the position for
  18209. */
  18210. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18211. /**
  18212. * Clones the current emitter and returns a copy of it
  18213. * @returns the new emitter
  18214. */
  18215. clone(): CylinderParticleEmitter;
  18216. /**
  18217. * Called by the GPUParticleSystem to setup the update shader
  18218. * @param effect defines the update shader
  18219. */
  18220. applyToShader(effect: Effect): void;
  18221. /**
  18222. * Returns a string to use to update the GPU particles update shader
  18223. * @returns a string containng the defines string
  18224. */
  18225. getEffectDefines(): string;
  18226. /**
  18227. * Returns the string "CylinderParticleEmitter"
  18228. * @returns a string containing the class name
  18229. */
  18230. getClassName(): string;
  18231. /**
  18232. * Serializes the particle system to a JSON object.
  18233. * @returns the JSON object
  18234. */
  18235. serialize(): any;
  18236. /**
  18237. * Parse properties from a JSON object
  18238. * @param serializationObject defines the JSON object
  18239. */
  18240. parse(serializationObject: any): void;
  18241. }
  18242. /**
  18243. * Particle emitter emitting particles from the inside of a cylinder.
  18244. * It emits the particles randomly between two vectors.
  18245. */
  18246. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  18247. /**
  18248. * The min limit of the emission direction.
  18249. */
  18250. direction1: Vector3;
  18251. /**
  18252. * The max limit of the emission direction.
  18253. */
  18254. direction2: Vector3;
  18255. /**
  18256. * Creates a new instance CylinderDirectedParticleEmitter
  18257. * @param radius the radius of the emission cylinder (1 by default)
  18258. * @param height the height of the emission cylinder (1 by default)
  18259. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18260. * @param direction1 the min limit of the emission direction (up vector by default)
  18261. * @param direction2 the max limit of the emission direction (up vector by default)
  18262. */
  18263. constructor(radius?: number, height?: number, radiusRange?: number,
  18264. /**
  18265. * The min limit of the emission direction.
  18266. */
  18267. direction1?: Vector3,
  18268. /**
  18269. * The max limit of the emission direction.
  18270. */
  18271. direction2?: Vector3);
  18272. /**
  18273. * Called by the particle System when the direction is computed for the created particle.
  18274. * @param worldMatrix is the world matrix of the particle system
  18275. * @param directionToUpdate is the direction vector to update with the result
  18276. * @param particle is the particle we are computed the direction for
  18277. */
  18278. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18279. /**
  18280. * Clones the current emitter and returns a copy of it
  18281. * @returns the new emitter
  18282. */
  18283. clone(): CylinderDirectedParticleEmitter;
  18284. /**
  18285. * Called by the GPUParticleSystem to setup the update shader
  18286. * @param effect defines the update shader
  18287. */
  18288. applyToShader(effect: Effect): void;
  18289. /**
  18290. * Returns a string to use to update the GPU particles update shader
  18291. * @returns a string containng the defines string
  18292. */
  18293. getEffectDefines(): string;
  18294. /**
  18295. * Returns the string "CylinderDirectedParticleEmitter"
  18296. * @returns a string containing the class name
  18297. */
  18298. getClassName(): string;
  18299. /**
  18300. * Serializes the particle system to a JSON object.
  18301. * @returns the JSON object
  18302. */
  18303. serialize(): any;
  18304. /**
  18305. * Parse properties from a JSON object
  18306. * @param serializationObject defines the JSON object
  18307. */
  18308. parse(serializationObject: any): void;
  18309. }
  18310. }
  18311. declare module BABYLON {
  18312. /**
  18313. * Particle emitter emitting particles from the inside of a hemisphere.
  18314. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  18315. */
  18316. export class HemisphericParticleEmitter implements IParticleEmitterType {
  18317. /**
  18318. * The radius of the emission hemisphere.
  18319. */
  18320. radius: number;
  18321. /**
  18322. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18323. */
  18324. radiusRange: number;
  18325. /**
  18326. * How much to randomize the particle direction [0-1].
  18327. */
  18328. directionRandomizer: number;
  18329. /**
  18330. * Creates a new instance HemisphericParticleEmitter
  18331. * @param radius the radius of the emission hemisphere (1 by default)
  18332. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18333. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18334. */
  18335. constructor(
  18336. /**
  18337. * The radius of the emission hemisphere.
  18338. */
  18339. radius?: number,
  18340. /**
  18341. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18342. */
  18343. radiusRange?: number,
  18344. /**
  18345. * How much to randomize the particle direction [0-1].
  18346. */
  18347. directionRandomizer?: number);
  18348. /**
  18349. * Called by the particle System when the direction is computed for the created particle.
  18350. * @param worldMatrix is the world matrix of the particle system
  18351. * @param directionToUpdate is the direction vector to update with the result
  18352. * @param particle is the particle we are computed the direction for
  18353. */
  18354. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18355. /**
  18356. * Called by the particle System when the position is computed for the created particle.
  18357. * @param worldMatrix is the world matrix of the particle system
  18358. * @param positionToUpdate is the position vector to update with the result
  18359. * @param particle is the particle we are computed the position for
  18360. */
  18361. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18362. /**
  18363. * Clones the current emitter and returns a copy of it
  18364. * @returns the new emitter
  18365. */
  18366. clone(): HemisphericParticleEmitter;
  18367. /**
  18368. * Called by the GPUParticleSystem to setup the update shader
  18369. * @param effect defines the update shader
  18370. */
  18371. applyToShader(effect: Effect): void;
  18372. /**
  18373. * Returns a string to use to update the GPU particles update shader
  18374. * @returns a string containng the defines string
  18375. */
  18376. getEffectDefines(): string;
  18377. /**
  18378. * Returns the string "HemisphericParticleEmitter"
  18379. * @returns a string containing the class name
  18380. */
  18381. getClassName(): string;
  18382. /**
  18383. * Serializes the particle system to a JSON object.
  18384. * @returns the JSON object
  18385. */
  18386. serialize(): any;
  18387. /**
  18388. * Parse properties from a JSON object
  18389. * @param serializationObject defines the JSON object
  18390. */
  18391. parse(serializationObject: any): void;
  18392. }
  18393. }
  18394. declare module BABYLON {
  18395. /**
  18396. * Particle emitter emitting particles from a point.
  18397. * It emits the particles randomly between 2 given directions.
  18398. */
  18399. export class PointParticleEmitter implements IParticleEmitterType {
  18400. /**
  18401. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18402. */
  18403. direction1: Vector3;
  18404. /**
  18405. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18406. */
  18407. direction2: Vector3;
  18408. /**
  18409. * Creates a new instance PointParticleEmitter
  18410. */
  18411. constructor();
  18412. /**
  18413. * Called by the particle System when the direction is computed for the created particle.
  18414. * @param worldMatrix is the world matrix of the particle system
  18415. * @param directionToUpdate is the direction vector to update with the result
  18416. * @param particle is the particle we are computed the direction for
  18417. */
  18418. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18419. /**
  18420. * Called by the particle System when the position is computed for the created particle.
  18421. * @param worldMatrix is the world matrix of the particle system
  18422. * @param positionToUpdate is the position vector to update with the result
  18423. * @param particle is the particle we are computed the position for
  18424. */
  18425. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18426. /**
  18427. * Clones the current emitter and returns a copy of it
  18428. * @returns the new emitter
  18429. */
  18430. clone(): PointParticleEmitter;
  18431. /**
  18432. * Called by the GPUParticleSystem to setup the update shader
  18433. * @param effect defines the update shader
  18434. */
  18435. applyToShader(effect: Effect): void;
  18436. /**
  18437. * Returns a string to use to update the GPU particles update shader
  18438. * @returns a string containng the defines string
  18439. */
  18440. getEffectDefines(): string;
  18441. /**
  18442. * Returns the string "PointParticleEmitter"
  18443. * @returns a string containing the class name
  18444. */
  18445. getClassName(): string;
  18446. /**
  18447. * Serializes the particle system to a JSON object.
  18448. * @returns the JSON object
  18449. */
  18450. serialize(): any;
  18451. /**
  18452. * Parse properties from a JSON object
  18453. * @param serializationObject defines the JSON object
  18454. */
  18455. parse(serializationObject: any): void;
  18456. }
  18457. }
  18458. declare module BABYLON {
  18459. /**
  18460. * Particle emitter emitting particles from the inside of a sphere.
  18461. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  18462. */
  18463. export class SphereParticleEmitter implements IParticleEmitterType {
  18464. /**
  18465. * The radius of the emission sphere.
  18466. */
  18467. radius: number;
  18468. /**
  18469. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18470. */
  18471. radiusRange: number;
  18472. /**
  18473. * How much to randomize the particle direction [0-1].
  18474. */
  18475. directionRandomizer: number;
  18476. /**
  18477. * Creates a new instance SphereParticleEmitter
  18478. * @param radius the radius of the emission sphere (1 by default)
  18479. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18480. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18481. */
  18482. constructor(
  18483. /**
  18484. * The radius of the emission sphere.
  18485. */
  18486. radius?: number,
  18487. /**
  18488. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18489. */
  18490. radiusRange?: number,
  18491. /**
  18492. * How much to randomize the particle direction [0-1].
  18493. */
  18494. directionRandomizer?: number);
  18495. /**
  18496. * Called by the particle System when the direction is computed for the created particle.
  18497. * @param worldMatrix is the world matrix of the particle system
  18498. * @param directionToUpdate is the direction vector to update with the result
  18499. * @param particle is the particle we are computed the direction for
  18500. */
  18501. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18502. /**
  18503. * Called by the particle System when the position is computed for the created particle.
  18504. * @param worldMatrix is the world matrix of the particle system
  18505. * @param positionToUpdate is the position vector to update with the result
  18506. * @param particle is the particle we are computed the position for
  18507. */
  18508. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18509. /**
  18510. * Clones the current emitter and returns a copy of it
  18511. * @returns the new emitter
  18512. */
  18513. clone(): SphereParticleEmitter;
  18514. /**
  18515. * Called by the GPUParticleSystem to setup the update shader
  18516. * @param effect defines the update shader
  18517. */
  18518. applyToShader(effect: Effect): void;
  18519. /**
  18520. * Returns a string to use to update the GPU particles update shader
  18521. * @returns a string containng the defines string
  18522. */
  18523. getEffectDefines(): string;
  18524. /**
  18525. * Returns the string "SphereParticleEmitter"
  18526. * @returns a string containing the class name
  18527. */
  18528. getClassName(): string;
  18529. /**
  18530. * Serializes the particle system to a JSON object.
  18531. * @returns the JSON object
  18532. */
  18533. serialize(): any;
  18534. /**
  18535. * Parse properties from a JSON object
  18536. * @param serializationObject defines the JSON object
  18537. */
  18538. parse(serializationObject: any): void;
  18539. }
  18540. /**
  18541. * Particle emitter emitting particles from the inside of a sphere.
  18542. * It emits the particles randomly between two vectors.
  18543. */
  18544. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  18545. /**
  18546. * The min limit of the emission direction.
  18547. */
  18548. direction1: Vector3;
  18549. /**
  18550. * The max limit of the emission direction.
  18551. */
  18552. direction2: Vector3;
  18553. /**
  18554. * Creates a new instance SphereDirectedParticleEmitter
  18555. * @param radius the radius of the emission sphere (1 by default)
  18556. * @param direction1 the min limit of the emission direction (up vector by default)
  18557. * @param direction2 the max limit of the emission direction (up vector by default)
  18558. */
  18559. constructor(radius?: number,
  18560. /**
  18561. * The min limit of the emission direction.
  18562. */
  18563. direction1?: Vector3,
  18564. /**
  18565. * The max limit of the emission direction.
  18566. */
  18567. direction2?: Vector3);
  18568. /**
  18569. * Called by the particle System when the direction is computed for the created particle.
  18570. * @param worldMatrix is the world matrix of the particle system
  18571. * @param directionToUpdate is the direction vector to update with the result
  18572. * @param particle is the particle we are computed the direction for
  18573. */
  18574. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18575. /**
  18576. * Clones the current emitter and returns a copy of it
  18577. * @returns the new emitter
  18578. */
  18579. clone(): SphereDirectedParticleEmitter;
  18580. /**
  18581. * Called by the GPUParticleSystem to setup the update shader
  18582. * @param effect defines the update shader
  18583. */
  18584. applyToShader(effect: Effect): void;
  18585. /**
  18586. * Returns a string to use to update the GPU particles update shader
  18587. * @returns a string containng the defines string
  18588. */
  18589. getEffectDefines(): string;
  18590. /**
  18591. * Returns the string "SphereDirectedParticleEmitter"
  18592. * @returns a string containing the class name
  18593. */
  18594. getClassName(): string;
  18595. /**
  18596. * Serializes the particle system to a JSON object.
  18597. * @returns the JSON object
  18598. */
  18599. serialize(): any;
  18600. /**
  18601. * Parse properties from a JSON object
  18602. * @param serializationObject defines the JSON object
  18603. */
  18604. parse(serializationObject: any): void;
  18605. }
  18606. }
  18607. declare module BABYLON {
  18608. /**
  18609. * Particle emitter emitting particles from a custom list of positions.
  18610. */
  18611. export class CustomParticleEmitter implements IParticleEmitterType {
  18612. /**
  18613. * Gets or sets the position generator that will create the inital position of each particle.
  18614. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  18615. */
  18616. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  18617. /**
  18618. * Gets or sets the destination generator that will create the final destination of each particle.
  18619. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  18620. */
  18621. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  18622. /**
  18623. * Creates a new instance CustomParticleEmitter
  18624. */
  18625. constructor();
  18626. /**
  18627. * Called by the particle System when the direction is computed for the created particle.
  18628. * @param worldMatrix is the world matrix of the particle system
  18629. * @param directionToUpdate is the direction vector to update with the result
  18630. * @param particle is the particle we are computed the direction for
  18631. */
  18632. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18633. /**
  18634. * Called by the particle System when the position is computed for the created particle.
  18635. * @param worldMatrix is the world matrix of the particle system
  18636. * @param positionToUpdate is the position vector to update with the result
  18637. * @param particle is the particle we are computed the position for
  18638. */
  18639. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18640. /**
  18641. * Clones the current emitter and returns a copy of it
  18642. * @returns the new emitter
  18643. */
  18644. clone(): CustomParticleEmitter;
  18645. /**
  18646. * Called by the GPUParticleSystem to setup the update shader
  18647. * @param effect defines the update shader
  18648. */
  18649. applyToShader(effect: Effect): void;
  18650. /**
  18651. * Returns a string to use to update the GPU particles update shader
  18652. * @returns a string containng the defines string
  18653. */
  18654. getEffectDefines(): string;
  18655. /**
  18656. * Returns the string "PointParticleEmitter"
  18657. * @returns a string containing the class name
  18658. */
  18659. getClassName(): string;
  18660. /**
  18661. * Serializes the particle system to a JSON object.
  18662. * @returns the JSON object
  18663. */
  18664. serialize(): any;
  18665. /**
  18666. * Parse properties from a JSON object
  18667. * @param serializationObject defines the JSON object
  18668. */
  18669. parse(serializationObject: any): void;
  18670. }
  18671. }
  18672. declare module BABYLON {
  18673. /**
  18674. * Particle emitter emitting particles from the inside of a box.
  18675. * It emits the particles randomly between 2 given directions.
  18676. */
  18677. export class MeshParticleEmitter implements IParticleEmitterType {
  18678. /** Defines the mesh to use as source */
  18679. mesh?: AbstractMesh | undefined;
  18680. private _indices;
  18681. private _positions;
  18682. private _normals;
  18683. private _storedNormal;
  18684. /**
  18685. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18686. */
  18687. direction1: Vector3;
  18688. /**
  18689. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18690. */
  18691. direction2: Vector3;
  18692. /**
  18693. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  18694. */
  18695. useMeshNormalsForDirection: boolean;
  18696. /**
  18697. * Creates a new instance MeshParticleEmitter
  18698. * @param mesh defines the mesh to use as source
  18699. */
  18700. constructor(
  18701. /** Defines the mesh to use as source */
  18702. mesh?: AbstractMesh | undefined);
  18703. /**
  18704. * Called by the particle System when the direction is computed for the created particle.
  18705. * @param worldMatrix is the world matrix of the particle system
  18706. * @param directionToUpdate is the direction vector to update with the result
  18707. * @param particle is the particle we are computed the direction for
  18708. */
  18709. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18710. /**
  18711. * Called by the particle System when the position is computed for the created particle.
  18712. * @param worldMatrix is the world matrix of the particle system
  18713. * @param positionToUpdate is the position vector to update with the result
  18714. * @param particle is the particle we are computed the position for
  18715. */
  18716. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18717. /**
  18718. * Clones the current emitter and returns a copy of it
  18719. * @returns the new emitter
  18720. */
  18721. clone(): MeshParticleEmitter;
  18722. /**
  18723. * Called by the GPUParticleSystem to setup the update shader
  18724. * @param effect defines the update shader
  18725. */
  18726. applyToShader(effect: Effect): void;
  18727. /**
  18728. * Returns a string to use to update the GPU particles update shader
  18729. * @returns a string containng the defines string
  18730. */
  18731. getEffectDefines(): string;
  18732. /**
  18733. * Returns the string "BoxParticleEmitter"
  18734. * @returns a string containing the class name
  18735. */
  18736. getClassName(): string;
  18737. /**
  18738. * Serializes the particle system to a JSON object.
  18739. * @returns the JSON object
  18740. */
  18741. serialize(): any;
  18742. /**
  18743. * Parse properties from a JSON object
  18744. * @param serializationObject defines the JSON object
  18745. * @param scene defines the hosting scene
  18746. */
  18747. parse(serializationObject: any, scene: Scene): void;
  18748. }
  18749. }
  18750. declare module BABYLON {
  18751. /**
  18752. * Interface representing a particle system in Babylon.js.
  18753. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  18754. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  18755. */
  18756. export interface IParticleSystem {
  18757. /**
  18758. * List of animations used by the particle system.
  18759. */
  18760. animations: Animation[];
  18761. /**
  18762. * The id of the Particle system.
  18763. */
  18764. id: string;
  18765. /**
  18766. * The name of the Particle system.
  18767. */
  18768. name: string;
  18769. /**
  18770. * The emitter represents the Mesh or position we are attaching the particle system to.
  18771. */
  18772. emitter: Nullable<AbstractMesh | Vector3>;
  18773. /**
  18774. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  18775. */
  18776. isBillboardBased: boolean;
  18777. /**
  18778. * The rendering group used by the Particle system to chose when to render.
  18779. */
  18780. renderingGroupId: number;
  18781. /**
  18782. * The layer mask we are rendering the particles through.
  18783. */
  18784. layerMask: number;
  18785. /**
  18786. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  18787. */
  18788. updateSpeed: number;
  18789. /**
  18790. * The amount of time the particle system is running (depends of the overall update speed).
  18791. */
  18792. targetStopDuration: number;
  18793. /**
  18794. * The texture used to render each particle. (this can be a spritesheet)
  18795. */
  18796. particleTexture: Nullable<Texture>;
  18797. /**
  18798. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  18799. */
  18800. blendMode: number;
  18801. /**
  18802. * Minimum life time of emitting particles.
  18803. */
  18804. minLifeTime: number;
  18805. /**
  18806. * Maximum life time of emitting particles.
  18807. */
  18808. maxLifeTime: number;
  18809. /**
  18810. * Minimum Size of emitting particles.
  18811. */
  18812. minSize: number;
  18813. /**
  18814. * Maximum Size of emitting particles.
  18815. */
  18816. maxSize: number;
  18817. /**
  18818. * Minimum scale of emitting particles on X axis.
  18819. */
  18820. minScaleX: number;
  18821. /**
  18822. * Maximum scale of emitting particles on X axis.
  18823. */
  18824. maxScaleX: number;
  18825. /**
  18826. * Minimum scale of emitting particles on Y axis.
  18827. */
  18828. minScaleY: number;
  18829. /**
  18830. * Maximum scale of emitting particles on Y axis.
  18831. */
  18832. maxScaleY: number;
  18833. /**
  18834. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18835. */
  18836. color1: Color4;
  18837. /**
  18838. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18839. */
  18840. color2: Color4;
  18841. /**
  18842. * Color the particle will have at the end of its lifetime.
  18843. */
  18844. colorDead: Color4;
  18845. /**
  18846. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  18847. */
  18848. emitRate: number;
  18849. /**
  18850. * You can use gravity if you want to give an orientation to your particles.
  18851. */
  18852. gravity: Vector3;
  18853. /**
  18854. * Minimum power of emitting particles.
  18855. */
  18856. minEmitPower: number;
  18857. /**
  18858. * Maximum power of emitting particles.
  18859. */
  18860. maxEmitPower: number;
  18861. /**
  18862. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  18863. */
  18864. minAngularSpeed: number;
  18865. /**
  18866. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  18867. */
  18868. maxAngularSpeed: number;
  18869. /**
  18870. * Gets or sets the minimal initial rotation in radians.
  18871. */
  18872. minInitialRotation: number;
  18873. /**
  18874. * Gets or sets the maximal initial rotation in radians.
  18875. */
  18876. maxInitialRotation: number;
  18877. /**
  18878. * The particle emitter type defines the emitter used by the particle system.
  18879. * It can be for example box, sphere, or cone...
  18880. */
  18881. particleEmitterType: Nullable<IParticleEmitterType>;
  18882. /**
  18883. * Defines the delay in milliseconds before starting the system (0 by default)
  18884. */
  18885. startDelay: number;
  18886. /**
  18887. * 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
  18888. */
  18889. preWarmCycles: number;
  18890. /**
  18891. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  18892. */
  18893. preWarmStepOffset: number;
  18894. /**
  18895. * 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)
  18896. */
  18897. spriteCellChangeSpeed: number;
  18898. /**
  18899. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  18900. */
  18901. startSpriteCellID: number;
  18902. /**
  18903. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  18904. */
  18905. endSpriteCellID: number;
  18906. /**
  18907. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  18908. */
  18909. spriteCellWidth: number;
  18910. /**
  18911. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  18912. */
  18913. spriteCellHeight: number;
  18914. /**
  18915. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  18916. */
  18917. spriteRandomStartCell: boolean;
  18918. /**
  18919. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  18920. */
  18921. isAnimationSheetEnabled: boolean;
  18922. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  18923. translationPivot: Vector2;
  18924. /**
  18925. * Gets or sets a texture used to add random noise to particle positions
  18926. */
  18927. noiseTexture: Nullable<BaseTexture>;
  18928. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  18929. noiseStrength: Vector3;
  18930. /**
  18931. * Gets or sets the billboard mode to use when isBillboardBased = true.
  18932. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  18933. */
  18934. billboardMode: number;
  18935. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  18936. limitVelocityDamping: number;
  18937. /**
  18938. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  18939. */
  18940. beginAnimationOnStart: boolean;
  18941. /**
  18942. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  18943. */
  18944. beginAnimationFrom: number;
  18945. /**
  18946. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  18947. */
  18948. beginAnimationTo: number;
  18949. /**
  18950. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  18951. */
  18952. beginAnimationLoop: boolean;
  18953. /**
  18954. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  18955. */
  18956. disposeOnStop: boolean;
  18957. /**
  18958. * Gets the maximum number of particles active at the same time.
  18959. * @returns The max number of active particles.
  18960. */
  18961. getCapacity(): number;
  18962. /**
  18963. * Gets if the system has been started. (Note: this will still be true after stop is called)
  18964. * @returns True if it has been started, otherwise false.
  18965. */
  18966. isStarted(): boolean;
  18967. /**
  18968. * Animates the particle system for this frame.
  18969. */
  18970. animate(): void;
  18971. /**
  18972. * Renders the particle system in its current state.
  18973. * @returns the current number of particles
  18974. */
  18975. render(): number;
  18976. /**
  18977. * Dispose the particle system and frees its associated resources.
  18978. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  18979. */
  18980. dispose(disposeTexture?: boolean): void;
  18981. /**
  18982. * Clones the particle system.
  18983. * @param name The name of the cloned object
  18984. * @param newEmitter The new emitter to use
  18985. * @returns the cloned particle system
  18986. */
  18987. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  18988. /**
  18989. * Serializes the particle system to a JSON object.
  18990. * @returns the JSON object
  18991. */
  18992. serialize(): any;
  18993. /**
  18994. * Rebuild the particle system
  18995. */
  18996. rebuild(): void;
  18997. /**
  18998. * Starts the particle system and begins to emit
  18999. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  19000. */
  19001. start(delay?: number): void;
  19002. /**
  19003. * Stops the particle system.
  19004. */
  19005. stop(): void;
  19006. /**
  19007. * Remove all active particles
  19008. */
  19009. reset(): void;
  19010. /**
  19011. * Is this system ready to be used/rendered
  19012. * @return true if the system is ready
  19013. */
  19014. isReady(): boolean;
  19015. /**
  19016. * Adds a new color gradient
  19017. * @param gradient defines the gradient to use (between 0 and 1)
  19018. * @param color1 defines the color to affect to the specified gradient
  19019. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  19020. * @returns the current particle system
  19021. */
  19022. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  19023. /**
  19024. * Remove a specific color gradient
  19025. * @param gradient defines the gradient to remove
  19026. * @returns the current particle system
  19027. */
  19028. removeColorGradient(gradient: number): IParticleSystem;
  19029. /**
  19030. * Adds a new size gradient
  19031. * @param gradient defines the gradient to use (between 0 and 1)
  19032. * @param factor defines the size factor to affect to the specified gradient
  19033. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19034. * @returns the current particle system
  19035. */
  19036. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19037. /**
  19038. * Remove a specific size gradient
  19039. * @param gradient defines the gradient to remove
  19040. * @returns the current particle system
  19041. */
  19042. removeSizeGradient(gradient: number): IParticleSystem;
  19043. /**
  19044. * Gets the current list of color gradients.
  19045. * You must use addColorGradient and removeColorGradient to udpate this list
  19046. * @returns the list of color gradients
  19047. */
  19048. getColorGradients(): Nullable<Array<ColorGradient>>;
  19049. /**
  19050. * Gets the current list of size gradients.
  19051. * You must use addSizeGradient and removeSizeGradient to udpate this list
  19052. * @returns the list of size gradients
  19053. */
  19054. getSizeGradients(): Nullable<Array<FactorGradient>>;
  19055. /**
  19056. * Gets the current list of angular speed gradients.
  19057. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  19058. * @returns the list of angular speed gradients
  19059. */
  19060. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  19061. /**
  19062. * Adds a new angular speed gradient
  19063. * @param gradient defines the gradient to use (between 0 and 1)
  19064. * @param factor defines the angular speed to affect to the specified gradient
  19065. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19066. * @returns the current particle system
  19067. */
  19068. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19069. /**
  19070. * Remove a specific angular speed gradient
  19071. * @param gradient defines the gradient to remove
  19072. * @returns the current particle system
  19073. */
  19074. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  19075. /**
  19076. * Gets the current list of velocity gradients.
  19077. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  19078. * @returns the list of velocity gradients
  19079. */
  19080. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  19081. /**
  19082. * Adds a new velocity gradient
  19083. * @param gradient defines the gradient to use (between 0 and 1)
  19084. * @param factor defines the velocity to affect to the specified gradient
  19085. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19086. * @returns the current particle system
  19087. */
  19088. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19089. /**
  19090. * Remove a specific velocity gradient
  19091. * @param gradient defines the gradient to remove
  19092. * @returns the current particle system
  19093. */
  19094. removeVelocityGradient(gradient: number): IParticleSystem;
  19095. /**
  19096. * Gets the current list of limit velocity gradients.
  19097. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  19098. * @returns the list of limit velocity gradients
  19099. */
  19100. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  19101. /**
  19102. * Adds a new limit velocity gradient
  19103. * @param gradient defines the gradient to use (between 0 and 1)
  19104. * @param factor defines the limit velocity to affect to the specified gradient
  19105. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19106. * @returns the current particle system
  19107. */
  19108. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19109. /**
  19110. * Remove a specific limit velocity gradient
  19111. * @param gradient defines the gradient to remove
  19112. * @returns the current particle system
  19113. */
  19114. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  19115. /**
  19116. * Adds a new drag gradient
  19117. * @param gradient defines the gradient to use (between 0 and 1)
  19118. * @param factor defines the drag to affect to the specified gradient
  19119. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19120. * @returns the current particle system
  19121. */
  19122. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19123. /**
  19124. * Remove a specific drag gradient
  19125. * @param gradient defines the gradient to remove
  19126. * @returns the current particle system
  19127. */
  19128. removeDragGradient(gradient: number): IParticleSystem;
  19129. /**
  19130. * Gets the current list of drag gradients.
  19131. * You must use addDragGradient and removeDragGradient to udpate this list
  19132. * @returns the list of drag gradients
  19133. */
  19134. getDragGradients(): Nullable<Array<FactorGradient>>;
  19135. /**
  19136. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  19137. * @param gradient defines the gradient to use (between 0 and 1)
  19138. * @param factor defines the emit rate to affect to the specified gradient
  19139. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19140. * @returns the current particle system
  19141. */
  19142. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19143. /**
  19144. * Remove a specific emit rate gradient
  19145. * @param gradient defines the gradient to remove
  19146. * @returns the current particle system
  19147. */
  19148. removeEmitRateGradient(gradient: number): IParticleSystem;
  19149. /**
  19150. * Gets the current list of emit rate gradients.
  19151. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  19152. * @returns the list of emit rate gradients
  19153. */
  19154. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  19155. /**
  19156. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  19157. * @param gradient defines the gradient to use (between 0 and 1)
  19158. * @param factor defines the start size to affect to the specified gradient
  19159. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19160. * @returns the current particle system
  19161. */
  19162. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19163. /**
  19164. * Remove a specific start size gradient
  19165. * @param gradient defines the gradient to remove
  19166. * @returns the current particle system
  19167. */
  19168. removeStartSizeGradient(gradient: number): IParticleSystem;
  19169. /**
  19170. * Gets the current list of start size gradients.
  19171. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  19172. * @returns the list of start size gradients
  19173. */
  19174. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  19175. /**
  19176. * Adds a new life time gradient
  19177. * @param gradient defines the gradient to use (between 0 and 1)
  19178. * @param factor defines the life time factor to affect to the specified gradient
  19179. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19180. * @returns the current particle system
  19181. */
  19182. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19183. /**
  19184. * Remove a specific life time gradient
  19185. * @param gradient defines the gradient to remove
  19186. * @returns the current particle system
  19187. */
  19188. removeLifeTimeGradient(gradient: number): IParticleSystem;
  19189. /**
  19190. * Gets the current list of life time gradients.
  19191. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  19192. * @returns the list of life time gradients
  19193. */
  19194. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  19195. /**
  19196. * Gets the current list of color gradients.
  19197. * You must use addColorGradient and removeColorGradient to udpate this list
  19198. * @returns the list of color gradients
  19199. */
  19200. getColorGradients(): Nullable<Array<ColorGradient>>;
  19201. /**
  19202. * Adds a new ramp gradient used to remap particle colors
  19203. * @param gradient defines the gradient to use (between 0 and 1)
  19204. * @param color defines the color to affect to the specified gradient
  19205. * @returns the current particle system
  19206. */
  19207. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  19208. /**
  19209. * Gets the current list of ramp gradients.
  19210. * You must use addRampGradient and removeRampGradient to udpate this list
  19211. * @returns the list of ramp gradients
  19212. */
  19213. getRampGradients(): Nullable<Array<Color3Gradient>>;
  19214. /** Gets or sets a boolean indicating that ramp gradients must be used
  19215. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  19216. */
  19217. useRampGradients: boolean;
  19218. /**
  19219. * Adds a new color remap gradient
  19220. * @param gradient defines the gradient to use (between 0 and 1)
  19221. * @param min defines the color remap minimal range
  19222. * @param max defines the color remap maximal range
  19223. * @returns the current particle system
  19224. */
  19225. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  19226. /**
  19227. * Gets the current list of color remap gradients.
  19228. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  19229. * @returns the list of color remap gradients
  19230. */
  19231. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  19232. /**
  19233. * Adds a new alpha remap gradient
  19234. * @param gradient defines the gradient to use (between 0 and 1)
  19235. * @param min defines the alpha remap minimal range
  19236. * @param max defines the alpha remap maximal range
  19237. * @returns the current particle system
  19238. */
  19239. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  19240. /**
  19241. * Gets the current list of alpha remap gradients.
  19242. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  19243. * @returns the list of alpha remap gradients
  19244. */
  19245. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  19246. /**
  19247. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  19248. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19249. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19250. * @returns the emitter
  19251. */
  19252. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  19253. /**
  19254. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  19255. * @param radius The radius of the hemisphere to emit from
  19256. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  19257. * @returns the emitter
  19258. */
  19259. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  19260. /**
  19261. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  19262. * @param radius The radius of the sphere to emit from
  19263. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  19264. * @returns the emitter
  19265. */
  19266. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  19267. /**
  19268. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  19269. * @param radius The radius of the sphere to emit from
  19270. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  19271. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  19272. * @returns the emitter
  19273. */
  19274. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  19275. /**
  19276. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  19277. * @param radius The radius of the emission cylinder
  19278. * @param height The height of the emission cylinder
  19279. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  19280. * @param directionRandomizer How much to randomize the particle direction [0-1]
  19281. * @returns the emitter
  19282. */
  19283. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  19284. /**
  19285. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  19286. * @param radius The radius of the cylinder to emit from
  19287. * @param height The height of the emission cylinder
  19288. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  19289. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  19290. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  19291. * @returns the emitter
  19292. */
  19293. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  19294. /**
  19295. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  19296. * @param radius The radius of the cone to emit from
  19297. * @param angle The base angle of the cone
  19298. * @returns the emitter
  19299. */
  19300. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  19301. /**
  19302. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  19303. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19304. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19305. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19306. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19307. * @returns the emitter
  19308. */
  19309. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  19310. /**
  19311. * Get hosting scene
  19312. * @returns the scene
  19313. */
  19314. getScene(): Scene;
  19315. }
  19316. }
  19317. declare module BABYLON {
  19318. /**
  19319. * Creates an instance based on a source mesh.
  19320. */
  19321. export class InstancedMesh extends AbstractMesh {
  19322. private _sourceMesh;
  19323. private _currentLOD;
  19324. /** @hidden */
  19325. _indexInSourceMeshInstanceArray: number;
  19326. constructor(name: string, source: Mesh);
  19327. /**
  19328. * Returns the string "InstancedMesh".
  19329. */
  19330. getClassName(): string;
  19331. /** Gets the list of lights affecting that mesh */
  19332. get lightSources(): Light[];
  19333. _resyncLightSources(): void;
  19334. _resyncLightSource(light: Light): void;
  19335. _removeLightSource(light: Light, dispose: boolean): void;
  19336. /**
  19337. * If the source mesh receives shadows
  19338. */
  19339. get receiveShadows(): boolean;
  19340. /**
  19341. * The material of the source mesh
  19342. */
  19343. get material(): Nullable<Material>;
  19344. /**
  19345. * Visibility of the source mesh
  19346. */
  19347. get visibility(): number;
  19348. /**
  19349. * Skeleton of the source mesh
  19350. */
  19351. get skeleton(): Nullable<Skeleton>;
  19352. /**
  19353. * Rendering ground id of the source mesh
  19354. */
  19355. get renderingGroupId(): number;
  19356. set renderingGroupId(value: number);
  19357. /**
  19358. * Returns the total number of vertices (integer).
  19359. */
  19360. getTotalVertices(): number;
  19361. /**
  19362. * Returns a positive integer : the total number of indices in this mesh geometry.
  19363. * @returns the numner of indices or zero if the mesh has no geometry.
  19364. */
  19365. getTotalIndices(): number;
  19366. /**
  19367. * The source mesh of the instance
  19368. */
  19369. get sourceMesh(): Mesh;
  19370. /**
  19371. * Is this node ready to be used/rendered
  19372. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  19373. * @return {boolean} is it ready
  19374. */
  19375. isReady(completeCheck?: boolean): boolean;
  19376. /**
  19377. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  19378. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  19379. * @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.
  19380. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  19381. */
  19382. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  19383. /**
  19384. * Sets the vertex data of the mesh geometry for the requested `kind`.
  19385. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  19386. * The `data` are either a numeric array either a Float32Array.
  19387. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  19388. * 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).
  19389. * Note that a new underlying VertexBuffer object is created each call.
  19390. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  19391. *
  19392. * Possible `kind` values :
  19393. * - VertexBuffer.PositionKind
  19394. * - VertexBuffer.UVKind
  19395. * - VertexBuffer.UV2Kind
  19396. * - VertexBuffer.UV3Kind
  19397. * - VertexBuffer.UV4Kind
  19398. * - VertexBuffer.UV5Kind
  19399. * - VertexBuffer.UV6Kind
  19400. * - VertexBuffer.ColorKind
  19401. * - VertexBuffer.MatricesIndicesKind
  19402. * - VertexBuffer.MatricesIndicesExtraKind
  19403. * - VertexBuffer.MatricesWeightsKind
  19404. * - VertexBuffer.MatricesWeightsExtraKind
  19405. *
  19406. * Returns the Mesh.
  19407. */
  19408. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  19409. /**
  19410. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  19411. * If the mesh has no geometry, it is simply returned as it is.
  19412. * The `data` are either a numeric array either a Float32Array.
  19413. * No new underlying VertexBuffer object is created.
  19414. * 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.
  19415. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  19416. *
  19417. * Possible `kind` values :
  19418. * - VertexBuffer.PositionKind
  19419. * - VertexBuffer.UVKind
  19420. * - VertexBuffer.UV2Kind
  19421. * - VertexBuffer.UV3Kind
  19422. * - VertexBuffer.UV4Kind
  19423. * - VertexBuffer.UV5Kind
  19424. * - VertexBuffer.UV6Kind
  19425. * - VertexBuffer.ColorKind
  19426. * - VertexBuffer.MatricesIndicesKind
  19427. * - VertexBuffer.MatricesIndicesExtraKind
  19428. * - VertexBuffer.MatricesWeightsKind
  19429. * - VertexBuffer.MatricesWeightsExtraKind
  19430. *
  19431. * Returns the Mesh.
  19432. */
  19433. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  19434. /**
  19435. * Sets the mesh indices.
  19436. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  19437. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  19438. * This method creates a new index buffer each call.
  19439. * Returns the Mesh.
  19440. */
  19441. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  19442. /**
  19443. * Boolean : True if the mesh owns the requested kind of data.
  19444. */
  19445. isVerticesDataPresent(kind: string): boolean;
  19446. /**
  19447. * Returns an array of indices (IndicesArray).
  19448. */
  19449. getIndices(): Nullable<IndicesArray>;
  19450. get _positions(): Nullable<Vector3[]>;
  19451. /**
  19452. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  19453. * This means the mesh underlying bounding box and sphere are recomputed.
  19454. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  19455. * @returns the current mesh
  19456. */
  19457. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  19458. /** @hidden */
  19459. _preActivate(): InstancedMesh;
  19460. /** @hidden */
  19461. _activate(renderId: number, intermediateRendering: boolean): boolean;
  19462. /** @hidden */
  19463. _postActivate(): void;
  19464. getWorldMatrix(): Matrix;
  19465. get isAnInstance(): boolean;
  19466. /**
  19467. * Returns the current associated LOD AbstractMesh.
  19468. */
  19469. getLOD(camera: Camera): AbstractMesh;
  19470. /** @hidden */
  19471. _syncSubMeshes(): InstancedMesh;
  19472. /** @hidden */
  19473. _generatePointsArray(): boolean;
  19474. /**
  19475. * Creates a new InstancedMesh from the current mesh.
  19476. * - name (string) : the cloned mesh name
  19477. * - newParent (optional Node) : the optional Node to parent the clone to.
  19478. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  19479. *
  19480. * Returns the clone.
  19481. */
  19482. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  19483. /**
  19484. * Disposes the InstancedMesh.
  19485. * Returns nothing.
  19486. */
  19487. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  19488. }
  19489. interface Mesh {
  19490. /**
  19491. * Register a custom buffer that will be instanced
  19492. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  19493. * @param kind defines the buffer kind
  19494. * @param stride defines the stride in floats
  19495. */
  19496. registerInstancedBuffer(kind: string, stride: number): void;
  19497. /** @hidden */
  19498. _userInstancedBuffersStorage: {
  19499. data: {
  19500. [key: string]: Float32Array;
  19501. };
  19502. sizes: {
  19503. [key: string]: number;
  19504. };
  19505. vertexBuffers: {
  19506. [key: string]: Nullable<VertexBuffer>;
  19507. };
  19508. strides: {
  19509. [key: string]: number;
  19510. };
  19511. };
  19512. }
  19513. interface AbstractMesh {
  19514. /**
  19515. * Object used to store instanced buffers defined by user
  19516. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  19517. */
  19518. instancedBuffers: {
  19519. [key: string]: any;
  19520. };
  19521. }
  19522. }
  19523. declare module BABYLON {
  19524. /**
  19525. * Defines the options associated with the creation of a shader material.
  19526. */
  19527. export interface IShaderMaterialOptions {
  19528. /**
  19529. * Does the material work in alpha blend mode
  19530. */
  19531. needAlphaBlending: boolean;
  19532. /**
  19533. * Does the material work in alpha test mode
  19534. */
  19535. needAlphaTesting: boolean;
  19536. /**
  19537. * The list of attribute names used in the shader
  19538. */
  19539. attributes: string[];
  19540. /**
  19541. * The list of unifrom names used in the shader
  19542. */
  19543. uniforms: string[];
  19544. /**
  19545. * The list of UBO names used in the shader
  19546. */
  19547. uniformBuffers: string[];
  19548. /**
  19549. * The list of sampler names used in the shader
  19550. */
  19551. samplers: string[];
  19552. /**
  19553. * The list of defines used in the shader
  19554. */
  19555. defines: string[];
  19556. }
  19557. /**
  19558. * 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.
  19559. *
  19560. * This returned material effects how the mesh will look based on the code in the shaders.
  19561. *
  19562. * @see http://doc.babylonjs.com/how_to/shader_material
  19563. */
  19564. export class ShaderMaterial extends Material {
  19565. private _shaderPath;
  19566. private _options;
  19567. private _textures;
  19568. private _textureArrays;
  19569. private _floats;
  19570. private _ints;
  19571. private _floatsArrays;
  19572. private _colors3;
  19573. private _colors3Arrays;
  19574. private _colors4;
  19575. private _colors4Arrays;
  19576. private _vectors2;
  19577. private _vectors3;
  19578. private _vectors4;
  19579. private _matrices;
  19580. private _matrixArrays;
  19581. private _matrices3x3;
  19582. private _matrices2x2;
  19583. private _vectors2Arrays;
  19584. private _vectors3Arrays;
  19585. private _vectors4Arrays;
  19586. private _cachedWorldViewMatrix;
  19587. private _cachedWorldViewProjectionMatrix;
  19588. private _renderId;
  19589. private _multiview;
  19590. /**
  19591. * Instantiate a new shader material.
  19592. * 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.
  19593. * This returned material effects how the mesh will look based on the code in the shaders.
  19594. * @see http://doc.babylonjs.com/how_to/shader_material
  19595. * @param name Define the name of the material in the scene
  19596. * @param scene Define the scene the material belongs to
  19597. * @param shaderPath Defines the route to the shader code in one of three ways:
  19598. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  19599. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  19600. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  19601. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  19602. * @param options Define the options used to create the shader
  19603. */
  19604. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  19605. /**
  19606. * Gets the shader path used to define the shader code
  19607. * It can be modified to trigger a new compilation
  19608. */
  19609. get shaderPath(): any;
  19610. /**
  19611. * Sets the shader path used to define the shader code
  19612. * It can be modified to trigger a new compilation
  19613. */
  19614. set shaderPath(shaderPath: any);
  19615. /**
  19616. * Gets the options used to compile the shader.
  19617. * They can be modified to trigger a new compilation
  19618. */
  19619. get options(): IShaderMaterialOptions;
  19620. /**
  19621. * Gets the current class name of the material e.g. "ShaderMaterial"
  19622. * Mainly use in serialization.
  19623. * @returns the class name
  19624. */
  19625. getClassName(): string;
  19626. /**
  19627. * Specifies if the material will require alpha blending
  19628. * @returns a boolean specifying if alpha blending is needed
  19629. */
  19630. needAlphaBlending(): boolean;
  19631. /**
  19632. * Specifies if this material should be rendered in alpha test mode
  19633. * @returns a boolean specifying if an alpha test is needed.
  19634. */
  19635. needAlphaTesting(): boolean;
  19636. private _checkUniform;
  19637. /**
  19638. * Set a texture in the shader.
  19639. * @param name Define the name of the uniform samplers as defined in the shader
  19640. * @param texture Define the texture to bind to this sampler
  19641. * @return the material itself allowing "fluent" like uniform updates
  19642. */
  19643. setTexture(name: string, texture: Texture): ShaderMaterial;
  19644. /**
  19645. * Set a texture array in the shader.
  19646. * @param name Define the name of the uniform sampler array as defined in the shader
  19647. * @param textures Define the list of textures to bind to this sampler
  19648. * @return the material itself allowing "fluent" like uniform updates
  19649. */
  19650. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  19651. /**
  19652. * Set a float in the shader.
  19653. * @param name Define the name of the uniform as defined in the shader
  19654. * @param value Define the value to give to the uniform
  19655. * @return the material itself allowing "fluent" like uniform updates
  19656. */
  19657. setFloat(name: string, value: number): ShaderMaterial;
  19658. /**
  19659. * Set a int in the shader.
  19660. * @param name Define the name of the uniform as defined in the shader
  19661. * @param value Define the value to give to the uniform
  19662. * @return the material itself allowing "fluent" like uniform updates
  19663. */
  19664. setInt(name: string, value: number): ShaderMaterial;
  19665. /**
  19666. * Set an array of floats in the shader.
  19667. * @param name Define the name of the uniform as defined in the shader
  19668. * @param value Define the value to give to the uniform
  19669. * @return the material itself allowing "fluent" like uniform updates
  19670. */
  19671. setFloats(name: string, value: number[]): ShaderMaterial;
  19672. /**
  19673. * Set a vec3 in the shader from a Color3.
  19674. * @param name Define the name of the uniform as defined in the shader
  19675. * @param value Define the value to give to the uniform
  19676. * @return the material itself allowing "fluent" like uniform updates
  19677. */
  19678. setColor3(name: string, value: Color3): ShaderMaterial;
  19679. /**
  19680. * Set a vec3 array in the shader from a Color3 array.
  19681. * @param name Define the name of the uniform as defined in the shader
  19682. * @param value Define the value to give to the uniform
  19683. * @return the material itself allowing "fluent" like uniform updates
  19684. */
  19685. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  19686. /**
  19687. * Set a vec4 in the shader from a Color4.
  19688. * @param name Define the name of the uniform as defined in the shader
  19689. * @param value Define the value to give to the uniform
  19690. * @return the material itself allowing "fluent" like uniform updates
  19691. */
  19692. setColor4(name: string, value: Color4): ShaderMaterial;
  19693. /**
  19694. * Set a vec4 array in the shader from a Color4 array.
  19695. * @param name Define the name of the uniform as defined in the shader
  19696. * @param value Define the value to give to the uniform
  19697. * @return the material itself allowing "fluent" like uniform updates
  19698. */
  19699. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  19700. /**
  19701. * Set a vec2 in the shader from a Vector2.
  19702. * @param name Define the name of the uniform as defined in the shader
  19703. * @param value Define the value to give to the uniform
  19704. * @return the material itself allowing "fluent" like uniform updates
  19705. */
  19706. setVector2(name: string, value: Vector2): ShaderMaterial;
  19707. /**
  19708. * Set a vec3 in the shader from a Vector3.
  19709. * @param name Define the name of the uniform as defined in the shader
  19710. * @param value Define the value to give to the uniform
  19711. * @return the material itself allowing "fluent" like uniform updates
  19712. */
  19713. setVector3(name: string, value: Vector3): ShaderMaterial;
  19714. /**
  19715. * Set a vec4 in the shader from a Vector4.
  19716. * @param name Define the name of the uniform as defined in the shader
  19717. * @param value Define the value to give to the uniform
  19718. * @return the material itself allowing "fluent" like uniform updates
  19719. */
  19720. setVector4(name: string, value: Vector4): ShaderMaterial;
  19721. /**
  19722. * Set a mat4 in the shader from a Matrix.
  19723. * @param name Define the name of the uniform as defined in the shader
  19724. * @param value Define the value to give to the uniform
  19725. * @return the material itself allowing "fluent" like uniform updates
  19726. */
  19727. setMatrix(name: string, value: Matrix): ShaderMaterial;
  19728. /**
  19729. * Set a float32Array in the shader from a matrix array.
  19730. * @param name Define the name of the uniform as defined in the shader
  19731. * @param value Define the value to give to the uniform
  19732. * @return the material itself allowing "fluent" like uniform updates
  19733. */
  19734. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  19735. /**
  19736. * Set a mat3 in the shader from a Float32Array.
  19737. * @param name Define the name of the uniform as defined in the shader
  19738. * @param value Define the value to give to the uniform
  19739. * @return the material itself allowing "fluent" like uniform updates
  19740. */
  19741. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  19742. /**
  19743. * Set a mat2 in the shader from a Float32Array.
  19744. * @param name Define the name of the uniform as defined in the shader
  19745. * @param value Define the value to give to the uniform
  19746. * @return the material itself allowing "fluent" like uniform updates
  19747. */
  19748. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  19749. /**
  19750. * Set a vec2 array in the shader from a number array.
  19751. * @param name Define the name of the uniform as defined in the shader
  19752. * @param value Define the value to give to the uniform
  19753. * @return the material itself allowing "fluent" like uniform updates
  19754. */
  19755. setArray2(name: string, value: number[]): ShaderMaterial;
  19756. /**
  19757. * Set a vec3 array in the shader from a number array.
  19758. * @param name Define the name of the uniform as defined in the shader
  19759. * @param value Define the value to give to the uniform
  19760. * @return the material itself allowing "fluent" like uniform updates
  19761. */
  19762. setArray3(name: string, value: number[]): ShaderMaterial;
  19763. /**
  19764. * Set a vec4 array in the shader from a number array.
  19765. * @param name Define the name of the uniform as defined in the shader
  19766. * @param value Define the value to give to the uniform
  19767. * @return the material itself allowing "fluent" like uniform updates
  19768. */
  19769. setArray4(name: string, value: number[]): ShaderMaterial;
  19770. private _checkCache;
  19771. /**
  19772. * Specifies that the submesh is ready to be used
  19773. * @param mesh defines the mesh to check
  19774. * @param subMesh defines which submesh to check
  19775. * @param useInstances specifies that instances should be used
  19776. * @returns a boolean indicating that the submesh is ready or not
  19777. */
  19778. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  19779. /**
  19780. * Checks if the material is ready to render the requested mesh
  19781. * @param mesh Define the mesh to render
  19782. * @param useInstances Define whether or not the material is used with instances
  19783. * @returns true if ready, otherwise false
  19784. */
  19785. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  19786. /**
  19787. * Binds the world matrix to the material
  19788. * @param world defines the world transformation matrix
  19789. */
  19790. bindOnlyWorldMatrix(world: Matrix): void;
  19791. /**
  19792. * Binds the material to the mesh
  19793. * @param world defines the world transformation matrix
  19794. * @param mesh defines the mesh to bind the material to
  19795. */
  19796. bind(world: Matrix, mesh?: Mesh): void;
  19797. /**
  19798. * Gets the active textures from the material
  19799. * @returns an array of textures
  19800. */
  19801. getActiveTextures(): BaseTexture[];
  19802. /**
  19803. * Specifies if the material uses a texture
  19804. * @param texture defines the texture to check against the material
  19805. * @returns a boolean specifying if the material uses the texture
  19806. */
  19807. hasTexture(texture: BaseTexture): boolean;
  19808. /**
  19809. * Makes a duplicate of the material, and gives it a new name
  19810. * @param name defines the new name for the duplicated material
  19811. * @returns the cloned material
  19812. */
  19813. clone(name: string): ShaderMaterial;
  19814. /**
  19815. * Disposes the material
  19816. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  19817. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  19818. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  19819. */
  19820. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  19821. /**
  19822. * Serializes this material in a JSON representation
  19823. * @returns the serialized material object
  19824. */
  19825. serialize(): any;
  19826. /**
  19827. * Creates a shader material from parsed shader material data
  19828. * @param source defines the JSON represnetation of the material
  19829. * @param scene defines the hosting scene
  19830. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  19831. * @returns a new material
  19832. */
  19833. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  19834. }
  19835. }
  19836. declare module BABYLON {
  19837. /** @hidden */
  19838. export var colorPixelShader: {
  19839. name: string;
  19840. shader: string;
  19841. };
  19842. }
  19843. declare module BABYLON {
  19844. /** @hidden */
  19845. export var colorVertexShader: {
  19846. name: string;
  19847. shader: string;
  19848. };
  19849. }
  19850. declare module BABYLON {
  19851. /**
  19852. * Line mesh
  19853. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  19854. */
  19855. export class LinesMesh extends Mesh {
  19856. /**
  19857. * If vertex color should be applied to the mesh
  19858. */
  19859. readonly useVertexColor?: boolean | undefined;
  19860. /**
  19861. * If vertex alpha should be applied to the mesh
  19862. */
  19863. readonly useVertexAlpha?: boolean | undefined;
  19864. /**
  19865. * Color of the line (Default: White)
  19866. */
  19867. color: Color3;
  19868. /**
  19869. * Alpha of the line (Default: 1)
  19870. */
  19871. alpha: number;
  19872. /**
  19873. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19874. * This margin is expressed in world space coordinates, so its value may vary.
  19875. * Default value is 0.1
  19876. */
  19877. intersectionThreshold: number;
  19878. private _colorShader;
  19879. private color4;
  19880. /**
  19881. * Creates a new LinesMesh
  19882. * @param name defines the name
  19883. * @param scene defines the hosting scene
  19884. * @param parent defines the parent mesh if any
  19885. * @param source defines the optional source LinesMesh used to clone data from
  19886. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  19887. * When false, achieved by calling a clone(), also passing False.
  19888. * This will make creation of children, recursive.
  19889. * @param useVertexColor defines if this LinesMesh supports vertex color
  19890. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  19891. */
  19892. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  19893. /**
  19894. * If vertex color should be applied to the mesh
  19895. */
  19896. useVertexColor?: boolean | undefined,
  19897. /**
  19898. * If vertex alpha should be applied to the mesh
  19899. */
  19900. useVertexAlpha?: boolean | undefined);
  19901. private _addClipPlaneDefine;
  19902. private _removeClipPlaneDefine;
  19903. isReady(): boolean;
  19904. /**
  19905. * Returns the string "LineMesh"
  19906. */
  19907. getClassName(): string;
  19908. /**
  19909. * @hidden
  19910. */
  19911. get material(): Material;
  19912. /**
  19913. * @hidden
  19914. */
  19915. set material(value: Material);
  19916. /**
  19917. * @hidden
  19918. */
  19919. get checkCollisions(): boolean;
  19920. /** @hidden */
  19921. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  19922. /** @hidden */
  19923. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  19924. /**
  19925. * Disposes of the line mesh
  19926. * @param doNotRecurse If children should be disposed
  19927. */
  19928. dispose(doNotRecurse?: boolean): void;
  19929. /**
  19930. * Returns a new LineMesh object cloned from the current one.
  19931. */
  19932. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  19933. /**
  19934. * Creates a new InstancedLinesMesh object from the mesh model.
  19935. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  19936. * @param name defines the name of the new instance
  19937. * @returns a new InstancedLinesMesh
  19938. */
  19939. createInstance(name: string): InstancedLinesMesh;
  19940. }
  19941. /**
  19942. * Creates an instance based on a source LinesMesh
  19943. */
  19944. export class InstancedLinesMesh extends InstancedMesh {
  19945. /**
  19946. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19947. * This margin is expressed in world space coordinates, so its value may vary.
  19948. * Initilized with the intersectionThreshold value of the source LinesMesh
  19949. */
  19950. intersectionThreshold: number;
  19951. constructor(name: string, source: LinesMesh);
  19952. /**
  19953. * Returns the string "InstancedLinesMesh".
  19954. */
  19955. getClassName(): string;
  19956. }
  19957. }
  19958. declare module BABYLON {
  19959. /** @hidden */
  19960. export var linePixelShader: {
  19961. name: string;
  19962. shader: string;
  19963. };
  19964. }
  19965. declare module BABYLON {
  19966. /** @hidden */
  19967. export var lineVertexShader: {
  19968. name: string;
  19969. shader: string;
  19970. };
  19971. }
  19972. declare module BABYLON {
  19973. interface AbstractMesh {
  19974. /**
  19975. * Gets the edgesRenderer associated with the mesh
  19976. */
  19977. edgesRenderer: Nullable<EdgesRenderer>;
  19978. }
  19979. interface LinesMesh {
  19980. /**
  19981. * Enables the edge rendering mode on the mesh.
  19982. * This mode makes the mesh edges visible
  19983. * @param epsilon defines the maximal distance between two angles to detect a face
  19984. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  19985. * @returns the currentAbstractMesh
  19986. * @see https://www.babylonjs-playground.com/#19O9TU#0
  19987. */
  19988. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  19989. }
  19990. interface InstancedLinesMesh {
  19991. /**
  19992. * Enables the edge rendering mode on the mesh.
  19993. * This mode makes the mesh edges visible
  19994. * @param epsilon defines the maximal distance between two angles to detect a face
  19995. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  19996. * @returns the current InstancedLinesMesh
  19997. * @see https://www.babylonjs-playground.com/#19O9TU#0
  19998. */
  19999. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  20000. }
  20001. /**
  20002. * Defines the minimum contract an Edges renderer should follow.
  20003. */
  20004. export interface IEdgesRenderer extends IDisposable {
  20005. /**
  20006. * Gets or sets a boolean indicating if the edgesRenderer is active
  20007. */
  20008. isEnabled: boolean;
  20009. /**
  20010. * Renders the edges of the attached mesh,
  20011. */
  20012. render(): void;
  20013. /**
  20014. * Checks wether or not the edges renderer is ready to render.
  20015. * @return true if ready, otherwise false.
  20016. */
  20017. isReady(): boolean;
  20018. }
  20019. /**
  20020. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  20021. */
  20022. export class EdgesRenderer implements IEdgesRenderer {
  20023. /**
  20024. * Define the size of the edges with an orthographic camera
  20025. */
  20026. edgesWidthScalerForOrthographic: number;
  20027. /**
  20028. * Define the size of the edges with a perspective camera
  20029. */
  20030. edgesWidthScalerForPerspective: number;
  20031. protected _source: AbstractMesh;
  20032. protected _linesPositions: number[];
  20033. protected _linesNormals: number[];
  20034. protected _linesIndices: number[];
  20035. protected _epsilon: number;
  20036. protected _indicesCount: number;
  20037. protected _lineShader: ShaderMaterial;
  20038. protected _ib: DataBuffer;
  20039. protected _buffers: {
  20040. [key: string]: Nullable<VertexBuffer>;
  20041. };
  20042. protected _checkVerticesInsteadOfIndices: boolean;
  20043. private _meshRebuildObserver;
  20044. private _meshDisposeObserver;
  20045. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  20046. isEnabled: boolean;
  20047. /**
  20048. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  20049. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  20050. * @param source Mesh used to create edges
  20051. * @param epsilon sum of angles in adjacency to check for edge
  20052. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  20053. * @param generateEdgesLines - should generate Lines or only prepare resources.
  20054. */
  20055. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  20056. protected _prepareRessources(): void;
  20057. /** @hidden */
  20058. _rebuild(): void;
  20059. /**
  20060. * Releases the required resources for the edges renderer
  20061. */
  20062. dispose(): void;
  20063. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  20064. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  20065. /**
  20066. * Checks if the pair of p0 and p1 is en edge
  20067. * @param faceIndex
  20068. * @param edge
  20069. * @param faceNormals
  20070. * @param p0
  20071. * @param p1
  20072. * @private
  20073. */
  20074. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  20075. /**
  20076. * push line into the position, normal and index buffer
  20077. * @protected
  20078. */
  20079. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  20080. /**
  20081. * Generates lines edges from adjacencjes
  20082. * @private
  20083. */
  20084. _generateEdgesLines(): void;
  20085. /**
  20086. * Checks wether or not the edges renderer is ready to render.
  20087. * @return true if ready, otherwise false.
  20088. */
  20089. isReady(): boolean;
  20090. /**
  20091. * Renders the edges of the attached mesh,
  20092. */
  20093. render(): void;
  20094. }
  20095. /**
  20096. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  20097. */
  20098. export class LineEdgesRenderer extends EdgesRenderer {
  20099. /**
  20100. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  20101. * @param source LineMesh used to generate edges
  20102. * @param epsilon not important (specified angle for edge detection)
  20103. * @param checkVerticesInsteadOfIndices not important for LineMesh
  20104. */
  20105. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  20106. /**
  20107. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  20108. */
  20109. _generateEdgesLines(): void;
  20110. }
  20111. }
  20112. declare module BABYLON {
  20113. /**
  20114. * This represents the object necessary to create a rendering group.
  20115. * This is exclusively used and created by the rendering manager.
  20116. * To modify the behavior, you use the available helpers in your scene or meshes.
  20117. * @hidden
  20118. */
  20119. export class RenderingGroup {
  20120. index: number;
  20121. private static _zeroVector;
  20122. private _scene;
  20123. private _opaqueSubMeshes;
  20124. private _transparentSubMeshes;
  20125. private _alphaTestSubMeshes;
  20126. private _depthOnlySubMeshes;
  20127. private _particleSystems;
  20128. private _spriteManagers;
  20129. private _opaqueSortCompareFn;
  20130. private _alphaTestSortCompareFn;
  20131. private _transparentSortCompareFn;
  20132. private _renderOpaque;
  20133. private _renderAlphaTest;
  20134. private _renderTransparent;
  20135. /** @hidden */
  20136. _edgesRenderers: SmartArray<IEdgesRenderer>;
  20137. onBeforeTransparentRendering: () => void;
  20138. /**
  20139. * Set the opaque sort comparison function.
  20140. * If null the sub meshes will be render in the order they were created
  20141. */
  20142. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  20143. /**
  20144. * Set the alpha test sort comparison function.
  20145. * If null the sub meshes will be render in the order they were created
  20146. */
  20147. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  20148. /**
  20149. * Set the transparent sort comparison function.
  20150. * If null the sub meshes will be render in the order they were created
  20151. */
  20152. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  20153. /**
  20154. * Creates a new rendering group.
  20155. * @param index The rendering group index
  20156. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  20157. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  20158. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  20159. */
  20160. 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>);
  20161. /**
  20162. * Render all the sub meshes contained in the group.
  20163. * @param customRenderFunction Used to override the default render behaviour of the group.
  20164. * @returns true if rendered some submeshes.
  20165. */
  20166. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  20167. /**
  20168. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  20169. * @param subMeshes The submeshes to render
  20170. */
  20171. private renderOpaqueSorted;
  20172. /**
  20173. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  20174. * @param subMeshes The submeshes to render
  20175. */
  20176. private renderAlphaTestSorted;
  20177. /**
  20178. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  20179. * @param subMeshes The submeshes to render
  20180. */
  20181. private renderTransparentSorted;
  20182. /**
  20183. * Renders the submeshes in a specified order.
  20184. * @param subMeshes The submeshes to sort before render
  20185. * @param sortCompareFn The comparison function use to sort
  20186. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  20187. * @param transparent Specifies to activate blending if true
  20188. */
  20189. private static renderSorted;
  20190. /**
  20191. * Renders the submeshes in the order they were dispatched (no sort applied).
  20192. * @param subMeshes The submeshes to render
  20193. */
  20194. private static renderUnsorted;
  20195. /**
  20196. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20197. * are rendered back to front if in the same alpha index.
  20198. *
  20199. * @param a The first submesh
  20200. * @param b The second submesh
  20201. * @returns The result of the comparison
  20202. */
  20203. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  20204. /**
  20205. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20206. * are rendered back to front.
  20207. *
  20208. * @param a The first submesh
  20209. * @param b The second submesh
  20210. * @returns The result of the comparison
  20211. */
  20212. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  20213. /**
  20214. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20215. * are rendered front to back (prevent overdraw).
  20216. *
  20217. * @param a The first submesh
  20218. * @param b The second submesh
  20219. * @returns The result of the comparison
  20220. */
  20221. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  20222. /**
  20223. * Resets the different lists of submeshes to prepare a new frame.
  20224. */
  20225. prepare(): void;
  20226. dispose(): void;
  20227. /**
  20228. * Inserts the submesh in its correct queue depending on its material.
  20229. * @param subMesh The submesh to dispatch
  20230. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  20231. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  20232. */
  20233. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  20234. dispatchSprites(spriteManager: ISpriteManager): void;
  20235. dispatchParticles(particleSystem: IParticleSystem): void;
  20236. private _renderParticles;
  20237. private _renderSprites;
  20238. }
  20239. }
  20240. declare module BABYLON {
  20241. /**
  20242. * Interface describing the different options available in the rendering manager
  20243. * regarding Auto Clear between groups.
  20244. */
  20245. export interface IRenderingManagerAutoClearSetup {
  20246. /**
  20247. * Defines whether or not autoclear is enable.
  20248. */
  20249. autoClear: boolean;
  20250. /**
  20251. * Defines whether or not to autoclear the depth buffer.
  20252. */
  20253. depth: boolean;
  20254. /**
  20255. * Defines whether or not to autoclear the stencil buffer.
  20256. */
  20257. stencil: boolean;
  20258. }
  20259. /**
  20260. * This class is used by the onRenderingGroupObservable
  20261. */
  20262. export class RenderingGroupInfo {
  20263. /**
  20264. * The Scene that being rendered
  20265. */
  20266. scene: Scene;
  20267. /**
  20268. * The camera currently used for the rendering pass
  20269. */
  20270. camera: Nullable<Camera>;
  20271. /**
  20272. * The ID of the renderingGroup being processed
  20273. */
  20274. renderingGroupId: number;
  20275. }
  20276. /**
  20277. * This is the manager responsible of all the rendering for meshes sprites and particles.
  20278. * It is enable to manage the different groups as well as the different necessary sort functions.
  20279. * This should not be used directly aside of the few static configurations
  20280. */
  20281. export class RenderingManager {
  20282. /**
  20283. * The max id used for rendering groups (not included)
  20284. */
  20285. static MAX_RENDERINGGROUPS: number;
  20286. /**
  20287. * The min id used for rendering groups (included)
  20288. */
  20289. static MIN_RENDERINGGROUPS: number;
  20290. /**
  20291. * Used to globally prevent autoclearing scenes.
  20292. */
  20293. static AUTOCLEAR: boolean;
  20294. /**
  20295. * @hidden
  20296. */
  20297. _useSceneAutoClearSetup: boolean;
  20298. private _scene;
  20299. private _renderingGroups;
  20300. private _depthStencilBufferAlreadyCleaned;
  20301. private _autoClearDepthStencil;
  20302. private _customOpaqueSortCompareFn;
  20303. private _customAlphaTestSortCompareFn;
  20304. private _customTransparentSortCompareFn;
  20305. private _renderingGroupInfo;
  20306. /**
  20307. * Instantiates a new rendering group for a particular scene
  20308. * @param scene Defines the scene the groups belongs to
  20309. */
  20310. constructor(scene: Scene);
  20311. private _clearDepthStencilBuffer;
  20312. /**
  20313. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  20314. * @hidden
  20315. */
  20316. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  20317. /**
  20318. * Resets the different information of the group to prepare a new frame
  20319. * @hidden
  20320. */
  20321. reset(): void;
  20322. /**
  20323. * Dispose and release the group and its associated resources.
  20324. * @hidden
  20325. */
  20326. dispose(): void;
  20327. /**
  20328. * Clear the info related to rendering groups preventing retention points during dispose.
  20329. */
  20330. freeRenderingGroups(): void;
  20331. private _prepareRenderingGroup;
  20332. /**
  20333. * Add a sprite manager to the rendering manager in order to render it this frame.
  20334. * @param spriteManager Define the sprite manager to render
  20335. */
  20336. dispatchSprites(spriteManager: ISpriteManager): void;
  20337. /**
  20338. * Add a particle system to the rendering manager in order to render it this frame.
  20339. * @param particleSystem Define the particle system to render
  20340. */
  20341. dispatchParticles(particleSystem: IParticleSystem): void;
  20342. /**
  20343. * Add a submesh to the manager in order to render it this frame
  20344. * @param subMesh The submesh to dispatch
  20345. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  20346. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  20347. */
  20348. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  20349. /**
  20350. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20351. * This allowed control for front to back rendering or reversly depending of the special needs.
  20352. *
  20353. * @param renderingGroupId The rendering group id corresponding to its index
  20354. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20355. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20356. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20357. */
  20358. 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;
  20359. /**
  20360. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20361. *
  20362. * @param renderingGroupId The rendering group id corresponding to its index
  20363. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20364. * @param depth Automatically clears depth between groups if true and autoClear is true.
  20365. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  20366. */
  20367. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  20368. /**
  20369. * Gets the current auto clear configuration for one rendering group of the rendering
  20370. * manager.
  20371. * @param index the rendering group index to get the information for
  20372. * @returns The auto clear setup for the requested rendering group
  20373. */
  20374. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  20375. }
  20376. }
  20377. declare module BABYLON {
  20378. /**
  20379. * This Helps creating a texture that will be created from a camera in your scene.
  20380. * It is basically a dynamic texture that could be used to create special effects for instance.
  20381. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  20382. */
  20383. export class RenderTargetTexture extends Texture {
  20384. isCube: boolean;
  20385. /**
  20386. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  20387. */
  20388. static readonly REFRESHRATE_RENDER_ONCE: number;
  20389. /**
  20390. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  20391. */
  20392. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  20393. /**
  20394. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  20395. * the central point of your effect and can save a lot of performances.
  20396. */
  20397. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  20398. /**
  20399. * Use this predicate to dynamically define the list of mesh you want to render.
  20400. * If set, the renderList property will be overwritten.
  20401. */
  20402. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  20403. private _renderList;
  20404. /**
  20405. * Use this list to define the list of mesh you want to render.
  20406. */
  20407. get renderList(): Nullable<Array<AbstractMesh>>;
  20408. set renderList(value: Nullable<Array<AbstractMesh>>);
  20409. /**
  20410. * Use this function to overload the renderList array at rendering time.
  20411. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  20412. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  20413. * the cube (if the RTT is a cube, else layerOrFace=0).
  20414. * The renderList passed to the function is the current render list (the one that will be used if the function returns null)
  20415. */
  20416. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>) => Nullable<Array<AbstractMesh>>;
  20417. private _hookArray;
  20418. /**
  20419. * Define if particles should be rendered in your texture.
  20420. */
  20421. renderParticles: boolean;
  20422. /**
  20423. * Define if sprites should be rendered in your texture.
  20424. */
  20425. renderSprites: boolean;
  20426. /**
  20427. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  20428. */
  20429. coordinatesMode: number;
  20430. /**
  20431. * Define the camera used to render the texture.
  20432. */
  20433. activeCamera: Nullable<Camera>;
  20434. /**
  20435. * Override the render function of the texture with your own one.
  20436. */
  20437. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  20438. /**
  20439. * Define if camera post processes should be use while rendering the texture.
  20440. */
  20441. useCameraPostProcesses: boolean;
  20442. /**
  20443. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  20444. */
  20445. ignoreCameraViewport: boolean;
  20446. private _postProcessManager;
  20447. private _postProcesses;
  20448. private _resizeObserver;
  20449. /**
  20450. * An event triggered when the texture is unbind.
  20451. */
  20452. onBeforeBindObservable: Observable<RenderTargetTexture>;
  20453. /**
  20454. * An event triggered when the texture is unbind.
  20455. */
  20456. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  20457. private _onAfterUnbindObserver;
  20458. /**
  20459. * Set a after unbind callback in the texture.
  20460. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  20461. */
  20462. set onAfterUnbind(callback: () => void);
  20463. /**
  20464. * An event triggered before rendering the texture
  20465. */
  20466. onBeforeRenderObservable: Observable<number>;
  20467. private _onBeforeRenderObserver;
  20468. /**
  20469. * Set a before render callback in the texture.
  20470. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  20471. */
  20472. set onBeforeRender(callback: (faceIndex: number) => void);
  20473. /**
  20474. * An event triggered after rendering the texture
  20475. */
  20476. onAfterRenderObservable: Observable<number>;
  20477. private _onAfterRenderObserver;
  20478. /**
  20479. * Set a after render callback in the texture.
  20480. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  20481. */
  20482. set onAfterRender(callback: (faceIndex: number) => void);
  20483. /**
  20484. * An event triggered after the texture clear
  20485. */
  20486. onClearObservable: Observable<Engine>;
  20487. private _onClearObserver;
  20488. /**
  20489. * Set a clear callback in the texture.
  20490. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  20491. */
  20492. set onClear(callback: (Engine: Engine) => void);
  20493. /**
  20494. * An event triggered when the texture is resized.
  20495. */
  20496. onResizeObservable: Observable<RenderTargetTexture>;
  20497. /**
  20498. * Define the clear color of the Render Target if it should be different from the scene.
  20499. */
  20500. clearColor: Color4;
  20501. protected _size: number | {
  20502. width: number;
  20503. height: number;
  20504. layers?: number;
  20505. };
  20506. protected _initialSizeParameter: number | {
  20507. width: number;
  20508. height: number;
  20509. } | {
  20510. ratio: number;
  20511. };
  20512. protected _sizeRatio: Nullable<number>;
  20513. /** @hidden */
  20514. _generateMipMaps: boolean;
  20515. protected _renderingManager: RenderingManager;
  20516. /** @hidden */
  20517. _waitingRenderList: string[];
  20518. protected _doNotChangeAspectRatio: boolean;
  20519. protected _currentRefreshId: number;
  20520. protected _refreshRate: number;
  20521. protected _textureMatrix: Matrix;
  20522. protected _samples: number;
  20523. protected _renderTargetOptions: RenderTargetCreationOptions;
  20524. /**
  20525. * Gets render target creation options that were used.
  20526. */
  20527. get renderTargetOptions(): RenderTargetCreationOptions;
  20528. protected _engine: Engine;
  20529. protected _onRatioRescale(): void;
  20530. /**
  20531. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  20532. * It must define where the camera used to render the texture is set
  20533. */
  20534. boundingBoxPosition: Vector3;
  20535. private _boundingBoxSize;
  20536. /**
  20537. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  20538. * When defined, the cubemap will switch to local mode
  20539. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  20540. * @example https://www.babylonjs-playground.com/#RNASML
  20541. */
  20542. set boundingBoxSize(value: Vector3);
  20543. get boundingBoxSize(): Vector3;
  20544. /**
  20545. * In case the RTT has been created with a depth texture, get the associated
  20546. * depth texture.
  20547. * Otherwise, return null.
  20548. */
  20549. get depthStencilTexture(): Nullable<InternalTexture>;
  20550. /**
  20551. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  20552. * or used a shadow, depth texture...
  20553. * @param name The friendly name of the texture
  20554. * @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)
  20555. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  20556. * @param generateMipMaps True if mip maps need to be generated after render.
  20557. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  20558. * @param type The type of the buffer in the RTT (int, half float, float...)
  20559. * @param isCube True if a cube texture needs to be created
  20560. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  20561. * @param generateDepthBuffer True to generate a depth buffer
  20562. * @param generateStencilBuffer True to generate a stencil buffer
  20563. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  20564. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  20565. * @param delayAllocation if the texture allocation should be delayed (default: false)
  20566. */
  20567. constructor(name: string, size: number | {
  20568. width: number;
  20569. height: number;
  20570. layers?: number;
  20571. } | {
  20572. ratio: number;
  20573. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  20574. /**
  20575. * Creates a depth stencil texture.
  20576. * This is only available in WebGL 2 or with the depth texture extension available.
  20577. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  20578. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  20579. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  20580. */
  20581. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  20582. private _processSizeParameter;
  20583. /**
  20584. * Define the number of samples to use in case of MSAA.
  20585. * It defaults to one meaning no MSAA has been enabled.
  20586. */
  20587. get samples(): number;
  20588. set samples(value: number);
  20589. /**
  20590. * Resets the refresh counter of the texture and start bak from scratch.
  20591. * Could be useful to regenerate the texture if it is setup to render only once.
  20592. */
  20593. resetRefreshCounter(): void;
  20594. /**
  20595. * Define the refresh rate of the texture or the rendering frequency.
  20596. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  20597. */
  20598. get refreshRate(): number;
  20599. set refreshRate(value: number);
  20600. /**
  20601. * Adds a post process to the render target rendering passes.
  20602. * @param postProcess define the post process to add
  20603. */
  20604. addPostProcess(postProcess: PostProcess): void;
  20605. /**
  20606. * Clear all the post processes attached to the render target
  20607. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  20608. */
  20609. clearPostProcesses(dispose?: boolean): void;
  20610. /**
  20611. * Remove one of the post process from the list of attached post processes to the texture
  20612. * @param postProcess define the post process to remove from the list
  20613. */
  20614. removePostProcess(postProcess: PostProcess): void;
  20615. /** @hidden */
  20616. _shouldRender(): boolean;
  20617. /**
  20618. * Gets the actual render size of the texture.
  20619. * @returns the width of the render size
  20620. */
  20621. getRenderSize(): number;
  20622. /**
  20623. * Gets the actual render width of the texture.
  20624. * @returns the width of the render size
  20625. */
  20626. getRenderWidth(): number;
  20627. /**
  20628. * Gets the actual render height of the texture.
  20629. * @returns the height of the render size
  20630. */
  20631. getRenderHeight(): number;
  20632. /**
  20633. * Gets the actual number of layers of the texture.
  20634. * @returns the number of layers
  20635. */
  20636. getRenderLayers(): number;
  20637. /**
  20638. * Get if the texture can be rescaled or not.
  20639. */
  20640. get canRescale(): boolean;
  20641. /**
  20642. * Resize the texture using a ratio.
  20643. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  20644. */
  20645. scale(ratio: number): void;
  20646. /**
  20647. * Get the texture reflection matrix used to rotate/transform the reflection.
  20648. * @returns the reflection matrix
  20649. */
  20650. getReflectionTextureMatrix(): Matrix;
  20651. /**
  20652. * Resize the texture to a new desired size.
  20653. * Be carrefull as it will recreate all the data in the new texture.
  20654. * @param size Define the new size. It can be:
  20655. * - a number for squared texture,
  20656. * - an object containing { width: number, height: number }
  20657. * - or an object containing a ratio { ratio: number }
  20658. */
  20659. resize(size: number | {
  20660. width: number;
  20661. height: number;
  20662. } | {
  20663. ratio: number;
  20664. }): void;
  20665. private _defaultRenderListPrepared;
  20666. /**
  20667. * Renders all the objects from the render list into the texture.
  20668. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  20669. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  20670. */
  20671. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  20672. private _bestReflectionRenderTargetDimension;
  20673. private _prepareRenderingManager;
  20674. /**
  20675. * @hidden
  20676. * @param faceIndex face index to bind to if this is a cubetexture
  20677. * @param layer defines the index of the texture to bind in the array
  20678. */
  20679. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  20680. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  20681. private renderToTarget;
  20682. /**
  20683. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20684. * This allowed control for front to back rendering or reversly depending of the special needs.
  20685. *
  20686. * @param renderingGroupId The rendering group id corresponding to its index
  20687. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20688. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20689. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20690. */
  20691. 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;
  20692. /**
  20693. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20694. *
  20695. * @param renderingGroupId The rendering group id corresponding to its index
  20696. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20697. */
  20698. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  20699. /**
  20700. * Clones the texture.
  20701. * @returns the cloned texture
  20702. */
  20703. clone(): RenderTargetTexture;
  20704. /**
  20705. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  20706. * @returns The JSON representation of the texture
  20707. */
  20708. serialize(): any;
  20709. /**
  20710. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  20711. */
  20712. disposeFramebufferObjects(): void;
  20713. /**
  20714. * Dispose the texture and release its associated resources.
  20715. */
  20716. dispose(): void;
  20717. /** @hidden */
  20718. _rebuild(): void;
  20719. /**
  20720. * Clear the info related to rendering groups preventing retention point in material dispose.
  20721. */
  20722. freeRenderingGroups(): void;
  20723. /**
  20724. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  20725. * @returns the view count
  20726. */
  20727. getViewCount(): number;
  20728. }
  20729. }
  20730. declare module BABYLON {
  20731. /**
  20732. * Options for compiling materials.
  20733. */
  20734. export interface IMaterialCompilationOptions {
  20735. /**
  20736. * Defines whether clip planes are enabled.
  20737. */
  20738. clipPlane: boolean;
  20739. /**
  20740. * Defines whether instances are enabled.
  20741. */
  20742. useInstances: boolean;
  20743. }
  20744. /**
  20745. * Base class for the main features of a material in Babylon.js
  20746. */
  20747. export class Material implements IAnimatable {
  20748. /**
  20749. * Returns the triangle fill mode
  20750. */
  20751. static readonly TriangleFillMode: number;
  20752. /**
  20753. * Returns the wireframe mode
  20754. */
  20755. static readonly WireFrameFillMode: number;
  20756. /**
  20757. * Returns the point fill mode
  20758. */
  20759. static readonly PointFillMode: number;
  20760. /**
  20761. * Returns the point list draw mode
  20762. */
  20763. static readonly PointListDrawMode: number;
  20764. /**
  20765. * Returns the line list draw mode
  20766. */
  20767. static readonly LineListDrawMode: number;
  20768. /**
  20769. * Returns the line loop draw mode
  20770. */
  20771. static readonly LineLoopDrawMode: number;
  20772. /**
  20773. * Returns the line strip draw mode
  20774. */
  20775. static readonly LineStripDrawMode: number;
  20776. /**
  20777. * Returns the triangle strip draw mode
  20778. */
  20779. static readonly TriangleStripDrawMode: number;
  20780. /**
  20781. * Returns the triangle fan draw mode
  20782. */
  20783. static readonly TriangleFanDrawMode: number;
  20784. /**
  20785. * Stores the clock-wise side orientation
  20786. */
  20787. static readonly ClockWiseSideOrientation: number;
  20788. /**
  20789. * Stores the counter clock-wise side orientation
  20790. */
  20791. static readonly CounterClockWiseSideOrientation: number;
  20792. /**
  20793. * The dirty texture flag value
  20794. */
  20795. static readonly TextureDirtyFlag: number;
  20796. /**
  20797. * The dirty light flag value
  20798. */
  20799. static readonly LightDirtyFlag: number;
  20800. /**
  20801. * The dirty fresnel flag value
  20802. */
  20803. static readonly FresnelDirtyFlag: number;
  20804. /**
  20805. * The dirty attribute flag value
  20806. */
  20807. static readonly AttributesDirtyFlag: number;
  20808. /**
  20809. * The dirty misc flag value
  20810. */
  20811. static readonly MiscDirtyFlag: number;
  20812. /**
  20813. * The all dirty flag value
  20814. */
  20815. static readonly AllDirtyFlag: number;
  20816. /**
  20817. * The ID of the material
  20818. */
  20819. id: string;
  20820. /**
  20821. * Gets or sets the unique id of the material
  20822. */
  20823. uniqueId: number;
  20824. /**
  20825. * The name of the material
  20826. */
  20827. name: string;
  20828. /**
  20829. * Gets or sets user defined metadata
  20830. */
  20831. metadata: any;
  20832. /**
  20833. * For internal use only. Please do not use.
  20834. */
  20835. reservedDataStore: any;
  20836. /**
  20837. * Specifies if the ready state should be checked on each call
  20838. */
  20839. checkReadyOnEveryCall: boolean;
  20840. /**
  20841. * Specifies if the ready state should be checked once
  20842. */
  20843. checkReadyOnlyOnce: boolean;
  20844. /**
  20845. * The state of the material
  20846. */
  20847. state: string;
  20848. /**
  20849. * The alpha value of the material
  20850. */
  20851. protected _alpha: number;
  20852. /**
  20853. * List of inspectable custom properties (used by the Inspector)
  20854. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  20855. */
  20856. inspectableCustomProperties: IInspectable[];
  20857. /**
  20858. * Sets the alpha value of the material
  20859. */
  20860. set alpha(value: number);
  20861. /**
  20862. * Gets the alpha value of the material
  20863. */
  20864. get alpha(): number;
  20865. /**
  20866. * Specifies if back face culling is enabled
  20867. */
  20868. protected _backFaceCulling: boolean;
  20869. /**
  20870. * Sets the back-face culling state
  20871. */
  20872. set backFaceCulling(value: boolean);
  20873. /**
  20874. * Gets the back-face culling state
  20875. */
  20876. get backFaceCulling(): boolean;
  20877. /**
  20878. * Stores the value for side orientation
  20879. */
  20880. sideOrientation: number;
  20881. /**
  20882. * Callback triggered when the material is compiled
  20883. */
  20884. onCompiled: Nullable<(effect: Effect) => void>;
  20885. /**
  20886. * Callback triggered when an error occurs
  20887. */
  20888. onError: Nullable<(effect: Effect, errors: string) => void>;
  20889. /**
  20890. * Callback triggered to get the render target textures
  20891. */
  20892. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  20893. /**
  20894. * Gets a boolean indicating that current material needs to register RTT
  20895. */
  20896. get hasRenderTargetTextures(): boolean;
  20897. /**
  20898. * Specifies if the material should be serialized
  20899. */
  20900. doNotSerialize: boolean;
  20901. /**
  20902. * @hidden
  20903. */
  20904. _storeEffectOnSubMeshes: boolean;
  20905. /**
  20906. * Stores the animations for the material
  20907. */
  20908. animations: Nullable<Array<Animation>>;
  20909. /**
  20910. * An event triggered when the material is disposed
  20911. */
  20912. onDisposeObservable: Observable<Material>;
  20913. /**
  20914. * An observer which watches for dispose events
  20915. */
  20916. private _onDisposeObserver;
  20917. private _onUnBindObservable;
  20918. /**
  20919. * Called during a dispose event
  20920. */
  20921. set onDispose(callback: () => void);
  20922. private _onBindObservable;
  20923. /**
  20924. * An event triggered when the material is bound
  20925. */
  20926. get onBindObservable(): Observable<AbstractMesh>;
  20927. /**
  20928. * An observer which watches for bind events
  20929. */
  20930. private _onBindObserver;
  20931. /**
  20932. * Called during a bind event
  20933. */
  20934. set onBind(callback: (Mesh: AbstractMesh) => void);
  20935. /**
  20936. * An event triggered when the material is unbound
  20937. */
  20938. get onUnBindObservable(): Observable<Material>;
  20939. /**
  20940. * Stores the value of the alpha mode
  20941. */
  20942. private _alphaMode;
  20943. /**
  20944. * Sets the value of the alpha mode.
  20945. *
  20946. * | Value | Type | Description |
  20947. * | --- | --- | --- |
  20948. * | 0 | ALPHA_DISABLE | |
  20949. * | 1 | ALPHA_ADD | |
  20950. * | 2 | ALPHA_COMBINE | |
  20951. * | 3 | ALPHA_SUBTRACT | |
  20952. * | 4 | ALPHA_MULTIPLY | |
  20953. * | 5 | ALPHA_MAXIMIZED | |
  20954. * | 6 | ALPHA_ONEONE | |
  20955. * | 7 | ALPHA_PREMULTIPLIED | |
  20956. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  20957. * | 9 | ALPHA_INTERPOLATE | |
  20958. * | 10 | ALPHA_SCREENMODE | |
  20959. *
  20960. */
  20961. set alphaMode(value: number);
  20962. /**
  20963. * Gets the value of the alpha mode
  20964. */
  20965. get alphaMode(): number;
  20966. /**
  20967. * Stores the state of the need depth pre-pass value
  20968. */
  20969. private _needDepthPrePass;
  20970. /**
  20971. * Sets the need depth pre-pass value
  20972. */
  20973. set needDepthPrePass(value: boolean);
  20974. /**
  20975. * Gets the depth pre-pass value
  20976. */
  20977. get needDepthPrePass(): boolean;
  20978. /**
  20979. * Specifies if depth writing should be disabled
  20980. */
  20981. disableDepthWrite: boolean;
  20982. /**
  20983. * Specifies if depth writing should be forced
  20984. */
  20985. forceDepthWrite: boolean;
  20986. /**
  20987. * Specifies the depth function that should be used. 0 means the default engine function
  20988. */
  20989. depthFunction: number;
  20990. /**
  20991. * Specifies if there should be a separate pass for culling
  20992. */
  20993. separateCullingPass: boolean;
  20994. /**
  20995. * Stores the state specifing if fog should be enabled
  20996. */
  20997. private _fogEnabled;
  20998. /**
  20999. * Sets the state for enabling fog
  21000. */
  21001. set fogEnabled(value: boolean);
  21002. /**
  21003. * Gets the value of the fog enabled state
  21004. */
  21005. get fogEnabled(): boolean;
  21006. /**
  21007. * Stores the size of points
  21008. */
  21009. pointSize: number;
  21010. /**
  21011. * Stores the z offset value
  21012. */
  21013. zOffset: number;
  21014. /**
  21015. * Gets a value specifying if wireframe mode is enabled
  21016. */
  21017. get wireframe(): boolean;
  21018. /**
  21019. * Sets the state of wireframe mode
  21020. */
  21021. set wireframe(value: boolean);
  21022. /**
  21023. * Gets the value specifying if point clouds are enabled
  21024. */
  21025. get pointsCloud(): boolean;
  21026. /**
  21027. * Sets the state of point cloud mode
  21028. */
  21029. set pointsCloud(value: boolean);
  21030. /**
  21031. * Gets the material fill mode
  21032. */
  21033. get fillMode(): number;
  21034. /**
  21035. * Sets the material fill mode
  21036. */
  21037. set fillMode(value: number);
  21038. /**
  21039. * @hidden
  21040. * Stores the effects for the material
  21041. */
  21042. _effect: Nullable<Effect>;
  21043. /**
  21044. * Specifies if uniform buffers should be used
  21045. */
  21046. private _useUBO;
  21047. /**
  21048. * Stores a reference to the scene
  21049. */
  21050. private _scene;
  21051. /**
  21052. * Stores the fill mode state
  21053. */
  21054. private _fillMode;
  21055. /**
  21056. * Specifies if the depth write state should be cached
  21057. */
  21058. private _cachedDepthWriteState;
  21059. /**
  21060. * Specifies if the depth function state should be cached
  21061. */
  21062. private _cachedDepthFunctionState;
  21063. /**
  21064. * Stores the uniform buffer
  21065. */
  21066. protected _uniformBuffer: UniformBuffer;
  21067. /** @hidden */
  21068. _indexInSceneMaterialArray: number;
  21069. /** @hidden */
  21070. meshMap: Nullable<{
  21071. [id: string]: AbstractMesh | undefined;
  21072. }>;
  21073. /**
  21074. * Creates a material instance
  21075. * @param name defines the name of the material
  21076. * @param scene defines the scene to reference
  21077. * @param doNotAdd specifies if the material should be added to the scene
  21078. */
  21079. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  21080. /**
  21081. * Returns a string representation of the current material
  21082. * @param fullDetails defines a boolean indicating which levels of logging is desired
  21083. * @returns a string with material information
  21084. */
  21085. toString(fullDetails?: boolean): string;
  21086. /**
  21087. * Gets the class name of the material
  21088. * @returns a string with the class name of the material
  21089. */
  21090. getClassName(): string;
  21091. /**
  21092. * Specifies if updates for the material been locked
  21093. */
  21094. get isFrozen(): boolean;
  21095. /**
  21096. * Locks updates for the material
  21097. */
  21098. freeze(): void;
  21099. /**
  21100. * Unlocks updates for the material
  21101. */
  21102. unfreeze(): void;
  21103. /**
  21104. * Specifies if the material is ready to be used
  21105. * @param mesh defines the mesh to check
  21106. * @param useInstances specifies if instances should be used
  21107. * @returns a boolean indicating if the material is ready to be used
  21108. */
  21109. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21110. /**
  21111. * Specifies that the submesh is ready to be used
  21112. * @param mesh defines the mesh to check
  21113. * @param subMesh defines which submesh to check
  21114. * @param useInstances specifies that instances should be used
  21115. * @returns a boolean indicating that the submesh is ready or not
  21116. */
  21117. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21118. /**
  21119. * Returns the material effect
  21120. * @returns the effect associated with the material
  21121. */
  21122. getEffect(): Nullable<Effect>;
  21123. /**
  21124. * Returns the current scene
  21125. * @returns a Scene
  21126. */
  21127. getScene(): Scene;
  21128. /**
  21129. * Specifies if the material will require alpha blending
  21130. * @returns a boolean specifying if alpha blending is needed
  21131. */
  21132. needAlphaBlending(): boolean;
  21133. /**
  21134. * Specifies if the mesh will require alpha blending
  21135. * @param mesh defines the mesh to check
  21136. * @returns a boolean specifying if alpha blending is needed for the mesh
  21137. */
  21138. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  21139. /**
  21140. * Specifies if this material should be rendered in alpha test mode
  21141. * @returns a boolean specifying if an alpha test is needed.
  21142. */
  21143. needAlphaTesting(): boolean;
  21144. /**
  21145. * Gets the texture used for the alpha test
  21146. * @returns the texture to use for alpha testing
  21147. */
  21148. getAlphaTestTexture(): Nullable<BaseTexture>;
  21149. /**
  21150. * Marks the material to indicate that it needs to be re-calculated
  21151. */
  21152. markDirty(): void;
  21153. /** @hidden */
  21154. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  21155. /**
  21156. * Binds the material to the mesh
  21157. * @param world defines the world transformation matrix
  21158. * @param mesh defines the mesh to bind the material to
  21159. */
  21160. bind(world: Matrix, mesh?: Mesh): void;
  21161. /**
  21162. * Binds the submesh to the material
  21163. * @param world defines the world transformation matrix
  21164. * @param mesh defines the mesh containing the submesh
  21165. * @param subMesh defines the submesh to bind the material to
  21166. */
  21167. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  21168. /**
  21169. * Binds the world matrix to the material
  21170. * @param world defines the world transformation matrix
  21171. */
  21172. bindOnlyWorldMatrix(world: Matrix): void;
  21173. /**
  21174. * Binds the scene's uniform buffer to the effect.
  21175. * @param effect defines the effect to bind to the scene uniform buffer
  21176. * @param sceneUbo defines the uniform buffer storing scene data
  21177. */
  21178. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  21179. /**
  21180. * Binds the view matrix to the effect
  21181. * @param effect defines the effect to bind the view matrix to
  21182. */
  21183. bindView(effect: Effect): void;
  21184. /**
  21185. * Binds the view projection matrix to the effect
  21186. * @param effect defines the effect to bind the view projection matrix to
  21187. */
  21188. bindViewProjection(effect: Effect): void;
  21189. /**
  21190. * Specifies if material alpha testing should be turned on for the mesh
  21191. * @param mesh defines the mesh to check
  21192. */
  21193. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  21194. /**
  21195. * Processes to execute after binding the material to a mesh
  21196. * @param mesh defines the rendered mesh
  21197. */
  21198. protected _afterBind(mesh?: Mesh): void;
  21199. /**
  21200. * Unbinds the material from the mesh
  21201. */
  21202. unbind(): void;
  21203. /**
  21204. * Gets the active textures from the material
  21205. * @returns an array of textures
  21206. */
  21207. getActiveTextures(): BaseTexture[];
  21208. /**
  21209. * Specifies if the material uses a texture
  21210. * @param texture defines the texture to check against the material
  21211. * @returns a boolean specifying if the material uses the texture
  21212. */
  21213. hasTexture(texture: BaseTexture): boolean;
  21214. /**
  21215. * Makes a duplicate of the material, and gives it a new name
  21216. * @param name defines the new name for the duplicated material
  21217. * @returns the cloned material
  21218. */
  21219. clone(name: string): Nullable<Material>;
  21220. /**
  21221. * Gets the meshes bound to the material
  21222. * @returns an array of meshes bound to the material
  21223. */
  21224. getBindedMeshes(): AbstractMesh[];
  21225. /**
  21226. * Force shader compilation
  21227. * @param mesh defines the mesh associated with this material
  21228. * @param onCompiled defines a function to execute once the material is compiled
  21229. * @param options defines the options to configure the compilation
  21230. * @param onError defines a function to execute if the material fails compiling
  21231. */
  21232. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  21233. /**
  21234. * Force shader compilation
  21235. * @param mesh defines the mesh that will use this material
  21236. * @param options defines additional options for compiling the shaders
  21237. * @returns a promise that resolves when the compilation completes
  21238. */
  21239. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  21240. private static readonly _AllDirtyCallBack;
  21241. private static readonly _ImageProcessingDirtyCallBack;
  21242. private static readonly _TextureDirtyCallBack;
  21243. private static readonly _FresnelDirtyCallBack;
  21244. private static readonly _MiscDirtyCallBack;
  21245. private static readonly _LightsDirtyCallBack;
  21246. private static readonly _AttributeDirtyCallBack;
  21247. private static _FresnelAndMiscDirtyCallBack;
  21248. private static _TextureAndMiscDirtyCallBack;
  21249. private static readonly _DirtyCallbackArray;
  21250. private static readonly _RunDirtyCallBacks;
  21251. /**
  21252. * Marks a define in the material to indicate that it needs to be re-computed
  21253. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  21254. */
  21255. markAsDirty(flag: number): void;
  21256. /**
  21257. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  21258. * @param func defines a function which checks material defines against the submeshes
  21259. */
  21260. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  21261. /**
  21262. * Indicates that we need to re-calculated for all submeshes
  21263. */
  21264. protected _markAllSubMeshesAsAllDirty(): void;
  21265. /**
  21266. * Indicates that image processing needs to be re-calculated for all submeshes
  21267. */
  21268. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  21269. /**
  21270. * Indicates that textures need to be re-calculated for all submeshes
  21271. */
  21272. protected _markAllSubMeshesAsTexturesDirty(): void;
  21273. /**
  21274. * Indicates that fresnel needs to be re-calculated for all submeshes
  21275. */
  21276. protected _markAllSubMeshesAsFresnelDirty(): void;
  21277. /**
  21278. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  21279. */
  21280. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  21281. /**
  21282. * Indicates that lights need to be re-calculated for all submeshes
  21283. */
  21284. protected _markAllSubMeshesAsLightsDirty(): void;
  21285. /**
  21286. * Indicates that attributes need to be re-calculated for all submeshes
  21287. */
  21288. protected _markAllSubMeshesAsAttributesDirty(): void;
  21289. /**
  21290. * Indicates that misc needs to be re-calculated for all submeshes
  21291. */
  21292. protected _markAllSubMeshesAsMiscDirty(): void;
  21293. /**
  21294. * Indicates that textures and misc need to be re-calculated for all submeshes
  21295. */
  21296. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  21297. /**
  21298. * Disposes the material
  21299. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  21300. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  21301. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  21302. */
  21303. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  21304. /** @hidden */
  21305. private releaseVertexArrayObject;
  21306. /**
  21307. * Serializes this material
  21308. * @returns the serialized material object
  21309. */
  21310. serialize(): any;
  21311. /**
  21312. * Creates a material from parsed material data
  21313. * @param parsedMaterial defines parsed material data
  21314. * @param scene defines the hosting scene
  21315. * @param rootUrl defines the root URL to use to load textures
  21316. * @returns a new material
  21317. */
  21318. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  21319. }
  21320. }
  21321. declare module BABYLON {
  21322. /**
  21323. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21324. * separate meshes. This can be use to improve performances.
  21325. * @see http://doc.babylonjs.com/how_to/multi_materials
  21326. */
  21327. export class MultiMaterial extends Material {
  21328. private _subMaterials;
  21329. /**
  21330. * Gets or Sets the list of Materials used within the multi material.
  21331. * They need to be ordered according to the submeshes order in the associated mesh
  21332. */
  21333. get subMaterials(): Nullable<Material>[];
  21334. set subMaterials(value: Nullable<Material>[]);
  21335. /**
  21336. * Function used to align with Node.getChildren()
  21337. * @returns the list of Materials used within the multi material
  21338. */
  21339. getChildren(): Nullable<Material>[];
  21340. /**
  21341. * Instantiates a new Multi Material
  21342. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21343. * separate meshes. This can be use to improve performances.
  21344. * @see http://doc.babylonjs.com/how_to/multi_materials
  21345. * @param name Define the name in the scene
  21346. * @param scene Define the scene the material belongs to
  21347. */
  21348. constructor(name: string, scene: Scene);
  21349. private _hookArray;
  21350. /**
  21351. * Get one of the submaterial by its index in the submaterials array
  21352. * @param index The index to look the sub material at
  21353. * @returns The Material if the index has been defined
  21354. */
  21355. getSubMaterial(index: number): Nullable<Material>;
  21356. /**
  21357. * Get the list of active textures for the whole sub materials list.
  21358. * @returns All the textures that will be used during the rendering
  21359. */
  21360. getActiveTextures(): BaseTexture[];
  21361. /**
  21362. * Gets the current class name of the material e.g. "MultiMaterial"
  21363. * Mainly use in serialization.
  21364. * @returns the class name
  21365. */
  21366. getClassName(): string;
  21367. /**
  21368. * Checks if the material is ready to render the requested sub mesh
  21369. * @param mesh Define the mesh the submesh belongs to
  21370. * @param subMesh Define the sub mesh to look readyness for
  21371. * @param useInstances Define whether or not the material is used with instances
  21372. * @returns true if ready, otherwise false
  21373. */
  21374. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21375. /**
  21376. * Clones the current material and its related sub materials
  21377. * @param name Define the name of the newly cloned material
  21378. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  21379. * @returns the cloned material
  21380. */
  21381. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  21382. /**
  21383. * Serializes the materials into a JSON representation.
  21384. * @returns the JSON representation
  21385. */
  21386. serialize(): any;
  21387. /**
  21388. * Dispose the material and release its associated resources
  21389. * @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)
  21390. * @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)
  21391. * @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)
  21392. */
  21393. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  21394. /**
  21395. * Creates a MultiMaterial from parsed MultiMaterial data.
  21396. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  21397. * @param scene defines the hosting scene
  21398. * @returns a new MultiMaterial
  21399. */
  21400. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  21401. }
  21402. }
  21403. declare module BABYLON {
  21404. /**
  21405. * Base class for submeshes
  21406. */
  21407. export class BaseSubMesh {
  21408. /** @hidden */
  21409. _materialDefines: Nullable<MaterialDefines>;
  21410. /** @hidden */
  21411. _materialEffect: Nullable<Effect>;
  21412. /**
  21413. * Gets material defines used by the effect associated to the sub mesh
  21414. */
  21415. get materialDefines(): Nullable<MaterialDefines>;
  21416. /**
  21417. * Sets material defines used by the effect associated to the sub mesh
  21418. */
  21419. set materialDefines(defines: Nullable<MaterialDefines>);
  21420. /**
  21421. * Gets associated effect
  21422. */
  21423. get effect(): Nullable<Effect>;
  21424. /**
  21425. * Sets associated effect (effect used to render this submesh)
  21426. * @param effect defines the effect to associate with
  21427. * @param defines defines the set of defines used to compile this effect
  21428. */
  21429. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  21430. }
  21431. /**
  21432. * Defines a subdivision inside a mesh
  21433. */
  21434. export class SubMesh extends BaseSubMesh implements ICullable {
  21435. /** the material index to use */
  21436. materialIndex: number;
  21437. /** vertex index start */
  21438. verticesStart: number;
  21439. /** vertices count */
  21440. verticesCount: number;
  21441. /** index start */
  21442. indexStart: number;
  21443. /** indices count */
  21444. indexCount: number;
  21445. /** @hidden */
  21446. _linesIndexCount: number;
  21447. private _mesh;
  21448. private _renderingMesh;
  21449. private _boundingInfo;
  21450. private _linesIndexBuffer;
  21451. /** @hidden */
  21452. _lastColliderWorldVertices: Nullable<Vector3[]>;
  21453. /** @hidden */
  21454. _trianglePlanes: Plane[];
  21455. /** @hidden */
  21456. _lastColliderTransformMatrix: Nullable<Matrix>;
  21457. /** @hidden */
  21458. _renderId: number;
  21459. /** @hidden */
  21460. _alphaIndex: number;
  21461. /** @hidden */
  21462. _distanceToCamera: number;
  21463. /** @hidden */
  21464. _id: number;
  21465. private _currentMaterial;
  21466. /**
  21467. * Add a new submesh to a mesh
  21468. * @param materialIndex defines the material index to use
  21469. * @param verticesStart defines vertex index start
  21470. * @param verticesCount defines vertices count
  21471. * @param indexStart defines index start
  21472. * @param indexCount defines indices count
  21473. * @param mesh defines the parent mesh
  21474. * @param renderingMesh defines an optional rendering mesh
  21475. * @param createBoundingBox defines if bounding box should be created for this submesh
  21476. * @returns the new submesh
  21477. */
  21478. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  21479. /**
  21480. * Creates a new submesh
  21481. * @param materialIndex defines the material index to use
  21482. * @param verticesStart defines vertex index start
  21483. * @param verticesCount defines vertices count
  21484. * @param indexStart defines index start
  21485. * @param indexCount defines indices count
  21486. * @param mesh defines the parent mesh
  21487. * @param renderingMesh defines an optional rendering mesh
  21488. * @param createBoundingBox defines if bounding box should be created for this submesh
  21489. */
  21490. constructor(
  21491. /** the material index to use */
  21492. materialIndex: number,
  21493. /** vertex index start */
  21494. verticesStart: number,
  21495. /** vertices count */
  21496. verticesCount: number,
  21497. /** index start */
  21498. indexStart: number,
  21499. /** indices count */
  21500. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  21501. /**
  21502. * Returns true if this submesh covers the entire parent mesh
  21503. * @ignorenaming
  21504. */
  21505. get IsGlobal(): boolean;
  21506. /**
  21507. * Returns the submesh BoudingInfo object
  21508. * @returns current bounding info (or mesh's one if the submesh is global)
  21509. */
  21510. getBoundingInfo(): BoundingInfo;
  21511. /**
  21512. * Sets the submesh BoundingInfo
  21513. * @param boundingInfo defines the new bounding info to use
  21514. * @returns the SubMesh
  21515. */
  21516. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  21517. /**
  21518. * Returns the mesh of the current submesh
  21519. * @return the parent mesh
  21520. */
  21521. getMesh(): AbstractMesh;
  21522. /**
  21523. * Returns the rendering mesh of the submesh
  21524. * @returns the rendering mesh (could be different from parent mesh)
  21525. */
  21526. getRenderingMesh(): Mesh;
  21527. /**
  21528. * Returns the submesh material
  21529. * @returns null or the current material
  21530. */
  21531. getMaterial(): Nullable<Material>;
  21532. /**
  21533. * Sets a new updated BoundingInfo object to the submesh
  21534. * @param data defines an optional position array to use to determine the bounding info
  21535. * @returns the SubMesh
  21536. */
  21537. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  21538. /** @hidden */
  21539. _checkCollision(collider: Collider): boolean;
  21540. /**
  21541. * Updates the submesh BoundingInfo
  21542. * @param world defines the world matrix to use to update the bounding info
  21543. * @returns the submesh
  21544. */
  21545. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  21546. /**
  21547. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  21548. * @param frustumPlanes defines the frustum planes
  21549. * @returns true if the submesh is intersecting with the frustum
  21550. */
  21551. isInFrustum(frustumPlanes: Plane[]): boolean;
  21552. /**
  21553. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  21554. * @param frustumPlanes defines the frustum planes
  21555. * @returns true if the submesh is inside the frustum
  21556. */
  21557. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  21558. /**
  21559. * Renders the submesh
  21560. * @param enableAlphaMode defines if alpha needs to be used
  21561. * @returns the submesh
  21562. */
  21563. render(enableAlphaMode: boolean): SubMesh;
  21564. /**
  21565. * @hidden
  21566. */
  21567. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  21568. /**
  21569. * Checks if the submesh intersects with a ray
  21570. * @param ray defines the ray to test
  21571. * @returns true is the passed ray intersects the submesh bounding box
  21572. */
  21573. canIntersects(ray: Ray): boolean;
  21574. /**
  21575. * Intersects current submesh with a ray
  21576. * @param ray defines the ray to test
  21577. * @param positions defines mesh's positions array
  21578. * @param indices defines mesh's indices array
  21579. * @param fastCheck defines if only bounding info should be used
  21580. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  21581. * @returns intersection info or null if no intersection
  21582. */
  21583. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  21584. /** @hidden */
  21585. private _intersectLines;
  21586. /** @hidden */
  21587. private _intersectUnIndexedLines;
  21588. /** @hidden */
  21589. private _intersectTriangles;
  21590. /** @hidden */
  21591. private _intersectUnIndexedTriangles;
  21592. /** @hidden */
  21593. _rebuild(): void;
  21594. /**
  21595. * Creates a new submesh from the passed mesh
  21596. * @param newMesh defines the new hosting mesh
  21597. * @param newRenderingMesh defines an optional rendering mesh
  21598. * @returns the new submesh
  21599. */
  21600. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  21601. /**
  21602. * Release associated resources
  21603. */
  21604. dispose(): void;
  21605. /**
  21606. * Gets the class name
  21607. * @returns the string "SubMesh".
  21608. */
  21609. getClassName(): string;
  21610. /**
  21611. * Creates a new submesh from indices data
  21612. * @param materialIndex the index of the main mesh material
  21613. * @param startIndex the index where to start the copy in the mesh indices array
  21614. * @param indexCount the number of indices to copy then from the startIndex
  21615. * @param mesh the main mesh to create the submesh from
  21616. * @param renderingMesh the optional rendering mesh
  21617. * @returns a new submesh
  21618. */
  21619. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  21620. }
  21621. }
  21622. declare module BABYLON {
  21623. /**
  21624. * Class used to represent data loading progression
  21625. */
  21626. export class SceneLoaderFlags {
  21627. private static _ForceFullSceneLoadingForIncremental;
  21628. private static _ShowLoadingScreen;
  21629. private static _CleanBoneMatrixWeights;
  21630. private static _loggingLevel;
  21631. /**
  21632. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  21633. */
  21634. static get ForceFullSceneLoadingForIncremental(): boolean;
  21635. static set ForceFullSceneLoadingForIncremental(value: boolean);
  21636. /**
  21637. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  21638. */
  21639. static get ShowLoadingScreen(): boolean;
  21640. static set ShowLoadingScreen(value: boolean);
  21641. /**
  21642. * Defines the current logging level (while loading the scene)
  21643. * @ignorenaming
  21644. */
  21645. static get loggingLevel(): number;
  21646. static set loggingLevel(value: number);
  21647. /**
  21648. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  21649. */
  21650. static get CleanBoneMatrixWeights(): boolean;
  21651. static set CleanBoneMatrixWeights(value: boolean);
  21652. }
  21653. }
  21654. declare module BABYLON {
  21655. /**
  21656. * Class used to store geometry data (vertex buffers + index buffer)
  21657. */
  21658. export class Geometry implements IGetSetVerticesData {
  21659. /**
  21660. * Gets or sets the ID of the geometry
  21661. */
  21662. id: string;
  21663. /**
  21664. * Gets or sets the unique ID of the geometry
  21665. */
  21666. uniqueId: number;
  21667. /**
  21668. * Gets the delay loading state of the geometry (none by default which means not delayed)
  21669. */
  21670. delayLoadState: number;
  21671. /**
  21672. * Gets the file containing the data to load when running in delay load state
  21673. */
  21674. delayLoadingFile: Nullable<string>;
  21675. /**
  21676. * Callback called when the geometry is updated
  21677. */
  21678. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  21679. private _scene;
  21680. private _engine;
  21681. private _meshes;
  21682. private _totalVertices;
  21683. /** @hidden */
  21684. _indices: IndicesArray;
  21685. /** @hidden */
  21686. _vertexBuffers: {
  21687. [key: string]: VertexBuffer;
  21688. };
  21689. private _isDisposed;
  21690. private _extend;
  21691. private _boundingBias;
  21692. /** @hidden */
  21693. _delayInfo: Array<string>;
  21694. private _indexBuffer;
  21695. private _indexBufferIsUpdatable;
  21696. /** @hidden */
  21697. _boundingInfo: Nullable<BoundingInfo>;
  21698. /** @hidden */
  21699. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  21700. /** @hidden */
  21701. _softwareSkinningFrameId: number;
  21702. private _vertexArrayObjects;
  21703. private _updatable;
  21704. /** @hidden */
  21705. _positions: Nullable<Vector3[]>;
  21706. /**
  21707. * 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
  21708. */
  21709. get boundingBias(): Vector2;
  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. set boundingBias(value: Vector2);
  21714. /**
  21715. * Static function used to attach a new empty geometry to a mesh
  21716. * @param mesh defines the mesh to attach the geometry to
  21717. * @returns the new Geometry
  21718. */
  21719. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  21720. /**
  21721. * Creates a new geometry
  21722. * @param id defines the unique ID
  21723. * @param scene defines the hosting scene
  21724. * @param vertexData defines the VertexData used to get geometry data
  21725. * @param updatable defines if geometry must be updatable (false by default)
  21726. * @param mesh defines the mesh that will be associated with the geometry
  21727. */
  21728. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  21729. /**
  21730. * Gets the current extend of the geometry
  21731. */
  21732. get extend(): {
  21733. minimum: Vector3;
  21734. maximum: Vector3;
  21735. };
  21736. /**
  21737. * Gets the hosting scene
  21738. * @returns the hosting Scene
  21739. */
  21740. getScene(): Scene;
  21741. /**
  21742. * Gets the hosting engine
  21743. * @returns the hosting Engine
  21744. */
  21745. getEngine(): Engine;
  21746. /**
  21747. * Defines if the geometry is ready to use
  21748. * @returns true if the geometry is ready to be used
  21749. */
  21750. isReady(): boolean;
  21751. /**
  21752. * Gets a value indicating that the geometry should not be serialized
  21753. */
  21754. get doNotSerialize(): boolean;
  21755. /** @hidden */
  21756. _rebuild(): void;
  21757. /**
  21758. * Affects all geometry data in one call
  21759. * @param vertexData defines the geometry data
  21760. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  21761. */
  21762. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  21763. /**
  21764. * Set specific vertex data
  21765. * @param kind defines the data kind (Position, normal, etc...)
  21766. * @param data defines the vertex data to use
  21767. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21768. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21769. */
  21770. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  21771. /**
  21772. * Removes a specific vertex data
  21773. * @param kind defines the data kind (Position, normal, etc...)
  21774. */
  21775. removeVerticesData(kind: string): void;
  21776. /**
  21777. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  21778. * @param buffer defines the vertex buffer to use
  21779. * @param totalVertices defines the total number of vertices for position kind (could be null)
  21780. */
  21781. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  21782. /**
  21783. * Update a specific vertex buffer
  21784. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  21785. * It will do nothing if the buffer is not updatable
  21786. * @param kind defines the data kind (Position, normal, etc...)
  21787. * @param data defines the data to use
  21788. * @param offset defines the offset in the target buffer where to store the data
  21789. * @param useBytes set to true if the offset is in bytes
  21790. */
  21791. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  21792. /**
  21793. * Update a specific vertex buffer
  21794. * This function will create a new buffer if the current one is not updatable
  21795. * @param kind defines the data kind (Position, normal, etc...)
  21796. * @param data defines the data to use
  21797. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  21798. */
  21799. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  21800. private _updateBoundingInfo;
  21801. /** @hidden */
  21802. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  21803. /**
  21804. * Gets total number of vertices
  21805. * @returns the total number of vertices
  21806. */
  21807. getTotalVertices(): number;
  21808. /**
  21809. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21810. * @param kind defines the data kind (Position, normal, etc...)
  21811. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21812. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21813. * @returns a float array containing vertex data
  21814. */
  21815. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21816. /**
  21817. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  21818. * @param kind defines the data kind (Position, normal, etc...)
  21819. * @returns true if the vertex buffer with the specified kind is updatable
  21820. */
  21821. isVertexBufferUpdatable(kind: string): boolean;
  21822. /**
  21823. * Gets a specific vertex buffer
  21824. * @param kind defines the data kind (Position, normal, etc...)
  21825. * @returns a VertexBuffer
  21826. */
  21827. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  21828. /**
  21829. * Returns all vertex buffers
  21830. * @return an object holding all vertex buffers indexed by kind
  21831. */
  21832. getVertexBuffers(): Nullable<{
  21833. [key: string]: VertexBuffer;
  21834. }>;
  21835. /**
  21836. * Gets a boolean indicating if specific vertex buffer is present
  21837. * @param kind defines the data kind (Position, normal, etc...)
  21838. * @returns true if data is present
  21839. */
  21840. isVerticesDataPresent(kind: string): boolean;
  21841. /**
  21842. * Gets a list of all attached data kinds (Position, normal, etc...)
  21843. * @returns a list of string containing all kinds
  21844. */
  21845. getVerticesDataKinds(): string[];
  21846. /**
  21847. * Update index buffer
  21848. * @param indices defines the indices to store in the index buffer
  21849. * @param offset defines the offset in the target buffer where to store the data
  21850. * @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)
  21851. */
  21852. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  21853. /**
  21854. * Creates a new index buffer
  21855. * @param indices defines the indices to store in the index buffer
  21856. * @param totalVertices defines the total number of vertices (could be null)
  21857. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21858. */
  21859. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  21860. /**
  21861. * Return the total number of indices
  21862. * @returns the total number of indices
  21863. */
  21864. getTotalIndices(): number;
  21865. /**
  21866. * Gets the index buffer array
  21867. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21868. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21869. * @returns the index buffer array
  21870. */
  21871. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21872. /**
  21873. * Gets the index buffer
  21874. * @return the index buffer
  21875. */
  21876. getIndexBuffer(): Nullable<DataBuffer>;
  21877. /** @hidden */
  21878. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  21879. /**
  21880. * Release the associated resources for a specific mesh
  21881. * @param mesh defines the source mesh
  21882. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  21883. */
  21884. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  21885. /**
  21886. * Apply current geometry to a given mesh
  21887. * @param mesh defines the mesh to apply geometry to
  21888. */
  21889. applyToMesh(mesh: Mesh): void;
  21890. private _updateExtend;
  21891. private _applyToMesh;
  21892. private notifyUpdate;
  21893. /**
  21894. * Load the geometry if it was flagged as delay loaded
  21895. * @param scene defines the hosting scene
  21896. * @param onLoaded defines a callback called when the geometry is loaded
  21897. */
  21898. load(scene: Scene, onLoaded?: () => void): void;
  21899. private _queueLoad;
  21900. /**
  21901. * Invert the geometry to move from a right handed system to a left handed one.
  21902. */
  21903. toLeftHanded(): void;
  21904. /** @hidden */
  21905. _resetPointsArrayCache(): void;
  21906. /** @hidden */
  21907. _generatePointsArray(): boolean;
  21908. /**
  21909. * Gets a value indicating if the geometry is disposed
  21910. * @returns true if the geometry was disposed
  21911. */
  21912. isDisposed(): boolean;
  21913. private _disposeVertexArrayObjects;
  21914. /**
  21915. * Free all associated resources
  21916. */
  21917. dispose(): void;
  21918. /**
  21919. * Clone the current geometry into a new geometry
  21920. * @param id defines the unique ID of the new geometry
  21921. * @returns a new geometry object
  21922. */
  21923. copy(id: string): Geometry;
  21924. /**
  21925. * Serialize the current geometry info (and not the vertices data) into a JSON object
  21926. * @return a JSON representation of the current geometry data (without the vertices data)
  21927. */
  21928. serialize(): any;
  21929. private toNumberArray;
  21930. /**
  21931. * Serialize all vertices data into a JSON oject
  21932. * @returns a JSON representation of the current geometry data
  21933. */
  21934. serializeVerticeData(): any;
  21935. /**
  21936. * Extracts a clone of a mesh geometry
  21937. * @param mesh defines the source mesh
  21938. * @param id defines the unique ID of the new geometry object
  21939. * @returns the new geometry object
  21940. */
  21941. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  21942. /**
  21943. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  21944. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  21945. * Be aware Math.random() could cause collisions, but:
  21946. * "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"
  21947. * @returns a string containing a new GUID
  21948. */
  21949. static RandomId(): string;
  21950. /** @hidden */
  21951. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  21952. private static _CleanMatricesWeights;
  21953. /**
  21954. * Create a new geometry from persisted data (Using .babylon file format)
  21955. * @param parsedVertexData defines the persisted data
  21956. * @param scene defines the hosting scene
  21957. * @param rootUrl defines the root url to use to load assets (like delayed data)
  21958. * @returns the new geometry object
  21959. */
  21960. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  21961. }
  21962. }
  21963. declare module BABYLON {
  21964. /**
  21965. * Define an interface for all classes that will get and set the data on vertices
  21966. */
  21967. export interface IGetSetVerticesData {
  21968. /**
  21969. * Gets a boolean indicating if specific vertex data is present
  21970. * @param kind defines the vertex data kind to use
  21971. * @returns true is data kind is present
  21972. */
  21973. isVerticesDataPresent(kind: string): boolean;
  21974. /**
  21975. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21976. * @param kind defines the data kind (Position, normal, etc...)
  21977. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21978. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21979. * @returns a float array containing vertex data
  21980. */
  21981. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21982. /**
  21983. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  21984. * @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.
  21985. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21986. * @returns the indices array or an empty array if the mesh has no geometry
  21987. */
  21988. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21989. /**
  21990. * Set specific vertex data
  21991. * @param kind defines the data kind (Position, normal, etc...)
  21992. * @param data defines the vertex data to use
  21993. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21994. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21995. */
  21996. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  21997. /**
  21998. * Update a specific associated vertex buffer
  21999. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  22000. * - VertexBuffer.PositionKind
  22001. * - VertexBuffer.UVKind
  22002. * - VertexBuffer.UV2Kind
  22003. * - VertexBuffer.UV3Kind
  22004. * - VertexBuffer.UV4Kind
  22005. * - VertexBuffer.UV5Kind
  22006. * - VertexBuffer.UV6Kind
  22007. * - VertexBuffer.ColorKind
  22008. * - VertexBuffer.MatricesIndicesKind
  22009. * - VertexBuffer.MatricesIndicesExtraKind
  22010. * - VertexBuffer.MatricesWeightsKind
  22011. * - VertexBuffer.MatricesWeightsExtraKind
  22012. * @param data defines the data source
  22013. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  22014. * @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)
  22015. */
  22016. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  22017. /**
  22018. * Creates a new index buffer
  22019. * @param indices defines the indices to store in the index buffer
  22020. * @param totalVertices defines the total number of vertices (could be null)
  22021. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22022. */
  22023. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  22024. }
  22025. /**
  22026. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  22027. */
  22028. export class VertexData {
  22029. /**
  22030. * Mesh side orientation : usually the external or front surface
  22031. */
  22032. static readonly FRONTSIDE: number;
  22033. /**
  22034. * Mesh side orientation : usually the internal or back surface
  22035. */
  22036. static readonly BACKSIDE: number;
  22037. /**
  22038. * Mesh side orientation : both internal and external or front and back surfaces
  22039. */
  22040. static readonly DOUBLESIDE: number;
  22041. /**
  22042. * Mesh side orientation : by default, `FRONTSIDE`
  22043. */
  22044. static readonly DEFAULTSIDE: number;
  22045. /**
  22046. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  22047. */
  22048. positions: Nullable<FloatArray>;
  22049. /**
  22050. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  22051. */
  22052. normals: Nullable<FloatArray>;
  22053. /**
  22054. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  22055. */
  22056. tangents: Nullable<FloatArray>;
  22057. /**
  22058. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22059. */
  22060. uvs: Nullable<FloatArray>;
  22061. /**
  22062. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22063. */
  22064. uvs2: Nullable<FloatArray>;
  22065. /**
  22066. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22067. */
  22068. uvs3: Nullable<FloatArray>;
  22069. /**
  22070. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22071. */
  22072. uvs4: Nullable<FloatArray>;
  22073. /**
  22074. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22075. */
  22076. uvs5: Nullable<FloatArray>;
  22077. /**
  22078. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22079. */
  22080. uvs6: Nullable<FloatArray>;
  22081. /**
  22082. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  22083. */
  22084. colors: Nullable<FloatArray>;
  22085. /**
  22086. * 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).
  22087. */
  22088. matricesIndices: Nullable<FloatArray>;
  22089. /**
  22090. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  22091. */
  22092. matricesWeights: Nullable<FloatArray>;
  22093. /**
  22094. * An array extending the number of possible indices
  22095. */
  22096. matricesIndicesExtra: Nullable<FloatArray>;
  22097. /**
  22098. * An array extending the number of possible weights when the number of indices is extended
  22099. */
  22100. matricesWeightsExtra: Nullable<FloatArray>;
  22101. /**
  22102. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  22103. */
  22104. indices: Nullable<IndicesArray>;
  22105. /**
  22106. * Uses the passed data array to set the set the values for the specified kind of data
  22107. * @param data a linear array of floating numbers
  22108. * @param kind the type of data that is being set, eg positions, colors etc
  22109. */
  22110. set(data: FloatArray, kind: string): void;
  22111. /**
  22112. * Associates the vertexData to the passed Mesh.
  22113. * Sets it as updatable or not (default `false`)
  22114. * @param mesh the mesh the vertexData is applied to
  22115. * @param updatable when used and having the value true allows new data to update the vertexData
  22116. * @returns the VertexData
  22117. */
  22118. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  22119. /**
  22120. * Associates the vertexData to the passed Geometry.
  22121. * Sets it as updatable or not (default `false`)
  22122. * @param geometry the geometry the vertexData is applied to
  22123. * @param updatable when used and having the value true allows new data to update the vertexData
  22124. * @returns VertexData
  22125. */
  22126. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  22127. /**
  22128. * Updates the associated mesh
  22129. * @param mesh the mesh to be updated
  22130. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22131. * @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
  22132. * @returns VertexData
  22133. */
  22134. updateMesh(mesh: Mesh): VertexData;
  22135. /**
  22136. * Updates the associated geometry
  22137. * @param geometry the geometry to be updated
  22138. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22139. * @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
  22140. * @returns VertexData.
  22141. */
  22142. updateGeometry(geometry: Geometry): VertexData;
  22143. private _applyTo;
  22144. private _update;
  22145. /**
  22146. * Transforms each position and each normal of the vertexData according to the passed Matrix
  22147. * @param matrix the transforming matrix
  22148. * @returns the VertexData
  22149. */
  22150. transform(matrix: Matrix): VertexData;
  22151. /**
  22152. * Merges the passed VertexData into the current one
  22153. * @param other the VertexData to be merged into the current one
  22154. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  22155. * @returns the modified VertexData
  22156. */
  22157. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  22158. private _mergeElement;
  22159. private _validate;
  22160. /**
  22161. * Serializes the VertexData
  22162. * @returns a serialized object
  22163. */
  22164. serialize(): any;
  22165. /**
  22166. * Extracts the vertexData from a mesh
  22167. * @param mesh the mesh from which to extract the VertexData
  22168. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  22169. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22170. * @returns the object VertexData associated to the passed mesh
  22171. */
  22172. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22173. /**
  22174. * Extracts the vertexData from the geometry
  22175. * @param geometry the geometry from which to extract the VertexData
  22176. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  22177. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22178. * @returns the object VertexData associated to the passed mesh
  22179. */
  22180. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22181. private static _ExtractFrom;
  22182. /**
  22183. * Creates the VertexData for a Ribbon
  22184. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  22185. * * pathArray array of paths, each of which an array of successive Vector3
  22186. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  22187. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  22188. * * 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
  22189. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22190. * * 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)
  22191. * * 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)
  22192. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  22193. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  22194. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  22195. * @returns the VertexData of the ribbon
  22196. */
  22197. static CreateRibbon(options: {
  22198. pathArray: Vector3[][];
  22199. closeArray?: boolean;
  22200. closePath?: boolean;
  22201. offset?: number;
  22202. sideOrientation?: number;
  22203. frontUVs?: Vector4;
  22204. backUVs?: Vector4;
  22205. invertUV?: boolean;
  22206. uvs?: Vector2[];
  22207. colors?: Color4[];
  22208. }): VertexData;
  22209. /**
  22210. * Creates the VertexData for a box
  22211. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22212. * * size sets the width, height and depth of the box to the value of size, optional default 1
  22213. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  22214. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  22215. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  22216. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22217. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22218. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22219. * * 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)
  22220. * * 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)
  22221. * @returns the VertexData of the box
  22222. */
  22223. static CreateBox(options: {
  22224. size?: number;
  22225. width?: number;
  22226. height?: number;
  22227. depth?: number;
  22228. faceUV?: Vector4[];
  22229. faceColors?: Color4[];
  22230. sideOrientation?: number;
  22231. frontUVs?: Vector4;
  22232. backUVs?: Vector4;
  22233. }): VertexData;
  22234. /**
  22235. * Creates the VertexData for a tiled box
  22236. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22237. * * faceTiles sets the pattern, tile size and number of tiles for a face
  22238. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22239. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22240. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22241. * @returns the VertexData of the box
  22242. */
  22243. static CreateTiledBox(options: {
  22244. pattern?: number;
  22245. width?: number;
  22246. height?: number;
  22247. depth?: number;
  22248. tileSize?: number;
  22249. tileWidth?: number;
  22250. tileHeight?: number;
  22251. alignHorizontal?: number;
  22252. alignVertical?: number;
  22253. faceUV?: Vector4[];
  22254. faceColors?: Color4[];
  22255. sideOrientation?: number;
  22256. }): VertexData;
  22257. /**
  22258. * Creates the VertexData for a tiled plane
  22259. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22260. * * pattern a limited pattern arrangement depending on the number
  22261. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  22262. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  22263. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  22264. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22265. * * 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)
  22266. * * 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)
  22267. * @returns the VertexData of the tiled plane
  22268. */
  22269. static CreateTiledPlane(options: {
  22270. pattern?: number;
  22271. tileSize?: number;
  22272. tileWidth?: number;
  22273. tileHeight?: number;
  22274. size?: number;
  22275. width?: number;
  22276. height?: number;
  22277. alignHorizontal?: number;
  22278. alignVertical?: number;
  22279. sideOrientation?: number;
  22280. frontUVs?: Vector4;
  22281. backUVs?: Vector4;
  22282. }): VertexData;
  22283. /**
  22284. * Creates the VertexData for an ellipsoid, defaults to a sphere
  22285. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22286. * * segments sets the number of horizontal strips optional, default 32
  22287. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  22288. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  22289. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  22290. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  22291. * * 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
  22292. * * 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
  22293. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22294. * * 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)
  22295. * * 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)
  22296. * @returns the VertexData of the ellipsoid
  22297. */
  22298. static CreateSphere(options: {
  22299. segments?: number;
  22300. diameter?: number;
  22301. diameterX?: number;
  22302. diameterY?: number;
  22303. diameterZ?: number;
  22304. arc?: number;
  22305. slice?: number;
  22306. sideOrientation?: number;
  22307. frontUVs?: Vector4;
  22308. backUVs?: Vector4;
  22309. }): VertexData;
  22310. /**
  22311. * Creates the VertexData for a cylinder, cone or prism
  22312. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22313. * * height sets the height (y direction) of the cylinder, optional, default 2
  22314. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  22315. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  22316. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  22317. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22318. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  22319. * * 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
  22320. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22321. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22322. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  22323. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  22324. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22325. * * 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)
  22326. * * 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)
  22327. * @returns the VertexData of the cylinder, cone or prism
  22328. */
  22329. static CreateCylinder(options: {
  22330. height?: number;
  22331. diameterTop?: number;
  22332. diameterBottom?: number;
  22333. diameter?: number;
  22334. tessellation?: number;
  22335. subdivisions?: number;
  22336. arc?: number;
  22337. faceColors?: Color4[];
  22338. faceUV?: Vector4[];
  22339. hasRings?: boolean;
  22340. enclose?: boolean;
  22341. sideOrientation?: number;
  22342. frontUVs?: Vector4;
  22343. backUVs?: Vector4;
  22344. }): VertexData;
  22345. /**
  22346. * Creates the VertexData for a torus
  22347. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22348. * * diameter the diameter of the torus, optional default 1
  22349. * * thickness the diameter of the tube forming the torus, optional default 0.5
  22350. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22351. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22352. * * 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)
  22353. * * 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)
  22354. * @returns the VertexData of the torus
  22355. */
  22356. static CreateTorus(options: {
  22357. diameter?: number;
  22358. thickness?: number;
  22359. tessellation?: number;
  22360. sideOrientation?: number;
  22361. frontUVs?: Vector4;
  22362. backUVs?: Vector4;
  22363. }): VertexData;
  22364. /**
  22365. * Creates the VertexData of the LineSystem
  22366. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  22367. * - lines an array of lines, each line being an array of successive Vector3
  22368. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  22369. * @returns the VertexData of the LineSystem
  22370. */
  22371. static CreateLineSystem(options: {
  22372. lines: Vector3[][];
  22373. colors?: Nullable<Color4[][]>;
  22374. }): VertexData;
  22375. /**
  22376. * Create the VertexData for a DashedLines
  22377. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  22378. * - points an array successive Vector3
  22379. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  22380. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  22381. * - dashNb the intended total number of dashes, optional, default 200
  22382. * @returns the VertexData for the DashedLines
  22383. */
  22384. static CreateDashedLines(options: {
  22385. points: Vector3[];
  22386. dashSize?: number;
  22387. gapSize?: number;
  22388. dashNb?: number;
  22389. }): VertexData;
  22390. /**
  22391. * Creates the VertexData for a Ground
  22392. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22393. * - width the width (x direction) of the ground, optional, default 1
  22394. * - height the height (z direction) of the ground, optional, default 1
  22395. * - subdivisions the number of subdivisions per side, optional, default 1
  22396. * @returns the VertexData of the Ground
  22397. */
  22398. static CreateGround(options: {
  22399. width?: number;
  22400. height?: number;
  22401. subdivisions?: number;
  22402. subdivisionsX?: number;
  22403. subdivisionsY?: number;
  22404. }): VertexData;
  22405. /**
  22406. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  22407. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22408. * * xmin the ground minimum X coordinate, optional, default -1
  22409. * * zmin the ground minimum Z coordinate, optional, default -1
  22410. * * xmax the ground maximum X coordinate, optional, default 1
  22411. * * zmax the ground maximum Z coordinate, optional, default 1
  22412. * * 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}
  22413. * * 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}
  22414. * @returns the VertexData of the TiledGround
  22415. */
  22416. static CreateTiledGround(options: {
  22417. xmin: number;
  22418. zmin: number;
  22419. xmax: number;
  22420. zmax: number;
  22421. subdivisions?: {
  22422. w: number;
  22423. h: number;
  22424. };
  22425. precision?: {
  22426. w: number;
  22427. h: number;
  22428. };
  22429. }): VertexData;
  22430. /**
  22431. * Creates the VertexData of the Ground designed from a heightmap
  22432. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  22433. * * width the width (x direction) of the ground
  22434. * * height the height (z direction) of the ground
  22435. * * subdivisions the number of subdivisions per side
  22436. * * minHeight the minimum altitude on the ground, optional, default 0
  22437. * * maxHeight the maximum altitude on the ground, optional default 1
  22438. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  22439. * * buffer the array holding the image color data
  22440. * * bufferWidth the width of image
  22441. * * bufferHeight the height of image
  22442. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  22443. * @returns the VertexData of the Ground designed from a heightmap
  22444. */
  22445. static CreateGroundFromHeightMap(options: {
  22446. width: number;
  22447. height: number;
  22448. subdivisions: number;
  22449. minHeight: number;
  22450. maxHeight: number;
  22451. colorFilter: Color3;
  22452. buffer: Uint8Array;
  22453. bufferWidth: number;
  22454. bufferHeight: number;
  22455. alphaFilter: number;
  22456. }): VertexData;
  22457. /**
  22458. * Creates the VertexData for a Plane
  22459. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  22460. * * size sets the width and height of the plane to the value of size, optional default 1
  22461. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  22462. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  22463. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22464. * * 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)
  22465. * * 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)
  22466. * @returns the VertexData of the box
  22467. */
  22468. static CreatePlane(options: {
  22469. size?: number;
  22470. width?: number;
  22471. height?: number;
  22472. sideOrientation?: number;
  22473. frontUVs?: Vector4;
  22474. backUVs?: Vector4;
  22475. }): VertexData;
  22476. /**
  22477. * Creates the VertexData of the Disc or regular Polygon
  22478. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  22479. * * radius the radius of the disc, optional default 0.5
  22480. * * tessellation the number of polygon sides, optional, default 64
  22481. * * 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
  22482. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22483. * * 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)
  22484. * * 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)
  22485. * @returns the VertexData of the box
  22486. */
  22487. static CreateDisc(options: {
  22488. radius?: number;
  22489. tessellation?: number;
  22490. arc?: number;
  22491. sideOrientation?: number;
  22492. frontUVs?: Vector4;
  22493. backUVs?: Vector4;
  22494. }): VertexData;
  22495. /**
  22496. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  22497. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  22498. * @param polygon a mesh built from polygonTriangulation.build()
  22499. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22500. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22501. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22502. * @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)
  22503. * @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)
  22504. * @returns the VertexData of the Polygon
  22505. */
  22506. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  22507. /**
  22508. * Creates the VertexData of the IcoSphere
  22509. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  22510. * * radius the radius of the IcoSphere, optional default 1
  22511. * * radiusX allows stretching in the x direction, optional, default radius
  22512. * * radiusY allows stretching in the y direction, optional, default radius
  22513. * * radiusZ allows stretching in the z direction, optional, default radius
  22514. * * flat when true creates a flat shaded mesh, optional, default true
  22515. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22516. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22517. * * 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)
  22518. * * 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)
  22519. * @returns the VertexData of the IcoSphere
  22520. */
  22521. static CreateIcoSphere(options: {
  22522. radius?: number;
  22523. radiusX?: number;
  22524. radiusY?: number;
  22525. radiusZ?: number;
  22526. flat?: boolean;
  22527. subdivisions?: number;
  22528. sideOrientation?: number;
  22529. frontUVs?: Vector4;
  22530. backUVs?: Vector4;
  22531. }): VertexData;
  22532. /**
  22533. * Creates the VertexData for a Polyhedron
  22534. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  22535. * * type provided types are:
  22536. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  22537. * * 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)
  22538. * * size the size of the IcoSphere, optional default 1
  22539. * * sizeX allows stretching in the x direction, optional, default size
  22540. * * sizeY allows stretching in the y direction, optional, default size
  22541. * * sizeZ allows stretching in the z direction, optional, default size
  22542. * * 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
  22543. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22544. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22545. * * flat when true creates a flat shaded mesh, optional, default true
  22546. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22547. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22548. * * 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)
  22549. * * 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)
  22550. * @returns the VertexData of the Polyhedron
  22551. */
  22552. static CreatePolyhedron(options: {
  22553. type?: number;
  22554. size?: number;
  22555. sizeX?: number;
  22556. sizeY?: number;
  22557. sizeZ?: number;
  22558. custom?: any;
  22559. faceUV?: Vector4[];
  22560. faceColors?: Color4[];
  22561. flat?: boolean;
  22562. sideOrientation?: number;
  22563. frontUVs?: Vector4;
  22564. backUVs?: Vector4;
  22565. }): VertexData;
  22566. /**
  22567. * Creates the VertexData for a TorusKnot
  22568. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  22569. * * radius the radius of the torus knot, optional, default 2
  22570. * * tube the thickness of the tube, optional, default 0.5
  22571. * * radialSegments the number of sides on each tube segments, optional, default 32
  22572. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  22573. * * p the number of windings around the z axis, optional, default 2
  22574. * * q the number of windings around the x axis, optional, default 3
  22575. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22576. * * 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)
  22577. * * 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)
  22578. * @returns the VertexData of the Torus Knot
  22579. */
  22580. static CreateTorusKnot(options: {
  22581. radius?: number;
  22582. tube?: number;
  22583. radialSegments?: number;
  22584. tubularSegments?: number;
  22585. p?: number;
  22586. q?: number;
  22587. sideOrientation?: number;
  22588. frontUVs?: Vector4;
  22589. backUVs?: Vector4;
  22590. }): VertexData;
  22591. /**
  22592. * Compute normals for given positions and indices
  22593. * @param positions an array of vertex positions, [...., x, y, z, ......]
  22594. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  22595. * @param normals an array of vertex normals, [...., x, y, z, ......]
  22596. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  22597. * * facetNormals : optional array of facet normals (vector3)
  22598. * * facetPositions : optional array of facet positions (vector3)
  22599. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  22600. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  22601. * * bInfo : optional bounding info, required for facetPartitioning computation
  22602. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  22603. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  22604. * * useRightHandedSystem: optional boolean to for right handed system computation
  22605. * * depthSort : optional boolean to enable the facet depth sort computation
  22606. * * distanceTo : optional Vector3 to compute the facet depth from this location
  22607. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  22608. */
  22609. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  22610. facetNormals?: any;
  22611. facetPositions?: any;
  22612. facetPartitioning?: any;
  22613. ratio?: number;
  22614. bInfo?: any;
  22615. bbSize?: Vector3;
  22616. subDiv?: any;
  22617. useRightHandedSystem?: boolean;
  22618. depthSort?: boolean;
  22619. distanceTo?: Vector3;
  22620. depthSortedFacets?: any;
  22621. }): void;
  22622. /** @hidden */
  22623. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  22624. /**
  22625. * Applies VertexData created from the imported parameters to the geometry
  22626. * @param parsedVertexData the parsed data from an imported file
  22627. * @param geometry the geometry to apply the VertexData to
  22628. */
  22629. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  22630. }
  22631. }
  22632. declare module BABYLON {
  22633. /**
  22634. * Defines a target to use with MorphTargetManager
  22635. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22636. */
  22637. export class MorphTarget implements IAnimatable {
  22638. /** defines the name of the target */
  22639. name: string;
  22640. /**
  22641. * Gets or sets the list of animations
  22642. */
  22643. animations: Animation[];
  22644. private _scene;
  22645. private _positions;
  22646. private _normals;
  22647. private _tangents;
  22648. private _uvs;
  22649. private _influence;
  22650. private _uniqueId;
  22651. /**
  22652. * Observable raised when the influence changes
  22653. */
  22654. onInfluenceChanged: Observable<boolean>;
  22655. /** @hidden */
  22656. _onDataLayoutChanged: Observable<void>;
  22657. /**
  22658. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  22659. */
  22660. get influence(): number;
  22661. set influence(influence: number);
  22662. /**
  22663. * Gets or sets the id of the morph Target
  22664. */
  22665. id: string;
  22666. private _animationPropertiesOverride;
  22667. /**
  22668. * Gets or sets the animation properties override
  22669. */
  22670. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  22671. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  22672. /**
  22673. * Creates a new MorphTarget
  22674. * @param name defines the name of the target
  22675. * @param influence defines the influence to use
  22676. * @param scene defines the scene the morphtarget belongs to
  22677. */
  22678. constructor(
  22679. /** defines the name of the target */
  22680. name: string, influence?: number, scene?: Nullable<Scene>);
  22681. /**
  22682. * Gets the unique ID of this manager
  22683. */
  22684. get uniqueId(): number;
  22685. /**
  22686. * Gets a boolean defining if the target contains position data
  22687. */
  22688. get hasPositions(): boolean;
  22689. /**
  22690. * Gets a boolean defining if the target contains normal data
  22691. */
  22692. get hasNormals(): boolean;
  22693. /**
  22694. * Gets a boolean defining if the target contains tangent data
  22695. */
  22696. get hasTangents(): boolean;
  22697. /**
  22698. * Gets a boolean defining if the target contains texture coordinates data
  22699. */
  22700. get hasUVs(): boolean;
  22701. /**
  22702. * Affects position data to this target
  22703. * @param data defines the position data to use
  22704. */
  22705. setPositions(data: Nullable<FloatArray>): void;
  22706. /**
  22707. * Gets the position data stored in this target
  22708. * @returns a FloatArray containing the position data (or null if not present)
  22709. */
  22710. getPositions(): Nullable<FloatArray>;
  22711. /**
  22712. * Affects normal data to this target
  22713. * @param data defines the normal data to use
  22714. */
  22715. setNormals(data: Nullable<FloatArray>): void;
  22716. /**
  22717. * Gets the normal data stored in this target
  22718. * @returns a FloatArray containing the normal data (or null if not present)
  22719. */
  22720. getNormals(): Nullable<FloatArray>;
  22721. /**
  22722. * Affects tangent data to this target
  22723. * @param data defines the tangent data to use
  22724. */
  22725. setTangents(data: Nullable<FloatArray>): void;
  22726. /**
  22727. * Gets the tangent data stored in this target
  22728. * @returns a FloatArray containing the tangent data (or null if not present)
  22729. */
  22730. getTangents(): Nullable<FloatArray>;
  22731. /**
  22732. * Affects texture coordinates data to this target
  22733. * @param data defines the texture coordinates data to use
  22734. */
  22735. setUVs(data: Nullable<FloatArray>): void;
  22736. /**
  22737. * Gets the texture coordinates data stored in this target
  22738. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  22739. */
  22740. getUVs(): Nullable<FloatArray>;
  22741. /**
  22742. * Clone the current target
  22743. * @returns a new MorphTarget
  22744. */
  22745. clone(): MorphTarget;
  22746. /**
  22747. * Serializes the current target into a Serialization object
  22748. * @returns the serialized object
  22749. */
  22750. serialize(): any;
  22751. /**
  22752. * Returns the string "MorphTarget"
  22753. * @returns "MorphTarget"
  22754. */
  22755. getClassName(): string;
  22756. /**
  22757. * Creates a new target from serialized data
  22758. * @param serializationObject defines the serialized data to use
  22759. * @returns a new MorphTarget
  22760. */
  22761. static Parse(serializationObject: any): MorphTarget;
  22762. /**
  22763. * Creates a MorphTarget from mesh data
  22764. * @param mesh defines the source mesh
  22765. * @param name defines the name to use for the new target
  22766. * @param influence defines the influence to attach to the target
  22767. * @returns a new MorphTarget
  22768. */
  22769. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  22770. }
  22771. }
  22772. declare module BABYLON {
  22773. /**
  22774. * This class is used to deform meshes using morphing between different targets
  22775. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22776. */
  22777. export class MorphTargetManager {
  22778. private _targets;
  22779. private _targetInfluenceChangedObservers;
  22780. private _targetDataLayoutChangedObservers;
  22781. private _activeTargets;
  22782. private _scene;
  22783. private _influences;
  22784. private _supportsNormals;
  22785. private _supportsTangents;
  22786. private _supportsUVs;
  22787. private _vertexCount;
  22788. private _uniqueId;
  22789. private _tempInfluences;
  22790. /**
  22791. * Gets or sets a boolean indicating if normals must be morphed
  22792. */
  22793. enableNormalMorphing: boolean;
  22794. /**
  22795. * Gets or sets a boolean indicating if tangents must be morphed
  22796. */
  22797. enableTangentMorphing: boolean;
  22798. /**
  22799. * Gets or sets a boolean indicating if UV must be morphed
  22800. */
  22801. enableUVMorphing: boolean;
  22802. /**
  22803. * Creates a new MorphTargetManager
  22804. * @param scene defines the current scene
  22805. */
  22806. constructor(scene?: Nullable<Scene>);
  22807. /**
  22808. * Gets the unique ID of this manager
  22809. */
  22810. get uniqueId(): number;
  22811. /**
  22812. * Gets the number of vertices handled by this manager
  22813. */
  22814. get vertexCount(): number;
  22815. /**
  22816. * Gets a boolean indicating if this manager supports morphing of normals
  22817. */
  22818. get supportsNormals(): boolean;
  22819. /**
  22820. * Gets a boolean indicating if this manager supports morphing of tangents
  22821. */
  22822. get supportsTangents(): boolean;
  22823. /**
  22824. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  22825. */
  22826. get supportsUVs(): boolean;
  22827. /**
  22828. * Gets the number of targets stored in this manager
  22829. */
  22830. get numTargets(): number;
  22831. /**
  22832. * Gets the number of influencers (ie. the number of targets with influences > 0)
  22833. */
  22834. get numInfluencers(): number;
  22835. /**
  22836. * Gets the list of influences (one per target)
  22837. */
  22838. get influences(): Float32Array;
  22839. /**
  22840. * Gets the active target at specified index. An active target is a target with an influence > 0
  22841. * @param index defines the index to check
  22842. * @returns the requested target
  22843. */
  22844. getActiveTarget(index: number): MorphTarget;
  22845. /**
  22846. * Gets the target at specified index
  22847. * @param index defines the index to check
  22848. * @returns the requested target
  22849. */
  22850. getTarget(index: number): MorphTarget;
  22851. /**
  22852. * Add a new target to this manager
  22853. * @param target defines the target to add
  22854. */
  22855. addTarget(target: MorphTarget): void;
  22856. /**
  22857. * Removes a target from the manager
  22858. * @param target defines the target to remove
  22859. */
  22860. removeTarget(target: MorphTarget): void;
  22861. /**
  22862. * Clone the current manager
  22863. * @returns a new MorphTargetManager
  22864. */
  22865. clone(): MorphTargetManager;
  22866. /**
  22867. * Serializes the current manager into a Serialization object
  22868. * @returns the serialized object
  22869. */
  22870. serialize(): any;
  22871. private _syncActiveTargets;
  22872. /**
  22873. * Syncrhonize the targets with all the meshes using this morph target manager
  22874. */
  22875. synchronize(): void;
  22876. /**
  22877. * Creates a new MorphTargetManager from serialized data
  22878. * @param serializationObject defines the serialized data
  22879. * @param scene defines the hosting scene
  22880. * @returns the new MorphTargetManager
  22881. */
  22882. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  22883. }
  22884. }
  22885. declare module BABYLON {
  22886. /**
  22887. * Class used to represent a specific level of detail of a mesh
  22888. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  22889. */
  22890. export class MeshLODLevel {
  22891. /** Defines the distance where this level should start being displayed */
  22892. distance: number;
  22893. /** Defines the mesh to use to render this level */
  22894. mesh: Nullable<Mesh>;
  22895. /**
  22896. * Creates a new LOD level
  22897. * @param distance defines the distance where this level should star being displayed
  22898. * @param mesh defines the mesh to use to render this level
  22899. */
  22900. constructor(
  22901. /** Defines the distance where this level should start being displayed */
  22902. distance: number,
  22903. /** Defines the mesh to use to render this level */
  22904. mesh: Nullable<Mesh>);
  22905. }
  22906. }
  22907. declare module BABYLON {
  22908. /**
  22909. * Mesh representing the gorund
  22910. */
  22911. export class GroundMesh extends Mesh {
  22912. /** If octree should be generated */
  22913. generateOctree: boolean;
  22914. private _heightQuads;
  22915. /** @hidden */
  22916. _subdivisionsX: number;
  22917. /** @hidden */
  22918. _subdivisionsY: number;
  22919. /** @hidden */
  22920. _width: number;
  22921. /** @hidden */
  22922. _height: number;
  22923. /** @hidden */
  22924. _minX: number;
  22925. /** @hidden */
  22926. _maxX: number;
  22927. /** @hidden */
  22928. _minZ: number;
  22929. /** @hidden */
  22930. _maxZ: number;
  22931. constructor(name: string, scene: Scene);
  22932. /**
  22933. * "GroundMesh"
  22934. * @returns "GroundMesh"
  22935. */
  22936. getClassName(): string;
  22937. /**
  22938. * The minimum of x and y subdivisions
  22939. */
  22940. get subdivisions(): number;
  22941. /**
  22942. * X subdivisions
  22943. */
  22944. get subdivisionsX(): number;
  22945. /**
  22946. * Y subdivisions
  22947. */
  22948. get subdivisionsY(): number;
  22949. /**
  22950. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  22951. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  22952. * @param chunksCount the number of subdivisions for x and y
  22953. * @param octreeBlocksSize (Default: 32)
  22954. */
  22955. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  22956. /**
  22957. * Returns a height (y) value in the Worl system :
  22958. * the ground altitude at the coordinates (x, z) expressed in the World system.
  22959. * @param x x coordinate
  22960. * @param z z coordinate
  22961. * @returns the ground y position if (x, z) are outside the ground surface.
  22962. */
  22963. getHeightAtCoordinates(x: number, z: number): number;
  22964. /**
  22965. * Returns a normalized vector (Vector3) orthogonal to the ground
  22966. * at the ground coordinates (x, z) expressed in the World system.
  22967. * @param x x coordinate
  22968. * @param z z coordinate
  22969. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  22970. */
  22971. getNormalAtCoordinates(x: number, z: number): Vector3;
  22972. /**
  22973. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  22974. * at the ground coordinates (x, z) expressed in the World system.
  22975. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  22976. * @param x x coordinate
  22977. * @param z z coordinate
  22978. * @param ref vector to store the result
  22979. * @returns the GroundMesh.
  22980. */
  22981. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  22982. /**
  22983. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  22984. * if the ground has been updated.
  22985. * This can be used in the render loop.
  22986. * @returns the GroundMesh.
  22987. */
  22988. updateCoordinateHeights(): GroundMesh;
  22989. private _getFacetAt;
  22990. private _initHeightQuads;
  22991. private _computeHeightQuads;
  22992. /**
  22993. * Serializes this ground mesh
  22994. * @param serializationObject object to write serialization to
  22995. */
  22996. serialize(serializationObject: any): void;
  22997. /**
  22998. * Parses a serialized ground mesh
  22999. * @param parsedMesh the serialized mesh
  23000. * @param scene the scene to create the ground mesh in
  23001. * @returns the created ground mesh
  23002. */
  23003. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  23004. }
  23005. }
  23006. declare module BABYLON {
  23007. /**
  23008. * Interface for Physics-Joint data
  23009. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23010. */
  23011. export interface PhysicsJointData {
  23012. /**
  23013. * The main pivot of the joint
  23014. */
  23015. mainPivot?: Vector3;
  23016. /**
  23017. * The connected pivot of the joint
  23018. */
  23019. connectedPivot?: Vector3;
  23020. /**
  23021. * The main axis of the joint
  23022. */
  23023. mainAxis?: Vector3;
  23024. /**
  23025. * The connected axis of the joint
  23026. */
  23027. connectedAxis?: Vector3;
  23028. /**
  23029. * The collision of the joint
  23030. */
  23031. collision?: boolean;
  23032. /**
  23033. * Native Oimo/Cannon/Energy data
  23034. */
  23035. nativeParams?: any;
  23036. }
  23037. /**
  23038. * This is a holder class for the physics joint created by the physics plugin
  23039. * It holds a set of functions to control the underlying joint
  23040. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23041. */
  23042. export class PhysicsJoint {
  23043. /**
  23044. * The type of the physics joint
  23045. */
  23046. type: number;
  23047. /**
  23048. * The data for the physics joint
  23049. */
  23050. jointData: PhysicsJointData;
  23051. private _physicsJoint;
  23052. protected _physicsPlugin: IPhysicsEnginePlugin;
  23053. /**
  23054. * Initializes the physics joint
  23055. * @param type The type of the physics joint
  23056. * @param jointData The data for the physics joint
  23057. */
  23058. constructor(
  23059. /**
  23060. * The type of the physics joint
  23061. */
  23062. type: number,
  23063. /**
  23064. * The data for the physics joint
  23065. */
  23066. jointData: PhysicsJointData);
  23067. /**
  23068. * Gets the physics joint
  23069. */
  23070. get physicsJoint(): any;
  23071. /**
  23072. * Sets the physics joint
  23073. */
  23074. set physicsJoint(newJoint: any);
  23075. /**
  23076. * Sets the physics plugin
  23077. */
  23078. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  23079. /**
  23080. * Execute a function that is physics-plugin specific.
  23081. * @param {Function} func the function that will be executed.
  23082. * It accepts two parameters: the physics world and the physics joint
  23083. */
  23084. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  23085. /**
  23086. * Distance-Joint type
  23087. */
  23088. static DistanceJoint: number;
  23089. /**
  23090. * Hinge-Joint type
  23091. */
  23092. static HingeJoint: number;
  23093. /**
  23094. * Ball-and-Socket joint type
  23095. */
  23096. static BallAndSocketJoint: number;
  23097. /**
  23098. * Wheel-Joint type
  23099. */
  23100. static WheelJoint: number;
  23101. /**
  23102. * Slider-Joint type
  23103. */
  23104. static SliderJoint: number;
  23105. /**
  23106. * Prismatic-Joint type
  23107. */
  23108. static PrismaticJoint: number;
  23109. /**
  23110. * Universal-Joint type
  23111. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  23112. */
  23113. static UniversalJoint: number;
  23114. /**
  23115. * Hinge-Joint 2 type
  23116. */
  23117. static Hinge2Joint: number;
  23118. /**
  23119. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  23120. */
  23121. static PointToPointJoint: number;
  23122. /**
  23123. * Spring-Joint type
  23124. */
  23125. static SpringJoint: number;
  23126. /**
  23127. * Lock-Joint type
  23128. */
  23129. static LockJoint: number;
  23130. }
  23131. /**
  23132. * A class representing a physics distance joint
  23133. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23134. */
  23135. export class DistanceJoint extends PhysicsJoint {
  23136. /**
  23137. *
  23138. * @param jointData The data for the Distance-Joint
  23139. */
  23140. constructor(jointData: DistanceJointData);
  23141. /**
  23142. * Update the predefined distance.
  23143. * @param maxDistance The maximum preferred distance
  23144. * @param minDistance The minimum preferred distance
  23145. */
  23146. updateDistance(maxDistance: number, minDistance?: number): void;
  23147. }
  23148. /**
  23149. * Represents a Motor-Enabled Joint
  23150. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23151. */
  23152. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  23153. /**
  23154. * Initializes the Motor-Enabled Joint
  23155. * @param type The type of the joint
  23156. * @param jointData The physica joint data for the joint
  23157. */
  23158. constructor(type: number, jointData: PhysicsJointData);
  23159. /**
  23160. * Set the motor values.
  23161. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23162. * @param force the force to apply
  23163. * @param maxForce max force for this motor.
  23164. */
  23165. setMotor(force?: number, maxForce?: number): void;
  23166. /**
  23167. * Set the motor's limits.
  23168. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23169. * @param upperLimit The upper limit of the motor
  23170. * @param lowerLimit The lower limit of the motor
  23171. */
  23172. setLimit(upperLimit: number, lowerLimit?: number): void;
  23173. }
  23174. /**
  23175. * This class represents a single physics Hinge-Joint
  23176. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23177. */
  23178. export class HingeJoint extends MotorEnabledJoint {
  23179. /**
  23180. * Initializes the Hinge-Joint
  23181. * @param jointData The joint data for the Hinge-Joint
  23182. */
  23183. constructor(jointData: PhysicsJointData);
  23184. /**
  23185. * Set the motor values.
  23186. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23187. * @param {number} force the force to apply
  23188. * @param {number} maxForce max force for this motor.
  23189. */
  23190. setMotor(force?: number, maxForce?: number): void;
  23191. /**
  23192. * Set the motor's limits.
  23193. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23194. * @param upperLimit The upper limit of the motor
  23195. * @param lowerLimit The lower limit of the motor
  23196. */
  23197. setLimit(upperLimit: number, lowerLimit?: number): void;
  23198. }
  23199. /**
  23200. * This class represents a dual hinge physics joint (same as wheel joint)
  23201. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23202. */
  23203. export class Hinge2Joint extends MotorEnabledJoint {
  23204. /**
  23205. * Initializes the Hinge2-Joint
  23206. * @param jointData The joint data for the Hinge2-Joint
  23207. */
  23208. constructor(jointData: PhysicsJointData);
  23209. /**
  23210. * Set the motor values.
  23211. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23212. * @param {number} targetSpeed the speed the motor is to reach
  23213. * @param {number} maxForce max force for this motor.
  23214. * @param {motorIndex} the motor's index, 0 or 1.
  23215. */
  23216. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  23217. /**
  23218. * Set the motor limits.
  23219. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23220. * @param {number} upperLimit the upper limit
  23221. * @param {number} lowerLimit lower limit
  23222. * @param {motorIndex} the motor's index, 0 or 1.
  23223. */
  23224. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23225. }
  23226. /**
  23227. * Interface for a motor enabled joint
  23228. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23229. */
  23230. export interface IMotorEnabledJoint {
  23231. /**
  23232. * Physics joint
  23233. */
  23234. physicsJoint: any;
  23235. /**
  23236. * Sets the motor of the motor-enabled joint
  23237. * @param force The force of the motor
  23238. * @param maxForce The maximum force of the motor
  23239. * @param motorIndex The index of the motor
  23240. */
  23241. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  23242. /**
  23243. * Sets the limit of the motor
  23244. * @param upperLimit The upper limit of the motor
  23245. * @param lowerLimit The lower limit of the motor
  23246. * @param motorIndex The index of the motor
  23247. */
  23248. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23249. }
  23250. /**
  23251. * Joint data for a Distance-Joint
  23252. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23253. */
  23254. export interface DistanceJointData extends PhysicsJointData {
  23255. /**
  23256. * Max distance the 2 joint objects can be apart
  23257. */
  23258. maxDistance: number;
  23259. }
  23260. /**
  23261. * Joint data from a spring joint
  23262. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23263. */
  23264. export interface SpringJointData extends PhysicsJointData {
  23265. /**
  23266. * Length of the spring
  23267. */
  23268. length: number;
  23269. /**
  23270. * Stiffness of the spring
  23271. */
  23272. stiffness: number;
  23273. /**
  23274. * Damping of the spring
  23275. */
  23276. damping: number;
  23277. /** this callback will be called when applying the force to the impostors. */
  23278. forceApplicationCallback: () => void;
  23279. }
  23280. }
  23281. declare module BABYLON {
  23282. /**
  23283. * Holds the data for the raycast result
  23284. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23285. */
  23286. export class PhysicsRaycastResult {
  23287. private _hasHit;
  23288. private _hitDistance;
  23289. private _hitNormalWorld;
  23290. private _hitPointWorld;
  23291. private _rayFromWorld;
  23292. private _rayToWorld;
  23293. /**
  23294. * Gets if there was a hit
  23295. */
  23296. get hasHit(): boolean;
  23297. /**
  23298. * Gets the distance from the hit
  23299. */
  23300. get hitDistance(): number;
  23301. /**
  23302. * Gets the hit normal/direction in the world
  23303. */
  23304. get hitNormalWorld(): Vector3;
  23305. /**
  23306. * Gets the hit point in the world
  23307. */
  23308. get hitPointWorld(): Vector3;
  23309. /**
  23310. * Gets the ray "start point" of the ray in the world
  23311. */
  23312. get rayFromWorld(): Vector3;
  23313. /**
  23314. * Gets the ray "end point" of the ray in the world
  23315. */
  23316. get rayToWorld(): Vector3;
  23317. /**
  23318. * Sets the hit data (normal & point in world space)
  23319. * @param hitNormalWorld defines the normal in world space
  23320. * @param hitPointWorld defines the point in world space
  23321. */
  23322. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  23323. /**
  23324. * Sets the distance from the start point to the hit point
  23325. * @param distance
  23326. */
  23327. setHitDistance(distance: number): void;
  23328. /**
  23329. * Calculates the distance manually
  23330. */
  23331. calculateHitDistance(): void;
  23332. /**
  23333. * Resets all the values to default
  23334. * @param from The from point on world space
  23335. * @param to The to point on world space
  23336. */
  23337. reset(from?: Vector3, to?: Vector3): void;
  23338. }
  23339. /**
  23340. * Interface for the size containing width and height
  23341. */
  23342. interface IXYZ {
  23343. /**
  23344. * X
  23345. */
  23346. x: number;
  23347. /**
  23348. * Y
  23349. */
  23350. y: number;
  23351. /**
  23352. * Z
  23353. */
  23354. z: number;
  23355. }
  23356. }
  23357. declare module BABYLON {
  23358. /**
  23359. * Interface used to describe a physics joint
  23360. */
  23361. export interface PhysicsImpostorJoint {
  23362. /** Defines the main impostor to which the joint is linked */
  23363. mainImpostor: PhysicsImpostor;
  23364. /** Defines the impostor that is connected to the main impostor using this joint */
  23365. connectedImpostor: PhysicsImpostor;
  23366. /** Defines the joint itself */
  23367. joint: PhysicsJoint;
  23368. }
  23369. /** @hidden */
  23370. export interface IPhysicsEnginePlugin {
  23371. world: any;
  23372. name: string;
  23373. setGravity(gravity: Vector3): void;
  23374. setTimeStep(timeStep: number): void;
  23375. getTimeStep(): number;
  23376. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  23377. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23378. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23379. generatePhysicsBody(impostor: PhysicsImpostor): void;
  23380. removePhysicsBody(impostor: PhysicsImpostor): void;
  23381. generateJoint(joint: PhysicsImpostorJoint): void;
  23382. removeJoint(joint: PhysicsImpostorJoint): void;
  23383. isSupported(): boolean;
  23384. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  23385. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  23386. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23387. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23388. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23389. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23390. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  23391. getBodyMass(impostor: PhysicsImpostor): number;
  23392. getBodyFriction(impostor: PhysicsImpostor): number;
  23393. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  23394. getBodyRestitution(impostor: PhysicsImpostor): number;
  23395. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  23396. getBodyPressure?(impostor: PhysicsImpostor): number;
  23397. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  23398. getBodyStiffness?(impostor: PhysicsImpostor): number;
  23399. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  23400. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  23401. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  23402. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  23403. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  23404. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23405. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23406. sleepBody(impostor: PhysicsImpostor): void;
  23407. wakeUpBody(impostor: PhysicsImpostor): void;
  23408. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23409. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  23410. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  23411. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23412. getRadius(impostor: PhysicsImpostor): number;
  23413. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  23414. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  23415. dispose(): void;
  23416. }
  23417. /**
  23418. * Interface used to define a physics engine
  23419. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  23420. */
  23421. export interface IPhysicsEngine {
  23422. /**
  23423. * Gets the gravity vector used by the simulation
  23424. */
  23425. gravity: Vector3;
  23426. /**
  23427. * Sets the gravity vector used by the simulation
  23428. * @param gravity defines the gravity vector to use
  23429. */
  23430. setGravity(gravity: Vector3): void;
  23431. /**
  23432. * Set the time step of the physics engine.
  23433. * Default is 1/60.
  23434. * To slow it down, enter 1/600 for example.
  23435. * To speed it up, 1/30
  23436. * @param newTimeStep the new timestep to apply to this world.
  23437. */
  23438. setTimeStep(newTimeStep: number): void;
  23439. /**
  23440. * Get the time step of the physics engine.
  23441. * @returns the current time step
  23442. */
  23443. getTimeStep(): number;
  23444. /**
  23445. * Set the sub time step of the physics engine.
  23446. * Default is 0 meaning there is no sub steps
  23447. * To increase physics resolution precision, set a small value (like 1 ms)
  23448. * @param subTimeStep defines the new sub timestep used for physics resolution.
  23449. */
  23450. setSubTimeStep(subTimeStep: number): void;
  23451. /**
  23452. * Get the sub time step of the physics engine.
  23453. * @returns the current sub time step
  23454. */
  23455. getSubTimeStep(): number;
  23456. /**
  23457. * Release all resources
  23458. */
  23459. dispose(): void;
  23460. /**
  23461. * Gets the name of the current physics plugin
  23462. * @returns the name of the plugin
  23463. */
  23464. getPhysicsPluginName(): string;
  23465. /**
  23466. * Adding a new impostor for the impostor tracking.
  23467. * This will be done by the impostor itself.
  23468. * @param impostor the impostor to add
  23469. */
  23470. addImpostor(impostor: PhysicsImpostor): void;
  23471. /**
  23472. * Remove an impostor from the engine.
  23473. * This impostor and its mesh will not longer be updated by the physics engine.
  23474. * @param impostor the impostor to remove
  23475. */
  23476. removeImpostor(impostor: PhysicsImpostor): void;
  23477. /**
  23478. * Add a joint to the physics engine
  23479. * @param mainImpostor defines the main impostor to which the joint is added.
  23480. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  23481. * @param joint defines the joint that will connect both impostors.
  23482. */
  23483. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23484. /**
  23485. * Removes a joint from the simulation
  23486. * @param mainImpostor defines the impostor used with the joint
  23487. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  23488. * @param joint defines the joint to remove
  23489. */
  23490. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23491. /**
  23492. * Gets the current plugin used to run the simulation
  23493. * @returns current plugin
  23494. */
  23495. getPhysicsPlugin(): IPhysicsEnginePlugin;
  23496. /**
  23497. * Gets the list of physic impostors
  23498. * @returns an array of PhysicsImpostor
  23499. */
  23500. getImpostors(): Array<PhysicsImpostor>;
  23501. /**
  23502. * Gets the impostor for a physics enabled object
  23503. * @param object defines the object impersonated by the impostor
  23504. * @returns the PhysicsImpostor or null if not found
  23505. */
  23506. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23507. /**
  23508. * Gets the impostor for a physics body object
  23509. * @param body defines physics body used by the impostor
  23510. * @returns the PhysicsImpostor or null if not found
  23511. */
  23512. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  23513. /**
  23514. * Does a raycast in the physics world
  23515. * @param from when should the ray start?
  23516. * @param to when should the ray end?
  23517. * @returns PhysicsRaycastResult
  23518. */
  23519. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23520. /**
  23521. * Called by the scene. No need to call it.
  23522. * @param delta defines the timespam between frames
  23523. */
  23524. _step(delta: number): void;
  23525. }
  23526. }
  23527. declare module BABYLON {
  23528. /**
  23529. * The interface for the physics imposter parameters
  23530. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23531. */
  23532. export interface PhysicsImpostorParameters {
  23533. /**
  23534. * The mass of the physics imposter
  23535. */
  23536. mass: number;
  23537. /**
  23538. * The friction of the physics imposter
  23539. */
  23540. friction?: number;
  23541. /**
  23542. * The coefficient of restitution of the physics imposter
  23543. */
  23544. restitution?: number;
  23545. /**
  23546. * The native options of the physics imposter
  23547. */
  23548. nativeOptions?: any;
  23549. /**
  23550. * Specifies if the parent should be ignored
  23551. */
  23552. ignoreParent?: boolean;
  23553. /**
  23554. * Specifies if bi-directional transformations should be disabled
  23555. */
  23556. disableBidirectionalTransformation?: boolean;
  23557. /**
  23558. * The pressure inside the physics imposter, soft object only
  23559. */
  23560. pressure?: number;
  23561. /**
  23562. * The stiffness the physics imposter, soft object only
  23563. */
  23564. stiffness?: number;
  23565. /**
  23566. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  23567. */
  23568. velocityIterations?: number;
  23569. /**
  23570. * The number of iterations used in maintaining consistent vertex positions, soft object only
  23571. */
  23572. positionIterations?: number;
  23573. /**
  23574. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  23575. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  23576. * Add to fix multiple points
  23577. */
  23578. fixedPoints?: number;
  23579. /**
  23580. * The collision margin around a soft object
  23581. */
  23582. margin?: number;
  23583. /**
  23584. * The collision margin around a soft object
  23585. */
  23586. damping?: number;
  23587. /**
  23588. * The path for a rope based on an extrusion
  23589. */
  23590. path?: any;
  23591. /**
  23592. * The shape of an extrusion used for a rope based on an extrusion
  23593. */
  23594. shape?: any;
  23595. }
  23596. /**
  23597. * Interface for a physics-enabled object
  23598. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23599. */
  23600. export interface IPhysicsEnabledObject {
  23601. /**
  23602. * The position of the physics-enabled object
  23603. */
  23604. position: Vector3;
  23605. /**
  23606. * The rotation of the physics-enabled object
  23607. */
  23608. rotationQuaternion: Nullable<Quaternion>;
  23609. /**
  23610. * The scale of the physics-enabled object
  23611. */
  23612. scaling: Vector3;
  23613. /**
  23614. * The rotation of the physics-enabled object
  23615. */
  23616. rotation?: Vector3;
  23617. /**
  23618. * The parent of the physics-enabled object
  23619. */
  23620. parent?: any;
  23621. /**
  23622. * The bounding info of the physics-enabled object
  23623. * @returns The bounding info of the physics-enabled object
  23624. */
  23625. getBoundingInfo(): BoundingInfo;
  23626. /**
  23627. * Computes the world matrix
  23628. * @param force Specifies if the world matrix should be computed by force
  23629. * @returns A world matrix
  23630. */
  23631. computeWorldMatrix(force: boolean): Matrix;
  23632. /**
  23633. * Gets the world matrix
  23634. * @returns A world matrix
  23635. */
  23636. getWorldMatrix?(): Matrix;
  23637. /**
  23638. * Gets the child meshes
  23639. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  23640. * @returns An array of abstract meshes
  23641. */
  23642. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  23643. /**
  23644. * Gets the vertex data
  23645. * @param kind The type of vertex data
  23646. * @returns A nullable array of numbers, or a float32 array
  23647. */
  23648. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  23649. /**
  23650. * Gets the indices from the mesh
  23651. * @returns A nullable array of index arrays
  23652. */
  23653. getIndices?(): Nullable<IndicesArray>;
  23654. /**
  23655. * Gets the scene from the mesh
  23656. * @returns the indices array or null
  23657. */
  23658. getScene?(): Scene;
  23659. /**
  23660. * Gets the absolute position from the mesh
  23661. * @returns the absolute position
  23662. */
  23663. getAbsolutePosition(): Vector3;
  23664. /**
  23665. * Gets the absolute pivot point from the mesh
  23666. * @returns the absolute pivot point
  23667. */
  23668. getAbsolutePivotPoint(): Vector3;
  23669. /**
  23670. * Rotates the mesh
  23671. * @param axis The axis of rotation
  23672. * @param amount The amount of rotation
  23673. * @param space The space of the rotation
  23674. * @returns The rotation transform node
  23675. */
  23676. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  23677. /**
  23678. * Translates the mesh
  23679. * @param axis The axis of translation
  23680. * @param distance The distance of translation
  23681. * @param space The space of the translation
  23682. * @returns The transform node
  23683. */
  23684. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  23685. /**
  23686. * Sets the absolute position of the mesh
  23687. * @param absolutePosition The absolute position of the mesh
  23688. * @returns The transform node
  23689. */
  23690. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  23691. /**
  23692. * Gets the class name of the mesh
  23693. * @returns The class name
  23694. */
  23695. getClassName(): string;
  23696. }
  23697. /**
  23698. * Represents a physics imposter
  23699. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23700. */
  23701. export class PhysicsImpostor {
  23702. /**
  23703. * The physics-enabled object used as the physics imposter
  23704. */
  23705. object: IPhysicsEnabledObject;
  23706. /**
  23707. * The type of the physics imposter
  23708. */
  23709. type: number;
  23710. private _options;
  23711. private _scene?;
  23712. /**
  23713. * The default object size of the imposter
  23714. */
  23715. static DEFAULT_OBJECT_SIZE: Vector3;
  23716. /**
  23717. * The identity quaternion of the imposter
  23718. */
  23719. static IDENTITY_QUATERNION: Quaternion;
  23720. /** @hidden */
  23721. _pluginData: any;
  23722. private _physicsEngine;
  23723. private _physicsBody;
  23724. private _bodyUpdateRequired;
  23725. private _onBeforePhysicsStepCallbacks;
  23726. private _onAfterPhysicsStepCallbacks;
  23727. /** @hidden */
  23728. _onPhysicsCollideCallbacks: Array<{
  23729. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  23730. otherImpostors: Array<PhysicsImpostor>;
  23731. }>;
  23732. private _deltaPosition;
  23733. private _deltaRotation;
  23734. private _deltaRotationConjugated;
  23735. /** @hidden */
  23736. _isFromLine: boolean;
  23737. private _parent;
  23738. private _isDisposed;
  23739. private static _tmpVecs;
  23740. private static _tmpQuat;
  23741. /**
  23742. * Specifies if the physics imposter is disposed
  23743. */
  23744. get isDisposed(): boolean;
  23745. /**
  23746. * Gets the mass of the physics imposter
  23747. */
  23748. get mass(): number;
  23749. set mass(value: number);
  23750. /**
  23751. * Gets the coefficient of friction
  23752. */
  23753. get friction(): number;
  23754. /**
  23755. * Sets the coefficient of friction
  23756. */
  23757. set friction(value: number);
  23758. /**
  23759. * Gets the coefficient of restitution
  23760. */
  23761. get restitution(): number;
  23762. /**
  23763. * Sets the coefficient of restitution
  23764. */
  23765. set restitution(value: number);
  23766. /**
  23767. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  23768. */
  23769. get pressure(): number;
  23770. /**
  23771. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  23772. */
  23773. set pressure(value: number);
  23774. /**
  23775. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23776. */
  23777. get stiffness(): number;
  23778. /**
  23779. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23780. */
  23781. set stiffness(value: number);
  23782. /**
  23783. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23784. */
  23785. get velocityIterations(): number;
  23786. /**
  23787. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23788. */
  23789. set velocityIterations(value: number);
  23790. /**
  23791. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23792. */
  23793. get positionIterations(): number;
  23794. /**
  23795. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23796. */
  23797. set positionIterations(value: number);
  23798. /**
  23799. * The unique id of the physics imposter
  23800. * set by the physics engine when adding this impostor to the array
  23801. */
  23802. uniqueId: number;
  23803. /**
  23804. * @hidden
  23805. */
  23806. soft: boolean;
  23807. /**
  23808. * @hidden
  23809. */
  23810. segments: number;
  23811. private _joints;
  23812. /**
  23813. * Initializes the physics imposter
  23814. * @param object The physics-enabled object used as the physics imposter
  23815. * @param type The type of the physics imposter
  23816. * @param _options The options for the physics imposter
  23817. * @param _scene The Babylon scene
  23818. */
  23819. constructor(
  23820. /**
  23821. * The physics-enabled object used as the physics imposter
  23822. */
  23823. object: IPhysicsEnabledObject,
  23824. /**
  23825. * The type of the physics imposter
  23826. */
  23827. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  23828. /**
  23829. * This function will completly initialize this impostor.
  23830. * It will create a new body - but only if this mesh has no parent.
  23831. * If it has, this impostor will not be used other than to define the impostor
  23832. * of the child mesh.
  23833. * @hidden
  23834. */
  23835. _init(): void;
  23836. private _getPhysicsParent;
  23837. /**
  23838. * Should a new body be generated.
  23839. * @returns boolean specifying if body initialization is required
  23840. */
  23841. isBodyInitRequired(): boolean;
  23842. /**
  23843. * Sets the updated scaling
  23844. * @param updated Specifies if the scaling is updated
  23845. */
  23846. setScalingUpdated(): void;
  23847. /**
  23848. * Force a regeneration of this or the parent's impostor's body.
  23849. * Use under cautious - This will remove all joints already implemented.
  23850. */
  23851. forceUpdate(): void;
  23852. /**
  23853. * Gets the body that holds this impostor. Either its own, or its parent.
  23854. */
  23855. get physicsBody(): any;
  23856. /**
  23857. * Get the parent of the physics imposter
  23858. * @returns Physics imposter or null
  23859. */
  23860. get parent(): Nullable<PhysicsImpostor>;
  23861. /**
  23862. * Sets the parent of the physics imposter
  23863. */
  23864. set parent(value: Nullable<PhysicsImpostor>);
  23865. /**
  23866. * Set the physics body. Used mainly by the physics engine/plugin
  23867. */
  23868. set physicsBody(physicsBody: any);
  23869. /**
  23870. * Resets the update flags
  23871. */
  23872. resetUpdateFlags(): void;
  23873. /**
  23874. * Gets the object extend size
  23875. * @returns the object extend size
  23876. */
  23877. getObjectExtendSize(): Vector3;
  23878. /**
  23879. * Gets the object center
  23880. * @returns The object center
  23881. */
  23882. getObjectCenter(): Vector3;
  23883. /**
  23884. * Get a specific parameter from the options parameters
  23885. * @param paramName The object parameter name
  23886. * @returns The object parameter
  23887. */
  23888. getParam(paramName: string): any;
  23889. /**
  23890. * Sets a specific parameter in the options given to the physics plugin
  23891. * @param paramName The parameter name
  23892. * @param value The value of the parameter
  23893. */
  23894. setParam(paramName: string, value: number): void;
  23895. /**
  23896. * Specifically change the body's mass option. Won't recreate the physics body object
  23897. * @param mass The mass of the physics imposter
  23898. */
  23899. setMass(mass: number): void;
  23900. /**
  23901. * Gets the linear velocity
  23902. * @returns linear velocity or null
  23903. */
  23904. getLinearVelocity(): Nullable<Vector3>;
  23905. /**
  23906. * Sets the linear velocity
  23907. * @param velocity linear velocity or null
  23908. */
  23909. setLinearVelocity(velocity: Nullable<Vector3>): void;
  23910. /**
  23911. * Gets the angular velocity
  23912. * @returns angular velocity or null
  23913. */
  23914. getAngularVelocity(): Nullable<Vector3>;
  23915. /**
  23916. * Sets the angular velocity
  23917. * @param velocity The velocity or null
  23918. */
  23919. setAngularVelocity(velocity: Nullable<Vector3>): void;
  23920. /**
  23921. * Execute a function with the physics plugin native code
  23922. * Provide a function the will have two variables - the world object and the physics body object
  23923. * @param func The function to execute with the physics plugin native code
  23924. */
  23925. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  23926. /**
  23927. * Register a function that will be executed before the physics world is stepping forward
  23928. * @param func The function to execute before the physics world is stepped forward
  23929. */
  23930. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23931. /**
  23932. * Unregister a function that will be executed before the physics world is stepping forward
  23933. * @param func The function to execute before the physics world is stepped forward
  23934. */
  23935. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23936. /**
  23937. * Register a function that will be executed after the physics step
  23938. * @param func The function to execute after physics step
  23939. */
  23940. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23941. /**
  23942. * Unregisters a function that will be executed after the physics step
  23943. * @param func The function to execute after physics step
  23944. */
  23945. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23946. /**
  23947. * register a function that will be executed when this impostor collides against a different body
  23948. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  23949. * @param func Callback that is executed on collision
  23950. */
  23951. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  23952. /**
  23953. * Unregisters the physics imposter on contact
  23954. * @param collideAgainst The physics object to collide against
  23955. * @param func Callback to execute on collision
  23956. */
  23957. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  23958. private _tmpQuat;
  23959. private _tmpQuat2;
  23960. /**
  23961. * Get the parent rotation
  23962. * @returns The parent rotation
  23963. */
  23964. getParentsRotation(): Quaternion;
  23965. /**
  23966. * this function is executed by the physics engine.
  23967. */
  23968. beforeStep: () => void;
  23969. /**
  23970. * this function is executed by the physics engine
  23971. */
  23972. afterStep: () => void;
  23973. /**
  23974. * Legacy collision detection event support
  23975. */
  23976. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  23977. /**
  23978. * event and body object due to cannon's event-based architecture.
  23979. */
  23980. onCollide: (e: {
  23981. body: any;
  23982. }) => void;
  23983. /**
  23984. * Apply a force
  23985. * @param force The force to apply
  23986. * @param contactPoint The contact point for the force
  23987. * @returns The physics imposter
  23988. */
  23989. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  23990. /**
  23991. * Apply an impulse
  23992. * @param force The impulse force
  23993. * @param contactPoint The contact point for the impulse force
  23994. * @returns The physics imposter
  23995. */
  23996. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  23997. /**
  23998. * A help function to create a joint
  23999. * @param otherImpostor A physics imposter used to create a joint
  24000. * @param jointType The type of joint
  24001. * @param jointData The data for the joint
  24002. * @returns The physics imposter
  24003. */
  24004. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  24005. /**
  24006. * Add a joint to this impostor with a different impostor
  24007. * @param otherImpostor A physics imposter used to add a joint
  24008. * @param joint The joint to add
  24009. * @returns The physics imposter
  24010. */
  24011. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  24012. /**
  24013. * Add an anchor to a cloth impostor
  24014. * @param otherImpostor rigid impostor to anchor to
  24015. * @param width ratio across width from 0 to 1
  24016. * @param height ratio up height from 0 to 1
  24017. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  24018. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  24019. * @returns impostor the soft imposter
  24020. */
  24021. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24022. /**
  24023. * Add a hook to a rope impostor
  24024. * @param otherImpostor rigid impostor to anchor to
  24025. * @param length ratio across rope from 0 to 1
  24026. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  24027. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  24028. * @returns impostor the rope imposter
  24029. */
  24030. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24031. /**
  24032. * Will keep this body still, in a sleep mode.
  24033. * @returns the physics imposter
  24034. */
  24035. sleep(): PhysicsImpostor;
  24036. /**
  24037. * Wake the body up.
  24038. * @returns The physics imposter
  24039. */
  24040. wakeUp(): PhysicsImpostor;
  24041. /**
  24042. * Clones the physics imposter
  24043. * @param newObject The physics imposter clones to this physics-enabled object
  24044. * @returns A nullable physics imposter
  24045. */
  24046. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  24047. /**
  24048. * Disposes the physics imposter
  24049. */
  24050. dispose(): void;
  24051. /**
  24052. * Sets the delta position
  24053. * @param position The delta position amount
  24054. */
  24055. setDeltaPosition(position: Vector3): void;
  24056. /**
  24057. * Sets the delta rotation
  24058. * @param rotation The delta rotation amount
  24059. */
  24060. setDeltaRotation(rotation: Quaternion): void;
  24061. /**
  24062. * Gets the box size of the physics imposter and stores the result in the input parameter
  24063. * @param result Stores the box size
  24064. * @returns The physics imposter
  24065. */
  24066. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  24067. /**
  24068. * Gets the radius of the physics imposter
  24069. * @returns Radius of the physics imposter
  24070. */
  24071. getRadius(): number;
  24072. /**
  24073. * Sync a bone with this impostor
  24074. * @param bone The bone to sync to the impostor.
  24075. * @param boneMesh The mesh that the bone is influencing.
  24076. * @param jointPivot The pivot of the joint / bone in local space.
  24077. * @param distToJoint Optional distance from the impostor to the joint.
  24078. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24079. */
  24080. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  24081. /**
  24082. * Sync impostor to a bone
  24083. * @param bone The bone that the impostor will be synced to.
  24084. * @param boneMesh The mesh that the bone is influencing.
  24085. * @param jointPivot The pivot of the joint / bone in local space.
  24086. * @param distToJoint Optional distance from the impostor to the joint.
  24087. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24088. * @param boneAxis Optional vector3 axis the bone is aligned with
  24089. */
  24090. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  24091. /**
  24092. * No-Imposter type
  24093. */
  24094. static NoImpostor: number;
  24095. /**
  24096. * Sphere-Imposter type
  24097. */
  24098. static SphereImpostor: number;
  24099. /**
  24100. * Box-Imposter type
  24101. */
  24102. static BoxImpostor: number;
  24103. /**
  24104. * Plane-Imposter type
  24105. */
  24106. static PlaneImpostor: number;
  24107. /**
  24108. * Mesh-imposter type
  24109. */
  24110. static MeshImpostor: number;
  24111. /**
  24112. * Capsule-Impostor type (Ammo.js plugin only)
  24113. */
  24114. static CapsuleImpostor: number;
  24115. /**
  24116. * Cylinder-Imposter type
  24117. */
  24118. static CylinderImpostor: number;
  24119. /**
  24120. * Particle-Imposter type
  24121. */
  24122. static ParticleImpostor: number;
  24123. /**
  24124. * Heightmap-Imposter type
  24125. */
  24126. static HeightmapImpostor: number;
  24127. /**
  24128. * ConvexHull-Impostor type (Ammo.js plugin only)
  24129. */
  24130. static ConvexHullImpostor: number;
  24131. /**
  24132. * Custom-Imposter type (Ammo.js plugin only)
  24133. */
  24134. static CustomImpostor: number;
  24135. /**
  24136. * Rope-Imposter type
  24137. */
  24138. static RopeImpostor: number;
  24139. /**
  24140. * Cloth-Imposter type
  24141. */
  24142. static ClothImpostor: number;
  24143. /**
  24144. * Softbody-Imposter type
  24145. */
  24146. static SoftbodyImpostor: number;
  24147. }
  24148. }
  24149. declare module BABYLON {
  24150. /**
  24151. * @hidden
  24152. **/
  24153. export class _CreationDataStorage {
  24154. closePath?: boolean;
  24155. closeArray?: boolean;
  24156. idx: number[];
  24157. dashSize: number;
  24158. gapSize: number;
  24159. path3D: Path3D;
  24160. pathArray: Vector3[][];
  24161. arc: number;
  24162. radius: number;
  24163. cap: number;
  24164. tessellation: number;
  24165. }
  24166. /**
  24167. * @hidden
  24168. **/
  24169. class _InstanceDataStorage {
  24170. visibleInstances: any;
  24171. batchCache: _InstancesBatch;
  24172. instancesBufferSize: number;
  24173. instancesBuffer: Nullable<Buffer>;
  24174. instancesData: Float32Array;
  24175. overridenInstanceCount: number;
  24176. isFrozen: boolean;
  24177. previousBatch: Nullable<_InstancesBatch>;
  24178. hardwareInstancedRendering: boolean;
  24179. sideOrientation: number;
  24180. manualUpdate: boolean;
  24181. }
  24182. /**
  24183. * @hidden
  24184. **/
  24185. export class _InstancesBatch {
  24186. mustReturn: boolean;
  24187. visibleInstances: Nullable<InstancedMesh[]>[];
  24188. renderSelf: boolean[];
  24189. hardwareInstancedRendering: boolean[];
  24190. }
  24191. /**
  24192. * Class used to represent renderable models
  24193. */
  24194. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  24195. /**
  24196. * Mesh side orientation : usually the external or front surface
  24197. */
  24198. static readonly FRONTSIDE: number;
  24199. /**
  24200. * Mesh side orientation : usually the internal or back surface
  24201. */
  24202. static readonly BACKSIDE: number;
  24203. /**
  24204. * Mesh side orientation : both internal and external or front and back surfaces
  24205. */
  24206. static readonly DOUBLESIDE: number;
  24207. /**
  24208. * Mesh side orientation : by default, `FRONTSIDE`
  24209. */
  24210. static readonly DEFAULTSIDE: number;
  24211. /**
  24212. * Mesh cap setting : no cap
  24213. */
  24214. static readonly NO_CAP: number;
  24215. /**
  24216. * Mesh cap setting : one cap at the beginning of the mesh
  24217. */
  24218. static readonly CAP_START: number;
  24219. /**
  24220. * Mesh cap setting : one cap at the end of the mesh
  24221. */
  24222. static readonly CAP_END: number;
  24223. /**
  24224. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  24225. */
  24226. static readonly CAP_ALL: number;
  24227. /**
  24228. * Mesh pattern setting : no flip or rotate
  24229. */
  24230. static readonly NO_FLIP: number;
  24231. /**
  24232. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  24233. */
  24234. static readonly FLIP_TILE: number;
  24235. /**
  24236. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  24237. */
  24238. static readonly ROTATE_TILE: number;
  24239. /**
  24240. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  24241. */
  24242. static readonly FLIP_ROW: number;
  24243. /**
  24244. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  24245. */
  24246. static readonly ROTATE_ROW: number;
  24247. /**
  24248. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  24249. */
  24250. static readonly FLIP_N_ROTATE_TILE: number;
  24251. /**
  24252. * Mesh pattern setting : rotate pattern and rotate
  24253. */
  24254. static readonly FLIP_N_ROTATE_ROW: number;
  24255. /**
  24256. * Mesh tile positioning : part tiles same on left/right or top/bottom
  24257. */
  24258. static readonly CENTER: number;
  24259. /**
  24260. * Mesh tile positioning : part tiles on left
  24261. */
  24262. static readonly LEFT: number;
  24263. /**
  24264. * Mesh tile positioning : part tiles on right
  24265. */
  24266. static readonly RIGHT: number;
  24267. /**
  24268. * Mesh tile positioning : part tiles on top
  24269. */
  24270. static readonly TOP: number;
  24271. /**
  24272. * Mesh tile positioning : part tiles on bottom
  24273. */
  24274. static readonly BOTTOM: number;
  24275. /**
  24276. * Gets the default side orientation.
  24277. * @param orientation the orientation to value to attempt to get
  24278. * @returns the default orientation
  24279. * @hidden
  24280. */
  24281. static _GetDefaultSideOrientation(orientation?: number): number;
  24282. private _internalMeshDataInfo;
  24283. /**
  24284. * An event triggered before rendering the mesh
  24285. */
  24286. get onBeforeRenderObservable(): Observable<Mesh>;
  24287. /**
  24288. * An event triggered before binding the mesh
  24289. */
  24290. get onBeforeBindObservable(): Observable<Mesh>;
  24291. /**
  24292. * An event triggered after rendering the mesh
  24293. */
  24294. get onAfterRenderObservable(): Observable<Mesh>;
  24295. /**
  24296. * An event triggered before drawing the mesh
  24297. */
  24298. get onBeforeDrawObservable(): Observable<Mesh>;
  24299. private _onBeforeDrawObserver;
  24300. /**
  24301. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  24302. */
  24303. set onBeforeDraw(callback: () => void);
  24304. get hasInstances(): boolean;
  24305. /**
  24306. * Gets the delay loading state of the mesh (when delay loading is turned on)
  24307. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  24308. */
  24309. delayLoadState: number;
  24310. /**
  24311. * Gets the list of instances created from this mesh
  24312. * it is not supposed to be modified manually.
  24313. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  24314. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24315. */
  24316. instances: InstancedMesh[];
  24317. /**
  24318. * Gets the file containing delay loading data for this mesh
  24319. */
  24320. delayLoadingFile: string;
  24321. /** @hidden */
  24322. _binaryInfo: any;
  24323. /**
  24324. * User defined function used to change how LOD level selection is done
  24325. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  24326. */
  24327. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  24328. /**
  24329. * Gets or sets the morph target manager
  24330. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  24331. */
  24332. get morphTargetManager(): Nullable<MorphTargetManager>;
  24333. set morphTargetManager(value: Nullable<MorphTargetManager>);
  24334. /** @hidden */
  24335. _creationDataStorage: Nullable<_CreationDataStorage>;
  24336. /** @hidden */
  24337. _geometry: Nullable<Geometry>;
  24338. /** @hidden */
  24339. _delayInfo: Array<string>;
  24340. /** @hidden */
  24341. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  24342. /** @hidden */
  24343. _instanceDataStorage: _InstanceDataStorage;
  24344. private _effectiveMaterial;
  24345. /** @hidden */
  24346. _shouldGenerateFlatShading: boolean;
  24347. /** @hidden */
  24348. _originalBuilderSideOrientation: number;
  24349. /**
  24350. * Use this property to change the original side orientation defined at construction time
  24351. */
  24352. overrideMaterialSideOrientation: Nullable<number>;
  24353. /**
  24354. * Gets the source mesh (the one used to clone this one from)
  24355. */
  24356. get source(): Nullable<Mesh>;
  24357. /**
  24358. * Gets or sets a boolean indicating that this mesh does not use index buffer
  24359. */
  24360. get isUnIndexed(): boolean;
  24361. set isUnIndexed(value: boolean);
  24362. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  24363. get worldMatrixInstancedBuffer(): Float32Array;
  24364. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  24365. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  24366. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  24367. /**
  24368. * @constructor
  24369. * @param name The value used by scene.getMeshByName() to do a lookup.
  24370. * @param scene The scene to add this mesh to.
  24371. * @param parent The parent of this mesh, if it has one
  24372. * @param source An optional Mesh from which geometry is shared, cloned.
  24373. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  24374. * When false, achieved by calling a clone(), also passing False.
  24375. * This will make creation of children, recursive.
  24376. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  24377. */
  24378. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  24379. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  24380. doNotInstantiate: boolean;
  24381. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  24382. /**
  24383. * Gets the class name
  24384. * @returns the string "Mesh".
  24385. */
  24386. getClassName(): string;
  24387. /** @hidden */
  24388. get _isMesh(): boolean;
  24389. /**
  24390. * Returns a description of this mesh
  24391. * @param fullDetails define if full details about this mesh must be used
  24392. * @returns a descriptive string representing this mesh
  24393. */
  24394. toString(fullDetails?: boolean): string;
  24395. /** @hidden */
  24396. _unBindEffect(): void;
  24397. /**
  24398. * Gets a boolean indicating if this mesh has LOD
  24399. */
  24400. get hasLODLevels(): boolean;
  24401. /**
  24402. * Gets the list of MeshLODLevel associated with the current mesh
  24403. * @returns an array of MeshLODLevel
  24404. */
  24405. getLODLevels(): MeshLODLevel[];
  24406. private _sortLODLevels;
  24407. /**
  24408. * Add a mesh as LOD level triggered at the given distance.
  24409. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24410. * @param distance The distance from the center of the object to show this level
  24411. * @param mesh The mesh to be added as LOD level (can be null)
  24412. * @return This mesh (for chaining)
  24413. */
  24414. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  24415. /**
  24416. * Returns the LOD level mesh at the passed distance or null if not found.
  24417. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24418. * @param distance The distance from the center of the object to show this level
  24419. * @returns a Mesh or `null`
  24420. */
  24421. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  24422. /**
  24423. * Remove a mesh from the LOD array
  24424. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24425. * @param mesh defines the mesh to be removed
  24426. * @return This mesh (for chaining)
  24427. */
  24428. removeLODLevel(mesh: Mesh): Mesh;
  24429. /**
  24430. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  24431. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24432. * @param camera defines the camera to use to compute distance
  24433. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  24434. * @return This mesh (for chaining)
  24435. */
  24436. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  24437. /**
  24438. * Gets the mesh internal Geometry object
  24439. */
  24440. get geometry(): Nullable<Geometry>;
  24441. /**
  24442. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  24443. * @returns the total number of vertices
  24444. */
  24445. getTotalVertices(): number;
  24446. /**
  24447. * Returns the content of an associated vertex buffer
  24448. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24449. * - VertexBuffer.PositionKind
  24450. * - VertexBuffer.UVKind
  24451. * - VertexBuffer.UV2Kind
  24452. * - VertexBuffer.UV3Kind
  24453. * - VertexBuffer.UV4Kind
  24454. * - VertexBuffer.UV5Kind
  24455. * - VertexBuffer.UV6Kind
  24456. * - VertexBuffer.ColorKind
  24457. * - VertexBuffer.MatricesIndicesKind
  24458. * - VertexBuffer.MatricesIndicesExtraKind
  24459. * - VertexBuffer.MatricesWeightsKind
  24460. * - VertexBuffer.MatricesWeightsExtraKind
  24461. * @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
  24462. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  24463. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  24464. */
  24465. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  24466. /**
  24467. * Returns the mesh VertexBuffer object from the requested `kind`
  24468. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24469. * - VertexBuffer.PositionKind
  24470. * - VertexBuffer.NormalKind
  24471. * - VertexBuffer.UVKind
  24472. * - VertexBuffer.UV2Kind
  24473. * - VertexBuffer.UV3Kind
  24474. * - VertexBuffer.UV4Kind
  24475. * - VertexBuffer.UV5Kind
  24476. * - VertexBuffer.UV6Kind
  24477. * - VertexBuffer.ColorKind
  24478. * - VertexBuffer.MatricesIndicesKind
  24479. * - VertexBuffer.MatricesIndicesExtraKind
  24480. * - VertexBuffer.MatricesWeightsKind
  24481. * - VertexBuffer.MatricesWeightsExtraKind
  24482. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  24483. */
  24484. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  24485. /**
  24486. * Tests if a specific vertex buffer is associated with this mesh
  24487. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24488. * - VertexBuffer.PositionKind
  24489. * - VertexBuffer.NormalKind
  24490. * - VertexBuffer.UVKind
  24491. * - VertexBuffer.UV2Kind
  24492. * - VertexBuffer.UV3Kind
  24493. * - VertexBuffer.UV4Kind
  24494. * - VertexBuffer.UV5Kind
  24495. * - VertexBuffer.UV6Kind
  24496. * - VertexBuffer.ColorKind
  24497. * - VertexBuffer.MatricesIndicesKind
  24498. * - VertexBuffer.MatricesIndicesExtraKind
  24499. * - VertexBuffer.MatricesWeightsKind
  24500. * - VertexBuffer.MatricesWeightsExtraKind
  24501. * @returns a boolean
  24502. */
  24503. isVerticesDataPresent(kind: string): boolean;
  24504. /**
  24505. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  24506. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24507. * - VertexBuffer.PositionKind
  24508. * - VertexBuffer.UVKind
  24509. * - VertexBuffer.UV2Kind
  24510. * - VertexBuffer.UV3Kind
  24511. * - VertexBuffer.UV4Kind
  24512. * - VertexBuffer.UV5Kind
  24513. * - VertexBuffer.UV6Kind
  24514. * - VertexBuffer.ColorKind
  24515. * - VertexBuffer.MatricesIndicesKind
  24516. * - VertexBuffer.MatricesIndicesExtraKind
  24517. * - VertexBuffer.MatricesWeightsKind
  24518. * - VertexBuffer.MatricesWeightsExtraKind
  24519. * @returns a boolean
  24520. */
  24521. isVertexBufferUpdatable(kind: string): boolean;
  24522. /**
  24523. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  24524. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24525. * - VertexBuffer.PositionKind
  24526. * - VertexBuffer.NormalKind
  24527. * - VertexBuffer.UVKind
  24528. * - VertexBuffer.UV2Kind
  24529. * - VertexBuffer.UV3Kind
  24530. * - VertexBuffer.UV4Kind
  24531. * - VertexBuffer.UV5Kind
  24532. * - VertexBuffer.UV6Kind
  24533. * - VertexBuffer.ColorKind
  24534. * - VertexBuffer.MatricesIndicesKind
  24535. * - VertexBuffer.MatricesIndicesExtraKind
  24536. * - VertexBuffer.MatricesWeightsKind
  24537. * - VertexBuffer.MatricesWeightsExtraKind
  24538. * @returns an array of strings
  24539. */
  24540. getVerticesDataKinds(): string[];
  24541. /**
  24542. * Returns a positive integer : the total number of indices in this mesh geometry.
  24543. * @returns the numner of indices or zero if the mesh has no geometry.
  24544. */
  24545. getTotalIndices(): number;
  24546. /**
  24547. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  24548. * @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.
  24549. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24550. * @returns the indices array or an empty array if the mesh has no geometry
  24551. */
  24552. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  24553. get isBlocked(): boolean;
  24554. /**
  24555. * Determine if the current mesh is ready to be rendered
  24556. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  24557. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  24558. * @returns true if all associated assets are ready (material, textures, shaders)
  24559. */
  24560. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  24561. /**
  24562. * 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.
  24563. */
  24564. get areNormalsFrozen(): boolean;
  24565. /**
  24566. * 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.
  24567. * @returns the current mesh
  24568. */
  24569. freezeNormals(): Mesh;
  24570. /**
  24571. * 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
  24572. * @returns the current mesh
  24573. */
  24574. unfreezeNormals(): Mesh;
  24575. /**
  24576. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  24577. */
  24578. set overridenInstanceCount(count: number);
  24579. /** @hidden */
  24580. _preActivate(): Mesh;
  24581. /** @hidden */
  24582. _preActivateForIntermediateRendering(renderId: number): Mesh;
  24583. /** @hidden */
  24584. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  24585. /**
  24586. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  24587. * This means the mesh underlying bounding box and sphere are recomputed.
  24588. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  24589. * @returns the current mesh
  24590. */
  24591. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  24592. /** @hidden */
  24593. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  24594. /**
  24595. * This function will subdivide the mesh into multiple submeshes
  24596. * @param count defines the expected number of submeshes
  24597. */
  24598. subdivide(count: number): void;
  24599. /**
  24600. * Copy a FloatArray into a specific associated vertex buffer
  24601. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24602. * - VertexBuffer.PositionKind
  24603. * - VertexBuffer.UVKind
  24604. * - VertexBuffer.UV2Kind
  24605. * - VertexBuffer.UV3Kind
  24606. * - VertexBuffer.UV4Kind
  24607. * - VertexBuffer.UV5Kind
  24608. * - VertexBuffer.UV6Kind
  24609. * - VertexBuffer.ColorKind
  24610. * - VertexBuffer.MatricesIndicesKind
  24611. * - VertexBuffer.MatricesIndicesExtraKind
  24612. * - VertexBuffer.MatricesWeightsKind
  24613. * - VertexBuffer.MatricesWeightsExtraKind
  24614. * @param data defines the data source
  24615. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24616. * @param stride defines the data stride size (can be null)
  24617. * @returns the current mesh
  24618. */
  24619. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  24620. /**
  24621. * Delete a vertex buffer associated with this mesh
  24622. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  24623. * - VertexBuffer.PositionKind
  24624. * - VertexBuffer.UVKind
  24625. * - VertexBuffer.UV2Kind
  24626. * - VertexBuffer.UV3Kind
  24627. * - VertexBuffer.UV4Kind
  24628. * - VertexBuffer.UV5Kind
  24629. * - VertexBuffer.UV6Kind
  24630. * - VertexBuffer.ColorKind
  24631. * - VertexBuffer.MatricesIndicesKind
  24632. * - VertexBuffer.MatricesIndicesExtraKind
  24633. * - VertexBuffer.MatricesWeightsKind
  24634. * - VertexBuffer.MatricesWeightsExtraKind
  24635. */
  24636. removeVerticesData(kind: string): void;
  24637. /**
  24638. * Flags an associated vertex buffer as updatable
  24639. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  24640. * - VertexBuffer.PositionKind
  24641. * - VertexBuffer.UVKind
  24642. * - VertexBuffer.UV2Kind
  24643. * - VertexBuffer.UV3Kind
  24644. * - VertexBuffer.UV4Kind
  24645. * - VertexBuffer.UV5Kind
  24646. * - VertexBuffer.UV6Kind
  24647. * - VertexBuffer.ColorKind
  24648. * - VertexBuffer.MatricesIndicesKind
  24649. * - VertexBuffer.MatricesIndicesExtraKind
  24650. * - VertexBuffer.MatricesWeightsKind
  24651. * - VertexBuffer.MatricesWeightsExtraKind
  24652. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24653. */
  24654. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  24655. /**
  24656. * Sets the mesh global Vertex Buffer
  24657. * @param buffer defines the buffer to use
  24658. * @returns the current mesh
  24659. */
  24660. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  24661. /**
  24662. * Update a specific associated vertex buffer
  24663. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24664. * - VertexBuffer.PositionKind
  24665. * - VertexBuffer.UVKind
  24666. * - VertexBuffer.UV2Kind
  24667. * - VertexBuffer.UV3Kind
  24668. * - VertexBuffer.UV4Kind
  24669. * - VertexBuffer.UV5Kind
  24670. * - VertexBuffer.UV6Kind
  24671. * - VertexBuffer.ColorKind
  24672. * - VertexBuffer.MatricesIndicesKind
  24673. * - VertexBuffer.MatricesIndicesExtraKind
  24674. * - VertexBuffer.MatricesWeightsKind
  24675. * - VertexBuffer.MatricesWeightsExtraKind
  24676. * @param data defines the data source
  24677. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  24678. * @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)
  24679. * @returns the current mesh
  24680. */
  24681. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  24682. /**
  24683. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  24684. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  24685. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  24686. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  24687. * @returns the current mesh
  24688. */
  24689. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  24690. /**
  24691. * Creates a un-shared specific occurence of the geometry for the mesh.
  24692. * @returns the current mesh
  24693. */
  24694. makeGeometryUnique(): Mesh;
  24695. /**
  24696. * Set the index buffer of this mesh
  24697. * @param indices defines the source data
  24698. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  24699. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  24700. * @returns the current mesh
  24701. */
  24702. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  24703. /**
  24704. * Update the current index buffer
  24705. * @param indices defines the source data
  24706. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  24707. * @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)
  24708. * @returns the current mesh
  24709. */
  24710. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  24711. /**
  24712. * Invert the geometry to move from a right handed system to a left handed one.
  24713. * @returns the current mesh
  24714. */
  24715. toLeftHanded(): Mesh;
  24716. /** @hidden */
  24717. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  24718. /** @hidden */
  24719. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  24720. /**
  24721. * Registers for this mesh a javascript function called just before the rendering process
  24722. * @param func defines the function to call before rendering this mesh
  24723. * @returns the current mesh
  24724. */
  24725. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24726. /**
  24727. * Disposes a previously registered javascript function called before the rendering
  24728. * @param func defines the function to remove
  24729. * @returns the current mesh
  24730. */
  24731. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24732. /**
  24733. * Registers for this mesh a javascript function called just after the rendering is complete
  24734. * @param func defines the function to call after rendering this mesh
  24735. * @returns the current mesh
  24736. */
  24737. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24738. /**
  24739. * Disposes a previously registered javascript function called after the rendering.
  24740. * @param func defines the function to remove
  24741. * @returns the current mesh
  24742. */
  24743. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24744. /** @hidden */
  24745. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  24746. /** @hidden */
  24747. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  24748. /** @hidden */
  24749. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  24750. /** @hidden */
  24751. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  24752. /** @hidden */
  24753. _rebuild(): void;
  24754. /** @hidden */
  24755. _freeze(): void;
  24756. /** @hidden */
  24757. _unFreeze(): void;
  24758. /**
  24759. * 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
  24760. * @param subMesh defines the subMesh to render
  24761. * @param enableAlphaMode defines if alpha mode can be changed
  24762. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  24763. * @returns the current mesh
  24764. */
  24765. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  24766. private _onBeforeDraw;
  24767. /**
  24768. * Renormalize the mesh and patch it up if there are no weights
  24769. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  24770. * However in the case of zero weights then we set just a single influence to 1.
  24771. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  24772. */
  24773. cleanMatrixWeights(): void;
  24774. private normalizeSkinFourWeights;
  24775. private normalizeSkinWeightsAndExtra;
  24776. /**
  24777. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  24778. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  24779. * the user know there was an issue with importing the mesh
  24780. * @returns a validation object with skinned, valid and report string
  24781. */
  24782. validateSkinning(): {
  24783. skinned: boolean;
  24784. valid: boolean;
  24785. report: string;
  24786. };
  24787. /** @hidden */
  24788. _checkDelayState(): Mesh;
  24789. private _queueLoad;
  24790. /**
  24791. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  24792. * A mesh is in the frustum if its bounding box intersects the frustum
  24793. * @param frustumPlanes defines the frustum to test
  24794. * @returns true if the mesh is in the frustum planes
  24795. */
  24796. isInFrustum(frustumPlanes: Plane[]): boolean;
  24797. /**
  24798. * Sets the mesh material by the material or multiMaterial `id` property
  24799. * @param id is a string identifying the material or the multiMaterial
  24800. * @returns the current mesh
  24801. */
  24802. setMaterialByID(id: string): Mesh;
  24803. /**
  24804. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  24805. * @returns an array of IAnimatable
  24806. */
  24807. getAnimatables(): IAnimatable[];
  24808. /**
  24809. * Modifies the mesh geometry according to the passed transformation matrix.
  24810. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  24811. * The mesh normals are modified using the same transformation.
  24812. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24813. * @param transform defines the transform matrix to use
  24814. * @see http://doc.babylonjs.com/resources/baking_transformations
  24815. * @returns the current mesh
  24816. */
  24817. bakeTransformIntoVertices(transform: Matrix): Mesh;
  24818. /**
  24819. * Modifies the mesh geometry according to its own current World Matrix.
  24820. * The mesh World Matrix is then reset.
  24821. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  24822. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24823. * @see http://doc.babylonjs.com/resources/baking_transformations
  24824. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  24825. * @returns the current mesh
  24826. */
  24827. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  24828. /** @hidden */
  24829. get _positions(): Nullable<Vector3[]>;
  24830. /** @hidden */
  24831. _resetPointsArrayCache(): Mesh;
  24832. /** @hidden */
  24833. _generatePointsArray(): boolean;
  24834. /**
  24835. * Returns a new Mesh object generated from the current mesh properties.
  24836. * This method must not get confused with createInstance()
  24837. * @param name is a string, the name given to the new mesh
  24838. * @param newParent can be any Node object (default `null`)
  24839. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  24840. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  24841. * @returns a new mesh
  24842. */
  24843. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  24844. /**
  24845. * Releases resources associated with this mesh.
  24846. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24847. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24848. */
  24849. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24850. /** @hidden */
  24851. _disposeInstanceSpecificData(): void;
  24852. /**
  24853. * Modifies the mesh geometry according to a displacement map.
  24854. * 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.
  24855. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  24856. * @param url is a string, the URL from the image file is to be downloaded.
  24857. * @param minHeight is the lower limit of the displacement.
  24858. * @param maxHeight is the upper limit of the displacement.
  24859. * @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.
  24860. * @param uvOffset is an optional vector2 used to offset UV.
  24861. * @param uvScale is an optional vector2 used to scale UV.
  24862. * @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.
  24863. * @returns the Mesh.
  24864. */
  24865. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  24866. /**
  24867. * Modifies the mesh geometry according to a displacementMap buffer.
  24868. * 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.
  24869. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  24870. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  24871. * @param heightMapWidth is the width of the buffer image.
  24872. * @param heightMapHeight is the height of the buffer image.
  24873. * @param minHeight is the lower limit of the displacement.
  24874. * @param maxHeight is the upper limit of the displacement.
  24875. * @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.
  24876. * @param uvOffset is an optional vector2 used to offset UV.
  24877. * @param uvScale is an optional vector2 used to scale UV.
  24878. * @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.
  24879. * @returns the Mesh.
  24880. */
  24881. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  24882. /**
  24883. * Modify the mesh to get a flat shading rendering.
  24884. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  24885. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  24886. * @returns current mesh
  24887. */
  24888. convertToFlatShadedMesh(): Mesh;
  24889. /**
  24890. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  24891. * In other words, more vertices, no more indices and a single bigger VBO.
  24892. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  24893. * @returns current mesh
  24894. */
  24895. convertToUnIndexedMesh(): Mesh;
  24896. /**
  24897. * Inverses facet orientations.
  24898. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24899. * @param flipNormals will also inverts the normals
  24900. * @returns current mesh
  24901. */
  24902. flipFaces(flipNormals?: boolean): Mesh;
  24903. /**
  24904. * Increase the number of facets and hence vertices in a mesh
  24905. * Vertex normals are interpolated from existing vertex normals
  24906. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24907. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  24908. */
  24909. increaseVertices(numberPerEdge: number): void;
  24910. /**
  24911. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  24912. * This will undo any application of covertToFlatShadedMesh
  24913. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24914. */
  24915. forceSharedVertices(): void;
  24916. /** @hidden */
  24917. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  24918. /** @hidden */
  24919. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  24920. /**
  24921. * Creates a new InstancedMesh object from the mesh model.
  24922. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24923. * @param name defines the name of the new instance
  24924. * @returns a new InstancedMesh
  24925. */
  24926. createInstance(name: string): InstancedMesh;
  24927. /**
  24928. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  24929. * After this call, all the mesh instances have the same submeshes than the current mesh.
  24930. * @returns the current mesh
  24931. */
  24932. synchronizeInstances(): Mesh;
  24933. /**
  24934. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  24935. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  24936. * This should be used together with the simplification to avoid disappearing triangles.
  24937. * @param successCallback an optional success callback to be called after the optimization finished.
  24938. * @returns the current mesh
  24939. */
  24940. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  24941. /**
  24942. * Serialize current mesh
  24943. * @param serializationObject defines the object which will receive the serialization data
  24944. */
  24945. serialize(serializationObject: any): void;
  24946. /** @hidden */
  24947. _syncGeometryWithMorphTargetManager(): void;
  24948. /** @hidden */
  24949. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  24950. /**
  24951. * Returns a new Mesh object parsed from the source provided.
  24952. * @param parsedMesh is the source
  24953. * @param scene defines the hosting scene
  24954. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  24955. * @returns a new Mesh
  24956. */
  24957. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  24958. /**
  24959. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  24960. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24961. * @param name defines the name of the mesh to create
  24962. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  24963. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  24964. * @param closePath creates a seam between the first and the last points of each path of the path array
  24965. * @param offset is taken in account only if the `pathArray` is containing a single path
  24966. * @param scene defines the hosting scene
  24967. * @param updatable defines if the mesh must be flagged as updatable
  24968. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24969. * @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)
  24970. * @returns a new Mesh
  24971. */
  24972. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24973. /**
  24974. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  24975. * @param name defines the name of the mesh to create
  24976. * @param radius sets the radius size (float) of the polygon (default 0.5)
  24977. * @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
  24978. * @param scene defines the hosting scene
  24979. * @param updatable defines if the mesh must be flagged as updatable
  24980. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24981. * @returns a new Mesh
  24982. */
  24983. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  24984. /**
  24985. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  24986. * @param name defines the name of the mesh to create
  24987. * @param size sets the size (float) of each box side (default 1)
  24988. * @param scene defines the hosting scene
  24989. * @param updatable defines if the mesh must be flagged as updatable
  24990. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24991. * @returns a new Mesh
  24992. */
  24993. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  24994. /**
  24995. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  24996. * @param name defines the name of the mesh to create
  24997. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  24998. * @param diameter sets the diameter size (float) of the sphere (default 1)
  24999. * @param scene defines the hosting scene
  25000. * @param updatable defines if the mesh must be flagged as updatable
  25001. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25002. * @returns a new Mesh
  25003. */
  25004. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25005. /**
  25006. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  25007. * @param name defines the name of the mesh to create
  25008. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25009. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25010. * @param scene defines the hosting scene
  25011. * @returns a new Mesh
  25012. */
  25013. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  25014. /**
  25015. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  25016. * @param name defines the name of the mesh to create
  25017. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  25018. * @param diameterTop set the top cap diameter (floats, default 1)
  25019. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  25020. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  25021. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  25022. * @param scene defines the hosting scene
  25023. * @param updatable defines if the mesh must be flagged as updatable
  25024. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25025. * @returns a new Mesh
  25026. */
  25027. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  25028. /**
  25029. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  25030. * @param name defines the name of the mesh to create
  25031. * @param diameter sets the diameter size (float) of the torus (default 1)
  25032. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  25033. * @param tessellation sets the number of torus sides (postive integer, default 16)
  25034. * @param scene defines the hosting scene
  25035. * @param updatable defines if the mesh must be flagged as updatable
  25036. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25037. * @returns a new Mesh
  25038. */
  25039. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25040. /**
  25041. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  25042. * @param name defines the name of the mesh to create
  25043. * @param radius sets the global radius size (float) of the torus knot (default 2)
  25044. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  25045. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  25046. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  25047. * @param p the number of windings on X axis (positive integers, default 2)
  25048. * @param q the number of windings on Y axis (positive integers, default 3)
  25049. * @param scene defines the hosting scene
  25050. * @param updatable defines if the mesh must be flagged as updatable
  25051. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25052. * @returns a new Mesh
  25053. */
  25054. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25055. /**
  25056. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  25057. * @param name defines the name of the mesh to create
  25058. * @param points is an array successive Vector3
  25059. * @param scene defines the hosting scene
  25060. * @param updatable defines if the mesh must be flagged as updatable
  25061. * @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).
  25062. * @returns a new Mesh
  25063. */
  25064. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  25065. /**
  25066. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  25067. * @param name defines the name of the mesh to create
  25068. * @param points is an array successive Vector3
  25069. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  25070. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  25071. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  25072. * @param scene defines the hosting scene
  25073. * @param updatable defines if the mesh must be flagged as updatable
  25074. * @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)
  25075. * @returns a new Mesh
  25076. */
  25077. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  25078. /**
  25079. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  25080. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  25081. * 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.
  25082. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25083. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  25084. * Remember you can only change the shape positions, not their number when updating a polygon.
  25085. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  25086. * @param name defines the name of the mesh to create
  25087. * @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
  25088. * @param scene defines the hosting scene
  25089. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25090. * @param updatable defines if the mesh must be flagged as updatable
  25091. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25092. * @param earcutInjection can be used to inject your own earcut reference
  25093. * @returns a new Mesh
  25094. */
  25095. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25096. /**
  25097. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  25098. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  25099. * @param name defines the name of the mesh to create
  25100. * @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
  25101. * @param depth defines the height of extrusion
  25102. * @param scene defines the hosting scene
  25103. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25104. * @param updatable defines if the mesh must be flagged as updatable
  25105. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25106. * @param earcutInjection can be used to inject your own earcut reference
  25107. * @returns a new Mesh
  25108. */
  25109. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25110. /**
  25111. * Creates an extruded shape mesh.
  25112. * 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
  25113. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25114. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25115. * @param name defines the name of the mesh to create
  25116. * @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
  25117. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25118. * @param scale is the value to scale the shape
  25119. * @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
  25120. * @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
  25121. * @param scene defines the hosting scene
  25122. * @param updatable defines if the mesh must be flagged as updatable
  25123. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25124. * @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)
  25125. * @returns a new Mesh
  25126. */
  25127. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25128. /**
  25129. * Creates an custom extruded shape mesh.
  25130. * The custom extrusion is a parametric shape.
  25131. * It has no predefined shape. Its final shape will depend on the input parameters.
  25132. * Please consider using the same method from the MeshBuilder class instead
  25133. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25134. * @param name defines the name of the mesh to create
  25135. * @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
  25136. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25137. * @param scaleFunction is a custom Javascript function called on each path point
  25138. * @param rotationFunction is a custom Javascript function called on each path point
  25139. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  25140. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  25141. * @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
  25142. * @param scene defines the hosting scene
  25143. * @param updatable defines if the mesh must be flagged as updatable
  25144. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25145. * @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)
  25146. * @returns a new Mesh
  25147. */
  25148. 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;
  25149. /**
  25150. * Creates lathe mesh.
  25151. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  25152. * Please consider using the same method from the MeshBuilder class instead
  25153. * @param name defines the name of the mesh to create
  25154. * @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
  25155. * @param radius is the radius value of the lathe
  25156. * @param tessellation is the side number of the lathe.
  25157. * @param scene defines the hosting scene
  25158. * @param updatable defines if the mesh must be flagged as updatable
  25159. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25160. * @returns a new Mesh
  25161. */
  25162. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25163. /**
  25164. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  25165. * @param name defines the name of the mesh to create
  25166. * @param size sets the size (float) of both sides of the plane at once (default 1)
  25167. * @param scene defines the hosting scene
  25168. * @param updatable defines if the mesh must be flagged as updatable
  25169. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25170. * @returns a new Mesh
  25171. */
  25172. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25173. /**
  25174. * Creates a ground mesh.
  25175. * Please consider using the same method from the MeshBuilder class instead
  25176. * @param name defines the name of the mesh to create
  25177. * @param width set the width of the ground
  25178. * @param height set the height of the ground
  25179. * @param subdivisions sets the number of subdivisions per side
  25180. * @param scene defines the hosting scene
  25181. * @param updatable defines if the mesh must be flagged as updatable
  25182. * @returns a new Mesh
  25183. */
  25184. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  25185. /**
  25186. * Creates a tiled ground mesh.
  25187. * Please consider using the same method from the MeshBuilder class instead
  25188. * @param name defines the name of the mesh to create
  25189. * @param xmin set the ground minimum X coordinate
  25190. * @param zmin set the ground minimum Y coordinate
  25191. * @param xmax set the ground maximum X coordinate
  25192. * @param zmax set the ground maximum Z coordinate
  25193. * @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
  25194. * @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
  25195. * @param scene defines the hosting scene
  25196. * @param updatable defines if the mesh must be flagged as updatable
  25197. * @returns a new Mesh
  25198. */
  25199. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  25200. w: number;
  25201. h: number;
  25202. }, precision: {
  25203. w: number;
  25204. h: number;
  25205. }, scene: Scene, updatable?: boolean): Mesh;
  25206. /**
  25207. * Creates a ground mesh from a height map.
  25208. * Please consider using the same method from the MeshBuilder class instead
  25209. * @see http://doc.babylonjs.com/babylon101/height_map
  25210. * @param name defines the name of the mesh to create
  25211. * @param url sets the URL of the height map image resource
  25212. * @param width set the ground width size
  25213. * @param height set the ground height size
  25214. * @param subdivisions sets the number of subdivision per side
  25215. * @param minHeight is the minimum altitude on the ground
  25216. * @param maxHeight is the maximum altitude on the ground
  25217. * @param scene defines the hosting scene
  25218. * @param updatable defines if the mesh must be flagged as updatable
  25219. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  25220. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  25221. * @returns a new Mesh
  25222. */
  25223. 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;
  25224. /**
  25225. * Creates a tube mesh.
  25226. * The tube is a parametric shape.
  25227. * It has no predefined shape. Its final shape will depend on the input parameters.
  25228. * Please consider using the same method from the MeshBuilder class instead
  25229. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25230. * @param name defines the name of the mesh to create
  25231. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  25232. * @param radius sets the tube radius size
  25233. * @param tessellation is the number of sides on the tubular surface
  25234. * @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
  25235. * @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
  25236. * @param scene defines the hosting scene
  25237. * @param updatable defines if the mesh must be flagged as updatable
  25238. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25239. * @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)
  25240. * @returns a new Mesh
  25241. */
  25242. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  25243. (i: number, distance: number): number;
  25244. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25245. /**
  25246. * Creates a polyhedron mesh.
  25247. * Please consider using the same method from the MeshBuilder class instead.
  25248. * * 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
  25249. * * The parameter `size` (positive float, default 1) sets the polygon size
  25250. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  25251. * * 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`
  25252. * * 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
  25253. * * 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)`)
  25254. * * 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
  25255. * * 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
  25256. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25257. * * 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
  25258. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25259. * @param name defines the name of the mesh to create
  25260. * @param options defines the options used to create the mesh
  25261. * @param scene defines the hosting scene
  25262. * @returns a new Mesh
  25263. */
  25264. static CreatePolyhedron(name: string, options: {
  25265. type?: number;
  25266. size?: number;
  25267. sizeX?: number;
  25268. sizeY?: number;
  25269. sizeZ?: number;
  25270. custom?: any;
  25271. faceUV?: Vector4[];
  25272. faceColors?: Color4[];
  25273. updatable?: boolean;
  25274. sideOrientation?: number;
  25275. }, scene: Scene): Mesh;
  25276. /**
  25277. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  25278. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  25279. * * 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`)
  25280. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  25281. * * 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
  25282. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25283. * * 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
  25284. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25285. * @param name defines the name of the mesh
  25286. * @param options defines the options used to create the mesh
  25287. * @param scene defines the hosting scene
  25288. * @returns a new Mesh
  25289. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  25290. */
  25291. static CreateIcoSphere(name: string, options: {
  25292. radius?: number;
  25293. flat?: boolean;
  25294. subdivisions?: number;
  25295. sideOrientation?: number;
  25296. updatable?: boolean;
  25297. }, scene: Scene): Mesh;
  25298. /**
  25299. * Creates a decal mesh.
  25300. * Please consider using the same method from the MeshBuilder class instead.
  25301. * A decal is a mesh usually applied as a model onto the surface of another mesh
  25302. * @param name defines the name of the mesh
  25303. * @param sourceMesh defines the mesh receiving the decal
  25304. * @param position sets the position of the decal in world coordinates
  25305. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  25306. * @param size sets the decal scaling
  25307. * @param angle sets the angle to rotate the decal
  25308. * @returns a new Mesh
  25309. */
  25310. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  25311. /**
  25312. * Prepare internal position array for software CPU skinning
  25313. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  25314. */
  25315. setPositionsForCPUSkinning(): Float32Array;
  25316. /**
  25317. * Prepare internal normal array for software CPU skinning
  25318. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  25319. */
  25320. setNormalsForCPUSkinning(): Float32Array;
  25321. /**
  25322. * Updates the vertex buffer by applying transformation from the bones
  25323. * @param skeleton defines the skeleton to apply to current mesh
  25324. * @returns the current mesh
  25325. */
  25326. applySkeleton(skeleton: Skeleton): Mesh;
  25327. /**
  25328. * 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
  25329. * @param meshes defines the list of meshes to scan
  25330. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  25331. */
  25332. static MinMax(meshes: AbstractMesh[]): {
  25333. min: Vector3;
  25334. max: Vector3;
  25335. };
  25336. /**
  25337. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  25338. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  25339. * @returns a vector3
  25340. */
  25341. static Center(meshesOrMinMaxVector: {
  25342. min: Vector3;
  25343. max: Vector3;
  25344. } | AbstractMesh[]): Vector3;
  25345. /**
  25346. * Merge the array of meshes into a single mesh for performance reasons.
  25347. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  25348. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  25349. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  25350. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  25351. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  25352. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  25353. * @returns a new mesh
  25354. */
  25355. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  25356. /** @hidden */
  25357. addInstance(instance: InstancedMesh): void;
  25358. /** @hidden */
  25359. removeInstance(instance: InstancedMesh): void;
  25360. }
  25361. }
  25362. declare module BABYLON {
  25363. /**
  25364. * This is the base class of all the camera used in the application.
  25365. * @see http://doc.babylonjs.com/features/cameras
  25366. */
  25367. export class Camera extends Node {
  25368. /** @hidden */
  25369. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  25370. /**
  25371. * This is the default projection mode used by the cameras.
  25372. * It helps recreating a feeling of perspective and better appreciate depth.
  25373. * This is the best way to simulate real life cameras.
  25374. */
  25375. static readonly PERSPECTIVE_CAMERA: number;
  25376. /**
  25377. * This helps creating camera with an orthographic mode.
  25378. * 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.
  25379. */
  25380. static readonly ORTHOGRAPHIC_CAMERA: number;
  25381. /**
  25382. * This is the default FOV mode for perspective cameras.
  25383. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  25384. */
  25385. static readonly FOVMODE_VERTICAL_FIXED: number;
  25386. /**
  25387. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  25388. */
  25389. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  25390. /**
  25391. * This specifies ther is no need for a camera rig.
  25392. * Basically only one eye is rendered corresponding to the camera.
  25393. */
  25394. static readonly RIG_MODE_NONE: number;
  25395. /**
  25396. * Simulates a camera Rig with one blue eye and one red eye.
  25397. * This can be use with 3d blue and red glasses.
  25398. */
  25399. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  25400. /**
  25401. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  25402. */
  25403. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  25404. /**
  25405. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  25406. */
  25407. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  25408. /**
  25409. * Defines that both eyes of the camera will be rendered over under each other.
  25410. */
  25411. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  25412. /**
  25413. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  25414. */
  25415. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  25416. /**
  25417. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  25418. */
  25419. static readonly RIG_MODE_VR: number;
  25420. /**
  25421. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  25422. */
  25423. static readonly RIG_MODE_WEBVR: number;
  25424. /**
  25425. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  25426. */
  25427. static readonly RIG_MODE_CUSTOM: number;
  25428. /**
  25429. * Defines if by default attaching controls should prevent the default javascript event to continue.
  25430. */
  25431. static ForceAttachControlToAlwaysPreventDefault: boolean;
  25432. /**
  25433. * Define the input manager associated with the camera.
  25434. */
  25435. inputs: CameraInputsManager<Camera>;
  25436. /** @hidden */
  25437. _position: Vector3;
  25438. /**
  25439. * Define the current local position of the camera in the scene
  25440. */
  25441. get position(): Vector3;
  25442. set position(newPosition: Vector3);
  25443. /**
  25444. * The vector the camera should consider as up.
  25445. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  25446. */
  25447. upVector: Vector3;
  25448. /**
  25449. * Define the current limit on the left side for an orthographic camera
  25450. * In scene unit
  25451. */
  25452. orthoLeft: Nullable<number>;
  25453. /**
  25454. * Define the current limit on the right side for an orthographic camera
  25455. * In scene unit
  25456. */
  25457. orthoRight: Nullable<number>;
  25458. /**
  25459. * Define the current limit on the bottom side for an orthographic camera
  25460. * In scene unit
  25461. */
  25462. orthoBottom: Nullable<number>;
  25463. /**
  25464. * Define the current limit on the top side for an orthographic camera
  25465. * In scene unit
  25466. */
  25467. orthoTop: Nullable<number>;
  25468. /**
  25469. * Field Of View is set in Radians. (default is 0.8)
  25470. */
  25471. fov: number;
  25472. /**
  25473. * Define the minimum distance the camera can see from.
  25474. * This is important to note that the depth buffer are not infinite and the closer it starts
  25475. * the more your scene might encounter depth fighting issue.
  25476. */
  25477. minZ: number;
  25478. /**
  25479. * Define the maximum distance the camera can see to.
  25480. * This is important to note that the depth buffer are not infinite and the further it end
  25481. * the more your scene might encounter depth fighting issue.
  25482. */
  25483. maxZ: number;
  25484. /**
  25485. * Define the default inertia of the camera.
  25486. * This helps giving a smooth feeling to the camera movement.
  25487. */
  25488. inertia: number;
  25489. /**
  25490. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  25491. */
  25492. mode: number;
  25493. /**
  25494. * Define whether the camera is intermediate.
  25495. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  25496. */
  25497. isIntermediate: boolean;
  25498. /**
  25499. * Define the viewport of the camera.
  25500. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  25501. */
  25502. viewport: Viewport;
  25503. /**
  25504. * Restricts the camera to viewing objects with the same layerMask.
  25505. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  25506. */
  25507. layerMask: number;
  25508. /**
  25509. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  25510. */
  25511. fovMode: number;
  25512. /**
  25513. * Rig mode of the camera.
  25514. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  25515. * This is normally controlled byt the camera themselves as internal use.
  25516. */
  25517. cameraRigMode: number;
  25518. /**
  25519. * Defines the distance between both "eyes" in case of a RIG
  25520. */
  25521. interaxialDistance: number;
  25522. /**
  25523. * Defines if stereoscopic rendering is done side by side or over under.
  25524. */
  25525. isStereoscopicSideBySide: boolean;
  25526. /**
  25527. * 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
  25528. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  25529. * else in the scene. (Eg. security camera)
  25530. *
  25531. * 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)
  25532. */
  25533. customRenderTargets: RenderTargetTexture[];
  25534. /**
  25535. * When set, the camera will render to this render target instead of the default canvas
  25536. *
  25537. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  25538. */
  25539. outputRenderTarget: Nullable<RenderTargetTexture>;
  25540. /**
  25541. * Observable triggered when the camera view matrix has changed.
  25542. */
  25543. onViewMatrixChangedObservable: Observable<Camera>;
  25544. /**
  25545. * Observable triggered when the camera Projection matrix has changed.
  25546. */
  25547. onProjectionMatrixChangedObservable: Observable<Camera>;
  25548. /**
  25549. * Observable triggered when the inputs have been processed.
  25550. */
  25551. onAfterCheckInputsObservable: Observable<Camera>;
  25552. /**
  25553. * Observable triggered when reset has been called and applied to the camera.
  25554. */
  25555. onRestoreStateObservable: Observable<Camera>;
  25556. /**
  25557. * Is this camera a part of a rig system?
  25558. */
  25559. isRigCamera: boolean;
  25560. /**
  25561. * If isRigCamera set to true this will be set with the parent camera.
  25562. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  25563. */
  25564. rigParent?: Camera;
  25565. /** @hidden */
  25566. _cameraRigParams: any;
  25567. /** @hidden */
  25568. _rigCameras: Camera[];
  25569. /** @hidden */
  25570. _rigPostProcess: Nullable<PostProcess>;
  25571. protected _webvrViewMatrix: Matrix;
  25572. /** @hidden */
  25573. _skipRendering: boolean;
  25574. /** @hidden */
  25575. _projectionMatrix: Matrix;
  25576. /** @hidden */
  25577. _postProcesses: Nullable<PostProcess>[];
  25578. /** @hidden */
  25579. _activeMeshes: SmartArray<AbstractMesh>;
  25580. protected _globalPosition: Vector3;
  25581. /** @hidden */
  25582. _computedViewMatrix: Matrix;
  25583. private _doNotComputeProjectionMatrix;
  25584. private _transformMatrix;
  25585. private _frustumPlanes;
  25586. private _refreshFrustumPlanes;
  25587. private _storedFov;
  25588. private _stateStored;
  25589. /**
  25590. * Instantiates a new camera object.
  25591. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  25592. * @see http://doc.babylonjs.com/features/cameras
  25593. * @param name Defines the name of the camera in the scene
  25594. * @param position Defines the position of the camera
  25595. * @param scene Defines the scene the camera belongs too
  25596. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  25597. */
  25598. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  25599. /**
  25600. * Store current camera state (fov, position, etc..)
  25601. * @returns the camera
  25602. */
  25603. storeState(): Camera;
  25604. /**
  25605. * Restores the camera state values if it has been stored. You must call storeState() first
  25606. */
  25607. protected _restoreStateValues(): boolean;
  25608. /**
  25609. * Restored camera state. You must call storeState() first.
  25610. * @returns true if restored and false otherwise
  25611. */
  25612. restoreState(): boolean;
  25613. /**
  25614. * Gets the class name of the camera.
  25615. * @returns the class name
  25616. */
  25617. getClassName(): string;
  25618. /** @hidden */
  25619. readonly _isCamera: boolean;
  25620. /**
  25621. * Gets a string representation of the camera useful for debug purpose.
  25622. * @param fullDetails Defines that a more verboe level of logging is required
  25623. * @returns the string representation
  25624. */
  25625. toString(fullDetails?: boolean): string;
  25626. /**
  25627. * Gets the current world space position of the camera.
  25628. */
  25629. get globalPosition(): Vector3;
  25630. /**
  25631. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  25632. * @returns the active meshe list
  25633. */
  25634. getActiveMeshes(): SmartArray<AbstractMesh>;
  25635. /**
  25636. * Check whether a mesh is part of the current active mesh list of the camera
  25637. * @param mesh Defines the mesh to check
  25638. * @returns true if active, false otherwise
  25639. */
  25640. isActiveMesh(mesh: Mesh): boolean;
  25641. /**
  25642. * Is this camera ready to be used/rendered
  25643. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  25644. * @return true if the camera is ready
  25645. */
  25646. isReady(completeCheck?: boolean): boolean;
  25647. /** @hidden */
  25648. _initCache(): void;
  25649. /** @hidden */
  25650. _updateCache(ignoreParentClass?: boolean): void;
  25651. /** @hidden */
  25652. _isSynchronized(): boolean;
  25653. /** @hidden */
  25654. _isSynchronizedViewMatrix(): boolean;
  25655. /** @hidden */
  25656. _isSynchronizedProjectionMatrix(): boolean;
  25657. /**
  25658. * Attach the input controls to a specific dom element to get the input from.
  25659. * @param element Defines the element the controls should be listened from
  25660. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  25661. */
  25662. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  25663. /**
  25664. * Detach the current controls from the specified dom element.
  25665. * @param element Defines the element to stop listening the inputs from
  25666. */
  25667. detachControl(element: HTMLElement): void;
  25668. /**
  25669. * Update the camera state according to the different inputs gathered during the frame.
  25670. */
  25671. update(): void;
  25672. /** @hidden */
  25673. _checkInputs(): void;
  25674. /** @hidden */
  25675. get rigCameras(): Camera[];
  25676. /**
  25677. * Gets the post process used by the rig cameras
  25678. */
  25679. get rigPostProcess(): Nullable<PostProcess>;
  25680. /**
  25681. * Internal, gets the first post proces.
  25682. * @returns the first post process to be run on this camera.
  25683. */
  25684. _getFirstPostProcess(): Nullable<PostProcess>;
  25685. private _cascadePostProcessesToRigCams;
  25686. /**
  25687. * Attach a post process to the camera.
  25688. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25689. * @param postProcess The post process to attach to the camera
  25690. * @param insertAt The position of the post process in case several of them are in use in the scene
  25691. * @returns the position the post process has been inserted at
  25692. */
  25693. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  25694. /**
  25695. * Detach a post process to the camera.
  25696. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25697. * @param postProcess The post process to detach from the camera
  25698. */
  25699. detachPostProcess(postProcess: PostProcess): void;
  25700. /**
  25701. * Gets the current world matrix of the camera
  25702. */
  25703. getWorldMatrix(): Matrix;
  25704. /** @hidden */
  25705. _getViewMatrix(): Matrix;
  25706. /**
  25707. * Gets the current view matrix of the camera.
  25708. * @param force forces the camera to recompute the matrix without looking at the cached state
  25709. * @returns the view matrix
  25710. */
  25711. getViewMatrix(force?: boolean): Matrix;
  25712. /**
  25713. * Freeze the projection matrix.
  25714. * It will prevent the cache check of the camera projection compute and can speed up perf
  25715. * if no parameter of the camera are meant to change
  25716. * @param projection Defines manually a projection if necessary
  25717. */
  25718. freezeProjectionMatrix(projection?: Matrix): void;
  25719. /**
  25720. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  25721. */
  25722. unfreezeProjectionMatrix(): void;
  25723. /**
  25724. * Gets the current projection matrix of the camera.
  25725. * @param force forces the camera to recompute the matrix without looking at the cached state
  25726. * @returns the projection matrix
  25727. */
  25728. getProjectionMatrix(force?: boolean): Matrix;
  25729. /**
  25730. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  25731. * @returns a Matrix
  25732. */
  25733. getTransformationMatrix(): Matrix;
  25734. private _updateFrustumPlanes;
  25735. /**
  25736. * Checks if a cullable object (mesh...) is in the camera frustum
  25737. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  25738. * @param target The object to check
  25739. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  25740. * @returns true if the object is in frustum otherwise false
  25741. */
  25742. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  25743. /**
  25744. * Checks if a cullable object (mesh...) is in the camera frustum
  25745. * Unlike isInFrustum this cheks the full bounding box
  25746. * @param target The object to check
  25747. * @returns true if the object is in frustum otherwise false
  25748. */
  25749. isCompletelyInFrustum(target: ICullable): boolean;
  25750. /**
  25751. * Gets a ray in the forward direction from the camera.
  25752. * @param length Defines the length of the ray to create
  25753. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  25754. * @param origin Defines the start point of the ray which defaults to the camera position
  25755. * @returns the forward ray
  25756. */
  25757. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  25758. /**
  25759. * Releases resources associated with this node.
  25760. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25761. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25762. */
  25763. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25764. /** @hidden */
  25765. _isLeftCamera: boolean;
  25766. /**
  25767. * Gets the left camera of a rig setup in case of Rigged Camera
  25768. */
  25769. get isLeftCamera(): boolean;
  25770. /** @hidden */
  25771. _isRightCamera: boolean;
  25772. /**
  25773. * Gets the right camera of a rig setup in case of Rigged Camera
  25774. */
  25775. get isRightCamera(): boolean;
  25776. /**
  25777. * Gets the left camera of a rig setup in case of Rigged Camera
  25778. */
  25779. get leftCamera(): Nullable<FreeCamera>;
  25780. /**
  25781. * Gets the right camera of a rig setup in case of Rigged Camera
  25782. */
  25783. get rightCamera(): Nullable<FreeCamera>;
  25784. /**
  25785. * Gets the left camera target of a rig setup in case of Rigged Camera
  25786. * @returns the target position
  25787. */
  25788. getLeftTarget(): Nullable<Vector3>;
  25789. /**
  25790. * Gets the right camera target of a rig setup in case of Rigged Camera
  25791. * @returns the target position
  25792. */
  25793. getRightTarget(): Nullable<Vector3>;
  25794. /**
  25795. * @hidden
  25796. */
  25797. setCameraRigMode(mode: number, rigParams: any): void;
  25798. /** @hidden */
  25799. static _setStereoscopicRigMode(camera: Camera): void;
  25800. /** @hidden */
  25801. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  25802. /** @hidden */
  25803. static _setVRRigMode(camera: Camera, rigParams: any): void;
  25804. /** @hidden */
  25805. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  25806. /** @hidden */
  25807. _getVRProjectionMatrix(): Matrix;
  25808. protected _updateCameraRotationMatrix(): void;
  25809. protected _updateWebVRCameraRotationMatrix(): void;
  25810. /**
  25811. * This function MUST be overwritten by the different WebVR cameras available.
  25812. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25813. * @hidden
  25814. */
  25815. _getWebVRProjectionMatrix(): Matrix;
  25816. /**
  25817. * This function MUST be overwritten by the different WebVR cameras available.
  25818. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25819. * @hidden
  25820. */
  25821. _getWebVRViewMatrix(): Matrix;
  25822. /** @hidden */
  25823. setCameraRigParameter(name: string, value: any): void;
  25824. /**
  25825. * needs to be overridden by children so sub has required properties to be copied
  25826. * @hidden
  25827. */
  25828. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  25829. /**
  25830. * May need to be overridden by children
  25831. * @hidden
  25832. */
  25833. _updateRigCameras(): void;
  25834. /** @hidden */
  25835. _setupInputs(): void;
  25836. /**
  25837. * Serialiaze the camera setup to a json represention
  25838. * @returns the JSON representation
  25839. */
  25840. serialize(): any;
  25841. /**
  25842. * Clones the current camera.
  25843. * @param name The cloned camera name
  25844. * @returns the cloned camera
  25845. */
  25846. clone(name: string): Camera;
  25847. /**
  25848. * Gets the direction of the camera relative to a given local axis.
  25849. * @param localAxis Defines the reference axis to provide a relative direction.
  25850. * @return the direction
  25851. */
  25852. getDirection(localAxis: Vector3): Vector3;
  25853. /**
  25854. * Returns the current camera absolute rotation
  25855. */
  25856. get absoluteRotation(): Quaternion;
  25857. /**
  25858. * Gets the direction of the camera relative to a given local axis into a passed vector.
  25859. * @param localAxis Defines the reference axis to provide a relative direction.
  25860. * @param result Defines the vector to store the result in
  25861. */
  25862. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  25863. /**
  25864. * Gets a camera constructor for a given camera type
  25865. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  25866. * @param name The name of the camera the result will be able to instantiate
  25867. * @param scene The scene the result will construct the camera in
  25868. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  25869. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  25870. * @returns a factory method to construc the camera
  25871. */
  25872. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  25873. /**
  25874. * Compute the world matrix of the camera.
  25875. * @returns the camera world matrix
  25876. */
  25877. computeWorldMatrix(): Matrix;
  25878. /**
  25879. * Parse a JSON and creates the camera from the parsed information
  25880. * @param parsedCamera The JSON to parse
  25881. * @param scene The scene to instantiate the camera in
  25882. * @returns the newly constructed camera
  25883. */
  25884. static Parse(parsedCamera: any, scene: Scene): Camera;
  25885. }
  25886. }
  25887. declare module BABYLON {
  25888. /**
  25889. * Class containing static functions to help procedurally build meshes
  25890. */
  25891. export class DiscBuilder {
  25892. /**
  25893. * Creates a plane polygonal mesh. By default, this is a disc
  25894. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  25895. * * 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
  25896. * * 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
  25897. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  25898. * * 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
  25899. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25900. * @param name defines the name of the mesh
  25901. * @param options defines the options used to create the mesh
  25902. * @param scene defines the hosting scene
  25903. * @returns the plane polygonal mesh
  25904. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  25905. */
  25906. static CreateDisc(name: string, options: {
  25907. radius?: number;
  25908. tessellation?: number;
  25909. arc?: number;
  25910. updatable?: boolean;
  25911. sideOrientation?: number;
  25912. frontUVs?: Vector4;
  25913. backUVs?: Vector4;
  25914. }, scene?: Nullable<Scene>): Mesh;
  25915. }
  25916. }
  25917. declare module BABYLON {
  25918. /**
  25919. * This represents all the required information to add a fresnel effect on a material:
  25920. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  25921. */
  25922. export class FresnelParameters {
  25923. private _isEnabled;
  25924. /**
  25925. * Define if the fresnel effect is enable or not.
  25926. */
  25927. get isEnabled(): boolean;
  25928. set isEnabled(value: boolean);
  25929. /**
  25930. * Define the color used on edges (grazing angle)
  25931. */
  25932. leftColor: Color3;
  25933. /**
  25934. * Define the color used on center
  25935. */
  25936. rightColor: Color3;
  25937. /**
  25938. * Define bias applied to computed fresnel term
  25939. */
  25940. bias: number;
  25941. /**
  25942. * Defined the power exponent applied to fresnel term
  25943. */
  25944. power: number;
  25945. /**
  25946. * Clones the current fresnel and its valuues
  25947. * @returns a clone fresnel configuration
  25948. */
  25949. clone(): FresnelParameters;
  25950. /**
  25951. * Serializes the current fresnel parameters to a JSON representation.
  25952. * @return the JSON serialization
  25953. */
  25954. serialize(): any;
  25955. /**
  25956. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  25957. * @param parsedFresnelParameters Define the JSON representation
  25958. * @returns the parsed parameters
  25959. */
  25960. static Parse(parsedFresnelParameters: any): FresnelParameters;
  25961. }
  25962. }
  25963. declare module BABYLON {
  25964. /**
  25965. * Base class of materials working in push mode in babylon JS
  25966. * @hidden
  25967. */
  25968. export class PushMaterial extends Material {
  25969. protected _activeEffect: Effect;
  25970. protected _normalMatrix: Matrix;
  25971. /**
  25972. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  25973. * This means that the material can keep using a previous shader while a new one is being compiled.
  25974. * This is mostly used when shader parallel compilation is supported (true by default)
  25975. */
  25976. allowShaderHotSwapping: boolean;
  25977. constructor(name: string, scene: Scene);
  25978. getEffect(): Effect;
  25979. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  25980. /**
  25981. * Binds the given world matrix to the active effect
  25982. *
  25983. * @param world the matrix to bind
  25984. */
  25985. bindOnlyWorldMatrix(world: Matrix): void;
  25986. /**
  25987. * Binds the given normal matrix to the active effect
  25988. *
  25989. * @param normalMatrix the matrix to bind
  25990. */
  25991. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  25992. bind(world: Matrix, mesh?: Mesh): void;
  25993. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  25994. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  25995. }
  25996. }
  25997. declare module BABYLON {
  25998. /**
  25999. * This groups all the flags used to control the materials channel.
  26000. */
  26001. export class MaterialFlags {
  26002. private static _DiffuseTextureEnabled;
  26003. /**
  26004. * Are diffuse textures enabled in the application.
  26005. */
  26006. static get DiffuseTextureEnabled(): boolean;
  26007. static set DiffuseTextureEnabled(value: boolean);
  26008. private static _AmbientTextureEnabled;
  26009. /**
  26010. * Are ambient textures enabled in the application.
  26011. */
  26012. static get AmbientTextureEnabled(): boolean;
  26013. static set AmbientTextureEnabled(value: boolean);
  26014. private static _OpacityTextureEnabled;
  26015. /**
  26016. * Are opacity textures enabled in the application.
  26017. */
  26018. static get OpacityTextureEnabled(): boolean;
  26019. static set OpacityTextureEnabled(value: boolean);
  26020. private static _ReflectionTextureEnabled;
  26021. /**
  26022. * Are reflection textures enabled in the application.
  26023. */
  26024. static get ReflectionTextureEnabled(): boolean;
  26025. static set ReflectionTextureEnabled(value: boolean);
  26026. private static _EmissiveTextureEnabled;
  26027. /**
  26028. * Are emissive textures enabled in the application.
  26029. */
  26030. static get EmissiveTextureEnabled(): boolean;
  26031. static set EmissiveTextureEnabled(value: boolean);
  26032. private static _SpecularTextureEnabled;
  26033. /**
  26034. * Are specular textures enabled in the application.
  26035. */
  26036. static get SpecularTextureEnabled(): boolean;
  26037. static set SpecularTextureEnabled(value: boolean);
  26038. private static _BumpTextureEnabled;
  26039. /**
  26040. * Are bump textures enabled in the application.
  26041. */
  26042. static get BumpTextureEnabled(): boolean;
  26043. static set BumpTextureEnabled(value: boolean);
  26044. private static _LightmapTextureEnabled;
  26045. /**
  26046. * Are lightmap textures enabled in the application.
  26047. */
  26048. static get LightmapTextureEnabled(): boolean;
  26049. static set LightmapTextureEnabled(value: boolean);
  26050. private static _RefractionTextureEnabled;
  26051. /**
  26052. * Are refraction textures enabled in the application.
  26053. */
  26054. static get RefractionTextureEnabled(): boolean;
  26055. static set RefractionTextureEnabled(value: boolean);
  26056. private static _ColorGradingTextureEnabled;
  26057. /**
  26058. * Are color grading textures enabled in the application.
  26059. */
  26060. static get ColorGradingTextureEnabled(): boolean;
  26061. static set ColorGradingTextureEnabled(value: boolean);
  26062. private static _FresnelEnabled;
  26063. /**
  26064. * Are fresnels enabled in the application.
  26065. */
  26066. static get FresnelEnabled(): boolean;
  26067. static set FresnelEnabled(value: boolean);
  26068. private static _ClearCoatTextureEnabled;
  26069. /**
  26070. * Are clear coat textures enabled in the application.
  26071. */
  26072. static get ClearCoatTextureEnabled(): boolean;
  26073. static set ClearCoatTextureEnabled(value: boolean);
  26074. private static _ClearCoatBumpTextureEnabled;
  26075. /**
  26076. * Are clear coat bump textures enabled in the application.
  26077. */
  26078. static get ClearCoatBumpTextureEnabled(): boolean;
  26079. static set ClearCoatBumpTextureEnabled(value: boolean);
  26080. private static _ClearCoatTintTextureEnabled;
  26081. /**
  26082. * Are clear coat tint textures enabled in the application.
  26083. */
  26084. static get ClearCoatTintTextureEnabled(): boolean;
  26085. static set ClearCoatTintTextureEnabled(value: boolean);
  26086. private static _SheenTextureEnabled;
  26087. /**
  26088. * Are sheen textures enabled in the application.
  26089. */
  26090. static get SheenTextureEnabled(): boolean;
  26091. static set SheenTextureEnabled(value: boolean);
  26092. private static _AnisotropicTextureEnabled;
  26093. /**
  26094. * Are anisotropic textures enabled in the application.
  26095. */
  26096. static get AnisotropicTextureEnabled(): boolean;
  26097. static set AnisotropicTextureEnabled(value: boolean);
  26098. private static _ThicknessTextureEnabled;
  26099. /**
  26100. * Are thickness textures enabled in the application.
  26101. */
  26102. static get ThicknessTextureEnabled(): boolean;
  26103. static set ThicknessTextureEnabled(value: boolean);
  26104. }
  26105. }
  26106. declare module BABYLON {
  26107. /** @hidden */
  26108. export var defaultFragmentDeclaration: {
  26109. name: string;
  26110. shader: string;
  26111. };
  26112. }
  26113. declare module BABYLON {
  26114. /** @hidden */
  26115. export var defaultUboDeclaration: {
  26116. name: string;
  26117. shader: string;
  26118. };
  26119. }
  26120. declare module BABYLON {
  26121. /** @hidden */
  26122. export var lightFragmentDeclaration: {
  26123. name: string;
  26124. shader: string;
  26125. };
  26126. }
  26127. declare module BABYLON {
  26128. /** @hidden */
  26129. export var lightUboDeclaration: {
  26130. name: string;
  26131. shader: string;
  26132. };
  26133. }
  26134. declare module BABYLON {
  26135. /** @hidden */
  26136. export var lightsFragmentFunctions: {
  26137. name: string;
  26138. shader: string;
  26139. };
  26140. }
  26141. declare module BABYLON {
  26142. /** @hidden */
  26143. export var shadowsFragmentFunctions: {
  26144. name: string;
  26145. shader: string;
  26146. };
  26147. }
  26148. declare module BABYLON {
  26149. /** @hidden */
  26150. export var fresnelFunction: {
  26151. name: string;
  26152. shader: string;
  26153. };
  26154. }
  26155. declare module BABYLON {
  26156. /** @hidden */
  26157. export var reflectionFunction: {
  26158. name: string;
  26159. shader: string;
  26160. };
  26161. }
  26162. declare module BABYLON {
  26163. /** @hidden */
  26164. export var bumpFragmentFunctions: {
  26165. name: string;
  26166. shader: string;
  26167. };
  26168. }
  26169. declare module BABYLON {
  26170. /** @hidden */
  26171. export var logDepthDeclaration: {
  26172. name: string;
  26173. shader: string;
  26174. };
  26175. }
  26176. declare module BABYLON {
  26177. /** @hidden */
  26178. export var bumpFragment: {
  26179. name: string;
  26180. shader: string;
  26181. };
  26182. }
  26183. declare module BABYLON {
  26184. /** @hidden */
  26185. export var depthPrePass: {
  26186. name: string;
  26187. shader: string;
  26188. };
  26189. }
  26190. declare module BABYLON {
  26191. /** @hidden */
  26192. export var lightFragment: {
  26193. name: string;
  26194. shader: string;
  26195. };
  26196. }
  26197. declare module BABYLON {
  26198. /** @hidden */
  26199. export var logDepthFragment: {
  26200. name: string;
  26201. shader: string;
  26202. };
  26203. }
  26204. declare module BABYLON {
  26205. /** @hidden */
  26206. export var defaultPixelShader: {
  26207. name: string;
  26208. shader: string;
  26209. };
  26210. }
  26211. declare module BABYLON {
  26212. /** @hidden */
  26213. export var defaultVertexDeclaration: {
  26214. name: string;
  26215. shader: string;
  26216. };
  26217. }
  26218. declare module BABYLON {
  26219. /** @hidden */
  26220. export var bumpVertexDeclaration: {
  26221. name: string;
  26222. shader: string;
  26223. };
  26224. }
  26225. declare module BABYLON {
  26226. /** @hidden */
  26227. export var bumpVertex: {
  26228. name: string;
  26229. shader: string;
  26230. };
  26231. }
  26232. declare module BABYLON {
  26233. /** @hidden */
  26234. export var fogVertex: {
  26235. name: string;
  26236. shader: string;
  26237. };
  26238. }
  26239. declare module BABYLON {
  26240. /** @hidden */
  26241. export var shadowsVertex: {
  26242. name: string;
  26243. shader: string;
  26244. };
  26245. }
  26246. declare module BABYLON {
  26247. /** @hidden */
  26248. export var pointCloudVertex: {
  26249. name: string;
  26250. shader: string;
  26251. };
  26252. }
  26253. declare module BABYLON {
  26254. /** @hidden */
  26255. export var logDepthVertex: {
  26256. name: string;
  26257. shader: string;
  26258. };
  26259. }
  26260. declare module BABYLON {
  26261. /** @hidden */
  26262. export var defaultVertexShader: {
  26263. name: string;
  26264. shader: string;
  26265. };
  26266. }
  26267. declare module BABYLON {
  26268. /** @hidden */
  26269. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  26270. MAINUV1: boolean;
  26271. MAINUV2: boolean;
  26272. DIFFUSE: boolean;
  26273. DIFFUSEDIRECTUV: number;
  26274. AMBIENT: boolean;
  26275. AMBIENTDIRECTUV: number;
  26276. OPACITY: boolean;
  26277. OPACITYDIRECTUV: number;
  26278. OPACITYRGB: boolean;
  26279. REFLECTION: boolean;
  26280. EMISSIVE: boolean;
  26281. EMISSIVEDIRECTUV: number;
  26282. SPECULAR: boolean;
  26283. SPECULARDIRECTUV: number;
  26284. BUMP: boolean;
  26285. BUMPDIRECTUV: number;
  26286. PARALLAX: boolean;
  26287. PARALLAXOCCLUSION: boolean;
  26288. SPECULAROVERALPHA: boolean;
  26289. CLIPPLANE: boolean;
  26290. CLIPPLANE2: boolean;
  26291. CLIPPLANE3: boolean;
  26292. CLIPPLANE4: boolean;
  26293. CLIPPLANE5: boolean;
  26294. CLIPPLANE6: boolean;
  26295. ALPHATEST: boolean;
  26296. DEPTHPREPASS: boolean;
  26297. ALPHAFROMDIFFUSE: boolean;
  26298. POINTSIZE: boolean;
  26299. FOG: boolean;
  26300. SPECULARTERM: boolean;
  26301. DIFFUSEFRESNEL: boolean;
  26302. OPACITYFRESNEL: boolean;
  26303. REFLECTIONFRESNEL: boolean;
  26304. REFRACTIONFRESNEL: boolean;
  26305. EMISSIVEFRESNEL: boolean;
  26306. FRESNEL: boolean;
  26307. NORMAL: boolean;
  26308. UV1: boolean;
  26309. UV2: boolean;
  26310. VERTEXCOLOR: boolean;
  26311. VERTEXALPHA: boolean;
  26312. NUM_BONE_INFLUENCERS: number;
  26313. BonesPerMesh: number;
  26314. BONETEXTURE: boolean;
  26315. INSTANCES: boolean;
  26316. GLOSSINESS: boolean;
  26317. ROUGHNESS: boolean;
  26318. EMISSIVEASILLUMINATION: boolean;
  26319. LINKEMISSIVEWITHDIFFUSE: boolean;
  26320. REFLECTIONFRESNELFROMSPECULAR: boolean;
  26321. LIGHTMAP: boolean;
  26322. LIGHTMAPDIRECTUV: number;
  26323. OBJECTSPACE_NORMALMAP: boolean;
  26324. USELIGHTMAPASSHADOWMAP: boolean;
  26325. REFLECTIONMAP_3D: boolean;
  26326. REFLECTIONMAP_SPHERICAL: boolean;
  26327. REFLECTIONMAP_PLANAR: boolean;
  26328. REFLECTIONMAP_CUBIC: boolean;
  26329. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  26330. REFLECTIONMAP_PROJECTION: boolean;
  26331. REFLECTIONMAP_SKYBOX: boolean;
  26332. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  26333. REFLECTIONMAP_EXPLICIT: boolean;
  26334. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  26335. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  26336. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  26337. INVERTCUBICMAP: boolean;
  26338. LOGARITHMICDEPTH: boolean;
  26339. REFRACTION: boolean;
  26340. REFRACTIONMAP_3D: boolean;
  26341. REFLECTIONOVERALPHA: boolean;
  26342. TWOSIDEDLIGHTING: boolean;
  26343. SHADOWFLOAT: boolean;
  26344. MORPHTARGETS: boolean;
  26345. MORPHTARGETS_NORMAL: boolean;
  26346. MORPHTARGETS_TANGENT: boolean;
  26347. MORPHTARGETS_UV: boolean;
  26348. NUM_MORPH_INFLUENCERS: number;
  26349. NONUNIFORMSCALING: boolean;
  26350. PREMULTIPLYALPHA: boolean;
  26351. IMAGEPROCESSING: boolean;
  26352. VIGNETTE: boolean;
  26353. VIGNETTEBLENDMODEMULTIPLY: boolean;
  26354. VIGNETTEBLENDMODEOPAQUE: boolean;
  26355. TONEMAPPING: boolean;
  26356. TONEMAPPING_ACES: boolean;
  26357. CONTRAST: boolean;
  26358. COLORCURVES: boolean;
  26359. COLORGRADING: boolean;
  26360. COLORGRADING3D: boolean;
  26361. SAMPLER3DGREENDEPTH: boolean;
  26362. SAMPLER3DBGRMAP: boolean;
  26363. IMAGEPROCESSINGPOSTPROCESS: boolean;
  26364. MULTIVIEW: boolean;
  26365. /**
  26366. * If the reflection texture on this material is in linear color space
  26367. * @hidden
  26368. */
  26369. IS_REFLECTION_LINEAR: boolean;
  26370. /**
  26371. * If the refraction texture on this material is in linear color space
  26372. * @hidden
  26373. */
  26374. IS_REFRACTION_LINEAR: boolean;
  26375. EXPOSURE: boolean;
  26376. constructor();
  26377. setReflectionMode(modeToEnable: string): void;
  26378. }
  26379. /**
  26380. * This is the default material used in Babylon. It is the best trade off between quality
  26381. * and performances.
  26382. * @see http://doc.babylonjs.com/babylon101/materials
  26383. */
  26384. export class StandardMaterial extends PushMaterial {
  26385. private _diffuseTexture;
  26386. /**
  26387. * The basic texture of the material as viewed under a light.
  26388. */
  26389. diffuseTexture: Nullable<BaseTexture>;
  26390. private _ambientTexture;
  26391. /**
  26392. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  26393. */
  26394. ambientTexture: Nullable<BaseTexture>;
  26395. private _opacityTexture;
  26396. /**
  26397. * Define the transparency of the material from a texture.
  26398. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  26399. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  26400. */
  26401. opacityTexture: Nullable<BaseTexture>;
  26402. private _reflectionTexture;
  26403. /**
  26404. * Define the texture used to display the reflection.
  26405. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26406. */
  26407. reflectionTexture: Nullable<BaseTexture>;
  26408. private _emissiveTexture;
  26409. /**
  26410. * Define texture of the material as if self lit.
  26411. * This will be mixed in the final result even in the absence of light.
  26412. */
  26413. emissiveTexture: Nullable<BaseTexture>;
  26414. private _specularTexture;
  26415. /**
  26416. * Define how the color and intensity of the highlight given by the light in the material.
  26417. */
  26418. specularTexture: Nullable<BaseTexture>;
  26419. private _bumpTexture;
  26420. /**
  26421. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  26422. * 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.
  26423. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  26424. */
  26425. bumpTexture: Nullable<BaseTexture>;
  26426. private _lightmapTexture;
  26427. /**
  26428. * Complex lighting can be computationally expensive to compute at runtime.
  26429. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  26430. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  26431. */
  26432. lightmapTexture: Nullable<BaseTexture>;
  26433. private _refractionTexture;
  26434. /**
  26435. * Define the texture used to display the refraction.
  26436. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26437. */
  26438. refractionTexture: Nullable<BaseTexture>;
  26439. /**
  26440. * The color of the material lit by the environmental background lighting.
  26441. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  26442. */
  26443. ambientColor: Color3;
  26444. /**
  26445. * The basic color of the material as viewed under a light.
  26446. */
  26447. diffuseColor: Color3;
  26448. /**
  26449. * Define how the color and intensity of the highlight given by the light in the material.
  26450. */
  26451. specularColor: Color3;
  26452. /**
  26453. * Define the color of the material as if self lit.
  26454. * This will be mixed in the final result even in the absence of light.
  26455. */
  26456. emissiveColor: Color3;
  26457. /**
  26458. * Defines how sharp are the highlights in the material.
  26459. * The bigger the value the sharper giving a more glossy feeling to the result.
  26460. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  26461. */
  26462. specularPower: number;
  26463. private _useAlphaFromDiffuseTexture;
  26464. /**
  26465. * Does the transparency come from the diffuse texture alpha channel.
  26466. */
  26467. useAlphaFromDiffuseTexture: boolean;
  26468. private _useEmissiveAsIllumination;
  26469. /**
  26470. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  26471. */
  26472. useEmissiveAsIllumination: boolean;
  26473. private _linkEmissiveWithDiffuse;
  26474. /**
  26475. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  26476. * the emissive level when the final color is close to one.
  26477. */
  26478. linkEmissiveWithDiffuse: boolean;
  26479. private _useSpecularOverAlpha;
  26480. /**
  26481. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  26482. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  26483. */
  26484. useSpecularOverAlpha: boolean;
  26485. private _useReflectionOverAlpha;
  26486. /**
  26487. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  26488. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  26489. */
  26490. useReflectionOverAlpha: boolean;
  26491. private _disableLighting;
  26492. /**
  26493. * Does lights from the scene impacts this material.
  26494. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  26495. */
  26496. disableLighting: boolean;
  26497. private _useObjectSpaceNormalMap;
  26498. /**
  26499. * Allows using an object space normal map (instead of tangent space).
  26500. */
  26501. useObjectSpaceNormalMap: boolean;
  26502. private _useParallax;
  26503. /**
  26504. * Is parallax enabled or not.
  26505. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  26506. */
  26507. useParallax: boolean;
  26508. private _useParallaxOcclusion;
  26509. /**
  26510. * Is parallax occlusion enabled or not.
  26511. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  26512. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  26513. */
  26514. useParallaxOcclusion: boolean;
  26515. /**
  26516. * 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.
  26517. */
  26518. parallaxScaleBias: number;
  26519. private _roughness;
  26520. /**
  26521. * Helps to define how blurry the reflections should appears in the material.
  26522. */
  26523. roughness: number;
  26524. /**
  26525. * In case of refraction, define the value of the index of refraction.
  26526. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26527. */
  26528. indexOfRefraction: number;
  26529. /**
  26530. * Invert the refraction texture alongside the y axis.
  26531. * It can be useful with procedural textures or probe for instance.
  26532. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26533. */
  26534. invertRefractionY: boolean;
  26535. /**
  26536. * Defines the alpha limits in alpha test mode.
  26537. */
  26538. alphaCutOff: number;
  26539. private _useLightmapAsShadowmap;
  26540. /**
  26541. * In case of light mapping, define whether the map contains light or shadow informations.
  26542. */
  26543. useLightmapAsShadowmap: boolean;
  26544. private _diffuseFresnelParameters;
  26545. /**
  26546. * Define the diffuse fresnel parameters of the material.
  26547. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26548. */
  26549. diffuseFresnelParameters: FresnelParameters;
  26550. private _opacityFresnelParameters;
  26551. /**
  26552. * Define the opacity fresnel parameters of the material.
  26553. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26554. */
  26555. opacityFresnelParameters: FresnelParameters;
  26556. private _reflectionFresnelParameters;
  26557. /**
  26558. * Define the reflection fresnel parameters of the material.
  26559. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26560. */
  26561. reflectionFresnelParameters: FresnelParameters;
  26562. private _refractionFresnelParameters;
  26563. /**
  26564. * Define the refraction fresnel parameters of the material.
  26565. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26566. */
  26567. refractionFresnelParameters: FresnelParameters;
  26568. private _emissiveFresnelParameters;
  26569. /**
  26570. * Define the emissive fresnel parameters of the material.
  26571. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26572. */
  26573. emissiveFresnelParameters: FresnelParameters;
  26574. private _useReflectionFresnelFromSpecular;
  26575. /**
  26576. * If true automatically deducts the fresnels values from the material specularity.
  26577. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26578. */
  26579. useReflectionFresnelFromSpecular: boolean;
  26580. private _useGlossinessFromSpecularMapAlpha;
  26581. /**
  26582. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  26583. */
  26584. useGlossinessFromSpecularMapAlpha: boolean;
  26585. private _maxSimultaneousLights;
  26586. /**
  26587. * Defines the maximum number of lights that can be used in the material
  26588. */
  26589. maxSimultaneousLights: number;
  26590. private _invertNormalMapX;
  26591. /**
  26592. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  26593. */
  26594. invertNormalMapX: boolean;
  26595. private _invertNormalMapY;
  26596. /**
  26597. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  26598. */
  26599. invertNormalMapY: boolean;
  26600. private _twoSidedLighting;
  26601. /**
  26602. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  26603. */
  26604. twoSidedLighting: boolean;
  26605. /**
  26606. * Default configuration related to image processing available in the standard Material.
  26607. */
  26608. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  26609. /**
  26610. * Gets the image processing configuration used either in this material.
  26611. */
  26612. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  26613. /**
  26614. * Sets the Default image processing configuration used either in the this material.
  26615. *
  26616. * If sets to null, the scene one is in use.
  26617. */
  26618. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  26619. /**
  26620. * Keep track of the image processing observer to allow dispose and replace.
  26621. */
  26622. private _imageProcessingObserver;
  26623. /**
  26624. * Attaches a new image processing configuration to the Standard Material.
  26625. * @param configuration
  26626. */
  26627. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  26628. /**
  26629. * Gets wether the color curves effect is enabled.
  26630. */
  26631. get cameraColorCurvesEnabled(): boolean;
  26632. /**
  26633. * Sets wether the color curves effect is enabled.
  26634. */
  26635. set cameraColorCurvesEnabled(value: boolean);
  26636. /**
  26637. * Gets wether the color grading effect is enabled.
  26638. */
  26639. get cameraColorGradingEnabled(): boolean;
  26640. /**
  26641. * Gets wether the color grading effect is enabled.
  26642. */
  26643. set cameraColorGradingEnabled(value: boolean);
  26644. /**
  26645. * Gets wether tonemapping is enabled or not.
  26646. */
  26647. get cameraToneMappingEnabled(): boolean;
  26648. /**
  26649. * Sets wether tonemapping is enabled or not
  26650. */
  26651. set cameraToneMappingEnabled(value: boolean);
  26652. /**
  26653. * The camera exposure used on this material.
  26654. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  26655. * This corresponds to a photographic exposure.
  26656. */
  26657. get cameraExposure(): number;
  26658. /**
  26659. * The camera exposure used on this material.
  26660. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  26661. * This corresponds to a photographic exposure.
  26662. */
  26663. set cameraExposure(value: number);
  26664. /**
  26665. * Gets The camera contrast used on this material.
  26666. */
  26667. get cameraContrast(): number;
  26668. /**
  26669. * Sets The camera contrast used on this material.
  26670. */
  26671. set cameraContrast(value: number);
  26672. /**
  26673. * Gets the Color Grading 2D Lookup Texture.
  26674. */
  26675. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  26676. /**
  26677. * Sets the Color Grading 2D Lookup Texture.
  26678. */
  26679. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  26680. /**
  26681. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  26682. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  26683. * 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;
  26684. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  26685. */
  26686. get cameraColorCurves(): Nullable<ColorCurves>;
  26687. /**
  26688. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  26689. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  26690. * 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;
  26691. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  26692. */
  26693. set cameraColorCurves(value: Nullable<ColorCurves>);
  26694. /**
  26695. * Custom callback helping to override the default shader used in the material.
  26696. */
  26697. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  26698. protected _renderTargets: SmartArray<RenderTargetTexture>;
  26699. protected _worldViewProjectionMatrix: Matrix;
  26700. protected _globalAmbientColor: Color3;
  26701. protected _useLogarithmicDepth: boolean;
  26702. protected _rebuildInParallel: boolean;
  26703. /**
  26704. * Instantiates a new standard material.
  26705. * This is the default material used in Babylon. It is the best trade off between quality
  26706. * and performances.
  26707. * @see http://doc.babylonjs.com/babylon101/materials
  26708. * @param name Define the name of the material in the scene
  26709. * @param scene Define the scene the material belong to
  26710. */
  26711. constructor(name: string, scene: Scene);
  26712. /**
  26713. * Gets a boolean indicating that current material needs to register RTT
  26714. */
  26715. get hasRenderTargetTextures(): boolean;
  26716. /**
  26717. * Gets the current class name of the material e.g. "StandardMaterial"
  26718. * Mainly use in serialization.
  26719. * @returns the class name
  26720. */
  26721. getClassName(): string;
  26722. /**
  26723. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  26724. * You can try switching to logarithmic depth.
  26725. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  26726. */
  26727. get useLogarithmicDepth(): boolean;
  26728. set useLogarithmicDepth(value: boolean);
  26729. /**
  26730. * Specifies if the material will require alpha blending
  26731. * @returns a boolean specifying if alpha blending is needed
  26732. */
  26733. needAlphaBlending(): boolean;
  26734. /**
  26735. * Specifies if this material should be rendered in alpha test mode
  26736. * @returns a boolean specifying if an alpha test is needed.
  26737. */
  26738. needAlphaTesting(): boolean;
  26739. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  26740. /**
  26741. * Get the texture used for alpha test purpose.
  26742. * @returns the diffuse texture in case of the standard material.
  26743. */
  26744. getAlphaTestTexture(): Nullable<BaseTexture>;
  26745. /**
  26746. * Get if the submesh is ready to be used and all its information available.
  26747. * Child classes can use it to update shaders
  26748. * @param mesh defines the mesh to check
  26749. * @param subMesh defines which submesh to check
  26750. * @param useInstances specifies that instances should be used
  26751. * @returns a boolean indicating that the submesh is ready or not
  26752. */
  26753. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  26754. /**
  26755. * Builds the material UBO layouts.
  26756. * Used internally during the effect preparation.
  26757. */
  26758. buildUniformLayout(): void;
  26759. /**
  26760. * Unbinds the material from the mesh
  26761. */
  26762. unbind(): void;
  26763. /**
  26764. * Binds the submesh to this material by preparing the effect and shader to draw
  26765. * @param world defines the world transformation matrix
  26766. * @param mesh defines the mesh containing the submesh
  26767. * @param subMesh defines the submesh to bind the material to
  26768. */
  26769. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  26770. /**
  26771. * Get the list of animatables in the material.
  26772. * @returns the list of animatables object used in the material
  26773. */
  26774. getAnimatables(): IAnimatable[];
  26775. /**
  26776. * Gets the active textures from the material
  26777. * @returns an array of textures
  26778. */
  26779. getActiveTextures(): BaseTexture[];
  26780. /**
  26781. * Specifies if the material uses a texture
  26782. * @param texture defines the texture to check against the material
  26783. * @returns a boolean specifying if the material uses the texture
  26784. */
  26785. hasTexture(texture: BaseTexture): boolean;
  26786. /**
  26787. * Disposes the material
  26788. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  26789. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  26790. */
  26791. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  26792. /**
  26793. * Makes a duplicate of the material, and gives it a new name
  26794. * @param name defines the new name for the duplicated material
  26795. * @returns the cloned material
  26796. */
  26797. clone(name: string): StandardMaterial;
  26798. /**
  26799. * Serializes this material in a JSON representation
  26800. * @returns the serialized material object
  26801. */
  26802. serialize(): any;
  26803. /**
  26804. * Creates a standard material from parsed material data
  26805. * @param source defines the JSON representation of the material
  26806. * @param scene defines the hosting scene
  26807. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  26808. * @returns a new standard material
  26809. */
  26810. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  26811. /**
  26812. * Are diffuse textures enabled in the application.
  26813. */
  26814. static get DiffuseTextureEnabled(): boolean;
  26815. static set DiffuseTextureEnabled(value: boolean);
  26816. /**
  26817. * Are ambient textures enabled in the application.
  26818. */
  26819. static get AmbientTextureEnabled(): boolean;
  26820. static set AmbientTextureEnabled(value: boolean);
  26821. /**
  26822. * Are opacity textures enabled in the application.
  26823. */
  26824. static get OpacityTextureEnabled(): boolean;
  26825. static set OpacityTextureEnabled(value: boolean);
  26826. /**
  26827. * Are reflection textures enabled in the application.
  26828. */
  26829. static get ReflectionTextureEnabled(): boolean;
  26830. static set ReflectionTextureEnabled(value: boolean);
  26831. /**
  26832. * Are emissive textures enabled in the application.
  26833. */
  26834. static get EmissiveTextureEnabled(): boolean;
  26835. static set EmissiveTextureEnabled(value: boolean);
  26836. /**
  26837. * Are specular textures enabled in the application.
  26838. */
  26839. static get SpecularTextureEnabled(): boolean;
  26840. static set SpecularTextureEnabled(value: boolean);
  26841. /**
  26842. * Are bump textures enabled in the application.
  26843. */
  26844. static get BumpTextureEnabled(): boolean;
  26845. static set BumpTextureEnabled(value: boolean);
  26846. /**
  26847. * Are lightmap textures enabled in the application.
  26848. */
  26849. static get LightmapTextureEnabled(): boolean;
  26850. static set LightmapTextureEnabled(value: boolean);
  26851. /**
  26852. * Are refraction textures enabled in the application.
  26853. */
  26854. static get RefractionTextureEnabled(): boolean;
  26855. static set RefractionTextureEnabled(value: boolean);
  26856. /**
  26857. * Are color grading textures enabled in the application.
  26858. */
  26859. static get ColorGradingTextureEnabled(): boolean;
  26860. static set ColorGradingTextureEnabled(value: boolean);
  26861. /**
  26862. * Are fresnels enabled in the application.
  26863. */
  26864. static get FresnelEnabled(): boolean;
  26865. static set FresnelEnabled(value: boolean);
  26866. }
  26867. }
  26868. declare module BABYLON {
  26869. /**
  26870. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  26871. *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.
  26872. * The SPS is also a particle system. It provides some methods to manage the particles.
  26873. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  26874. *
  26875. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  26876. */
  26877. export class SolidParticleSystem implements IDisposable {
  26878. /**
  26879. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  26880. * Example : var p = SPS.particles[i];
  26881. */
  26882. particles: SolidParticle[];
  26883. /**
  26884. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  26885. */
  26886. nbParticles: number;
  26887. /**
  26888. * If the particles must ever face the camera (default false). Useful for planar particles.
  26889. */
  26890. billboard: boolean;
  26891. /**
  26892. * Recompute normals when adding a shape
  26893. */
  26894. recomputeNormals: boolean;
  26895. /**
  26896. * This a counter ofr your own usage. It's not set by any SPS functions.
  26897. */
  26898. counter: number;
  26899. /**
  26900. * The SPS name. This name is also given to the underlying mesh.
  26901. */
  26902. name: string;
  26903. /**
  26904. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  26905. */
  26906. mesh: Mesh;
  26907. /**
  26908. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  26909. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  26910. */
  26911. vars: any;
  26912. /**
  26913. * This array is populated when the SPS is set as 'pickable'.
  26914. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  26915. * Each element of this array is an object `{idx: int, faceId: int}`.
  26916. * `idx` is the picked particle index in the `SPS.particles` array
  26917. * `faceId` is the picked face index counted within this particle.
  26918. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  26919. */
  26920. pickedParticles: {
  26921. idx: number;
  26922. faceId: number;
  26923. }[];
  26924. /**
  26925. * This array is populated when `enableDepthSort` is set to true.
  26926. * Each element of this array is an instance of the class DepthSortedParticle.
  26927. */
  26928. depthSortedParticles: DepthSortedParticle[];
  26929. /**
  26930. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  26931. * @hidden
  26932. */
  26933. _bSphereOnly: boolean;
  26934. /**
  26935. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  26936. * @hidden
  26937. */
  26938. _bSphereRadiusFactor: number;
  26939. private _scene;
  26940. private _positions;
  26941. private _indices;
  26942. private _normals;
  26943. private _colors;
  26944. private _uvs;
  26945. private _indices32;
  26946. private _positions32;
  26947. private _normals32;
  26948. private _fixedNormal32;
  26949. private _colors32;
  26950. private _uvs32;
  26951. private _index;
  26952. private _updatable;
  26953. private _pickable;
  26954. private _isVisibilityBoxLocked;
  26955. private _alwaysVisible;
  26956. private _depthSort;
  26957. private _expandable;
  26958. private _shapeCounter;
  26959. private _copy;
  26960. private _color;
  26961. private _computeParticleColor;
  26962. private _computeParticleTexture;
  26963. private _computeParticleRotation;
  26964. private _computeParticleVertex;
  26965. private _computeBoundingBox;
  26966. private _depthSortParticles;
  26967. private _camera;
  26968. private _mustUnrotateFixedNormals;
  26969. private _particlesIntersect;
  26970. private _needs32Bits;
  26971. private _isNotBuilt;
  26972. private _lastParticleId;
  26973. private _idxOfId;
  26974. private _multimaterialEnabled;
  26975. private _useModelMaterial;
  26976. private _indicesByMaterial;
  26977. private _materialIndexes;
  26978. private _depthSortFunction;
  26979. private _materialSortFunction;
  26980. private _materials;
  26981. private _multimaterial;
  26982. private _materialIndexesById;
  26983. private _defaultMaterial;
  26984. private _autoUpdateSubMeshes;
  26985. /**
  26986. * Creates a SPS (Solid Particle System) object.
  26987. * @param name (String) is the SPS name, this will be the underlying mesh name.
  26988. * @param scene (Scene) is the scene in which the SPS is added.
  26989. * @param options defines the options of the sps e.g.
  26990. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  26991. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  26992. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  26993. * * 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.
  26994. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  26995. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  26996. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  26997. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  26998. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  26999. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  27000. */
  27001. constructor(name: string, scene: Scene, options?: {
  27002. updatable?: boolean;
  27003. isPickable?: boolean;
  27004. enableDepthSort?: boolean;
  27005. particleIntersection?: boolean;
  27006. boundingSphereOnly?: boolean;
  27007. bSphereRadiusFactor?: number;
  27008. expandable?: boolean;
  27009. useModelMaterial?: boolean;
  27010. enableMultiMaterial?: boolean;
  27011. });
  27012. /**
  27013. * Builds the SPS underlying mesh. Returns a standard Mesh.
  27014. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  27015. * @returns the created mesh
  27016. */
  27017. buildMesh(): Mesh;
  27018. /**
  27019. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  27020. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  27021. * Thus the particles generated from `digest()` have their property `position` set yet.
  27022. * @param mesh ( Mesh ) is the mesh to be digested
  27023. * @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
  27024. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  27025. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  27026. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  27027. * @returns the current SPS
  27028. */
  27029. digest(mesh: Mesh, options?: {
  27030. facetNb?: number;
  27031. number?: number;
  27032. delta?: number;
  27033. storage?: [];
  27034. }): SolidParticleSystem;
  27035. /**
  27036. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  27037. * @hidden
  27038. */
  27039. private _unrotateFixedNormals;
  27040. /**
  27041. * Resets the temporary working copy particle
  27042. * @hidden
  27043. */
  27044. private _resetCopy;
  27045. /**
  27046. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  27047. * @param p the current index in the positions array to be updated
  27048. * @param ind the current index in the indices array
  27049. * @param shape a Vector3 array, the shape geometry
  27050. * @param positions the positions array to be updated
  27051. * @param meshInd the shape indices array
  27052. * @param indices the indices array to be updated
  27053. * @param meshUV the shape uv array
  27054. * @param uvs the uv array to be updated
  27055. * @param meshCol the shape color array
  27056. * @param colors the color array to be updated
  27057. * @param meshNor the shape normals array
  27058. * @param normals the normals array to be updated
  27059. * @param idx the particle index
  27060. * @param idxInShape the particle index in its shape
  27061. * @param options the addShape() method passed options
  27062. * @model the particle model
  27063. * @hidden
  27064. */
  27065. private _meshBuilder;
  27066. /**
  27067. * Returns a shape Vector3 array from positions float array
  27068. * @param positions float array
  27069. * @returns a vector3 array
  27070. * @hidden
  27071. */
  27072. private _posToShape;
  27073. /**
  27074. * Returns a shapeUV array from a float uvs (array deep copy)
  27075. * @param uvs as a float array
  27076. * @returns a shapeUV array
  27077. * @hidden
  27078. */
  27079. private _uvsToShapeUV;
  27080. /**
  27081. * Adds a new particle object in the particles array
  27082. * @param idx particle index in particles array
  27083. * @param id particle id
  27084. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  27085. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  27086. * @param model particle ModelShape object
  27087. * @param shapeId model shape identifier
  27088. * @param idxInShape index of the particle in the current model
  27089. * @param bInfo model bounding info object
  27090. * @param storage target storage array, if any
  27091. * @hidden
  27092. */
  27093. private _addParticle;
  27094. /**
  27095. * Adds some particles to the SPS from the model shape. Returns the shape id.
  27096. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  27097. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  27098. * @param nb (positive integer) the number of particles to be created from this model
  27099. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  27100. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  27101. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  27102. * @returns the number of shapes in the system
  27103. */
  27104. addShape(mesh: Mesh, nb: number, options?: {
  27105. positionFunction?: any;
  27106. vertexFunction?: any;
  27107. storage?: [];
  27108. }): number;
  27109. /**
  27110. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  27111. * @hidden
  27112. */
  27113. private _rebuildParticle;
  27114. /**
  27115. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  27116. * @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.
  27117. * @returns the SPS.
  27118. */
  27119. rebuildMesh(reset?: boolean): SolidParticleSystem;
  27120. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  27121. * Returns an array with the removed particles.
  27122. * 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.
  27123. * The SPS can't be empty so at least one particle needs to remain in place.
  27124. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  27125. * @param start index of the first particle to remove
  27126. * @param end index of the last particle to remove (included)
  27127. * @returns an array populated with the removed particles
  27128. */
  27129. removeParticles(start: number, end: number): SolidParticle[];
  27130. /**
  27131. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  27132. * @param solidParticleArray an array populated with Solid Particles objects
  27133. * @returns the SPS
  27134. */
  27135. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  27136. /**
  27137. * Creates a new particle and modifies the SPS mesh geometry :
  27138. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  27139. * - calls _addParticle() to populate the particle array
  27140. * factorized code from addShape() and insertParticlesFromArray()
  27141. * @param idx particle index in the particles array
  27142. * @param i particle index in its shape
  27143. * @param modelShape particle ModelShape object
  27144. * @param shape shape vertex array
  27145. * @param meshInd shape indices array
  27146. * @param meshUV shape uv array
  27147. * @param meshCol shape color array
  27148. * @param meshNor shape normals array
  27149. * @param bbInfo shape bounding info
  27150. * @param storage target particle storage
  27151. * @options addShape() passed options
  27152. * @hidden
  27153. */
  27154. private _insertNewParticle;
  27155. /**
  27156. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  27157. * This method calls `updateParticle()` for each particle of the SPS.
  27158. * For an animated SPS, it is usually called within the render loop.
  27159. * 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.
  27160. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  27161. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  27162. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  27163. * @returns the SPS.
  27164. */
  27165. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  27166. /**
  27167. * Disposes the SPS.
  27168. */
  27169. dispose(): void;
  27170. /**
  27171. * Returns a SolidParticle object from its identifier : particle.id
  27172. * @param id (integer) the particle Id
  27173. * @returns the searched particle or null if not found in the SPS.
  27174. */
  27175. getParticleById(id: number): Nullable<SolidParticle>;
  27176. /**
  27177. * Returns a new array populated with the particles having the passed shapeId.
  27178. * @param shapeId (integer) the shape identifier
  27179. * @returns a new solid particle array
  27180. */
  27181. getParticlesByShapeId(shapeId: number): SolidParticle[];
  27182. /**
  27183. * Populates the passed array "ref" with the particles having the passed shapeId.
  27184. * @param shapeId the shape identifier
  27185. * @returns the SPS
  27186. * @param ref
  27187. */
  27188. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  27189. /**
  27190. * Computes the required SubMeshes according the materials assigned to the particles.
  27191. * @returns the solid particle system.
  27192. * Does nothing if called before the SPS mesh is built.
  27193. */
  27194. computeSubMeshes(): SolidParticleSystem;
  27195. /**
  27196. * Sorts the solid particles by material when MultiMaterial is enabled.
  27197. * Updates the indices32 array.
  27198. * Updates the indicesByMaterial array.
  27199. * Updates the mesh indices array.
  27200. * @returns the SPS
  27201. * @hidden
  27202. */
  27203. private _sortParticlesByMaterial;
  27204. /**
  27205. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  27206. * @hidden
  27207. */
  27208. private _setMaterialIndexesById;
  27209. /**
  27210. * Returns an array with unique values of Materials from the passed array
  27211. * @param array the material array to be checked and filtered
  27212. * @hidden
  27213. */
  27214. private _filterUniqueMaterialId;
  27215. /**
  27216. * Sets a new Standard Material as _defaultMaterial if not already set.
  27217. * @hidden
  27218. */
  27219. private _setDefaultMaterial;
  27220. /**
  27221. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  27222. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27223. * @returns the SPS.
  27224. */
  27225. refreshVisibleSize(): SolidParticleSystem;
  27226. /**
  27227. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  27228. * @param size the size (float) of the visibility box
  27229. * note : this doesn't lock the SPS mesh bounding box.
  27230. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27231. */
  27232. setVisibilityBox(size: number): void;
  27233. /**
  27234. * Gets whether the SPS as always visible or not
  27235. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27236. */
  27237. get isAlwaysVisible(): boolean;
  27238. /**
  27239. * Sets the SPS as always visible or not
  27240. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27241. */
  27242. set isAlwaysVisible(val: boolean);
  27243. /**
  27244. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  27245. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27246. */
  27247. set isVisibilityBoxLocked(val: boolean);
  27248. /**
  27249. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  27250. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27251. */
  27252. get isVisibilityBoxLocked(): boolean;
  27253. /**
  27254. * Tells to `setParticles()` to compute the particle rotations or not.
  27255. * Default value : true. The SPS is faster when it's set to false.
  27256. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  27257. */
  27258. set computeParticleRotation(val: boolean);
  27259. /**
  27260. * Tells to `setParticles()` to compute the particle colors or not.
  27261. * Default value : true. The SPS is faster when it's set to false.
  27262. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  27263. */
  27264. set computeParticleColor(val: boolean);
  27265. set computeParticleTexture(val: boolean);
  27266. /**
  27267. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  27268. * Default value : false. The SPS is faster when it's set to false.
  27269. * Note : the particle custom vertex positions aren't stored values.
  27270. */
  27271. set computeParticleVertex(val: boolean);
  27272. /**
  27273. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  27274. */
  27275. set computeBoundingBox(val: boolean);
  27276. /**
  27277. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  27278. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  27279. * Default : `true`
  27280. */
  27281. set depthSortParticles(val: boolean);
  27282. /**
  27283. * Gets if `setParticles()` computes the particle rotations or not.
  27284. * Default value : true. The SPS is faster when it's set to false.
  27285. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  27286. */
  27287. get computeParticleRotation(): boolean;
  27288. /**
  27289. * Gets if `setParticles()` computes the particle colors or not.
  27290. * Default value : true. The SPS is faster when it's set to false.
  27291. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  27292. */
  27293. get computeParticleColor(): boolean;
  27294. /**
  27295. * Gets if `setParticles()` computes the particle textures or not.
  27296. * Default value : true. The SPS is faster when it's set to false.
  27297. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  27298. */
  27299. get computeParticleTexture(): boolean;
  27300. /**
  27301. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  27302. * Default value : false. The SPS is faster when it's set to false.
  27303. * Note : the particle custom vertex positions aren't stored values.
  27304. */
  27305. get computeParticleVertex(): boolean;
  27306. /**
  27307. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  27308. */
  27309. get computeBoundingBox(): boolean;
  27310. /**
  27311. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  27312. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  27313. * Default : `true`
  27314. */
  27315. get depthSortParticles(): boolean;
  27316. /**
  27317. * Gets if the SPS is created as expandable at construction time.
  27318. * Default : `false`
  27319. */
  27320. get expandable(): boolean;
  27321. /**
  27322. * Gets if the SPS supports the Multi Materials
  27323. */
  27324. get multimaterialEnabled(): boolean;
  27325. /**
  27326. * Gets if the SPS uses the model materials for its own multimaterial.
  27327. */
  27328. get useModelMaterial(): boolean;
  27329. /**
  27330. * The SPS used material array.
  27331. */
  27332. get materials(): Material[];
  27333. /**
  27334. * Sets the SPS MultiMaterial from the passed materials.
  27335. * Note : the passed array is internally copied and not used then by reference.
  27336. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  27337. */
  27338. setMultiMaterial(materials: Material[]): void;
  27339. /**
  27340. * The SPS computed multimaterial object
  27341. */
  27342. get multimaterial(): MultiMaterial;
  27343. set multimaterial(mm: MultiMaterial);
  27344. /**
  27345. * If the subMeshes must be updated on the next call to setParticles()
  27346. */
  27347. get autoUpdateSubMeshes(): boolean;
  27348. set autoUpdateSubMeshes(val: boolean);
  27349. /**
  27350. * This function does nothing. It may be overwritten to set all the particle first values.
  27351. * The SPS doesn't call this function, you may have to call it by your own.
  27352. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  27353. */
  27354. initParticles(): void;
  27355. /**
  27356. * This function does nothing. It may be overwritten to recycle a particle.
  27357. * The SPS doesn't call this function, you may have to call it by your own.
  27358. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  27359. * @param particle The particle to recycle
  27360. * @returns the recycled particle
  27361. */
  27362. recycleParticle(particle: SolidParticle): SolidParticle;
  27363. /**
  27364. * Updates a particle : this function should be overwritten by the user.
  27365. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  27366. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  27367. * @example : just set a particle position or velocity and recycle conditions
  27368. * @param particle The particle to update
  27369. * @returns the updated particle
  27370. */
  27371. updateParticle(particle: SolidParticle): SolidParticle;
  27372. /**
  27373. * Updates a vertex of a particle : it can be overwritten by the user.
  27374. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  27375. * @param particle the current particle
  27376. * @param vertex the current index of the current particle
  27377. * @param pt the index of the current vertex in the particle shape
  27378. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  27379. * @example : just set a vertex particle position
  27380. * @returns the updated vertex
  27381. */
  27382. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  27383. /**
  27384. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  27385. * This does nothing and may be overwritten by the user.
  27386. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27387. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27388. * @param update the boolean update value actually passed to setParticles()
  27389. */
  27390. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  27391. /**
  27392. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  27393. * This will be passed three parameters.
  27394. * This does nothing and may be overwritten by the user.
  27395. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27396. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27397. * @param update the boolean update value actually passed to setParticles()
  27398. */
  27399. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  27400. }
  27401. }
  27402. declare module BABYLON {
  27403. /**
  27404. * Represents one particle of a solid particle system.
  27405. */
  27406. export class SolidParticle {
  27407. /**
  27408. * particle global index
  27409. */
  27410. idx: number;
  27411. /**
  27412. * particle identifier
  27413. */
  27414. id: number;
  27415. /**
  27416. * The color of the particle
  27417. */
  27418. color: Nullable<Color4>;
  27419. /**
  27420. * The world space position of the particle.
  27421. */
  27422. position: Vector3;
  27423. /**
  27424. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  27425. */
  27426. rotation: Vector3;
  27427. /**
  27428. * The world space rotation quaternion of the particle.
  27429. */
  27430. rotationQuaternion: Nullable<Quaternion>;
  27431. /**
  27432. * The scaling of the particle.
  27433. */
  27434. scaling: Vector3;
  27435. /**
  27436. * The uvs of the particle.
  27437. */
  27438. uvs: Vector4;
  27439. /**
  27440. * The current speed of the particle.
  27441. */
  27442. velocity: Vector3;
  27443. /**
  27444. * The pivot point in the particle local space.
  27445. */
  27446. pivot: Vector3;
  27447. /**
  27448. * Must the particle be translated from its pivot point in its local space ?
  27449. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  27450. * Default : false
  27451. */
  27452. translateFromPivot: boolean;
  27453. /**
  27454. * Is the particle active or not ?
  27455. */
  27456. alive: boolean;
  27457. /**
  27458. * Is the particle visible or not ?
  27459. */
  27460. isVisible: boolean;
  27461. /**
  27462. * Index of this particle in the global "positions" array (Internal use)
  27463. * @hidden
  27464. */
  27465. _pos: number;
  27466. /**
  27467. * @hidden Index of this particle in the global "indices" array (Internal use)
  27468. */
  27469. _ind: number;
  27470. /**
  27471. * @hidden ModelShape of this particle (Internal use)
  27472. */
  27473. _model: ModelShape;
  27474. /**
  27475. * ModelShape id of this particle
  27476. */
  27477. shapeId: number;
  27478. /**
  27479. * Index of the particle in its shape id
  27480. */
  27481. idxInShape: number;
  27482. /**
  27483. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  27484. */
  27485. _modelBoundingInfo: BoundingInfo;
  27486. /**
  27487. * @hidden Particle BoundingInfo object (Internal use)
  27488. */
  27489. _boundingInfo: BoundingInfo;
  27490. /**
  27491. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  27492. */
  27493. _sps: SolidParticleSystem;
  27494. /**
  27495. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  27496. */
  27497. _stillInvisible: boolean;
  27498. /**
  27499. * @hidden Last computed particle rotation matrix
  27500. */
  27501. _rotationMatrix: number[];
  27502. /**
  27503. * Parent particle Id, if any.
  27504. * Default null.
  27505. */
  27506. parentId: Nullable<number>;
  27507. /**
  27508. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  27509. */
  27510. materialIndex: Nullable<number>;
  27511. /**
  27512. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  27513. * The possible values are :
  27514. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  27515. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  27516. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  27517. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  27518. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  27519. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  27520. * */
  27521. cullingStrategy: number;
  27522. /**
  27523. * @hidden Internal global position in the SPS.
  27524. */
  27525. _globalPosition: Vector3;
  27526. /**
  27527. * Creates a Solid Particle object.
  27528. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  27529. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  27530. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  27531. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  27532. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  27533. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  27534. * @param shapeId (integer) is the model shape identifier in the SPS.
  27535. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  27536. * @param sps defines the sps it is associated to
  27537. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  27538. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  27539. */
  27540. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  27541. /**
  27542. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  27543. * @param target the particle target
  27544. * @returns the current particle
  27545. */
  27546. copyToRef(target: SolidParticle): SolidParticle;
  27547. /**
  27548. * Legacy support, changed scale to scaling
  27549. */
  27550. get scale(): Vector3;
  27551. /**
  27552. * Legacy support, changed scale to scaling
  27553. */
  27554. set scale(scale: Vector3);
  27555. /**
  27556. * Legacy support, changed quaternion to rotationQuaternion
  27557. */
  27558. get quaternion(): Nullable<Quaternion>;
  27559. /**
  27560. * Legacy support, changed quaternion to rotationQuaternion
  27561. */
  27562. set quaternion(q: Nullable<Quaternion>);
  27563. /**
  27564. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  27565. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  27566. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  27567. * @returns true if it intersects
  27568. */
  27569. intersectsMesh(target: Mesh | SolidParticle): boolean;
  27570. /**
  27571. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  27572. * A particle is in the frustum if its bounding box intersects the frustum
  27573. * @param frustumPlanes defines the frustum to test
  27574. * @returns true if the particle is in the frustum planes
  27575. */
  27576. isInFrustum(frustumPlanes: Plane[]): boolean;
  27577. /**
  27578. * get the rotation matrix of the particle
  27579. * @hidden
  27580. */
  27581. getRotationMatrix(m: Matrix): void;
  27582. }
  27583. /**
  27584. * Represents the shape of the model used by one particle of a solid particle system.
  27585. * SPS internal tool, don't use it manually.
  27586. */
  27587. export class ModelShape {
  27588. /**
  27589. * The shape id
  27590. * @hidden
  27591. */
  27592. shapeID: number;
  27593. /**
  27594. * flat array of model positions (internal use)
  27595. * @hidden
  27596. */
  27597. _shape: Vector3[];
  27598. /**
  27599. * flat array of model UVs (internal use)
  27600. * @hidden
  27601. */
  27602. _shapeUV: number[];
  27603. /**
  27604. * color array of the model
  27605. * @hidden
  27606. */
  27607. _shapeColors: number[];
  27608. /**
  27609. * indices array of the model
  27610. * @hidden
  27611. */
  27612. _indices: number[];
  27613. /**
  27614. * normals array of the model
  27615. * @hidden
  27616. */
  27617. _normals: number[];
  27618. /**
  27619. * length of the shape in the model indices array (internal use)
  27620. * @hidden
  27621. */
  27622. _indicesLength: number;
  27623. /**
  27624. * Custom position function (internal use)
  27625. * @hidden
  27626. */
  27627. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  27628. /**
  27629. * Custom vertex function (internal use)
  27630. * @hidden
  27631. */
  27632. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  27633. /**
  27634. * Model material (internal use)
  27635. * @hidden
  27636. */
  27637. _material: Nullable<Material>;
  27638. /**
  27639. * 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.
  27640. * SPS internal tool, don't use it manually.
  27641. * @hidden
  27642. */
  27643. 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>);
  27644. }
  27645. /**
  27646. * Represents a Depth Sorted Particle in the solid particle system.
  27647. * @hidden
  27648. */
  27649. export class DepthSortedParticle {
  27650. /**
  27651. * Index of the particle in the "indices" array
  27652. */
  27653. ind: number;
  27654. /**
  27655. * Length of the particle shape in the "indices" array
  27656. */
  27657. indicesLength: number;
  27658. /**
  27659. * Squared distance from the particle to the camera
  27660. */
  27661. sqDistance: number;
  27662. /**
  27663. * Material index when used with MultiMaterials
  27664. */
  27665. materialIndex: number;
  27666. /**
  27667. * Creates a new sorted particle
  27668. * @param materialIndex
  27669. */
  27670. constructor(ind: number, indLength: number, materialIndex: number);
  27671. }
  27672. }
  27673. declare module BABYLON {
  27674. /**
  27675. * @hidden
  27676. */
  27677. export class _MeshCollisionData {
  27678. _checkCollisions: boolean;
  27679. _collisionMask: number;
  27680. _collisionGroup: number;
  27681. _collider: Nullable<Collider>;
  27682. _oldPositionForCollisions: Vector3;
  27683. _diffPositionForCollisions: Vector3;
  27684. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  27685. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  27686. }
  27687. }
  27688. declare module BABYLON {
  27689. /** @hidden */
  27690. class _FacetDataStorage {
  27691. facetPositions: Vector3[];
  27692. facetNormals: Vector3[];
  27693. facetPartitioning: number[][];
  27694. facetNb: number;
  27695. partitioningSubdivisions: number;
  27696. partitioningBBoxRatio: number;
  27697. facetDataEnabled: boolean;
  27698. facetParameters: any;
  27699. bbSize: Vector3;
  27700. subDiv: {
  27701. max: number;
  27702. X: number;
  27703. Y: number;
  27704. Z: number;
  27705. };
  27706. facetDepthSort: boolean;
  27707. facetDepthSortEnabled: boolean;
  27708. depthSortedIndices: IndicesArray;
  27709. depthSortedFacets: {
  27710. ind: number;
  27711. sqDistance: number;
  27712. }[];
  27713. facetDepthSortFunction: (f1: {
  27714. ind: number;
  27715. sqDistance: number;
  27716. }, f2: {
  27717. ind: number;
  27718. sqDistance: number;
  27719. }) => number;
  27720. facetDepthSortFrom: Vector3;
  27721. facetDepthSortOrigin: Vector3;
  27722. invertedMatrix: Matrix;
  27723. }
  27724. /**
  27725. * @hidden
  27726. **/
  27727. class _InternalAbstractMeshDataInfo {
  27728. _hasVertexAlpha: boolean;
  27729. _useVertexColors: boolean;
  27730. _numBoneInfluencers: number;
  27731. _applyFog: boolean;
  27732. _receiveShadows: boolean;
  27733. _facetData: _FacetDataStorage;
  27734. _visibility: number;
  27735. _skeleton: Nullable<Skeleton>;
  27736. _layerMask: number;
  27737. _computeBonesUsingShaders: boolean;
  27738. _isActive: boolean;
  27739. _onlyForInstances: boolean;
  27740. _isActiveIntermediate: boolean;
  27741. _onlyForInstancesIntermediate: boolean;
  27742. _actAsRegularMesh: boolean;
  27743. }
  27744. /**
  27745. * Class used to store all common mesh properties
  27746. */
  27747. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  27748. /** No occlusion */
  27749. static OCCLUSION_TYPE_NONE: number;
  27750. /** Occlusion set to optimisitic */
  27751. static OCCLUSION_TYPE_OPTIMISTIC: number;
  27752. /** Occlusion set to strict */
  27753. static OCCLUSION_TYPE_STRICT: number;
  27754. /** Use an accurante occlusion algorithm */
  27755. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  27756. /** Use a conservative occlusion algorithm */
  27757. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  27758. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  27759. * Test order :
  27760. * Is the bounding sphere outside the frustum ?
  27761. * If not, are the bounding box vertices outside the frustum ?
  27762. * It not, then the cullable object is in the frustum.
  27763. */
  27764. static readonly CULLINGSTRATEGY_STANDARD: number;
  27765. /** Culling strategy : Bounding Sphere Only.
  27766. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  27767. * It's also less accurate than the standard because some not visible objects can still be selected.
  27768. * Test : is the bounding sphere outside the frustum ?
  27769. * If not, then the cullable object is in the frustum.
  27770. */
  27771. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  27772. /** Culling strategy : Optimistic Inclusion.
  27773. * This in an inclusion test first, then the standard exclusion test.
  27774. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  27775. * 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.
  27776. * Anyway, it's as accurate as the standard strategy.
  27777. * Test :
  27778. * Is the cullable object bounding sphere center in the frustum ?
  27779. * If not, apply the default culling strategy.
  27780. */
  27781. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  27782. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  27783. * This in an inclusion test first, then the bounding sphere only exclusion test.
  27784. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  27785. * 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.
  27786. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  27787. * Test :
  27788. * Is the cullable object bounding sphere center in the frustum ?
  27789. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  27790. */
  27791. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  27792. /**
  27793. * No billboard
  27794. */
  27795. static get BILLBOARDMODE_NONE(): number;
  27796. /** Billboard on X axis */
  27797. static get BILLBOARDMODE_X(): number;
  27798. /** Billboard on Y axis */
  27799. static get BILLBOARDMODE_Y(): number;
  27800. /** Billboard on Z axis */
  27801. static get BILLBOARDMODE_Z(): number;
  27802. /** Billboard on all axes */
  27803. static get BILLBOARDMODE_ALL(): number;
  27804. /** Billboard on using position instead of orientation */
  27805. static get BILLBOARDMODE_USE_POSITION(): number;
  27806. /** @hidden */
  27807. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  27808. /**
  27809. * The culling strategy to use to check whether the mesh must be rendered or not.
  27810. * This value can be changed at any time and will be used on the next render mesh selection.
  27811. * The possible values are :
  27812. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  27813. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  27814. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  27815. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  27816. * Please read each static variable documentation to get details about the culling process.
  27817. * */
  27818. cullingStrategy: number;
  27819. /**
  27820. * Gets the number of facets in the mesh
  27821. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  27822. */
  27823. get facetNb(): number;
  27824. /**
  27825. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  27826. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  27827. */
  27828. get partitioningSubdivisions(): number;
  27829. set partitioningSubdivisions(nb: number);
  27830. /**
  27831. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  27832. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  27833. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  27834. */
  27835. get partitioningBBoxRatio(): number;
  27836. set partitioningBBoxRatio(ratio: number);
  27837. /**
  27838. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  27839. * Works only for updatable meshes.
  27840. * Doesn't work with multi-materials
  27841. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  27842. */
  27843. get mustDepthSortFacets(): boolean;
  27844. set mustDepthSortFacets(sort: boolean);
  27845. /**
  27846. * The location (Vector3) where the facet depth sort must be computed from.
  27847. * By default, the active camera position.
  27848. * Used only when facet depth sort is enabled
  27849. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  27850. */
  27851. get facetDepthSortFrom(): Vector3;
  27852. set facetDepthSortFrom(location: Vector3);
  27853. /**
  27854. * gets a boolean indicating if facetData is enabled
  27855. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  27856. */
  27857. get isFacetDataEnabled(): boolean;
  27858. /** @hidden */
  27859. _updateNonUniformScalingState(value: boolean): boolean;
  27860. /**
  27861. * An event triggered when this mesh collides with another one
  27862. */
  27863. onCollideObservable: Observable<AbstractMesh>;
  27864. /** Set a function to call when this mesh collides with another one */
  27865. set onCollide(callback: () => void);
  27866. /**
  27867. * An event triggered when the collision's position changes
  27868. */
  27869. onCollisionPositionChangeObservable: Observable<Vector3>;
  27870. /** Set a function to call when the collision's position changes */
  27871. set onCollisionPositionChange(callback: () => void);
  27872. /**
  27873. * An event triggered when material is changed
  27874. */
  27875. onMaterialChangedObservable: Observable<AbstractMesh>;
  27876. /**
  27877. * Gets or sets the orientation for POV movement & rotation
  27878. */
  27879. definedFacingForward: boolean;
  27880. /** @hidden */
  27881. _occlusionQuery: Nullable<WebGLQuery>;
  27882. /** @hidden */
  27883. _renderingGroup: Nullable<RenderingGroup>;
  27884. /**
  27885. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  27886. */
  27887. get visibility(): number;
  27888. /**
  27889. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  27890. */
  27891. set visibility(value: number);
  27892. /** Gets or sets the alpha index used to sort transparent meshes
  27893. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  27894. */
  27895. alphaIndex: number;
  27896. /**
  27897. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  27898. */
  27899. isVisible: boolean;
  27900. /**
  27901. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  27902. */
  27903. isPickable: boolean;
  27904. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  27905. showSubMeshesBoundingBox: boolean;
  27906. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  27907. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  27908. */
  27909. isBlocker: boolean;
  27910. /**
  27911. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  27912. */
  27913. enablePointerMoveEvents: boolean;
  27914. /**
  27915. * Specifies the rendering group id for this mesh (0 by default)
  27916. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  27917. */
  27918. renderingGroupId: number;
  27919. private _material;
  27920. /** Gets or sets current material */
  27921. get material(): Nullable<Material>;
  27922. set material(value: Nullable<Material>);
  27923. /**
  27924. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  27925. * @see http://doc.babylonjs.com/babylon101/shadows
  27926. */
  27927. get receiveShadows(): boolean;
  27928. set receiveShadows(value: boolean);
  27929. /** Defines color to use when rendering outline */
  27930. outlineColor: Color3;
  27931. /** Define width to use when rendering outline */
  27932. outlineWidth: number;
  27933. /** Defines color to use when rendering overlay */
  27934. overlayColor: Color3;
  27935. /** Defines alpha to use when rendering overlay */
  27936. overlayAlpha: number;
  27937. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  27938. get hasVertexAlpha(): boolean;
  27939. set hasVertexAlpha(value: boolean);
  27940. /** 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) */
  27941. get useVertexColors(): boolean;
  27942. set useVertexColors(value: boolean);
  27943. /**
  27944. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  27945. */
  27946. get computeBonesUsingShaders(): boolean;
  27947. set computeBonesUsingShaders(value: boolean);
  27948. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  27949. get numBoneInfluencers(): number;
  27950. set numBoneInfluencers(value: number);
  27951. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  27952. get applyFog(): boolean;
  27953. set applyFog(value: boolean);
  27954. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  27955. useOctreeForRenderingSelection: boolean;
  27956. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  27957. useOctreeForPicking: boolean;
  27958. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  27959. useOctreeForCollisions: boolean;
  27960. /**
  27961. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  27962. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  27963. */
  27964. get layerMask(): number;
  27965. set layerMask(value: number);
  27966. /**
  27967. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  27968. */
  27969. alwaysSelectAsActiveMesh: boolean;
  27970. /**
  27971. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  27972. */
  27973. doNotSyncBoundingInfo: boolean;
  27974. /**
  27975. * Gets or sets the current action manager
  27976. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  27977. */
  27978. actionManager: Nullable<AbstractActionManager>;
  27979. private _meshCollisionData;
  27980. /**
  27981. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  27982. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27983. */
  27984. ellipsoid: Vector3;
  27985. /**
  27986. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  27987. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27988. */
  27989. ellipsoidOffset: Vector3;
  27990. /**
  27991. * Gets or sets a collision mask used to mask collisions (default is -1).
  27992. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  27993. */
  27994. get collisionMask(): number;
  27995. set collisionMask(mask: number);
  27996. /**
  27997. * Gets or sets the current collision group mask (-1 by default).
  27998. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  27999. */
  28000. get collisionGroup(): number;
  28001. set collisionGroup(mask: number);
  28002. /**
  28003. * Defines edge width used when edgesRenderer is enabled
  28004. * @see https://www.babylonjs-playground.com/#10OJSG#13
  28005. */
  28006. edgesWidth: number;
  28007. /**
  28008. * Defines edge color used when edgesRenderer is enabled
  28009. * @see https://www.babylonjs-playground.com/#10OJSG#13
  28010. */
  28011. edgesColor: Color4;
  28012. /** @hidden */
  28013. _edgesRenderer: Nullable<IEdgesRenderer>;
  28014. /** @hidden */
  28015. _masterMesh: Nullable<AbstractMesh>;
  28016. /** @hidden */
  28017. _boundingInfo: Nullable<BoundingInfo>;
  28018. /** @hidden */
  28019. _renderId: number;
  28020. /**
  28021. * Gets or sets the list of subMeshes
  28022. * @see http://doc.babylonjs.com/how_to/multi_materials
  28023. */
  28024. subMeshes: SubMesh[];
  28025. /** @hidden */
  28026. _intersectionsInProgress: AbstractMesh[];
  28027. /** @hidden */
  28028. _unIndexed: boolean;
  28029. /** @hidden */
  28030. _lightSources: Light[];
  28031. /** Gets the list of lights affecting that mesh */
  28032. get lightSources(): Light[];
  28033. /** @hidden */
  28034. get _positions(): Nullable<Vector3[]>;
  28035. /** @hidden */
  28036. _waitingData: {
  28037. lods: Nullable<any>;
  28038. actions: Nullable<any>;
  28039. freezeWorldMatrix: Nullable<boolean>;
  28040. };
  28041. /** @hidden */
  28042. _bonesTransformMatrices: Nullable<Float32Array>;
  28043. /** @hidden */
  28044. _transformMatrixTexture: Nullable<RawTexture>;
  28045. /**
  28046. * Gets or sets a skeleton to apply skining transformations
  28047. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  28048. */
  28049. set skeleton(value: Nullable<Skeleton>);
  28050. get skeleton(): Nullable<Skeleton>;
  28051. /**
  28052. * An event triggered when the mesh is rebuilt.
  28053. */
  28054. onRebuildObservable: Observable<AbstractMesh>;
  28055. /**
  28056. * Creates a new AbstractMesh
  28057. * @param name defines the name of the mesh
  28058. * @param scene defines the hosting scene
  28059. */
  28060. constructor(name: string, scene?: Nullable<Scene>);
  28061. /**
  28062. * Returns the string "AbstractMesh"
  28063. * @returns "AbstractMesh"
  28064. */
  28065. getClassName(): string;
  28066. /**
  28067. * Gets a string representation of the current mesh
  28068. * @param fullDetails defines a boolean indicating if full details must be included
  28069. * @returns a string representation of the current mesh
  28070. */
  28071. toString(fullDetails?: boolean): string;
  28072. /**
  28073. * @hidden
  28074. */
  28075. protected _getEffectiveParent(): Nullable<Node>;
  28076. /** @hidden */
  28077. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  28078. /** @hidden */
  28079. _rebuild(): void;
  28080. /** @hidden */
  28081. _resyncLightSources(): void;
  28082. /** @hidden */
  28083. _resyncLightSource(light: Light): void;
  28084. /** @hidden */
  28085. _unBindEffect(): void;
  28086. /** @hidden */
  28087. _removeLightSource(light: Light, dispose: boolean): void;
  28088. private _markSubMeshesAsDirty;
  28089. /** @hidden */
  28090. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  28091. /** @hidden */
  28092. _markSubMeshesAsAttributesDirty(): void;
  28093. /** @hidden */
  28094. _markSubMeshesAsMiscDirty(): void;
  28095. /**
  28096. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  28097. */
  28098. get scaling(): Vector3;
  28099. set scaling(newScaling: Vector3);
  28100. /**
  28101. * Returns true if the mesh is blocked. Implemented by child classes
  28102. */
  28103. get isBlocked(): boolean;
  28104. /**
  28105. * Returns the mesh itself by default. Implemented by child classes
  28106. * @param camera defines the camera to use to pick the right LOD level
  28107. * @returns the currentAbstractMesh
  28108. */
  28109. getLOD(camera: Camera): Nullable<AbstractMesh>;
  28110. /**
  28111. * Returns 0 by default. Implemented by child classes
  28112. * @returns an integer
  28113. */
  28114. getTotalVertices(): number;
  28115. /**
  28116. * Returns a positive integer : the total number of indices in this mesh geometry.
  28117. * @returns the numner of indices or zero if the mesh has no geometry.
  28118. */
  28119. getTotalIndices(): number;
  28120. /**
  28121. * Returns null by default. Implemented by child classes
  28122. * @returns null
  28123. */
  28124. getIndices(): Nullable<IndicesArray>;
  28125. /**
  28126. * Returns the array of the requested vertex data kind. Implemented by child classes
  28127. * @param kind defines the vertex data kind to use
  28128. * @returns null
  28129. */
  28130. getVerticesData(kind: string): Nullable<FloatArray>;
  28131. /**
  28132. * Sets the vertex data of the mesh geometry for the requested `kind`.
  28133. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  28134. * Note that a new underlying VertexBuffer object is created each call.
  28135. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  28136. * @param kind defines vertex data kind:
  28137. * * VertexBuffer.PositionKind
  28138. * * VertexBuffer.UVKind
  28139. * * VertexBuffer.UV2Kind
  28140. * * VertexBuffer.UV3Kind
  28141. * * VertexBuffer.UV4Kind
  28142. * * VertexBuffer.UV5Kind
  28143. * * VertexBuffer.UV6Kind
  28144. * * VertexBuffer.ColorKind
  28145. * * VertexBuffer.MatricesIndicesKind
  28146. * * VertexBuffer.MatricesIndicesExtraKind
  28147. * * VertexBuffer.MatricesWeightsKind
  28148. * * VertexBuffer.MatricesWeightsExtraKind
  28149. * @param data defines the data source
  28150. * @param updatable defines if the data must be flagged as updatable (or static)
  28151. * @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
  28152. * @returns the current mesh
  28153. */
  28154. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  28155. /**
  28156. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  28157. * If the mesh has no geometry, it is simply returned as it is.
  28158. * @param kind defines vertex data kind:
  28159. * * VertexBuffer.PositionKind
  28160. * * VertexBuffer.UVKind
  28161. * * VertexBuffer.UV2Kind
  28162. * * VertexBuffer.UV3Kind
  28163. * * VertexBuffer.UV4Kind
  28164. * * VertexBuffer.UV5Kind
  28165. * * VertexBuffer.UV6Kind
  28166. * * VertexBuffer.ColorKind
  28167. * * VertexBuffer.MatricesIndicesKind
  28168. * * VertexBuffer.MatricesIndicesExtraKind
  28169. * * VertexBuffer.MatricesWeightsKind
  28170. * * VertexBuffer.MatricesWeightsExtraKind
  28171. * @param data defines the data source
  28172. * @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
  28173. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  28174. * @returns the current mesh
  28175. */
  28176. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  28177. /**
  28178. * Sets the mesh indices,
  28179. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  28180. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  28181. * @param totalVertices Defines the total number of vertices
  28182. * @returns the current mesh
  28183. */
  28184. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  28185. /**
  28186. * Gets a boolean indicating if specific vertex data is present
  28187. * @param kind defines the vertex data kind to use
  28188. * @returns true is data kind is present
  28189. */
  28190. isVerticesDataPresent(kind: string): boolean;
  28191. /**
  28192. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  28193. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  28194. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  28195. * @returns a BoundingInfo
  28196. */
  28197. getBoundingInfo(): BoundingInfo;
  28198. /**
  28199. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  28200. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  28201. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  28202. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  28203. * @returns the current mesh
  28204. */
  28205. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  28206. /**
  28207. * Overwrite the current bounding info
  28208. * @param boundingInfo defines the new bounding info
  28209. * @returns the current mesh
  28210. */
  28211. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  28212. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  28213. get useBones(): boolean;
  28214. /** @hidden */
  28215. _preActivate(): void;
  28216. /** @hidden */
  28217. _preActivateForIntermediateRendering(renderId: number): void;
  28218. /** @hidden */
  28219. _activate(renderId: number, intermediateRendering: boolean): boolean;
  28220. /** @hidden */
  28221. _postActivate(): void;
  28222. /** @hidden */
  28223. _freeze(): void;
  28224. /** @hidden */
  28225. _unFreeze(): void;
  28226. /**
  28227. * Gets the current world matrix
  28228. * @returns a Matrix
  28229. */
  28230. getWorldMatrix(): Matrix;
  28231. /** @hidden */
  28232. _getWorldMatrixDeterminant(): number;
  28233. /**
  28234. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  28235. */
  28236. get isAnInstance(): boolean;
  28237. /**
  28238. * Gets a boolean indicating if this mesh has instances
  28239. */
  28240. get hasInstances(): boolean;
  28241. /**
  28242. * Perform relative position change from the point of view of behind the front of the mesh.
  28243. * This is performed taking into account the meshes current rotation, so you do not have to care.
  28244. * Supports definition of mesh facing forward or backward
  28245. * @param amountRight defines the distance on the right axis
  28246. * @param amountUp defines the distance on the up axis
  28247. * @param amountForward defines the distance on the forward axis
  28248. * @returns the current mesh
  28249. */
  28250. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  28251. /**
  28252. * Calculate relative position change from the point of view of behind the front of the mesh.
  28253. * This is performed taking into account the meshes current rotation, so you do not have to care.
  28254. * Supports definition of mesh facing forward or backward
  28255. * @param amountRight defines the distance on the right axis
  28256. * @param amountUp defines the distance on the up axis
  28257. * @param amountForward defines the distance on the forward axis
  28258. * @returns the new displacement vector
  28259. */
  28260. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  28261. /**
  28262. * Perform relative rotation change from the point of view of behind the front of the mesh.
  28263. * Supports definition of mesh facing forward or backward
  28264. * @param flipBack defines the flip
  28265. * @param twirlClockwise defines the twirl
  28266. * @param tiltRight defines the tilt
  28267. * @returns the current mesh
  28268. */
  28269. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  28270. /**
  28271. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  28272. * Supports definition of mesh facing forward or backward.
  28273. * @param flipBack defines the flip
  28274. * @param twirlClockwise defines the twirl
  28275. * @param tiltRight defines the tilt
  28276. * @returns the new rotation vector
  28277. */
  28278. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  28279. /**
  28280. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  28281. * This means the mesh underlying bounding box and sphere are recomputed.
  28282. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  28283. * @returns the current mesh
  28284. */
  28285. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  28286. /** @hidden */
  28287. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  28288. /** @hidden */
  28289. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  28290. /** @hidden */
  28291. _updateBoundingInfo(): AbstractMesh;
  28292. /** @hidden */
  28293. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  28294. /** @hidden */
  28295. protected _afterComputeWorldMatrix(): void;
  28296. /** @hidden */
  28297. get _effectiveMesh(): AbstractMesh;
  28298. /**
  28299. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  28300. * A mesh is in the frustum if its bounding box intersects the frustum
  28301. * @param frustumPlanes defines the frustum to test
  28302. * @returns true if the mesh is in the frustum planes
  28303. */
  28304. isInFrustum(frustumPlanes: Plane[]): boolean;
  28305. /**
  28306. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  28307. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  28308. * @param frustumPlanes defines the frustum to test
  28309. * @returns true if the mesh is completely in the frustum planes
  28310. */
  28311. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  28312. /**
  28313. * True if the mesh intersects another mesh or a SolidParticle object
  28314. * @param mesh defines a target mesh or SolidParticle to test
  28315. * @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)
  28316. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  28317. * @returns true if there is an intersection
  28318. */
  28319. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  28320. /**
  28321. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  28322. * @param point defines the point to test
  28323. * @returns true if there is an intersection
  28324. */
  28325. intersectsPoint(point: Vector3): boolean;
  28326. /**
  28327. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  28328. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28329. */
  28330. get checkCollisions(): boolean;
  28331. set checkCollisions(collisionEnabled: boolean);
  28332. /**
  28333. * Gets Collider object used to compute collisions (not physics)
  28334. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28335. */
  28336. get collider(): Nullable<Collider>;
  28337. /**
  28338. * Move the mesh using collision engine
  28339. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28340. * @param displacement defines the requested displacement vector
  28341. * @returns the current mesh
  28342. */
  28343. moveWithCollisions(displacement: Vector3): AbstractMesh;
  28344. private _onCollisionPositionChange;
  28345. /** @hidden */
  28346. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  28347. /** @hidden */
  28348. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  28349. /** @hidden */
  28350. _checkCollision(collider: Collider): AbstractMesh;
  28351. /** @hidden */
  28352. _generatePointsArray(): boolean;
  28353. /**
  28354. * Checks if the passed Ray intersects with the mesh
  28355. * @param ray defines the ray to use
  28356. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  28357. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  28358. * @returns the picking info
  28359. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  28360. */
  28361. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  28362. /**
  28363. * Clones the current mesh
  28364. * @param name defines the mesh name
  28365. * @param newParent defines the new mesh parent
  28366. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  28367. * @returns the new mesh
  28368. */
  28369. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  28370. /**
  28371. * Disposes all the submeshes of the current meshnp
  28372. * @returns the current mesh
  28373. */
  28374. releaseSubMeshes(): AbstractMesh;
  28375. /**
  28376. * Releases resources associated with this abstract mesh.
  28377. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  28378. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  28379. */
  28380. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  28381. /**
  28382. * Adds the passed mesh as a child to the current mesh
  28383. * @param mesh defines the child mesh
  28384. * @returns the current mesh
  28385. */
  28386. addChild(mesh: AbstractMesh): AbstractMesh;
  28387. /**
  28388. * Removes the passed mesh from the current mesh children list
  28389. * @param mesh defines the child mesh
  28390. * @returns the current mesh
  28391. */
  28392. removeChild(mesh: AbstractMesh): AbstractMesh;
  28393. /** @hidden */
  28394. private _initFacetData;
  28395. /**
  28396. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  28397. * This method can be called within the render loop.
  28398. * 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
  28399. * @returns the current mesh
  28400. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28401. */
  28402. updateFacetData(): AbstractMesh;
  28403. /**
  28404. * Returns the facetLocalNormals array.
  28405. * The normals are expressed in the mesh local spac
  28406. * @returns an array of Vector3
  28407. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28408. */
  28409. getFacetLocalNormals(): Vector3[];
  28410. /**
  28411. * Returns the facetLocalPositions array.
  28412. * The facet positions are expressed in the mesh local space
  28413. * @returns an array of Vector3
  28414. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28415. */
  28416. getFacetLocalPositions(): Vector3[];
  28417. /**
  28418. * Returns the facetLocalPartioning array
  28419. * @returns an array of array of numbers
  28420. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28421. */
  28422. getFacetLocalPartitioning(): number[][];
  28423. /**
  28424. * Returns the i-th facet position in the world system.
  28425. * This method allocates a new Vector3 per call
  28426. * @param i defines the facet index
  28427. * @returns a new Vector3
  28428. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28429. */
  28430. getFacetPosition(i: number): Vector3;
  28431. /**
  28432. * Sets the reference Vector3 with the i-th facet position in the world system
  28433. * @param i defines the facet index
  28434. * @param ref defines the target vector
  28435. * @returns the current mesh
  28436. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28437. */
  28438. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  28439. /**
  28440. * Returns the i-th facet normal in the world system.
  28441. * This method allocates a new Vector3 per call
  28442. * @param i defines the facet index
  28443. * @returns a new Vector3
  28444. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28445. */
  28446. getFacetNormal(i: number): Vector3;
  28447. /**
  28448. * Sets the reference Vector3 with the i-th facet normal in the world system
  28449. * @param i defines the facet index
  28450. * @param ref defines the target vector
  28451. * @returns the current mesh
  28452. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28453. */
  28454. getFacetNormalToRef(i: number, ref: Vector3): this;
  28455. /**
  28456. * 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)
  28457. * @param x defines x coordinate
  28458. * @param y defines y coordinate
  28459. * @param z defines z coordinate
  28460. * @returns the array of facet indexes
  28461. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28462. */
  28463. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  28464. /**
  28465. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  28466. * @param projected sets as the (x,y,z) world projection on the facet
  28467. * @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
  28468. * @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
  28469. * @param x defines x coordinate
  28470. * @param y defines y coordinate
  28471. * @param z defines z coordinate
  28472. * @returns the face index if found (or null instead)
  28473. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28474. */
  28475. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  28476. /**
  28477. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  28478. * @param projected sets as the (x,y,z) local projection on the facet
  28479. * @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
  28480. * @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
  28481. * @param x defines x coordinate
  28482. * @param y defines y coordinate
  28483. * @param z defines z coordinate
  28484. * @returns the face index if found (or null instead)
  28485. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28486. */
  28487. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  28488. /**
  28489. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  28490. * @returns the parameters
  28491. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28492. */
  28493. getFacetDataParameters(): any;
  28494. /**
  28495. * Disables the feature FacetData and frees the related memory
  28496. * @returns the current mesh
  28497. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28498. */
  28499. disableFacetData(): AbstractMesh;
  28500. /**
  28501. * Updates the AbstractMesh indices array
  28502. * @param indices defines the data source
  28503. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  28504. * @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)
  28505. * @returns the current mesh
  28506. */
  28507. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  28508. /**
  28509. * Creates new normals data for the mesh
  28510. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  28511. * @returns the current mesh
  28512. */
  28513. createNormals(updatable: boolean): AbstractMesh;
  28514. /**
  28515. * Align the mesh with a normal
  28516. * @param normal defines the normal to use
  28517. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  28518. * @returns the current mesh
  28519. */
  28520. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  28521. /** @hidden */
  28522. _checkOcclusionQuery(): boolean;
  28523. /**
  28524. * Disables the mesh edge rendering mode
  28525. * @returns the currentAbstractMesh
  28526. */
  28527. disableEdgesRendering(): AbstractMesh;
  28528. /**
  28529. * Enables the edge rendering mode on the mesh.
  28530. * This mode makes the mesh edges visible
  28531. * @param epsilon defines the maximal distance between two angles to detect a face
  28532. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  28533. * @returns the currentAbstractMesh
  28534. * @see https://www.babylonjs-playground.com/#19O9TU#0
  28535. */
  28536. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  28537. }
  28538. }
  28539. declare module BABYLON {
  28540. /**
  28541. * Interface used to define ActionEvent
  28542. */
  28543. export interface IActionEvent {
  28544. /** The mesh or sprite that triggered the action */
  28545. source: any;
  28546. /** The X mouse cursor position at the time of the event */
  28547. pointerX: number;
  28548. /** The Y mouse cursor position at the time of the event */
  28549. pointerY: number;
  28550. /** The mesh that is currently pointed at (can be null) */
  28551. meshUnderPointer: Nullable<AbstractMesh>;
  28552. /** the original (browser) event that triggered the ActionEvent */
  28553. sourceEvent?: any;
  28554. /** additional data for the event */
  28555. additionalData?: any;
  28556. }
  28557. /**
  28558. * ActionEvent is the event being sent when an action is triggered.
  28559. */
  28560. export class ActionEvent implements IActionEvent {
  28561. /** The mesh or sprite that triggered the action */
  28562. source: any;
  28563. /** The X mouse cursor position at the time of the event */
  28564. pointerX: number;
  28565. /** The Y mouse cursor position at the time of the event */
  28566. pointerY: number;
  28567. /** The mesh that is currently pointed at (can be null) */
  28568. meshUnderPointer: Nullable<AbstractMesh>;
  28569. /** the original (browser) event that triggered the ActionEvent */
  28570. sourceEvent?: any;
  28571. /** additional data for the event */
  28572. additionalData?: any;
  28573. /**
  28574. * Creates a new ActionEvent
  28575. * @param source The mesh or sprite that triggered the action
  28576. * @param pointerX The X mouse cursor position at the time of the event
  28577. * @param pointerY The Y mouse cursor position at the time of the event
  28578. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  28579. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  28580. * @param additionalData additional data for the event
  28581. */
  28582. constructor(
  28583. /** The mesh or sprite that triggered the action */
  28584. source: any,
  28585. /** The X mouse cursor position at the time of the event */
  28586. pointerX: number,
  28587. /** The Y mouse cursor position at the time of the event */
  28588. pointerY: number,
  28589. /** The mesh that is currently pointed at (can be null) */
  28590. meshUnderPointer: Nullable<AbstractMesh>,
  28591. /** the original (browser) event that triggered the ActionEvent */
  28592. sourceEvent?: any,
  28593. /** additional data for the event */
  28594. additionalData?: any);
  28595. /**
  28596. * Helper function to auto-create an ActionEvent from a source mesh.
  28597. * @param source The source mesh that triggered the event
  28598. * @param evt The original (browser) event
  28599. * @param additionalData additional data for the event
  28600. * @returns the new ActionEvent
  28601. */
  28602. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  28603. /**
  28604. * Helper function to auto-create an ActionEvent from a source sprite
  28605. * @param source The source sprite that triggered the event
  28606. * @param scene Scene associated with the sprite
  28607. * @param evt The original (browser) event
  28608. * @param additionalData additional data for the event
  28609. * @returns the new ActionEvent
  28610. */
  28611. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  28612. /**
  28613. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  28614. * @param scene the scene where the event occurred
  28615. * @param evt The original (browser) event
  28616. * @returns the new ActionEvent
  28617. */
  28618. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  28619. /**
  28620. * Helper function to auto-create an ActionEvent from a primitive
  28621. * @param prim defines the target primitive
  28622. * @param pointerPos defines the pointer position
  28623. * @param evt The original (browser) event
  28624. * @param additionalData additional data for the event
  28625. * @returns the new ActionEvent
  28626. */
  28627. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  28628. }
  28629. }
  28630. declare module BABYLON {
  28631. /**
  28632. * Abstract class used to decouple action Manager from scene and meshes.
  28633. * Do not instantiate.
  28634. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  28635. */
  28636. export abstract class AbstractActionManager implements IDisposable {
  28637. /** Gets the list of active triggers */
  28638. static Triggers: {
  28639. [key: string]: number;
  28640. };
  28641. /** Gets the cursor to use when hovering items */
  28642. hoverCursor: string;
  28643. /** Gets the list of actions */
  28644. actions: IAction[];
  28645. /**
  28646. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  28647. */
  28648. isRecursive: boolean;
  28649. /**
  28650. * Releases all associated resources
  28651. */
  28652. abstract dispose(): void;
  28653. /**
  28654. * Does this action manager has pointer triggers
  28655. */
  28656. abstract get hasPointerTriggers(): boolean;
  28657. /**
  28658. * Does this action manager has pick triggers
  28659. */
  28660. abstract get hasPickTriggers(): boolean;
  28661. /**
  28662. * Process a specific trigger
  28663. * @param trigger defines the trigger to process
  28664. * @param evt defines the event details to be processed
  28665. */
  28666. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  28667. /**
  28668. * Does this action manager handles actions of any of the given triggers
  28669. * @param triggers defines the triggers to be tested
  28670. * @return a boolean indicating whether one (or more) of the triggers is handled
  28671. */
  28672. abstract hasSpecificTriggers(triggers: number[]): boolean;
  28673. /**
  28674. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  28675. * speed.
  28676. * @param triggerA defines the trigger to be tested
  28677. * @param triggerB defines the trigger to be tested
  28678. * @return a boolean indicating whether one (or more) of the triggers is handled
  28679. */
  28680. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  28681. /**
  28682. * Does this action manager handles actions of a given trigger
  28683. * @param trigger defines the trigger to be tested
  28684. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  28685. * @return whether the trigger is handled
  28686. */
  28687. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  28688. /**
  28689. * Serialize this manager to a JSON object
  28690. * @param name defines the property name to store this manager
  28691. * @returns a JSON representation of this manager
  28692. */
  28693. abstract serialize(name: string): any;
  28694. /**
  28695. * Registers an action to this action manager
  28696. * @param action defines the action to be registered
  28697. * @return the action amended (prepared) after registration
  28698. */
  28699. abstract registerAction(action: IAction): Nullable<IAction>;
  28700. /**
  28701. * Unregisters an action to this action manager
  28702. * @param action defines the action to be unregistered
  28703. * @return a boolean indicating whether the action has been unregistered
  28704. */
  28705. abstract unregisterAction(action: IAction): Boolean;
  28706. /**
  28707. * Does exist one action manager with at least one trigger
  28708. **/
  28709. static get HasTriggers(): boolean;
  28710. /**
  28711. * Does exist one action manager with at least one pick trigger
  28712. **/
  28713. static get HasPickTriggers(): boolean;
  28714. /**
  28715. * Does exist one action manager that handles actions of a given trigger
  28716. * @param trigger defines the trigger to be tested
  28717. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  28718. **/
  28719. static HasSpecificTrigger(trigger: number): boolean;
  28720. }
  28721. }
  28722. declare module BABYLON {
  28723. /**
  28724. * Defines how a node can be built from a string name.
  28725. */
  28726. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  28727. /**
  28728. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  28729. */
  28730. export class Node implements IBehaviorAware<Node> {
  28731. /** @hidden */
  28732. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  28733. private static _NodeConstructors;
  28734. /**
  28735. * Add a new node constructor
  28736. * @param type defines the type name of the node to construct
  28737. * @param constructorFunc defines the constructor function
  28738. */
  28739. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  28740. /**
  28741. * Returns a node constructor based on type name
  28742. * @param type defines the type name
  28743. * @param name defines the new node name
  28744. * @param scene defines the hosting scene
  28745. * @param options defines optional options to transmit to constructors
  28746. * @returns the new constructor or null
  28747. */
  28748. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  28749. /**
  28750. * Gets or sets the name of the node
  28751. */
  28752. name: string;
  28753. /**
  28754. * Gets or sets the id of the node
  28755. */
  28756. id: string;
  28757. /**
  28758. * Gets or sets the unique id of the node
  28759. */
  28760. uniqueId: number;
  28761. /**
  28762. * Gets or sets a string used to store user defined state for the node
  28763. */
  28764. state: string;
  28765. /**
  28766. * Gets or sets an object used to store user defined information for the node
  28767. */
  28768. metadata: any;
  28769. /**
  28770. * For internal use only. Please do not use.
  28771. */
  28772. reservedDataStore: any;
  28773. /**
  28774. * List of inspectable custom properties (used by the Inspector)
  28775. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  28776. */
  28777. inspectableCustomProperties: IInspectable[];
  28778. private _doNotSerialize;
  28779. /**
  28780. * Gets or sets a boolean used to define if the node must be serialized
  28781. */
  28782. get doNotSerialize(): boolean;
  28783. set doNotSerialize(value: boolean);
  28784. /** @hidden */
  28785. _isDisposed: boolean;
  28786. /**
  28787. * Gets a list of Animations associated with the node
  28788. */
  28789. animations: Animation[];
  28790. protected _ranges: {
  28791. [name: string]: Nullable<AnimationRange>;
  28792. };
  28793. /**
  28794. * Callback raised when the node is ready to be used
  28795. */
  28796. onReady: Nullable<(node: Node) => void>;
  28797. private _isEnabled;
  28798. private _isParentEnabled;
  28799. private _isReady;
  28800. /** @hidden */
  28801. _currentRenderId: number;
  28802. private _parentUpdateId;
  28803. /** @hidden */
  28804. _childUpdateId: number;
  28805. /** @hidden */
  28806. _waitingParentId: Nullable<string>;
  28807. /** @hidden */
  28808. _scene: Scene;
  28809. /** @hidden */
  28810. _cache: any;
  28811. private _parentNode;
  28812. private _children;
  28813. /** @hidden */
  28814. _worldMatrix: Matrix;
  28815. /** @hidden */
  28816. _worldMatrixDeterminant: number;
  28817. /** @hidden */
  28818. _worldMatrixDeterminantIsDirty: boolean;
  28819. /** @hidden */
  28820. private _sceneRootNodesIndex;
  28821. /**
  28822. * Gets a boolean indicating if the node has been disposed
  28823. * @returns true if the node was disposed
  28824. */
  28825. isDisposed(): boolean;
  28826. /**
  28827. * Gets or sets the parent of the node (without keeping the current position in the scene)
  28828. * @see https://doc.babylonjs.com/how_to/parenting
  28829. */
  28830. set parent(parent: Nullable<Node>);
  28831. get parent(): Nullable<Node>;
  28832. /** @hidden */
  28833. _addToSceneRootNodes(): void;
  28834. /** @hidden */
  28835. _removeFromSceneRootNodes(): void;
  28836. private _animationPropertiesOverride;
  28837. /**
  28838. * Gets or sets the animation properties override
  28839. */
  28840. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  28841. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  28842. /**
  28843. * Gets a string idenfifying the name of the class
  28844. * @returns "Node" string
  28845. */
  28846. getClassName(): string;
  28847. /** @hidden */
  28848. readonly _isNode: boolean;
  28849. /**
  28850. * An event triggered when the mesh is disposed
  28851. */
  28852. onDisposeObservable: Observable<Node>;
  28853. private _onDisposeObserver;
  28854. /**
  28855. * Sets a callback that will be raised when the node will be disposed
  28856. */
  28857. set onDispose(callback: () => void);
  28858. /**
  28859. * Creates a new Node
  28860. * @param name the name and id to be given to this node
  28861. * @param scene the scene this node will be added to
  28862. */
  28863. constructor(name: string, scene?: Nullable<Scene>);
  28864. /**
  28865. * Gets the scene of the node
  28866. * @returns a scene
  28867. */
  28868. getScene(): Scene;
  28869. /**
  28870. * Gets the engine of the node
  28871. * @returns a Engine
  28872. */
  28873. getEngine(): Engine;
  28874. private _behaviors;
  28875. /**
  28876. * Attach a behavior to the node
  28877. * @see http://doc.babylonjs.com/features/behaviour
  28878. * @param behavior defines the behavior to attach
  28879. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  28880. * @returns the current Node
  28881. */
  28882. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  28883. /**
  28884. * Remove an attached behavior
  28885. * @see http://doc.babylonjs.com/features/behaviour
  28886. * @param behavior defines the behavior to attach
  28887. * @returns the current Node
  28888. */
  28889. removeBehavior(behavior: Behavior<Node>): Node;
  28890. /**
  28891. * Gets the list of attached behaviors
  28892. * @see http://doc.babylonjs.com/features/behaviour
  28893. */
  28894. get behaviors(): Behavior<Node>[];
  28895. /**
  28896. * Gets an attached behavior by name
  28897. * @param name defines the name of the behavior to look for
  28898. * @see http://doc.babylonjs.com/features/behaviour
  28899. * @returns null if behavior was not found else the requested behavior
  28900. */
  28901. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  28902. /**
  28903. * Returns the latest update of the World matrix
  28904. * @returns a Matrix
  28905. */
  28906. getWorldMatrix(): Matrix;
  28907. /** @hidden */
  28908. _getWorldMatrixDeterminant(): number;
  28909. /**
  28910. * Returns directly the latest state of the mesh World matrix.
  28911. * A Matrix is returned.
  28912. */
  28913. get worldMatrixFromCache(): Matrix;
  28914. /** @hidden */
  28915. _initCache(): void;
  28916. /** @hidden */
  28917. updateCache(force?: boolean): void;
  28918. /** @hidden */
  28919. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  28920. /** @hidden */
  28921. _updateCache(ignoreParentClass?: boolean): void;
  28922. /** @hidden */
  28923. _isSynchronized(): boolean;
  28924. /** @hidden */
  28925. _markSyncedWithParent(): void;
  28926. /** @hidden */
  28927. isSynchronizedWithParent(): boolean;
  28928. /** @hidden */
  28929. isSynchronized(): boolean;
  28930. /**
  28931. * Is this node ready to be used/rendered
  28932. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  28933. * @return true if the node is ready
  28934. */
  28935. isReady(completeCheck?: boolean): boolean;
  28936. /**
  28937. * Is this node enabled?
  28938. * 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
  28939. * @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
  28940. * @return whether this node (and its parent) is enabled
  28941. */
  28942. isEnabled(checkAncestors?: boolean): boolean;
  28943. /** @hidden */
  28944. protected _syncParentEnabledState(): void;
  28945. /**
  28946. * Set the enabled state of this node
  28947. * @param value defines the new enabled state
  28948. */
  28949. setEnabled(value: boolean): void;
  28950. /**
  28951. * Is this node a descendant of the given node?
  28952. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  28953. * @param ancestor defines the parent node to inspect
  28954. * @returns a boolean indicating if this node is a descendant of the given node
  28955. */
  28956. isDescendantOf(ancestor: Node): boolean;
  28957. /** @hidden */
  28958. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  28959. /**
  28960. * Will return all nodes that have this node as ascendant
  28961. * @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
  28962. * @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
  28963. * @return all children nodes of all types
  28964. */
  28965. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  28966. /**
  28967. * Get all child-meshes of this node
  28968. * @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)
  28969. * @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
  28970. * @returns an array of AbstractMesh
  28971. */
  28972. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  28973. /**
  28974. * Get all direct children of this node
  28975. * @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
  28976. * @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)
  28977. * @returns an array of Node
  28978. */
  28979. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  28980. /** @hidden */
  28981. _setReady(state: boolean): void;
  28982. /**
  28983. * Get an animation by name
  28984. * @param name defines the name of the animation to look for
  28985. * @returns null if not found else the requested animation
  28986. */
  28987. getAnimationByName(name: string): Nullable<Animation>;
  28988. /**
  28989. * Creates an animation range for this node
  28990. * @param name defines the name of the range
  28991. * @param from defines the starting key
  28992. * @param to defines the end key
  28993. */
  28994. createAnimationRange(name: string, from: number, to: number): void;
  28995. /**
  28996. * Delete a specific animation range
  28997. * @param name defines the name of the range to delete
  28998. * @param deleteFrames defines if animation frames from the range must be deleted as well
  28999. */
  29000. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  29001. /**
  29002. * Get an animation range by name
  29003. * @param name defines the name of the animation range to look for
  29004. * @returns null if not found else the requested animation range
  29005. */
  29006. getAnimationRange(name: string): Nullable<AnimationRange>;
  29007. /**
  29008. * Gets the list of all animation ranges defined on this node
  29009. * @returns an array
  29010. */
  29011. getAnimationRanges(): Nullable<AnimationRange>[];
  29012. /**
  29013. * Will start the animation sequence
  29014. * @param name defines the range frames for animation sequence
  29015. * @param loop defines if the animation should loop (false by default)
  29016. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  29017. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  29018. * @returns the object created for this animation. If range does not exist, it will return null
  29019. */
  29020. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  29021. /**
  29022. * Serialize animation ranges into a JSON compatible object
  29023. * @returns serialization object
  29024. */
  29025. serializeAnimationRanges(): any;
  29026. /**
  29027. * Computes the world matrix of the node
  29028. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  29029. * @returns the world matrix
  29030. */
  29031. computeWorldMatrix(force?: boolean): Matrix;
  29032. /**
  29033. * Releases resources associated with this node.
  29034. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29035. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29036. */
  29037. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29038. /**
  29039. * Parse animation range data from a serialization object and store them into a given node
  29040. * @param node defines where to store the animation ranges
  29041. * @param parsedNode defines the serialization object to read data from
  29042. * @param scene defines the hosting scene
  29043. */
  29044. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  29045. /**
  29046. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  29047. * @param includeDescendants Include bounding info from descendants as well (true by default)
  29048. * @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
  29049. * @returns the new bounding vectors
  29050. */
  29051. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  29052. min: Vector3;
  29053. max: Vector3;
  29054. };
  29055. }
  29056. }
  29057. declare module BABYLON {
  29058. /**
  29059. * @hidden
  29060. */
  29061. export class _IAnimationState {
  29062. key: number;
  29063. repeatCount: number;
  29064. workValue?: any;
  29065. loopMode?: number;
  29066. offsetValue?: any;
  29067. highLimitValue?: any;
  29068. }
  29069. /**
  29070. * Class used to store any kind of animation
  29071. */
  29072. export class Animation {
  29073. /**Name of the animation */
  29074. name: string;
  29075. /**Property to animate */
  29076. targetProperty: string;
  29077. /**The frames per second of the animation */
  29078. framePerSecond: number;
  29079. /**The data type of the animation */
  29080. dataType: number;
  29081. /**The loop mode of the animation */
  29082. loopMode?: number | undefined;
  29083. /**Specifies if blending should be enabled */
  29084. enableBlending?: boolean | undefined;
  29085. /**
  29086. * Use matrix interpolation instead of using direct key value when animating matrices
  29087. */
  29088. static AllowMatricesInterpolation: boolean;
  29089. /**
  29090. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  29091. */
  29092. static AllowMatrixDecomposeForInterpolation: boolean;
  29093. /**
  29094. * Stores the key frames of the animation
  29095. */
  29096. private _keys;
  29097. /**
  29098. * Stores the easing function of the animation
  29099. */
  29100. private _easingFunction;
  29101. /**
  29102. * @hidden Internal use only
  29103. */
  29104. _runtimeAnimations: RuntimeAnimation[];
  29105. /**
  29106. * The set of event that will be linked to this animation
  29107. */
  29108. private _events;
  29109. /**
  29110. * Stores an array of target property paths
  29111. */
  29112. targetPropertyPath: string[];
  29113. /**
  29114. * Stores the blending speed of the animation
  29115. */
  29116. blendingSpeed: number;
  29117. /**
  29118. * Stores the animation ranges for the animation
  29119. */
  29120. private _ranges;
  29121. /**
  29122. * @hidden Internal use
  29123. */
  29124. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  29125. /**
  29126. * Sets up an animation
  29127. * @param property The property to animate
  29128. * @param animationType The animation type to apply
  29129. * @param framePerSecond The frames per second of the animation
  29130. * @param easingFunction The easing function used in the animation
  29131. * @returns The created animation
  29132. */
  29133. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  29134. /**
  29135. * Create and start an animation on a node
  29136. * @param name defines the name of the global animation that will be run on all nodes
  29137. * @param node defines the root node where the animation will take place
  29138. * @param targetProperty defines property to animate
  29139. * @param framePerSecond defines the number of frame per second yo use
  29140. * @param totalFrame defines the number of frames in total
  29141. * @param from defines the initial value
  29142. * @param to defines the final value
  29143. * @param loopMode defines which loop mode you want to use (off by default)
  29144. * @param easingFunction defines the easing function to use (linear by default)
  29145. * @param onAnimationEnd defines the callback to call when animation end
  29146. * @returns the animatable created for this animation
  29147. */
  29148. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  29149. /**
  29150. * Create and start an animation on a node and its descendants
  29151. * @param name defines the name of the global animation that will be run on all nodes
  29152. * @param node defines the root node where the animation will take place
  29153. * @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
  29154. * @param targetProperty defines property to animate
  29155. * @param framePerSecond defines the number of frame per second to use
  29156. * @param totalFrame defines the number of frames in total
  29157. * @param from defines the initial value
  29158. * @param to defines the final value
  29159. * @param loopMode defines which loop mode you want to use (off by default)
  29160. * @param easingFunction defines the easing function to use (linear by default)
  29161. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  29162. * @returns the list of animatables created for all nodes
  29163. * @example https://www.babylonjs-playground.com/#MH0VLI
  29164. */
  29165. 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[]>;
  29166. /**
  29167. * Creates a new animation, merges it with the existing animations and starts it
  29168. * @param name Name of the animation
  29169. * @param node Node which contains the scene that begins the animations
  29170. * @param targetProperty Specifies which property to animate
  29171. * @param framePerSecond The frames per second of the animation
  29172. * @param totalFrame The total number of frames
  29173. * @param from The frame at the beginning of the animation
  29174. * @param to The frame at the end of the animation
  29175. * @param loopMode Specifies the loop mode of the animation
  29176. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  29177. * @param onAnimationEnd Callback to run once the animation is complete
  29178. * @returns Nullable animation
  29179. */
  29180. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  29181. /**
  29182. * Transition property of an host to the target Value
  29183. * @param property The property to transition
  29184. * @param targetValue The target Value of the property
  29185. * @param host The object where the property to animate belongs
  29186. * @param scene Scene used to run the animation
  29187. * @param frameRate Framerate (in frame/s) to use
  29188. * @param transition The transition type we want to use
  29189. * @param duration The duration of the animation, in milliseconds
  29190. * @param onAnimationEnd Callback trigger at the end of the animation
  29191. * @returns Nullable animation
  29192. */
  29193. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  29194. /**
  29195. * Return the array of runtime animations currently using this animation
  29196. */
  29197. get runtimeAnimations(): RuntimeAnimation[];
  29198. /**
  29199. * Specifies if any of the runtime animations are currently running
  29200. */
  29201. get hasRunningRuntimeAnimations(): boolean;
  29202. /**
  29203. * Initializes the animation
  29204. * @param name Name of the animation
  29205. * @param targetProperty Property to animate
  29206. * @param framePerSecond The frames per second of the animation
  29207. * @param dataType The data type of the animation
  29208. * @param loopMode The loop mode of the animation
  29209. * @param enableBlending Specifies if blending should be enabled
  29210. */
  29211. constructor(
  29212. /**Name of the animation */
  29213. name: string,
  29214. /**Property to animate */
  29215. targetProperty: string,
  29216. /**The frames per second of the animation */
  29217. framePerSecond: number,
  29218. /**The data type of the animation */
  29219. dataType: number,
  29220. /**The loop mode of the animation */
  29221. loopMode?: number | undefined,
  29222. /**Specifies if blending should be enabled */
  29223. enableBlending?: boolean | undefined);
  29224. /**
  29225. * Converts the animation to a string
  29226. * @param fullDetails support for multiple levels of logging within scene loading
  29227. * @returns String form of the animation
  29228. */
  29229. toString(fullDetails?: boolean): string;
  29230. /**
  29231. * Add an event to this animation
  29232. * @param event Event to add
  29233. */
  29234. addEvent(event: AnimationEvent): void;
  29235. /**
  29236. * Remove all events found at the given frame
  29237. * @param frame The frame to remove events from
  29238. */
  29239. removeEvents(frame: number): void;
  29240. /**
  29241. * Retrieves all the events from the animation
  29242. * @returns Events from the animation
  29243. */
  29244. getEvents(): AnimationEvent[];
  29245. /**
  29246. * Creates an animation range
  29247. * @param name Name of the animation range
  29248. * @param from Starting frame of the animation range
  29249. * @param to Ending frame of the animation
  29250. */
  29251. createRange(name: string, from: number, to: number): void;
  29252. /**
  29253. * Deletes an animation range by name
  29254. * @param name Name of the animation range to delete
  29255. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  29256. */
  29257. deleteRange(name: string, deleteFrames?: boolean): void;
  29258. /**
  29259. * Gets the animation range by name, or null if not defined
  29260. * @param name Name of the animation range
  29261. * @returns Nullable animation range
  29262. */
  29263. getRange(name: string): Nullable<AnimationRange>;
  29264. /**
  29265. * Gets the key frames from the animation
  29266. * @returns The key frames of the animation
  29267. */
  29268. getKeys(): Array<IAnimationKey>;
  29269. /**
  29270. * Gets the highest frame rate of the animation
  29271. * @returns Highest frame rate of the animation
  29272. */
  29273. getHighestFrame(): number;
  29274. /**
  29275. * Gets the easing function of the animation
  29276. * @returns Easing function of the animation
  29277. */
  29278. getEasingFunction(): IEasingFunction;
  29279. /**
  29280. * Sets the easing function of the animation
  29281. * @param easingFunction A custom mathematical formula for animation
  29282. */
  29283. setEasingFunction(easingFunction: EasingFunction): void;
  29284. /**
  29285. * Interpolates a scalar linearly
  29286. * @param startValue Start value of the animation curve
  29287. * @param endValue End value of the animation curve
  29288. * @param gradient Scalar amount to interpolate
  29289. * @returns Interpolated scalar value
  29290. */
  29291. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  29292. /**
  29293. * Interpolates a scalar cubically
  29294. * @param startValue Start value of the animation curve
  29295. * @param outTangent End tangent of the animation
  29296. * @param endValue End value of the animation curve
  29297. * @param inTangent Start tangent of the animation curve
  29298. * @param gradient Scalar amount to interpolate
  29299. * @returns Interpolated scalar value
  29300. */
  29301. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  29302. /**
  29303. * Interpolates a quaternion using a spherical linear interpolation
  29304. * @param startValue Start value of the animation curve
  29305. * @param endValue End value of the animation curve
  29306. * @param gradient Scalar amount to interpolate
  29307. * @returns Interpolated quaternion value
  29308. */
  29309. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  29310. /**
  29311. * Interpolates a quaternion cubically
  29312. * @param startValue Start value of the animation curve
  29313. * @param outTangent End tangent of the animation curve
  29314. * @param endValue End value of the animation curve
  29315. * @param inTangent Start tangent of the animation curve
  29316. * @param gradient Scalar amount to interpolate
  29317. * @returns Interpolated quaternion value
  29318. */
  29319. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  29320. /**
  29321. * Interpolates a Vector3 linearl
  29322. * @param startValue Start value of the animation curve
  29323. * @param endValue End value of the animation curve
  29324. * @param gradient Scalar amount to interpolate
  29325. * @returns Interpolated scalar value
  29326. */
  29327. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  29328. /**
  29329. * Interpolates a Vector3 cubically
  29330. * @param startValue Start value of the animation curve
  29331. * @param outTangent End tangent of the animation
  29332. * @param endValue End value of the animation curve
  29333. * @param inTangent Start tangent of the animation curve
  29334. * @param gradient Scalar amount to interpolate
  29335. * @returns InterpolatedVector3 value
  29336. */
  29337. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  29338. /**
  29339. * Interpolates a Vector2 linearly
  29340. * @param startValue Start value of the animation curve
  29341. * @param endValue End value of the animation curve
  29342. * @param gradient Scalar amount to interpolate
  29343. * @returns Interpolated Vector2 value
  29344. */
  29345. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  29346. /**
  29347. * Interpolates a Vector2 cubically
  29348. * @param startValue Start value of the animation curve
  29349. * @param outTangent End tangent of the animation
  29350. * @param endValue End value of the animation curve
  29351. * @param inTangent Start tangent of the animation curve
  29352. * @param gradient Scalar amount to interpolate
  29353. * @returns Interpolated Vector2 value
  29354. */
  29355. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  29356. /**
  29357. * Interpolates a size linearly
  29358. * @param startValue Start value of the animation curve
  29359. * @param endValue End value of the animation curve
  29360. * @param gradient Scalar amount to interpolate
  29361. * @returns Interpolated Size value
  29362. */
  29363. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  29364. /**
  29365. * Interpolates a Color3 linearly
  29366. * @param startValue Start value of the animation curve
  29367. * @param endValue End value of the animation curve
  29368. * @param gradient Scalar amount to interpolate
  29369. * @returns Interpolated Color3 value
  29370. */
  29371. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  29372. /**
  29373. * Interpolates a Color4 linearly
  29374. * @param startValue Start value of the animation curve
  29375. * @param endValue End value of the animation curve
  29376. * @param gradient Scalar amount to interpolate
  29377. * @returns Interpolated Color3 value
  29378. */
  29379. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  29380. /**
  29381. * @hidden Internal use only
  29382. */
  29383. _getKeyValue(value: any): any;
  29384. /**
  29385. * @hidden Internal use only
  29386. */
  29387. _interpolate(currentFrame: number, state: _IAnimationState): any;
  29388. /**
  29389. * Defines the function to use to interpolate matrices
  29390. * @param startValue defines the start matrix
  29391. * @param endValue defines the end matrix
  29392. * @param gradient defines the gradient between both matrices
  29393. * @param result defines an optional target matrix where to store the interpolation
  29394. * @returns the interpolated matrix
  29395. */
  29396. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  29397. /**
  29398. * Makes a copy of the animation
  29399. * @returns Cloned animation
  29400. */
  29401. clone(): Animation;
  29402. /**
  29403. * Sets the key frames of the animation
  29404. * @param values The animation key frames to set
  29405. */
  29406. setKeys(values: Array<IAnimationKey>): void;
  29407. /**
  29408. * Serializes the animation to an object
  29409. * @returns Serialized object
  29410. */
  29411. serialize(): any;
  29412. /**
  29413. * Float animation type
  29414. */
  29415. static readonly ANIMATIONTYPE_FLOAT: number;
  29416. /**
  29417. * Vector3 animation type
  29418. */
  29419. static readonly ANIMATIONTYPE_VECTOR3: number;
  29420. /**
  29421. * Quaternion animation type
  29422. */
  29423. static readonly ANIMATIONTYPE_QUATERNION: number;
  29424. /**
  29425. * Matrix animation type
  29426. */
  29427. static readonly ANIMATIONTYPE_MATRIX: number;
  29428. /**
  29429. * Color3 animation type
  29430. */
  29431. static readonly ANIMATIONTYPE_COLOR3: number;
  29432. /**
  29433. * Color3 animation type
  29434. */
  29435. static readonly ANIMATIONTYPE_COLOR4: number;
  29436. /**
  29437. * Vector2 animation type
  29438. */
  29439. static readonly ANIMATIONTYPE_VECTOR2: number;
  29440. /**
  29441. * Size animation type
  29442. */
  29443. static readonly ANIMATIONTYPE_SIZE: number;
  29444. /**
  29445. * Relative Loop Mode
  29446. */
  29447. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  29448. /**
  29449. * Cycle Loop Mode
  29450. */
  29451. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  29452. /**
  29453. * Constant Loop Mode
  29454. */
  29455. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  29456. /** @hidden */
  29457. static _UniversalLerp(left: any, right: any, amount: number): any;
  29458. /**
  29459. * Parses an animation object and creates an animation
  29460. * @param parsedAnimation Parsed animation object
  29461. * @returns Animation object
  29462. */
  29463. static Parse(parsedAnimation: any): Animation;
  29464. /**
  29465. * Appends the serialized animations from the source animations
  29466. * @param source Source containing the animations
  29467. * @param destination Target to store the animations
  29468. */
  29469. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  29470. }
  29471. }
  29472. declare module BABYLON {
  29473. /**
  29474. * Interface containing an array of animations
  29475. */
  29476. export interface IAnimatable {
  29477. /**
  29478. * Array of animations
  29479. */
  29480. animations: Nullable<Array<Animation>>;
  29481. }
  29482. }
  29483. declare module BABYLON {
  29484. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  29485. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29486. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29487. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29488. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29489. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29490. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29491. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29492. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29493. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29494. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29495. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29496. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29497. /**
  29498. * Decorator used to define property that can be serialized as reference to a camera
  29499. * @param sourceName defines the name of the property to decorate
  29500. */
  29501. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29502. /**
  29503. * Class used to help serialization objects
  29504. */
  29505. export class SerializationHelper {
  29506. /** @hidden */
  29507. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  29508. /** @hidden */
  29509. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  29510. /** @hidden */
  29511. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  29512. /** @hidden */
  29513. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  29514. /**
  29515. * Appends the serialized animations from the source animations
  29516. * @param source Source containing the animations
  29517. * @param destination Target to store the animations
  29518. */
  29519. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  29520. /**
  29521. * Static function used to serialized a specific entity
  29522. * @param entity defines the entity to serialize
  29523. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  29524. * @returns a JSON compatible object representing the serialization of the entity
  29525. */
  29526. static Serialize<T>(entity: T, serializationObject?: any): any;
  29527. /**
  29528. * Creates a new entity from a serialization data object
  29529. * @param creationFunction defines a function used to instanciated the new entity
  29530. * @param source defines the source serialization data
  29531. * @param scene defines the hosting scene
  29532. * @param rootUrl defines the root url for resources
  29533. * @returns a new entity
  29534. */
  29535. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  29536. /**
  29537. * Clones an object
  29538. * @param creationFunction defines the function used to instanciate the new object
  29539. * @param source defines the source object
  29540. * @returns the cloned object
  29541. */
  29542. static Clone<T>(creationFunction: () => T, source: T): T;
  29543. /**
  29544. * Instanciates a new object based on a source one (some data will be shared between both object)
  29545. * @param creationFunction defines the function used to instanciate the new object
  29546. * @param source defines the source object
  29547. * @returns the new object
  29548. */
  29549. static Instanciate<T>(creationFunction: () => T, source: T): T;
  29550. }
  29551. }
  29552. declare module BABYLON {
  29553. /**
  29554. * Class used to manipulate GUIDs
  29555. */
  29556. export class GUID {
  29557. /**
  29558. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  29559. * Be aware Math.random() could cause collisions, but:
  29560. * "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"
  29561. * @returns a pseudo random id
  29562. */
  29563. static RandomId(): string;
  29564. }
  29565. }
  29566. declare module BABYLON {
  29567. /**
  29568. * Base class of all the textures in babylon.
  29569. * It groups all the common properties the materials, post process, lights... might need
  29570. * in order to make a correct use of the texture.
  29571. */
  29572. export class BaseTexture implements IAnimatable {
  29573. /**
  29574. * Default anisotropic filtering level for the application.
  29575. * It is set to 4 as a good tradeoff between perf and quality.
  29576. */
  29577. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  29578. /**
  29579. * Gets or sets the unique id of the texture
  29580. */
  29581. uniqueId: number;
  29582. /**
  29583. * Define the name of the texture.
  29584. */
  29585. name: string;
  29586. /**
  29587. * Gets or sets an object used to store user defined information.
  29588. */
  29589. metadata: any;
  29590. /**
  29591. * For internal use only. Please do not use.
  29592. */
  29593. reservedDataStore: any;
  29594. private _hasAlpha;
  29595. /**
  29596. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  29597. */
  29598. set hasAlpha(value: boolean);
  29599. get hasAlpha(): boolean;
  29600. /**
  29601. * Defines if the alpha value should be determined via the rgb values.
  29602. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  29603. */
  29604. getAlphaFromRGB: boolean;
  29605. /**
  29606. * Intensity or strength of the texture.
  29607. * It is commonly used by materials to fine tune the intensity of the texture
  29608. */
  29609. level: number;
  29610. /**
  29611. * Define the UV chanel to use starting from 0 and defaulting to 0.
  29612. * This is part of the texture as textures usually maps to one uv set.
  29613. */
  29614. coordinatesIndex: number;
  29615. private _coordinatesMode;
  29616. /**
  29617. * How a texture is mapped.
  29618. *
  29619. * | Value | Type | Description |
  29620. * | ----- | ----------------------------------- | ----------- |
  29621. * | 0 | EXPLICIT_MODE | |
  29622. * | 1 | SPHERICAL_MODE | |
  29623. * | 2 | PLANAR_MODE | |
  29624. * | 3 | CUBIC_MODE | |
  29625. * | 4 | PROJECTION_MODE | |
  29626. * | 5 | SKYBOX_MODE | |
  29627. * | 6 | INVCUBIC_MODE | |
  29628. * | 7 | EQUIRECTANGULAR_MODE | |
  29629. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  29630. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  29631. */
  29632. set coordinatesMode(value: number);
  29633. get coordinatesMode(): number;
  29634. /**
  29635. * | Value | Type | Description |
  29636. * | ----- | ------------------ | ----------- |
  29637. * | 0 | CLAMP_ADDRESSMODE | |
  29638. * | 1 | WRAP_ADDRESSMODE | |
  29639. * | 2 | MIRROR_ADDRESSMODE | |
  29640. */
  29641. wrapU: number;
  29642. /**
  29643. * | Value | Type | Description |
  29644. * | ----- | ------------------ | ----------- |
  29645. * | 0 | CLAMP_ADDRESSMODE | |
  29646. * | 1 | WRAP_ADDRESSMODE | |
  29647. * | 2 | MIRROR_ADDRESSMODE | |
  29648. */
  29649. wrapV: number;
  29650. /**
  29651. * | Value | Type | Description |
  29652. * | ----- | ------------------ | ----------- |
  29653. * | 0 | CLAMP_ADDRESSMODE | |
  29654. * | 1 | WRAP_ADDRESSMODE | |
  29655. * | 2 | MIRROR_ADDRESSMODE | |
  29656. */
  29657. wrapR: number;
  29658. /**
  29659. * With compliant hardware and browser (supporting anisotropic filtering)
  29660. * this defines the level of anisotropic filtering in the texture.
  29661. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  29662. */
  29663. anisotropicFilteringLevel: number;
  29664. /**
  29665. * Define if the texture is a cube texture or if false a 2d texture.
  29666. */
  29667. get isCube(): boolean;
  29668. set isCube(value: boolean);
  29669. /**
  29670. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  29671. */
  29672. get is3D(): boolean;
  29673. set is3D(value: boolean);
  29674. /**
  29675. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  29676. */
  29677. get is2DArray(): boolean;
  29678. set is2DArray(value: boolean);
  29679. /**
  29680. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  29681. * HDR texture are usually stored in linear space.
  29682. * This only impacts the PBR and Background materials
  29683. */
  29684. gammaSpace: boolean;
  29685. /**
  29686. * Gets or sets whether or not the texture contains RGBD data.
  29687. */
  29688. get isRGBD(): boolean;
  29689. set isRGBD(value: boolean);
  29690. /**
  29691. * Is Z inverted in the texture (useful in a cube texture).
  29692. */
  29693. invertZ: boolean;
  29694. /**
  29695. * Are mip maps generated for this texture or not.
  29696. */
  29697. get noMipmap(): boolean;
  29698. /**
  29699. * @hidden
  29700. */
  29701. lodLevelInAlpha: boolean;
  29702. /**
  29703. * With prefiltered texture, defined the offset used during the prefiltering steps.
  29704. */
  29705. get lodGenerationOffset(): number;
  29706. set lodGenerationOffset(value: number);
  29707. /**
  29708. * With prefiltered texture, defined the scale used during the prefiltering steps.
  29709. */
  29710. get lodGenerationScale(): number;
  29711. set lodGenerationScale(value: number);
  29712. /**
  29713. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  29714. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  29715. * average roughness values.
  29716. */
  29717. get linearSpecularLOD(): boolean;
  29718. set linearSpecularLOD(value: boolean);
  29719. /**
  29720. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  29721. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  29722. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  29723. */
  29724. get irradianceTexture(): Nullable<BaseTexture>;
  29725. set irradianceTexture(value: Nullable<BaseTexture>);
  29726. /**
  29727. * Define if the texture is a render target.
  29728. */
  29729. isRenderTarget: boolean;
  29730. /**
  29731. * Define the unique id of the texture in the scene.
  29732. */
  29733. get uid(): string;
  29734. /**
  29735. * Return a string representation of the texture.
  29736. * @returns the texture as a string
  29737. */
  29738. toString(): string;
  29739. /**
  29740. * Get the class name of the texture.
  29741. * @returns "BaseTexture"
  29742. */
  29743. getClassName(): string;
  29744. /**
  29745. * Define the list of animation attached to the texture.
  29746. */
  29747. animations: Animation[];
  29748. /**
  29749. * An event triggered when the texture is disposed.
  29750. */
  29751. onDisposeObservable: Observable<BaseTexture>;
  29752. private _onDisposeObserver;
  29753. /**
  29754. * Callback triggered when the texture has been disposed.
  29755. * Kept for back compatibility, you can use the onDisposeObservable instead.
  29756. */
  29757. set onDispose(callback: () => void);
  29758. /**
  29759. * Define the current state of the loading sequence when in delayed load mode.
  29760. */
  29761. delayLoadState: number;
  29762. private _scene;
  29763. /** @hidden */
  29764. _texture: Nullable<InternalTexture>;
  29765. private _uid;
  29766. /**
  29767. * Define if the texture is preventinga material to render or not.
  29768. * If not and the texture is not ready, the engine will use a default black texture instead.
  29769. */
  29770. get isBlocking(): boolean;
  29771. /**
  29772. * Instantiates a new BaseTexture.
  29773. * Base class of all the textures in babylon.
  29774. * It groups all the common properties the materials, post process, lights... might need
  29775. * in order to make a correct use of the texture.
  29776. * @param scene Define the scene the texture blongs to
  29777. */
  29778. constructor(scene: Nullable<Scene>);
  29779. /**
  29780. * Get the scene the texture belongs to.
  29781. * @returns the scene or null if undefined
  29782. */
  29783. getScene(): Nullable<Scene>;
  29784. /**
  29785. * Get the texture transform matrix used to offset tile the texture for istance.
  29786. * @returns the transformation matrix
  29787. */
  29788. getTextureMatrix(): Matrix;
  29789. /**
  29790. * Get the texture reflection matrix used to rotate/transform the reflection.
  29791. * @returns the reflection matrix
  29792. */
  29793. getReflectionTextureMatrix(): Matrix;
  29794. /**
  29795. * Get the underlying lower level texture from Babylon.
  29796. * @returns the insternal texture
  29797. */
  29798. getInternalTexture(): Nullable<InternalTexture>;
  29799. /**
  29800. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  29801. * @returns true if ready or not blocking
  29802. */
  29803. isReadyOrNotBlocking(): boolean;
  29804. /**
  29805. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  29806. * @returns true if fully ready
  29807. */
  29808. isReady(): boolean;
  29809. private _cachedSize;
  29810. /**
  29811. * Get the size of the texture.
  29812. * @returns the texture size.
  29813. */
  29814. getSize(): ISize;
  29815. /**
  29816. * Get the base size of the texture.
  29817. * It can be different from the size if the texture has been resized for POT for instance
  29818. * @returns the base size
  29819. */
  29820. getBaseSize(): ISize;
  29821. /**
  29822. * Update the sampling mode of the texture.
  29823. * Default is Trilinear mode.
  29824. *
  29825. * | Value | Type | Description |
  29826. * | ----- | ------------------ | ----------- |
  29827. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  29828. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  29829. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  29830. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  29831. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  29832. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  29833. * | 7 | NEAREST_LINEAR | |
  29834. * | 8 | NEAREST_NEAREST | |
  29835. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  29836. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  29837. * | 11 | LINEAR_LINEAR | |
  29838. * | 12 | LINEAR_NEAREST | |
  29839. *
  29840. * > _mag_: magnification filter (close to the viewer)
  29841. * > _min_: minification filter (far from the viewer)
  29842. * > _mip_: filter used between mip map levels
  29843. *@param samplingMode Define the new sampling mode of the texture
  29844. */
  29845. updateSamplingMode(samplingMode: number): void;
  29846. /**
  29847. * Scales the texture if is `canRescale()`
  29848. * @param ratio the resize factor we want to use to rescale
  29849. */
  29850. scale(ratio: number): void;
  29851. /**
  29852. * Get if the texture can rescale.
  29853. */
  29854. get canRescale(): boolean;
  29855. /** @hidden */
  29856. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  29857. /** @hidden */
  29858. _rebuild(): void;
  29859. /**
  29860. * Triggers the load sequence in delayed load mode.
  29861. */
  29862. delayLoad(): void;
  29863. /**
  29864. * Clones the texture.
  29865. * @returns the cloned texture
  29866. */
  29867. clone(): Nullable<BaseTexture>;
  29868. /**
  29869. * Get the texture underlying type (INT, FLOAT...)
  29870. */
  29871. get textureType(): number;
  29872. /**
  29873. * Get the texture underlying format (RGB, RGBA...)
  29874. */
  29875. get textureFormat(): number;
  29876. /**
  29877. * Indicates that textures need to be re-calculated for all materials
  29878. */
  29879. protected _markAllSubMeshesAsTexturesDirty(): void;
  29880. /**
  29881. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  29882. * This will returns an RGBA array buffer containing either in values (0-255) or
  29883. * float values (0-1) depending of the underlying buffer type.
  29884. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  29885. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  29886. * @param buffer defines a user defined buffer to fill with data (can be null)
  29887. * @returns The Array buffer containing the pixels data.
  29888. */
  29889. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  29890. /**
  29891. * Release and destroy the underlying lower level texture aka internalTexture.
  29892. */
  29893. releaseInternalTexture(): void;
  29894. /** @hidden */
  29895. get _lodTextureHigh(): Nullable<BaseTexture>;
  29896. /** @hidden */
  29897. get _lodTextureMid(): Nullable<BaseTexture>;
  29898. /** @hidden */
  29899. get _lodTextureLow(): Nullable<BaseTexture>;
  29900. /**
  29901. * Dispose the texture and release its associated resources.
  29902. */
  29903. dispose(): void;
  29904. /**
  29905. * Serialize the texture into a JSON representation that can be parsed later on.
  29906. * @returns the JSON representation of the texture
  29907. */
  29908. serialize(): any;
  29909. /**
  29910. * Helper function to be called back once a list of texture contains only ready textures.
  29911. * @param textures Define the list of textures to wait for
  29912. * @param callback Define the callback triggered once the entire list will be ready
  29913. */
  29914. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  29915. }
  29916. }
  29917. declare module BABYLON {
  29918. /**
  29919. * Options to be used when creating an effect.
  29920. */
  29921. export interface IEffectCreationOptions {
  29922. /**
  29923. * Atrributes that will be used in the shader.
  29924. */
  29925. attributes: string[];
  29926. /**
  29927. * Uniform varible names that will be set in the shader.
  29928. */
  29929. uniformsNames: string[];
  29930. /**
  29931. * Uniform buffer variable names that will be set in the shader.
  29932. */
  29933. uniformBuffersNames: string[];
  29934. /**
  29935. * Sampler texture variable names that will be set in the shader.
  29936. */
  29937. samplers: string[];
  29938. /**
  29939. * Define statements that will be set in the shader.
  29940. */
  29941. defines: any;
  29942. /**
  29943. * Possible fallbacks for this effect to improve performance when needed.
  29944. */
  29945. fallbacks: Nullable<IEffectFallbacks>;
  29946. /**
  29947. * Callback that will be called when the shader is compiled.
  29948. */
  29949. onCompiled: Nullable<(effect: Effect) => void>;
  29950. /**
  29951. * Callback that will be called if an error occurs during shader compilation.
  29952. */
  29953. onError: Nullable<(effect: Effect, errors: string) => void>;
  29954. /**
  29955. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29956. */
  29957. indexParameters?: any;
  29958. /**
  29959. * Max number of lights that can be used in the shader.
  29960. */
  29961. maxSimultaneousLights?: number;
  29962. /**
  29963. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  29964. */
  29965. transformFeedbackVaryings?: Nullable<string[]>;
  29966. }
  29967. /**
  29968. * Effect containing vertex and fragment shader that can be executed on an object.
  29969. */
  29970. export class Effect implements IDisposable {
  29971. /**
  29972. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  29973. */
  29974. static ShadersRepository: string;
  29975. /**
  29976. * Name of the effect.
  29977. */
  29978. name: any;
  29979. /**
  29980. * String container all the define statements that should be set on the shader.
  29981. */
  29982. defines: string;
  29983. /**
  29984. * Callback that will be called when the shader is compiled.
  29985. */
  29986. onCompiled: Nullable<(effect: Effect) => void>;
  29987. /**
  29988. * Callback that will be called if an error occurs during shader compilation.
  29989. */
  29990. onError: Nullable<(effect: Effect, errors: string) => void>;
  29991. /**
  29992. * Callback that will be called when effect is bound.
  29993. */
  29994. onBind: Nullable<(effect: Effect) => void>;
  29995. /**
  29996. * Unique ID of the effect.
  29997. */
  29998. uniqueId: number;
  29999. /**
  30000. * Observable that will be called when the shader is compiled.
  30001. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  30002. */
  30003. onCompileObservable: Observable<Effect>;
  30004. /**
  30005. * Observable that will be called if an error occurs during shader compilation.
  30006. */
  30007. onErrorObservable: Observable<Effect>;
  30008. /** @hidden */
  30009. _onBindObservable: Nullable<Observable<Effect>>;
  30010. /**
  30011. * @hidden
  30012. * Specifies if the effect was previously ready
  30013. */
  30014. _wasPreviouslyReady: boolean;
  30015. /**
  30016. * Observable that will be called when effect is bound.
  30017. */
  30018. get onBindObservable(): Observable<Effect>;
  30019. /** @hidden */
  30020. _bonesComputationForcedToCPU: boolean;
  30021. private static _uniqueIdSeed;
  30022. private _engine;
  30023. private _uniformBuffersNames;
  30024. private _uniformsNames;
  30025. private _samplerList;
  30026. private _samplers;
  30027. private _isReady;
  30028. private _compilationError;
  30029. private _allFallbacksProcessed;
  30030. private _attributesNames;
  30031. private _attributes;
  30032. private _attributeLocationByName;
  30033. private _uniforms;
  30034. /**
  30035. * Key for the effect.
  30036. * @hidden
  30037. */
  30038. _key: string;
  30039. private _indexParameters;
  30040. private _fallbacks;
  30041. private _vertexSourceCode;
  30042. private _fragmentSourceCode;
  30043. private _vertexSourceCodeOverride;
  30044. private _fragmentSourceCodeOverride;
  30045. private _transformFeedbackVaryings;
  30046. /**
  30047. * Compiled shader to webGL program.
  30048. * @hidden
  30049. */
  30050. _pipelineContext: Nullable<IPipelineContext>;
  30051. private _valueCache;
  30052. private static _baseCache;
  30053. /**
  30054. * Instantiates an effect.
  30055. * An effect can be used to create/manage/execute vertex and fragment shaders.
  30056. * @param baseName Name of the effect.
  30057. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  30058. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  30059. * @param samplers List of sampler variables that will be passed to the shader.
  30060. * @param engine Engine to be used to render the effect
  30061. * @param defines Define statements to be added to the shader.
  30062. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  30063. * @param onCompiled Callback that will be called when the shader is compiled.
  30064. * @param onError Callback that will be called if an error occurs during shader compilation.
  30065. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  30066. */
  30067. 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);
  30068. private _useFinalCode;
  30069. /**
  30070. * Unique key for this effect
  30071. */
  30072. get key(): string;
  30073. /**
  30074. * If the effect has been compiled and prepared.
  30075. * @returns if the effect is compiled and prepared.
  30076. */
  30077. isReady(): boolean;
  30078. private _isReadyInternal;
  30079. /**
  30080. * The engine the effect was initialized with.
  30081. * @returns the engine.
  30082. */
  30083. getEngine(): Engine;
  30084. /**
  30085. * The pipeline context for this effect
  30086. * @returns the associated pipeline context
  30087. */
  30088. getPipelineContext(): Nullable<IPipelineContext>;
  30089. /**
  30090. * The set of names of attribute variables for the shader.
  30091. * @returns An array of attribute names.
  30092. */
  30093. getAttributesNames(): string[];
  30094. /**
  30095. * Returns the attribute at the given index.
  30096. * @param index The index of the attribute.
  30097. * @returns The location of the attribute.
  30098. */
  30099. getAttributeLocation(index: number): number;
  30100. /**
  30101. * Returns the attribute based on the name of the variable.
  30102. * @param name of the attribute to look up.
  30103. * @returns the attribute location.
  30104. */
  30105. getAttributeLocationByName(name: string): number;
  30106. /**
  30107. * The number of attributes.
  30108. * @returns the numnber of attributes.
  30109. */
  30110. getAttributesCount(): number;
  30111. /**
  30112. * Gets the index of a uniform variable.
  30113. * @param uniformName of the uniform to look up.
  30114. * @returns the index.
  30115. */
  30116. getUniformIndex(uniformName: string): number;
  30117. /**
  30118. * Returns the attribute based on the name of the variable.
  30119. * @param uniformName of the uniform to look up.
  30120. * @returns the location of the uniform.
  30121. */
  30122. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  30123. /**
  30124. * Returns an array of sampler variable names
  30125. * @returns The array of sampler variable neames.
  30126. */
  30127. getSamplers(): string[];
  30128. /**
  30129. * The error from the last compilation.
  30130. * @returns the error string.
  30131. */
  30132. getCompilationError(): string;
  30133. /**
  30134. * Gets a boolean indicating that all fallbacks were used during compilation
  30135. * @returns true if all fallbacks were used
  30136. */
  30137. allFallbacksProcessed(): boolean;
  30138. /**
  30139. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  30140. * @param func The callback to be used.
  30141. */
  30142. executeWhenCompiled(func: (effect: Effect) => void): void;
  30143. private _checkIsReady;
  30144. private _loadShader;
  30145. /**
  30146. * Recompiles the webGL program
  30147. * @param vertexSourceCode The source code for the vertex shader.
  30148. * @param fragmentSourceCode The source code for the fragment shader.
  30149. * @param onCompiled Callback called when completed.
  30150. * @param onError Callback called on error.
  30151. * @hidden
  30152. */
  30153. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  30154. /**
  30155. * Prepares the effect
  30156. * @hidden
  30157. */
  30158. _prepareEffect(): void;
  30159. private _processCompilationErrors;
  30160. /**
  30161. * Checks if the effect is supported. (Must be called after compilation)
  30162. */
  30163. get isSupported(): boolean;
  30164. /**
  30165. * Binds a texture to the engine to be used as output of the shader.
  30166. * @param channel Name of the output variable.
  30167. * @param texture Texture to bind.
  30168. * @hidden
  30169. */
  30170. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  30171. /**
  30172. * Sets a texture on the engine to be used in the shader.
  30173. * @param channel Name of the sampler variable.
  30174. * @param texture Texture to set.
  30175. */
  30176. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  30177. /**
  30178. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  30179. * @param channel Name of the sampler variable.
  30180. * @param texture Texture to set.
  30181. */
  30182. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  30183. /**
  30184. * Sets an array of textures on the engine to be used in the shader.
  30185. * @param channel Name of the variable.
  30186. * @param textures Textures to set.
  30187. */
  30188. setTextureArray(channel: string, textures: BaseTexture[]): void;
  30189. /**
  30190. * 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)
  30191. * @param channel Name of the sampler variable.
  30192. * @param postProcess Post process to get the input texture from.
  30193. */
  30194. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  30195. /**
  30196. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  30197. * 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)
  30198. * @param channel Name of the sampler variable.
  30199. * @param postProcess Post process to get the output texture from.
  30200. */
  30201. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  30202. /** @hidden */
  30203. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  30204. /** @hidden */
  30205. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  30206. /** @hidden */
  30207. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  30208. /** @hidden */
  30209. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  30210. /**
  30211. * Binds a buffer to a uniform.
  30212. * @param buffer Buffer to bind.
  30213. * @param name Name of the uniform variable to bind to.
  30214. */
  30215. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  30216. /**
  30217. * Binds block to a uniform.
  30218. * @param blockName Name of the block to bind.
  30219. * @param index Index to bind.
  30220. */
  30221. bindUniformBlock(blockName: string, index: number): void;
  30222. /**
  30223. * Sets an interger value on a uniform variable.
  30224. * @param uniformName Name of the variable.
  30225. * @param value Value to be set.
  30226. * @returns this effect.
  30227. */
  30228. setInt(uniformName: string, value: number): Effect;
  30229. /**
  30230. * Sets an int array on a uniform variable.
  30231. * @param uniformName Name of the variable.
  30232. * @param array array to be set.
  30233. * @returns this effect.
  30234. */
  30235. setIntArray(uniformName: string, array: Int32Array): Effect;
  30236. /**
  30237. * 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)
  30238. * @param uniformName Name of the variable.
  30239. * @param array array to be set.
  30240. * @returns this effect.
  30241. */
  30242. setIntArray2(uniformName: string, array: Int32Array): Effect;
  30243. /**
  30244. * 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)
  30245. * @param uniformName Name of the variable.
  30246. * @param array array to be set.
  30247. * @returns this effect.
  30248. */
  30249. setIntArray3(uniformName: string, array: Int32Array): Effect;
  30250. /**
  30251. * 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)
  30252. * @param uniformName Name of the variable.
  30253. * @param array array to be set.
  30254. * @returns this effect.
  30255. */
  30256. setIntArray4(uniformName: string, array: Int32Array): Effect;
  30257. /**
  30258. * Sets an float array on a uniform variable.
  30259. * @param uniformName Name of the variable.
  30260. * @param array array to be set.
  30261. * @returns this effect.
  30262. */
  30263. setFloatArray(uniformName: string, array: Float32Array): Effect;
  30264. /**
  30265. * 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)
  30266. * @param uniformName Name of the variable.
  30267. * @param array array to be set.
  30268. * @returns this effect.
  30269. */
  30270. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  30271. /**
  30272. * 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)
  30273. * @param uniformName Name of the variable.
  30274. * @param array array to be set.
  30275. * @returns this effect.
  30276. */
  30277. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  30278. /**
  30279. * 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)
  30280. * @param uniformName Name of the variable.
  30281. * @param array array to be set.
  30282. * @returns this effect.
  30283. */
  30284. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  30285. /**
  30286. * Sets an array on a uniform variable.
  30287. * @param uniformName Name of the variable.
  30288. * @param array array to be set.
  30289. * @returns this effect.
  30290. */
  30291. setArray(uniformName: string, array: number[]): Effect;
  30292. /**
  30293. * 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)
  30294. * @param uniformName Name of the variable.
  30295. * @param array array to be set.
  30296. * @returns this effect.
  30297. */
  30298. setArray2(uniformName: string, array: number[]): Effect;
  30299. /**
  30300. * 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)
  30301. * @param uniformName Name of the variable.
  30302. * @param array array to be set.
  30303. * @returns this effect.
  30304. */
  30305. setArray3(uniformName: string, array: number[]): Effect;
  30306. /**
  30307. * 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)
  30308. * @param uniformName Name of the variable.
  30309. * @param array array to be set.
  30310. * @returns this effect.
  30311. */
  30312. setArray4(uniformName: string, array: number[]): Effect;
  30313. /**
  30314. * Sets matrices on a uniform variable.
  30315. * @param uniformName Name of the variable.
  30316. * @param matrices matrices to be set.
  30317. * @returns this effect.
  30318. */
  30319. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  30320. /**
  30321. * Sets matrix on a uniform variable.
  30322. * @param uniformName Name of the variable.
  30323. * @param matrix matrix to be set.
  30324. * @returns this effect.
  30325. */
  30326. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  30327. /**
  30328. * 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)
  30329. * @param uniformName Name of the variable.
  30330. * @param matrix matrix to be set.
  30331. * @returns this effect.
  30332. */
  30333. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  30334. /**
  30335. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  30336. * @param uniformName Name of the variable.
  30337. * @param matrix matrix to be set.
  30338. * @returns this effect.
  30339. */
  30340. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  30341. /**
  30342. * Sets a float on a uniform variable.
  30343. * @param uniformName Name of the variable.
  30344. * @param value value to be set.
  30345. * @returns this effect.
  30346. */
  30347. setFloat(uniformName: string, value: number): Effect;
  30348. /**
  30349. * Sets a boolean on a uniform variable.
  30350. * @param uniformName Name of the variable.
  30351. * @param bool value to be set.
  30352. * @returns this effect.
  30353. */
  30354. setBool(uniformName: string, bool: boolean): Effect;
  30355. /**
  30356. * Sets a Vector2 on a uniform variable.
  30357. * @param uniformName Name of the variable.
  30358. * @param vector2 vector2 to be set.
  30359. * @returns this effect.
  30360. */
  30361. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  30362. /**
  30363. * Sets a float2 on a uniform variable.
  30364. * @param uniformName Name of the variable.
  30365. * @param x First float in float2.
  30366. * @param y Second float in float2.
  30367. * @returns this effect.
  30368. */
  30369. setFloat2(uniformName: string, x: number, y: number): Effect;
  30370. /**
  30371. * Sets a Vector3 on a uniform variable.
  30372. * @param uniformName Name of the variable.
  30373. * @param vector3 Value to be set.
  30374. * @returns this effect.
  30375. */
  30376. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  30377. /**
  30378. * Sets a float3 on a uniform variable.
  30379. * @param uniformName Name of the variable.
  30380. * @param x First float in float3.
  30381. * @param y Second float in float3.
  30382. * @param z Third float in float3.
  30383. * @returns this effect.
  30384. */
  30385. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  30386. /**
  30387. * Sets a Vector4 on a uniform variable.
  30388. * @param uniformName Name of the variable.
  30389. * @param vector4 Value to be set.
  30390. * @returns this effect.
  30391. */
  30392. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  30393. /**
  30394. * Sets a float4 on a uniform variable.
  30395. * @param uniformName Name of the variable.
  30396. * @param x First float in float4.
  30397. * @param y Second float in float4.
  30398. * @param z Third float in float4.
  30399. * @param w Fourth float in float4.
  30400. * @returns this effect.
  30401. */
  30402. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  30403. /**
  30404. * Sets a Color3 on a uniform variable.
  30405. * @param uniformName Name of the variable.
  30406. * @param color3 Value to be set.
  30407. * @returns this effect.
  30408. */
  30409. setColor3(uniformName: string, color3: IColor3Like): Effect;
  30410. /**
  30411. * Sets a Color4 on a uniform variable.
  30412. * @param uniformName Name of the variable.
  30413. * @param color3 Value to be set.
  30414. * @param alpha Alpha value to be set.
  30415. * @returns this effect.
  30416. */
  30417. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  30418. /**
  30419. * Sets a Color4 on a uniform variable
  30420. * @param uniformName defines the name of the variable
  30421. * @param color4 defines the value to be set
  30422. * @returns this effect.
  30423. */
  30424. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  30425. /** Release all associated resources */
  30426. dispose(): void;
  30427. /**
  30428. * This function will add a new shader to the shader store
  30429. * @param name the name of the shader
  30430. * @param pixelShader optional pixel shader content
  30431. * @param vertexShader optional vertex shader content
  30432. */
  30433. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  30434. /**
  30435. * Store of each shader (The can be looked up using effect.key)
  30436. */
  30437. static ShadersStore: {
  30438. [key: string]: string;
  30439. };
  30440. /**
  30441. * Store of each included file for a shader (The can be looked up using effect.key)
  30442. */
  30443. static IncludesShadersStore: {
  30444. [key: string]: string;
  30445. };
  30446. /**
  30447. * Resets the cache of effects.
  30448. */
  30449. static ResetCache(): void;
  30450. }
  30451. }
  30452. declare module BABYLON {
  30453. /**
  30454. * Interface used to describe the capabilities of the engine relatively to the current browser
  30455. */
  30456. export interface EngineCapabilities {
  30457. /** Maximum textures units per fragment shader */
  30458. maxTexturesImageUnits: number;
  30459. /** Maximum texture units per vertex shader */
  30460. maxVertexTextureImageUnits: number;
  30461. /** Maximum textures units in the entire pipeline */
  30462. maxCombinedTexturesImageUnits: number;
  30463. /** Maximum texture size */
  30464. maxTextureSize: number;
  30465. /** Maximum texture samples */
  30466. maxSamples?: number;
  30467. /** Maximum cube texture size */
  30468. maxCubemapTextureSize: number;
  30469. /** Maximum render texture size */
  30470. maxRenderTextureSize: number;
  30471. /** Maximum number of vertex attributes */
  30472. maxVertexAttribs: number;
  30473. /** Maximum number of varyings */
  30474. maxVaryingVectors: number;
  30475. /** Maximum number of uniforms per vertex shader */
  30476. maxVertexUniformVectors: number;
  30477. /** Maximum number of uniforms per fragment shader */
  30478. maxFragmentUniformVectors: number;
  30479. /** Defines if standard derivates (dx/dy) are supported */
  30480. standardDerivatives: boolean;
  30481. /** Defines if s3tc texture compression is supported */
  30482. s3tc?: WEBGL_compressed_texture_s3tc;
  30483. /** Defines if pvrtc texture compression is supported */
  30484. pvrtc: any;
  30485. /** Defines if etc1 texture compression is supported */
  30486. etc1: any;
  30487. /** Defines if etc2 texture compression is supported */
  30488. etc2: any;
  30489. /** Defines if astc texture compression is supported */
  30490. astc: any;
  30491. /** Defines if float textures are supported */
  30492. textureFloat: boolean;
  30493. /** Defines if vertex array objects are supported */
  30494. vertexArrayObject: boolean;
  30495. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  30496. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  30497. /** Gets the maximum level of anisotropy supported */
  30498. maxAnisotropy: number;
  30499. /** Defines if instancing is supported */
  30500. instancedArrays: boolean;
  30501. /** Defines if 32 bits indices are supported */
  30502. uintIndices: boolean;
  30503. /** Defines if high precision shaders are supported */
  30504. highPrecisionShaderSupported: boolean;
  30505. /** Defines if depth reading in the fragment shader is supported */
  30506. fragmentDepthSupported: boolean;
  30507. /** Defines if float texture linear filtering is supported*/
  30508. textureFloatLinearFiltering: boolean;
  30509. /** Defines if rendering to float textures is supported */
  30510. textureFloatRender: boolean;
  30511. /** Defines if half float textures are supported*/
  30512. textureHalfFloat: boolean;
  30513. /** Defines if half float texture linear filtering is supported*/
  30514. textureHalfFloatLinearFiltering: boolean;
  30515. /** Defines if rendering to half float textures is supported */
  30516. textureHalfFloatRender: boolean;
  30517. /** Defines if textureLOD shader command is supported */
  30518. textureLOD: boolean;
  30519. /** Defines if draw buffers extension is supported */
  30520. drawBuffersExtension: boolean;
  30521. /** Defines if depth textures are supported */
  30522. depthTextureExtension: boolean;
  30523. /** Defines if float color buffer are supported */
  30524. colorBufferFloat: boolean;
  30525. /** Gets disjoint timer query extension (null if not supported) */
  30526. timerQuery?: EXT_disjoint_timer_query;
  30527. /** Defines if timestamp can be used with timer query */
  30528. canUseTimestampForTimerQuery: boolean;
  30529. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  30530. multiview?: any;
  30531. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  30532. oculusMultiview?: any;
  30533. /** Function used to let the system compiles shaders in background */
  30534. parallelShaderCompile?: {
  30535. COMPLETION_STATUS_KHR: number;
  30536. };
  30537. /** Max number of texture samples for MSAA */
  30538. maxMSAASamples: number;
  30539. /** Defines if the blend min max extension is supported */
  30540. blendMinMax: boolean;
  30541. }
  30542. }
  30543. declare module BABYLON {
  30544. /**
  30545. * @hidden
  30546. **/
  30547. export class DepthCullingState {
  30548. private _isDepthTestDirty;
  30549. private _isDepthMaskDirty;
  30550. private _isDepthFuncDirty;
  30551. private _isCullFaceDirty;
  30552. private _isCullDirty;
  30553. private _isZOffsetDirty;
  30554. private _isFrontFaceDirty;
  30555. private _depthTest;
  30556. private _depthMask;
  30557. private _depthFunc;
  30558. private _cull;
  30559. private _cullFace;
  30560. private _zOffset;
  30561. private _frontFace;
  30562. /**
  30563. * Initializes the state.
  30564. */
  30565. constructor();
  30566. get isDirty(): boolean;
  30567. get zOffset(): number;
  30568. set zOffset(value: number);
  30569. get cullFace(): Nullable<number>;
  30570. set cullFace(value: Nullable<number>);
  30571. get cull(): Nullable<boolean>;
  30572. set cull(value: Nullable<boolean>);
  30573. get depthFunc(): Nullable<number>;
  30574. set depthFunc(value: Nullable<number>);
  30575. get depthMask(): boolean;
  30576. set depthMask(value: boolean);
  30577. get depthTest(): boolean;
  30578. set depthTest(value: boolean);
  30579. get frontFace(): Nullable<number>;
  30580. set frontFace(value: Nullable<number>);
  30581. reset(): void;
  30582. apply(gl: WebGLRenderingContext): void;
  30583. }
  30584. }
  30585. declare module BABYLON {
  30586. /**
  30587. * @hidden
  30588. **/
  30589. export class StencilState {
  30590. /** 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 */
  30591. static readonly ALWAYS: number;
  30592. /** Passed to stencilOperation to specify that stencil value must be kept */
  30593. static readonly KEEP: number;
  30594. /** Passed to stencilOperation to specify that stencil value must be replaced */
  30595. static readonly REPLACE: number;
  30596. private _isStencilTestDirty;
  30597. private _isStencilMaskDirty;
  30598. private _isStencilFuncDirty;
  30599. private _isStencilOpDirty;
  30600. private _stencilTest;
  30601. private _stencilMask;
  30602. private _stencilFunc;
  30603. private _stencilFuncRef;
  30604. private _stencilFuncMask;
  30605. private _stencilOpStencilFail;
  30606. private _stencilOpDepthFail;
  30607. private _stencilOpStencilDepthPass;
  30608. get isDirty(): boolean;
  30609. get stencilFunc(): number;
  30610. set stencilFunc(value: number);
  30611. get stencilFuncRef(): number;
  30612. set stencilFuncRef(value: number);
  30613. get stencilFuncMask(): number;
  30614. set stencilFuncMask(value: number);
  30615. get stencilOpStencilFail(): number;
  30616. set stencilOpStencilFail(value: number);
  30617. get stencilOpDepthFail(): number;
  30618. set stencilOpDepthFail(value: number);
  30619. get stencilOpStencilDepthPass(): number;
  30620. set stencilOpStencilDepthPass(value: number);
  30621. get stencilMask(): number;
  30622. set stencilMask(value: number);
  30623. get stencilTest(): boolean;
  30624. set stencilTest(value: boolean);
  30625. constructor();
  30626. reset(): void;
  30627. apply(gl: WebGLRenderingContext): void;
  30628. }
  30629. }
  30630. declare module BABYLON {
  30631. /**
  30632. * @hidden
  30633. **/
  30634. export class AlphaState {
  30635. private _isAlphaBlendDirty;
  30636. private _isBlendFunctionParametersDirty;
  30637. private _isBlendEquationParametersDirty;
  30638. private _isBlendConstantsDirty;
  30639. private _alphaBlend;
  30640. private _blendFunctionParameters;
  30641. private _blendEquationParameters;
  30642. private _blendConstants;
  30643. /**
  30644. * Initializes the state.
  30645. */
  30646. constructor();
  30647. get isDirty(): boolean;
  30648. get alphaBlend(): boolean;
  30649. set alphaBlend(value: boolean);
  30650. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  30651. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  30652. setAlphaEquationParameters(rgb: number, alpha: number): void;
  30653. reset(): void;
  30654. apply(gl: WebGLRenderingContext): void;
  30655. }
  30656. }
  30657. declare module BABYLON {
  30658. /** @hidden */
  30659. export class WebGL2ShaderProcessor implements IShaderProcessor {
  30660. attributeProcessor(attribute: string): string;
  30661. varyingProcessor(varying: string, isFragment: boolean): string;
  30662. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  30663. }
  30664. }
  30665. declare module BABYLON {
  30666. /**
  30667. * Interface for attribute information associated with buffer instanciation
  30668. */
  30669. export interface InstancingAttributeInfo {
  30670. /**
  30671. * Name of the GLSL attribute
  30672. * if attribute index is not specified, this is used to retrieve the index from the effect
  30673. */
  30674. attributeName: string;
  30675. /**
  30676. * Index/offset of the attribute in the vertex shader
  30677. * if not specified, this will be computes from the name.
  30678. */
  30679. index?: number;
  30680. /**
  30681. * size of the attribute, 1, 2, 3 or 4
  30682. */
  30683. attributeSize: number;
  30684. /**
  30685. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  30686. */
  30687. offset: number;
  30688. /**
  30689. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  30690. * default to 1
  30691. */
  30692. divisor?: number;
  30693. /**
  30694. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  30695. * default is FLOAT
  30696. */
  30697. attributeType?: number;
  30698. /**
  30699. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  30700. */
  30701. normalized?: boolean;
  30702. }
  30703. }
  30704. declare module BABYLON {
  30705. interface ThinEngine {
  30706. /**
  30707. * Update a video texture
  30708. * @param texture defines the texture to update
  30709. * @param video defines the video element to use
  30710. * @param invertY defines if data must be stored with Y axis inverted
  30711. */
  30712. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  30713. }
  30714. }
  30715. declare module BABYLON {
  30716. /**
  30717. * Settings for finer control over video usage
  30718. */
  30719. export interface VideoTextureSettings {
  30720. /**
  30721. * Applies `autoplay` to video, if specified
  30722. */
  30723. autoPlay?: boolean;
  30724. /**
  30725. * Applies `loop` to video, if specified
  30726. */
  30727. loop?: boolean;
  30728. /**
  30729. * Automatically updates internal texture from video at every frame in the render loop
  30730. */
  30731. autoUpdateTexture: boolean;
  30732. /**
  30733. * Image src displayed during the video loading or until the user interacts with the video.
  30734. */
  30735. poster?: string;
  30736. }
  30737. /**
  30738. * If you want to display a video in your scene, this is the special texture for that.
  30739. * This special texture works similar to other textures, with the exception of a few parameters.
  30740. * @see https://doc.babylonjs.com/how_to/video_texture
  30741. */
  30742. export class VideoTexture extends Texture {
  30743. /**
  30744. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  30745. */
  30746. readonly autoUpdateTexture: boolean;
  30747. /**
  30748. * The video instance used by the texture internally
  30749. */
  30750. readonly video: HTMLVideoElement;
  30751. private _onUserActionRequestedObservable;
  30752. /**
  30753. * Event triggerd when a dom action is required by the user to play the video.
  30754. * This happens due to recent changes in browser policies preventing video to auto start.
  30755. */
  30756. get onUserActionRequestedObservable(): Observable<Texture>;
  30757. private _generateMipMaps;
  30758. private _engine;
  30759. private _stillImageCaptured;
  30760. private _displayingPosterTexture;
  30761. private _settings;
  30762. private _createInternalTextureOnEvent;
  30763. private _frameId;
  30764. private _currentSrc;
  30765. /**
  30766. * Creates a video texture.
  30767. * If you want to display a video in your scene, this is the special texture for that.
  30768. * This special texture works similar to other textures, with the exception of a few parameters.
  30769. * @see https://doc.babylonjs.com/how_to/video_texture
  30770. * @param name optional name, will detect from video source, if not defined
  30771. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  30772. * @param scene is obviously the current scene.
  30773. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  30774. * @param invertY is false by default but can be used to invert video on Y axis
  30775. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  30776. * @param settings allows finer control over video usage
  30777. */
  30778. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  30779. private _getName;
  30780. private _getVideo;
  30781. private _createInternalTexture;
  30782. private reset;
  30783. /**
  30784. * @hidden Internal method to initiate `update`.
  30785. */
  30786. _rebuild(): void;
  30787. /**
  30788. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  30789. */
  30790. update(): void;
  30791. /**
  30792. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  30793. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  30794. */
  30795. updateTexture(isVisible: boolean): void;
  30796. protected _updateInternalTexture: () => void;
  30797. /**
  30798. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  30799. * @param url New url.
  30800. */
  30801. updateURL(url: string): void;
  30802. /**
  30803. * Clones the texture.
  30804. * @returns the cloned texture
  30805. */
  30806. clone(): VideoTexture;
  30807. /**
  30808. * Dispose the texture and release its associated resources.
  30809. */
  30810. dispose(): void;
  30811. /**
  30812. * Creates a video texture straight from a stream.
  30813. * @param scene Define the scene the texture should be created in
  30814. * @param stream Define the stream the texture should be created from
  30815. * @returns The created video texture as a promise
  30816. */
  30817. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  30818. /**
  30819. * Creates a video texture straight from your WebCam video feed.
  30820. * @param scene Define the scene the texture should be created in
  30821. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  30822. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  30823. * @returns The created video texture as a promise
  30824. */
  30825. static CreateFromWebCamAsync(scene: Scene, constraints: {
  30826. minWidth: number;
  30827. maxWidth: number;
  30828. minHeight: number;
  30829. maxHeight: number;
  30830. deviceId: string;
  30831. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  30832. /**
  30833. * Creates a video texture straight from your WebCam video feed.
  30834. * @param scene Define the scene the texture should be created in
  30835. * @param onReady Define a callback to triggered once the texture will be ready
  30836. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  30837. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  30838. */
  30839. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  30840. minWidth: number;
  30841. maxWidth: number;
  30842. minHeight: number;
  30843. maxHeight: number;
  30844. deviceId: string;
  30845. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  30846. }
  30847. }
  30848. declare module BABYLON {
  30849. /**
  30850. * Defines the interface used by objects working like Scene
  30851. * @hidden
  30852. */
  30853. interface ISceneLike {
  30854. _addPendingData(data: any): void;
  30855. _removePendingData(data: any): void;
  30856. offlineProvider: IOfflineProvider;
  30857. }
  30858. /** Interface defining initialization parameters for Engine class */
  30859. export interface EngineOptions extends WebGLContextAttributes {
  30860. /**
  30861. * Defines if the engine should no exceed a specified device ratio
  30862. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  30863. */
  30864. limitDeviceRatio?: number;
  30865. /**
  30866. * Defines if webvr should be enabled automatically
  30867. * @see http://doc.babylonjs.com/how_to/webvr_camera
  30868. */
  30869. autoEnableWebVR?: boolean;
  30870. /**
  30871. * Defines if webgl2 should be turned off even if supported
  30872. * @see http://doc.babylonjs.com/features/webgl2
  30873. */
  30874. disableWebGL2Support?: boolean;
  30875. /**
  30876. * Defines if webaudio should be initialized as well
  30877. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  30878. */
  30879. audioEngine?: boolean;
  30880. /**
  30881. * Defines if animations should run using a deterministic lock step
  30882. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  30883. */
  30884. deterministicLockstep?: boolean;
  30885. /** Defines the maximum steps to use with deterministic lock step mode */
  30886. lockstepMaxSteps?: number;
  30887. /** Defines the seconds between each deterministic lock step */
  30888. timeStep?: number;
  30889. /**
  30890. * Defines that engine should ignore context lost events
  30891. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  30892. */
  30893. doNotHandleContextLost?: boolean;
  30894. /**
  30895. * Defines that engine should ignore modifying touch action attribute and style
  30896. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  30897. */
  30898. doNotHandleTouchAction?: boolean;
  30899. /**
  30900. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  30901. */
  30902. useHighPrecisionFloats?: boolean;
  30903. }
  30904. /**
  30905. * The base engine class (root of all engines)
  30906. */
  30907. export class ThinEngine {
  30908. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  30909. static ExceptionList: ({
  30910. key: string;
  30911. capture: string;
  30912. captureConstraint: number;
  30913. targets: string[];
  30914. } | {
  30915. key: string;
  30916. capture: null;
  30917. captureConstraint: null;
  30918. targets: string[];
  30919. })[];
  30920. /** @hidden */
  30921. static _TextureLoaders: IInternalTextureLoader[];
  30922. /**
  30923. * Returns the current npm package of the sdk
  30924. */
  30925. static get NpmPackage(): string;
  30926. /**
  30927. * Returns the current version of the framework
  30928. */
  30929. static get Version(): string;
  30930. /**
  30931. * Returns a string describing the current engine
  30932. */
  30933. get description(): string;
  30934. /**
  30935. * Gets or sets the epsilon value used by collision engine
  30936. */
  30937. static CollisionsEpsilon: number;
  30938. /**
  30939. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  30940. */
  30941. static get ShadersRepository(): string;
  30942. static set ShadersRepository(value: string);
  30943. /**
  30944. * Gets or sets the textures that the engine should not attempt to load as compressed
  30945. */
  30946. protected _excludedCompressedTextures: string[];
  30947. /**
  30948. * Filters the compressed texture formats to only include
  30949. * files that are not included in the skippable list
  30950. *
  30951. * @param url the current extension
  30952. * @param textureFormatInUse the current compressed texture format
  30953. * @returns "format" string
  30954. */
  30955. excludedCompressedTextureFormats(url: Nullable<string>, textureFormatInUse: Nullable<string>): Nullable<string>;
  30956. /** @hidden */
  30957. _shaderProcessor: IShaderProcessor;
  30958. /**
  30959. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  30960. */
  30961. forcePOTTextures: boolean;
  30962. /**
  30963. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  30964. */
  30965. isFullscreen: boolean;
  30966. /**
  30967. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  30968. */
  30969. cullBackFaces: boolean;
  30970. /**
  30971. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  30972. */
  30973. renderEvenInBackground: boolean;
  30974. /**
  30975. * Gets or sets a boolean indicating that cache can be kept between frames
  30976. */
  30977. preventCacheWipeBetweenFrames: boolean;
  30978. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  30979. validateShaderPrograms: boolean;
  30980. /**
  30981. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  30982. * This can provide greater z depth for distant objects.
  30983. */
  30984. useReverseDepthBuffer: boolean;
  30985. /**
  30986. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  30987. */
  30988. disableUniformBuffers: boolean;
  30989. /** @hidden */
  30990. _uniformBuffers: UniformBuffer[];
  30991. /**
  30992. * Gets a boolean indicating that the engine supports uniform buffers
  30993. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  30994. */
  30995. get supportsUniformBuffers(): boolean;
  30996. /** @hidden */
  30997. _gl: WebGLRenderingContext;
  30998. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  30999. protected _windowIsBackground: boolean;
  31000. protected _webGLVersion: number;
  31001. protected _creationOptions: EngineOptions;
  31002. protected _highPrecisionShadersAllowed: boolean;
  31003. /** @hidden */
  31004. get _shouldUseHighPrecisionShader(): boolean;
  31005. /**
  31006. * Gets a boolean indicating that only power of 2 textures are supported
  31007. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  31008. */
  31009. get needPOTTextures(): boolean;
  31010. /** @hidden */
  31011. _badOS: boolean;
  31012. /** @hidden */
  31013. _badDesktopOS: boolean;
  31014. private _hardwareScalingLevel;
  31015. /** @hidden */
  31016. _caps: EngineCapabilities;
  31017. private _isStencilEnable;
  31018. private _glVersion;
  31019. private _glRenderer;
  31020. private _glVendor;
  31021. /** @hidden */
  31022. _videoTextureSupported: boolean;
  31023. protected _renderingQueueLaunched: boolean;
  31024. protected _activeRenderLoops: (() => void)[];
  31025. /**
  31026. * Observable signaled when a context lost event is raised
  31027. */
  31028. onContextLostObservable: Observable<ThinEngine>;
  31029. /**
  31030. * Observable signaled when a context restored event is raised
  31031. */
  31032. onContextRestoredObservable: Observable<ThinEngine>;
  31033. private _onContextLost;
  31034. private _onContextRestored;
  31035. protected _contextWasLost: boolean;
  31036. /** @hidden */
  31037. _doNotHandleContextLost: boolean;
  31038. /**
  31039. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  31040. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  31041. */
  31042. get doNotHandleContextLost(): boolean;
  31043. set doNotHandleContextLost(value: boolean);
  31044. /**
  31045. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  31046. */
  31047. disableVertexArrayObjects: boolean;
  31048. /** @hidden */
  31049. protected _colorWrite: boolean;
  31050. /** @hidden */
  31051. protected _colorWriteChanged: boolean;
  31052. /** @hidden */
  31053. protected _depthCullingState: DepthCullingState;
  31054. /** @hidden */
  31055. protected _stencilState: StencilState;
  31056. /** @hidden */
  31057. _alphaState: AlphaState;
  31058. /** @hidden */
  31059. _alphaMode: number;
  31060. /** @hidden */
  31061. _alphaEquation: number;
  31062. /** @hidden */
  31063. _internalTexturesCache: InternalTexture[];
  31064. /** @hidden */
  31065. protected _activeChannel: number;
  31066. private _currentTextureChannel;
  31067. /** @hidden */
  31068. protected _boundTexturesCache: {
  31069. [key: string]: Nullable<InternalTexture>;
  31070. };
  31071. /** @hidden */
  31072. protected _currentEffect: Nullable<Effect>;
  31073. /** @hidden */
  31074. protected _currentProgram: Nullable<WebGLProgram>;
  31075. private _compiledEffects;
  31076. private _vertexAttribArraysEnabled;
  31077. /** @hidden */
  31078. protected _cachedViewport: Nullable<IViewportLike>;
  31079. private _cachedVertexArrayObject;
  31080. /** @hidden */
  31081. protected _cachedVertexBuffers: any;
  31082. /** @hidden */
  31083. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  31084. /** @hidden */
  31085. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  31086. /** @hidden */
  31087. _currentRenderTarget: Nullable<InternalTexture>;
  31088. private _uintIndicesCurrentlySet;
  31089. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  31090. /** @hidden */
  31091. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  31092. private _currentBufferPointers;
  31093. private _currentInstanceLocations;
  31094. private _currentInstanceBuffers;
  31095. private _textureUnits;
  31096. /** @hidden */
  31097. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  31098. /** @hidden */
  31099. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  31100. /** @hidden */
  31101. _boundRenderFunction: any;
  31102. private _vaoRecordInProgress;
  31103. private _mustWipeVertexAttributes;
  31104. private _emptyTexture;
  31105. private _emptyCubeTexture;
  31106. private _emptyTexture3D;
  31107. private _emptyTexture2DArray;
  31108. /** @hidden */
  31109. _frameHandler: number;
  31110. private _nextFreeTextureSlots;
  31111. private _maxSimultaneousTextures;
  31112. private _activeRequests;
  31113. protected _texturesSupported: string[];
  31114. /** @hidden */
  31115. _textureFormatInUse: Nullable<string>;
  31116. protected get _supportsHardwareTextureRescaling(): boolean;
  31117. /**
  31118. * Gets the list of texture formats supported
  31119. */
  31120. get texturesSupported(): Array<string>;
  31121. /**
  31122. * Gets the list of texture formats in use
  31123. */
  31124. get textureFormatInUse(): Nullable<string>;
  31125. /**
  31126. * Gets the current viewport
  31127. */
  31128. get currentViewport(): Nullable<IViewportLike>;
  31129. /**
  31130. * Gets the default empty texture
  31131. */
  31132. get emptyTexture(): InternalTexture;
  31133. /**
  31134. * Gets the default empty 3D texture
  31135. */
  31136. get emptyTexture3D(): InternalTexture;
  31137. /**
  31138. * Gets the default empty 2D array texture
  31139. */
  31140. get emptyTexture2DArray(): InternalTexture;
  31141. /**
  31142. * Gets the default empty cube texture
  31143. */
  31144. get emptyCubeTexture(): InternalTexture;
  31145. /**
  31146. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  31147. */
  31148. readonly premultipliedAlpha: boolean;
  31149. /**
  31150. * Observable event triggered before each texture is initialized
  31151. */
  31152. onBeforeTextureInitObservable: Observable<Texture>;
  31153. /**
  31154. * Creates a new engine
  31155. * @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
  31156. * @param antialias defines enable antialiasing (default: false)
  31157. * @param options defines further options to be sent to the getContext() function
  31158. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  31159. */
  31160. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  31161. private _rebuildInternalTextures;
  31162. private _rebuildEffects;
  31163. /**
  31164. * Gets a boolean indicating if all created effects are ready
  31165. * @returns true if all effects are ready
  31166. */
  31167. areAllEffectsReady(): boolean;
  31168. protected _rebuildBuffers(): void;
  31169. private _initGLContext;
  31170. /**
  31171. * Gets version of the current webGL context
  31172. */
  31173. get webGLVersion(): number;
  31174. /**
  31175. * Gets a string idenfifying the name of the class
  31176. * @returns "Engine" string
  31177. */
  31178. getClassName(): string;
  31179. /**
  31180. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  31181. */
  31182. get isStencilEnable(): boolean;
  31183. /** @hidden */
  31184. _prepareWorkingCanvas(): void;
  31185. /**
  31186. * Reset the texture cache to empty state
  31187. */
  31188. resetTextureCache(): void;
  31189. /**
  31190. * Gets an object containing information about the current webGL context
  31191. * @returns an object containing the vender, the renderer and the version of the current webGL context
  31192. */
  31193. getGlInfo(): {
  31194. vendor: string;
  31195. renderer: string;
  31196. version: string;
  31197. };
  31198. /**
  31199. * Defines the hardware scaling level.
  31200. * By default the hardware scaling level is computed from the window device ratio.
  31201. * 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.
  31202. * @param level defines the level to use
  31203. */
  31204. setHardwareScalingLevel(level: number): void;
  31205. /**
  31206. * Gets the current hardware scaling level.
  31207. * By default the hardware scaling level is computed from the window device ratio.
  31208. * 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.
  31209. * @returns a number indicating the current hardware scaling level
  31210. */
  31211. getHardwareScalingLevel(): number;
  31212. /**
  31213. * Gets the list of loaded textures
  31214. * @returns an array containing all loaded textures
  31215. */
  31216. getLoadedTexturesCache(): InternalTexture[];
  31217. /**
  31218. * Gets the object containing all engine capabilities
  31219. * @returns the EngineCapabilities object
  31220. */
  31221. getCaps(): EngineCapabilities;
  31222. /**
  31223. * stop executing a render loop function and remove it from the execution array
  31224. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  31225. */
  31226. stopRenderLoop(renderFunction?: () => void): void;
  31227. /** @hidden */
  31228. _renderLoop(): void;
  31229. /**
  31230. * Gets the HTML canvas attached with the current webGL context
  31231. * @returns a HTML canvas
  31232. */
  31233. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  31234. /**
  31235. * Gets host window
  31236. * @returns the host window object
  31237. */
  31238. getHostWindow(): Nullable<Window>;
  31239. /**
  31240. * Gets the current render width
  31241. * @param useScreen defines if screen size must be used (or the current render target if any)
  31242. * @returns a number defining the current render width
  31243. */
  31244. getRenderWidth(useScreen?: boolean): number;
  31245. /**
  31246. * Gets the current render height
  31247. * @param useScreen defines if screen size must be used (or the current render target if any)
  31248. * @returns a number defining the current render height
  31249. */
  31250. getRenderHeight(useScreen?: boolean): number;
  31251. /**
  31252. * Can be used to override the current requestAnimationFrame requester.
  31253. * @hidden
  31254. */
  31255. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  31256. /**
  31257. * Register and execute a render loop. The engine can have more than one render function
  31258. * @param renderFunction defines the function to continuously execute
  31259. */
  31260. runRenderLoop(renderFunction: () => void): void;
  31261. /**
  31262. * Clear the current render buffer or the current render target (if any is set up)
  31263. * @param color defines the color to use
  31264. * @param backBuffer defines if the back buffer must be cleared
  31265. * @param depth defines if the depth buffer must be cleared
  31266. * @param stencil defines if the stencil buffer must be cleared
  31267. */
  31268. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  31269. private _viewportCached;
  31270. /** @hidden */
  31271. _viewport(x: number, y: number, width: number, height: number): void;
  31272. /**
  31273. * Set the WebGL's viewport
  31274. * @param viewport defines the viewport element to be used
  31275. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  31276. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  31277. */
  31278. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  31279. /**
  31280. * Begin a new frame
  31281. */
  31282. beginFrame(): void;
  31283. /**
  31284. * Enf the current frame
  31285. */
  31286. endFrame(): void;
  31287. /**
  31288. * Resize the view according to the canvas' size
  31289. */
  31290. resize(): void;
  31291. /**
  31292. * Force a specific size of the canvas
  31293. * @param width defines the new canvas' width
  31294. * @param height defines the new canvas' height
  31295. */
  31296. setSize(width: number, height: number): void;
  31297. /**
  31298. * Binds the frame buffer to the specified texture.
  31299. * @param texture The texture to render to or null for the default canvas
  31300. * @param faceIndex The face of the texture to render to in case of cube texture
  31301. * @param requiredWidth The width of the target to render to
  31302. * @param requiredHeight The height of the target to render to
  31303. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  31304. * @param lodLevel defines the lod level to bind to the frame buffer
  31305. * @param layer defines the 2d array index to bind to frame buffer to
  31306. */
  31307. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  31308. /** @hidden */
  31309. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  31310. /**
  31311. * Unbind the current render target texture from the webGL context
  31312. * @param texture defines the render target texture to unbind
  31313. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  31314. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  31315. */
  31316. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  31317. /**
  31318. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  31319. */
  31320. flushFramebuffer(): void;
  31321. /**
  31322. * Unbind the current render target and bind the default framebuffer
  31323. */
  31324. restoreDefaultFramebuffer(): void;
  31325. /** @hidden */
  31326. protected _resetVertexBufferBinding(): void;
  31327. /**
  31328. * Creates a vertex buffer
  31329. * @param data the data for the vertex buffer
  31330. * @returns the new WebGL static buffer
  31331. */
  31332. createVertexBuffer(data: DataArray): DataBuffer;
  31333. private _createVertexBuffer;
  31334. /**
  31335. * Creates a dynamic vertex buffer
  31336. * @param data the data for the dynamic vertex buffer
  31337. * @returns the new WebGL dynamic buffer
  31338. */
  31339. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  31340. protected _resetIndexBufferBinding(): void;
  31341. /**
  31342. * Creates a new index buffer
  31343. * @param indices defines the content of the index buffer
  31344. * @param updatable defines if the index buffer must be updatable
  31345. * @returns a new webGL buffer
  31346. */
  31347. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  31348. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  31349. /**
  31350. * Bind a webGL buffer to the webGL context
  31351. * @param buffer defines the buffer to bind
  31352. */
  31353. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  31354. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  31355. private bindBuffer;
  31356. /**
  31357. * update the bound buffer with the given data
  31358. * @param data defines the data to update
  31359. */
  31360. updateArrayBuffer(data: Float32Array): void;
  31361. private _vertexAttribPointer;
  31362. /** @hidden */
  31363. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  31364. private _bindVertexBuffersAttributes;
  31365. /**
  31366. * Records a vertex array object
  31367. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  31368. * @param vertexBuffers defines the list of vertex buffers to store
  31369. * @param indexBuffer defines the index buffer to store
  31370. * @param effect defines the effect to store
  31371. * @returns the new vertex array object
  31372. */
  31373. recordVertexArrayObject(vertexBuffers: {
  31374. [key: string]: VertexBuffer;
  31375. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  31376. /**
  31377. * Bind a specific vertex array object
  31378. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  31379. * @param vertexArrayObject defines the vertex array object to bind
  31380. * @param indexBuffer defines the index buffer to bind
  31381. */
  31382. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  31383. /**
  31384. * Bind webGl buffers directly to the webGL context
  31385. * @param vertexBuffer defines the vertex buffer to bind
  31386. * @param indexBuffer defines the index buffer to bind
  31387. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  31388. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  31389. * @param effect defines the effect associated with the vertex buffer
  31390. */
  31391. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  31392. private _unbindVertexArrayObject;
  31393. /**
  31394. * Bind a list of vertex buffers to the webGL context
  31395. * @param vertexBuffers defines the list of vertex buffers to bind
  31396. * @param indexBuffer defines the index buffer to bind
  31397. * @param effect defines the effect associated with the vertex buffers
  31398. */
  31399. bindBuffers(vertexBuffers: {
  31400. [key: string]: Nullable<VertexBuffer>;
  31401. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  31402. /**
  31403. * Unbind all instance attributes
  31404. */
  31405. unbindInstanceAttributes(): void;
  31406. /**
  31407. * Release and free the memory of a vertex array object
  31408. * @param vao defines the vertex array object to delete
  31409. */
  31410. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  31411. /** @hidden */
  31412. _releaseBuffer(buffer: DataBuffer): boolean;
  31413. protected _deleteBuffer(buffer: DataBuffer): void;
  31414. /**
  31415. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  31416. * @param instancesBuffer defines the webGL buffer to update and bind
  31417. * @param data defines the data to store in the buffer
  31418. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  31419. */
  31420. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  31421. /**
  31422. * Bind the content of a webGL buffer used with instantiation
  31423. * @param instancesBuffer defines the webGL buffer to bind
  31424. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  31425. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  31426. */
  31427. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  31428. /**
  31429. * Disable the instance attribute corresponding to the name in parameter
  31430. * @param name defines the name of the attribute to disable
  31431. */
  31432. disableInstanceAttributeByName(name: string): void;
  31433. /**
  31434. * Disable the instance attribute corresponding to the location in parameter
  31435. * @param attributeLocation defines the attribute location of the attribute to disable
  31436. */
  31437. disableInstanceAttribute(attributeLocation: number): void;
  31438. /**
  31439. * Disable the attribute corresponding to the location in parameter
  31440. * @param attributeLocation defines the attribute location of the attribute to disable
  31441. */
  31442. disableAttributeByIndex(attributeLocation: number): void;
  31443. /**
  31444. * Send a draw order
  31445. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  31446. * @param indexStart defines the starting index
  31447. * @param indexCount defines the number of index to draw
  31448. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31449. */
  31450. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  31451. /**
  31452. * Draw a list of points
  31453. * @param verticesStart defines the index of first vertex to draw
  31454. * @param verticesCount defines the count of vertices to draw
  31455. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31456. */
  31457. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31458. /**
  31459. * Draw a list of unindexed primitives
  31460. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  31461. * @param verticesStart defines the index of first vertex to draw
  31462. * @param verticesCount defines the count of vertices to draw
  31463. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31464. */
  31465. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31466. /**
  31467. * Draw a list of indexed primitives
  31468. * @param fillMode defines the primitive to use
  31469. * @param indexStart defines the starting index
  31470. * @param indexCount defines the number of index to draw
  31471. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31472. */
  31473. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  31474. /**
  31475. * Draw a list of unindexed primitives
  31476. * @param fillMode defines the primitive to use
  31477. * @param verticesStart defines the index of first vertex to draw
  31478. * @param verticesCount defines the count of vertices to draw
  31479. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31480. */
  31481. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31482. private _drawMode;
  31483. /** @hidden */
  31484. protected _reportDrawCall(): void;
  31485. /** @hidden */
  31486. _releaseEffect(effect: Effect): void;
  31487. /** @hidden */
  31488. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  31489. /**
  31490. * Create a new effect (used to store vertex/fragment shaders)
  31491. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  31492. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  31493. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  31494. * @param samplers defines an array of string used to represent textures
  31495. * @param defines defines the string containing the defines to use to compile the shaders
  31496. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  31497. * @param onCompiled defines a function to call when the effect creation is successful
  31498. * @param onError defines a function to call when the effect creation has failed
  31499. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  31500. * @returns the new Effect
  31501. */
  31502. 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;
  31503. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  31504. private _compileShader;
  31505. private _compileRawShader;
  31506. /**
  31507. * Directly creates a webGL program
  31508. * @param pipelineContext defines the pipeline context to attach to
  31509. * @param vertexCode defines the vertex shader code to use
  31510. * @param fragmentCode defines the fragment shader code to use
  31511. * @param context defines the webGL context to use (if not set, the current one will be used)
  31512. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  31513. * @returns the new webGL program
  31514. */
  31515. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31516. /**
  31517. * Creates a webGL program
  31518. * @param pipelineContext defines the pipeline context to attach to
  31519. * @param vertexCode defines the vertex shader code to use
  31520. * @param fragmentCode defines the fragment shader code to use
  31521. * @param defines defines the string containing the defines to use to compile the shaders
  31522. * @param context defines the webGL context to use (if not set, the current one will be used)
  31523. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  31524. * @returns the new webGL program
  31525. */
  31526. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31527. /**
  31528. * Creates a new pipeline context
  31529. * @returns the new pipeline
  31530. */
  31531. createPipelineContext(): IPipelineContext;
  31532. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31533. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  31534. /** @hidden */
  31535. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  31536. /** @hidden */
  31537. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  31538. /** @hidden */
  31539. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  31540. /**
  31541. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  31542. * @param pipelineContext defines the pipeline context to use
  31543. * @param uniformsNames defines the list of uniform names
  31544. * @returns an array of webGL uniform locations
  31545. */
  31546. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  31547. /**
  31548. * Gets the lsit of active attributes for a given webGL program
  31549. * @param pipelineContext defines the pipeline context to use
  31550. * @param attributesNames defines the list of attribute names to get
  31551. * @returns an array of indices indicating the offset of each attribute
  31552. */
  31553. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  31554. /**
  31555. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  31556. * @param effect defines the effect to activate
  31557. */
  31558. enableEffect(effect: Nullable<Effect>): void;
  31559. /**
  31560. * Set the value of an uniform to a number (int)
  31561. * @param uniform defines the webGL uniform location where to store the value
  31562. * @param value defines the int number to store
  31563. */
  31564. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  31565. /**
  31566. * Set the value of an uniform to an array of int32
  31567. * @param uniform defines the webGL uniform location where to store the value
  31568. * @param array defines the array of int32 to store
  31569. */
  31570. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31571. /**
  31572. * Set the value of an uniform to an array of int32 (stored as vec2)
  31573. * @param uniform defines the webGL uniform location where to store the value
  31574. * @param array defines the array of int32 to store
  31575. */
  31576. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31577. /**
  31578. * Set the value of an uniform to an array of int32 (stored as vec3)
  31579. * @param uniform defines the webGL uniform location where to store the value
  31580. * @param array defines the array of int32 to store
  31581. */
  31582. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31583. /**
  31584. * Set the value of an uniform to an array of int32 (stored as vec4)
  31585. * @param uniform defines the webGL uniform location where to store the value
  31586. * @param array defines the array of int32 to store
  31587. */
  31588. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31589. /**
  31590. * Set the value of an uniform to an array of number
  31591. * @param uniform defines the webGL uniform location where to store the value
  31592. * @param array defines the array of number to store
  31593. */
  31594. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  31595. /**
  31596. * Set the value of an uniform to an array of number (stored as vec2)
  31597. * @param uniform defines the webGL uniform location where to store the value
  31598. * @param array defines the array of number to store
  31599. */
  31600. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  31601. /**
  31602. * Set the value of an uniform to an array of number (stored as vec3)
  31603. * @param uniform defines the webGL uniform location where to store the value
  31604. * @param array defines the array of number to store
  31605. */
  31606. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  31607. /**
  31608. * Set the value of an uniform to an array of number (stored as vec4)
  31609. * @param uniform defines the webGL uniform location where to store the value
  31610. * @param array defines the array of number to store
  31611. */
  31612. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  31613. /**
  31614. * Set the value of an uniform to an array of float32 (stored as matrices)
  31615. * @param uniform defines the webGL uniform location where to store the value
  31616. * @param matrices defines the array of float32 to store
  31617. */
  31618. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  31619. /**
  31620. * Set the value of an uniform to a matrix (3x3)
  31621. * @param uniform defines the webGL uniform location where to store the value
  31622. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  31623. */
  31624. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  31625. /**
  31626. * Set the value of an uniform to a matrix (2x2)
  31627. * @param uniform defines the webGL uniform location where to store the value
  31628. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  31629. */
  31630. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  31631. /**
  31632. * Set the value of an uniform to a number (float)
  31633. * @param uniform defines the webGL uniform location where to store the value
  31634. * @param value defines the float number to store
  31635. */
  31636. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  31637. /**
  31638. * Set the value of an uniform to a vec2
  31639. * @param uniform defines the webGL uniform location where to store the value
  31640. * @param x defines the 1st component of the value
  31641. * @param y defines the 2nd component of the value
  31642. */
  31643. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  31644. /**
  31645. * Set the value of an uniform to a vec3
  31646. * @param uniform defines the webGL uniform location where to store the value
  31647. * @param x defines the 1st component of the value
  31648. * @param y defines the 2nd component of the value
  31649. * @param z defines the 3rd component of the value
  31650. */
  31651. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  31652. /**
  31653. * Set the value of an uniform to a vec4
  31654. * @param uniform defines the webGL uniform location where to store the value
  31655. * @param x defines the 1st component of the value
  31656. * @param y defines the 2nd component of the value
  31657. * @param z defines the 3rd component of the value
  31658. * @param w defines the 4th component of the value
  31659. */
  31660. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  31661. /**
  31662. * Apply all cached states (depth, culling, stencil and alpha)
  31663. */
  31664. applyStates(): void;
  31665. /**
  31666. * Enable or disable color writing
  31667. * @param enable defines the state to set
  31668. */
  31669. setColorWrite(enable: boolean): void;
  31670. /**
  31671. * Gets a boolean indicating if color writing is enabled
  31672. * @returns the current color writing state
  31673. */
  31674. getColorWrite(): boolean;
  31675. /**
  31676. * Gets the depth culling state manager
  31677. */
  31678. get depthCullingState(): DepthCullingState;
  31679. /**
  31680. * Gets the alpha state manager
  31681. */
  31682. get alphaState(): AlphaState;
  31683. /**
  31684. * Gets the stencil state manager
  31685. */
  31686. get stencilState(): StencilState;
  31687. /**
  31688. * Clears the list of texture accessible through engine.
  31689. * This can help preventing texture load conflict due to name collision.
  31690. */
  31691. clearInternalTexturesCache(): void;
  31692. /**
  31693. * Force the entire cache to be cleared
  31694. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  31695. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  31696. */
  31697. wipeCaches(bruteForce?: boolean): void;
  31698. /** @hidden */
  31699. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  31700. min: number;
  31701. mag: number;
  31702. };
  31703. /** @hidden */
  31704. _createTexture(): WebGLTexture;
  31705. /**
  31706. * Usually called from Texture.ts.
  31707. * Passed information to create a WebGLTexture
  31708. * @param urlArg defines a value which contains one of the following:
  31709. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  31710. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  31711. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  31712. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  31713. * @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)
  31714. * @param scene needed for loading to the correct scene
  31715. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  31716. * @param onLoad optional callback to be called upon successful completion
  31717. * @param onError optional callback to be called upon failure
  31718. * @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
  31719. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  31720. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  31721. * @param forcedExtension defines the extension to use to pick the right loader
  31722. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  31723. * @param mimeType defines an optional mime type
  31724. * @returns a InternalTexture for assignment back into BABYLON.Texture
  31725. */
  31726. 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;
  31727. /**
  31728. * Loads an image as an HTMLImageElement.
  31729. * @param input url string, ArrayBuffer, or Blob to load
  31730. * @param onLoad callback called when the image successfully loads
  31731. * @param onError callback called when the image fails to load
  31732. * @param offlineProvider offline provider for caching
  31733. * @param mimeType optional mime type
  31734. * @returns the HTMLImageElement of the loaded image
  31735. * @hidden
  31736. */
  31737. 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>;
  31738. /**
  31739. * @hidden
  31740. */
  31741. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  31742. /**
  31743. * Creates a raw texture
  31744. * @param data defines the data to store in the texture
  31745. * @param width defines the width of the texture
  31746. * @param height defines the height of the texture
  31747. * @param format defines the format of the data
  31748. * @param generateMipMaps defines if the engine should generate the mip levels
  31749. * @param invertY defines if data must be stored with Y axis inverted
  31750. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  31751. * @param compression defines the compression used (null by default)
  31752. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  31753. * @returns the raw texture inside an InternalTexture
  31754. */
  31755. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  31756. /**
  31757. * Creates a new raw cube texture
  31758. * @param data defines the array of data to use to create each face
  31759. * @param size defines the size of the textures
  31760. * @param format defines the format of the data
  31761. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  31762. * @param generateMipMaps defines if the engine should generate the mip levels
  31763. * @param invertY defines if data must be stored with Y axis inverted
  31764. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  31765. * @param compression defines the compression used (null by default)
  31766. * @returns the cube texture as an InternalTexture
  31767. */
  31768. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  31769. /**
  31770. * Creates a new raw 3D texture
  31771. * @param data defines the data used to create the texture
  31772. * @param width defines the width of the texture
  31773. * @param height defines the height of the texture
  31774. * @param depth defines the depth of the texture
  31775. * @param format defines the format of the texture
  31776. * @param generateMipMaps defines if the engine must generate mip levels
  31777. * @param invertY defines if data must be stored with Y axis inverted
  31778. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  31779. * @param compression defines the compressed used (can be null)
  31780. * @param textureType defines the compressed used (can be null)
  31781. * @returns a new raw 3D texture (stored in an InternalTexture)
  31782. */
  31783. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  31784. /**
  31785. * Creates a new raw 2D array texture
  31786. * @param data defines the data used to create the texture
  31787. * @param width defines the width of the texture
  31788. * @param height defines the height of the texture
  31789. * @param depth defines the number of layers of the texture
  31790. * @param format defines the format of the texture
  31791. * @param generateMipMaps defines if the engine must generate mip levels
  31792. * @param invertY defines if data must be stored with Y axis inverted
  31793. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  31794. * @param compression defines the compressed used (can be null)
  31795. * @param textureType defines the compressed used (can be null)
  31796. * @returns a new raw 2D array texture (stored in an InternalTexture)
  31797. */
  31798. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  31799. private _unpackFlipYCached;
  31800. /**
  31801. * In case you are sharing the context with other applications, it might
  31802. * be interested to not cache the unpack flip y state to ensure a consistent
  31803. * value would be set.
  31804. */
  31805. enableUnpackFlipYCached: boolean;
  31806. /** @hidden */
  31807. _unpackFlipY(value: boolean): void;
  31808. /** @hidden */
  31809. _getUnpackAlignement(): number;
  31810. private _getTextureTarget;
  31811. /**
  31812. * Update the sampling mode of a given texture
  31813. * @param samplingMode defines the required sampling mode
  31814. * @param texture defines the texture to update
  31815. * @param generateMipMaps defines whether to generate mipmaps for the texture
  31816. */
  31817. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  31818. /**
  31819. * Update the sampling mode of a given texture
  31820. * @param texture defines the texture to update
  31821. * @param wrapU defines the texture wrap mode of the u coordinates
  31822. * @param wrapV defines the texture wrap mode of the v coordinates
  31823. * @param wrapR defines the texture wrap mode of the r coordinates
  31824. */
  31825. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  31826. /** @hidden */
  31827. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  31828. width: number;
  31829. height: number;
  31830. layers?: number;
  31831. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  31832. /** @hidden */
  31833. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  31834. /** @hidden */
  31835. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  31836. /**
  31837. * Update a portion of an internal texture
  31838. * @param texture defines the texture to update
  31839. * @param imageData defines the data to store into the texture
  31840. * @param xOffset defines the x coordinates of the update rectangle
  31841. * @param yOffset defines the y coordinates of the update rectangle
  31842. * @param width defines the width of the update rectangle
  31843. * @param height defines the height of the update rectangle
  31844. * @param faceIndex defines the face index if texture is a cube (0 by default)
  31845. * @param lod defines the lod level to update (0 by default)
  31846. */
  31847. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  31848. /** @hidden */
  31849. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  31850. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  31851. private _prepareWebGLTexture;
  31852. /** @hidden */
  31853. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  31854. private _getDepthStencilBuffer;
  31855. /** @hidden */
  31856. _releaseFramebufferObjects(texture: InternalTexture): void;
  31857. /** @hidden */
  31858. _releaseTexture(texture: InternalTexture): void;
  31859. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  31860. protected _setProgram(program: WebGLProgram): void;
  31861. protected _boundUniforms: {
  31862. [key: number]: WebGLUniformLocation;
  31863. };
  31864. /**
  31865. * Binds an effect to the webGL context
  31866. * @param effect defines the effect to bind
  31867. */
  31868. bindSamplers(effect: Effect): void;
  31869. private _activateCurrentTexture;
  31870. /** @hidden */
  31871. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  31872. /** @hidden */
  31873. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  31874. /**
  31875. * Unbind all textures from the webGL context
  31876. */
  31877. unbindAllTextures(): void;
  31878. /**
  31879. * Sets a texture to the according uniform.
  31880. * @param channel The texture channel
  31881. * @param uniform The uniform to set
  31882. * @param texture The texture to apply
  31883. */
  31884. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  31885. private _bindSamplerUniformToChannel;
  31886. private _getTextureWrapMode;
  31887. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  31888. /**
  31889. * Sets an array of texture to the webGL context
  31890. * @param channel defines the channel where the texture array must be set
  31891. * @param uniform defines the associated uniform location
  31892. * @param textures defines the array of textures to bind
  31893. */
  31894. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  31895. /** @hidden */
  31896. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  31897. private _setTextureParameterFloat;
  31898. private _setTextureParameterInteger;
  31899. /**
  31900. * Unbind all vertex attributes from the webGL context
  31901. */
  31902. unbindAllAttributes(): void;
  31903. /**
  31904. * 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
  31905. */
  31906. releaseEffects(): void;
  31907. /**
  31908. * Dispose and release all associated resources
  31909. */
  31910. dispose(): void;
  31911. /**
  31912. * Attach a new callback raised when context lost event is fired
  31913. * @param callback defines the callback to call
  31914. */
  31915. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  31916. /**
  31917. * Attach a new callback raised when context restored event is fired
  31918. * @param callback defines the callback to call
  31919. */
  31920. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  31921. /**
  31922. * Get the current error code of the webGL context
  31923. * @returns the error code
  31924. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  31925. */
  31926. getError(): number;
  31927. private _canRenderToFloatFramebuffer;
  31928. private _canRenderToHalfFloatFramebuffer;
  31929. private _canRenderToFramebuffer;
  31930. /** @hidden */
  31931. _getWebGLTextureType(type: number): number;
  31932. /** @hidden */
  31933. _getInternalFormat(format: number): number;
  31934. /** @hidden */
  31935. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  31936. /** @hidden */
  31937. _getRGBAMultiSampleBufferFormat(type: number): number;
  31938. /** @hidden */
  31939. _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;
  31940. /**
  31941. * Loads a file from a url
  31942. * @param url url to load
  31943. * @param onSuccess callback called when the file successfully loads
  31944. * @param onProgress callback called while file is loading (if the server supports this mode)
  31945. * @param offlineProvider defines the offline provider for caching
  31946. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  31947. * @param onError callback called when the file fails to load
  31948. * @returns a file request object
  31949. * @hidden
  31950. */
  31951. 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;
  31952. /**
  31953. * Reads pixels from the current frame buffer. Please note that this function can be slow
  31954. * @param x defines the x coordinate of the rectangle where pixels must be read
  31955. * @param y defines the y coordinate of the rectangle where pixels must be read
  31956. * @param width defines the width of the rectangle where pixels must be read
  31957. * @param height defines the height of the rectangle where pixels must be read
  31958. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  31959. * @returns a Uint8Array containing RGBA colors
  31960. */
  31961. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  31962. private static _isSupported;
  31963. /**
  31964. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  31965. * @returns true if the engine can be created
  31966. * @ignorenaming
  31967. */
  31968. static isSupported(): boolean;
  31969. /**
  31970. * Find the next highest power of two.
  31971. * @param x Number to start search from.
  31972. * @return Next highest power of two.
  31973. */
  31974. static CeilingPOT(x: number): number;
  31975. /**
  31976. * Find the next lowest power of two.
  31977. * @param x Number to start search from.
  31978. * @return Next lowest power of two.
  31979. */
  31980. static FloorPOT(x: number): number;
  31981. /**
  31982. * Find the nearest power of two.
  31983. * @param x Number to start search from.
  31984. * @return Next nearest power of two.
  31985. */
  31986. static NearestPOT(x: number): number;
  31987. /**
  31988. * Get the closest exponent of two
  31989. * @param value defines the value to approximate
  31990. * @param max defines the maximum value to return
  31991. * @param mode defines how to define the closest value
  31992. * @returns closest exponent of two of the given value
  31993. */
  31994. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  31995. /**
  31996. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  31997. * @param func - the function to be called
  31998. * @param requester - the object that will request the next frame. Falls back to window.
  31999. * @returns frame number
  32000. */
  32001. static QueueNewFrame(func: () => void, requester?: any): number;
  32002. /**
  32003. * Gets host document
  32004. * @returns the host document object
  32005. */
  32006. getHostDocument(): Nullable<Document>;
  32007. }
  32008. }
  32009. declare module BABYLON {
  32010. /**
  32011. * Class representing spherical harmonics coefficients to the 3rd degree
  32012. */
  32013. export class SphericalHarmonics {
  32014. /**
  32015. * Defines whether or not the harmonics have been prescaled for rendering.
  32016. */
  32017. preScaled: boolean;
  32018. /**
  32019. * The l0,0 coefficients of the spherical harmonics
  32020. */
  32021. l00: Vector3;
  32022. /**
  32023. * The l1,-1 coefficients of the spherical harmonics
  32024. */
  32025. l1_1: Vector3;
  32026. /**
  32027. * The l1,0 coefficients of the spherical harmonics
  32028. */
  32029. l10: Vector3;
  32030. /**
  32031. * The l1,1 coefficients of the spherical harmonics
  32032. */
  32033. l11: Vector3;
  32034. /**
  32035. * The l2,-2 coefficients of the spherical harmonics
  32036. */
  32037. l2_2: Vector3;
  32038. /**
  32039. * The l2,-1 coefficients of the spherical harmonics
  32040. */
  32041. l2_1: Vector3;
  32042. /**
  32043. * The l2,0 coefficients of the spherical harmonics
  32044. */
  32045. l20: Vector3;
  32046. /**
  32047. * The l2,1 coefficients of the spherical harmonics
  32048. */
  32049. l21: Vector3;
  32050. /**
  32051. * The l2,2 coefficients of the spherical harmonics
  32052. */
  32053. l22: Vector3;
  32054. /**
  32055. * Adds a light to the spherical harmonics
  32056. * @param direction the direction of the light
  32057. * @param color the color of the light
  32058. * @param deltaSolidAngle the delta solid angle of the light
  32059. */
  32060. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  32061. /**
  32062. * Scales the spherical harmonics by the given amount
  32063. * @param scale the amount to scale
  32064. */
  32065. scaleInPlace(scale: number): void;
  32066. /**
  32067. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  32068. *
  32069. * ```
  32070. * E_lm = A_l * L_lm
  32071. * ```
  32072. *
  32073. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  32074. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  32075. * the scaling factors are given in equation 9.
  32076. */
  32077. convertIncidentRadianceToIrradiance(): void;
  32078. /**
  32079. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  32080. *
  32081. * ```
  32082. * L = (1/pi) * E * rho
  32083. * ```
  32084. *
  32085. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  32086. */
  32087. convertIrradianceToLambertianRadiance(): void;
  32088. /**
  32089. * Integrates the reconstruction coefficients directly in to the SH preventing further
  32090. * required operations at run time.
  32091. *
  32092. * This is simply done by scaling back the SH with Ylm constants parameter.
  32093. * The trigonometric part being applied by the shader at run time.
  32094. */
  32095. preScaleForRendering(): void;
  32096. /**
  32097. * Constructs a spherical harmonics from an array.
  32098. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  32099. * @returns the spherical harmonics
  32100. */
  32101. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  32102. /**
  32103. * Gets the spherical harmonics from polynomial
  32104. * @param polynomial the spherical polynomial
  32105. * @returns the spherical harmonics
  32106. */
  32107. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  32108. }
  32109. /**
  32110. * Class representing spherical polynomial coefficients to the 3rd degree
  32111. */
  32112. export class SphericalPolynomial {
  32113. private _harmonics;
  32114. /**
  32115. * The spherical harmonics used to create the polynomials.
  32116. */
  32117. get preScaledHarmonics(): SphericalHarmonics;
  32118. /**
  32119. * The x coefficients of the spherical polynomial
  32120. */
  32121. x: Vector3;
  32122. /**
  32123. * The y coefficients of the spherical polynomial
  32124. */
  32125. y: Vector3;
  32126. /**
  32127. * The z coefficients of the spherical polynomial
  32128. */
  32129. z: Vector3;
  32130. /**
  32131. * The xx coefficients of the spherical polynomial
  32132. */
  32133. xx: Vector3;
  32134. /**
  32135. * The yy coefficients of the spherical polynomial
  32136. */
  32137. yy: Vector3;
  32138. /**
  32139. * The zz coefficients of the spherical polynomial
  32140. */
  32141. zz: Vector3;
  32142. /**
  32143. * The xy coefficients of the spherical polynomial
  32144. */
  32145. xy: Vector3;
  32146. /**
  32147. * The yz coefficients of the spherical polynomial
  32148. */
  32149. yz: Vector3;
  32150. /**
  32151. * The zx coefficients of the spherical polynomial
  32152. */
  32153. zx: Vector3;
  32154. /**
  32155. * Adds an ambient color to the spherical polynomial
  32156. * @param color the color to add
  32157. */
  32158. addAmbient(color: Color3): void;
  32159. /**
  32160. * Scales the spherical polynomial by the given amount
  32161. * @param scale the amount to scale
  32162. */
  32163. scaleInPlace(scale: number): void;
  32164. /**
  32165. * Gets the spherical polynomial from harmonics
  32166. * @param harmonics the spherical harmonics
  32167. * @returns the spherical polynomial
  32168. */
  32169. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  32170. /**
  32171. * Constructs a spherical polynomial from an array.
  32172. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  32173. * @returns the spherical polynomial
  32174. */
  32175. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  32176. }
  32177. }
  32178. declare module BABYLON {
  32179. /**
  32180. * Defines the source of the internal texture
  32181. */
  32182. export enum InternalTextureSource {
  32183. /**
  32184. * The source of the texture data is unknown
  32185. */
  32186. Unknown = 0,
  32187. /**
  32188. * Texture data comes from an URL
  32189. */
  32190. Url = 1,
  32191. /**
  32192. * Texture data is only used for temporary storage
  32193. */
  32194. Temp = 2,
  32195. /**
  32196. * Texture data comes from raw data (ArrayBuffer)
  32197. */
  32198. Raw = 3,
  32199. /**
  32200. * Texture content is dynamic (video or dynamic texture)
  32201. */
  32202. Dynamic = 4,
  32203. /**
  32204. * Texture content is generated by rendering to it
  32205. */
  32206. RenderTarget = 5,
  32207. /**
  32208. * Texture content is part of a multi render target process
  32209. */
  32210. MultiRenderTarget = 6,
  32211. /**
  32212. * Texture data comes from a cube data file
  32213. */
  32214. Cube = 7,
  32215. /**
  32216. * Texture data comes from a raw cube data
  32217. */
  32218. CubeRaw = 8,
  32219. /**
  32220. * Texture data come from a prefiltered cube data file
  32221. */
  32222. CubePrefiltered = 9,
  32223. /**
  32224. * Texture content is raw 3D data
  32225. */
  32226. Raw3D = 10,
  32227. /**
  32228. * Texture content is raw 2D array data
  32229. */
  32230. Raw2DArray = 11,
  32231. /**
  32232. * Texture content is a depth texture
  32233. */
  32234. Depth = 12,
  32235. /**
  32236. * Texture data comes from a raw cube data encoded with RGBD
  32237. */
  32238. CubeRawRGBD = 13
  32239. }
  32240. /**
  32241. * Class used to store data associated with WebGL texture data for the engine
  32242. * This class should not be used directly
  32243. */
  32244. export class InternalTexture {
  32245. /** @hidden */
  32246. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  32247. /**
  32248. * Defines if the texture is ready
  32249. */
  32250. isReady: boolean;
  32251. /**
  32252. * Defines if the texture is a cube texture
  32253. */
  32254. isCube: boolean;
  32255. /**
  32256. * Defines if the texture contains 3D data
  32257. */
  32258. is3D: boolean;
  32259. /**
  32260. * Defines if the texture contains 2D array data
  32261. */
  32262. is2DArray: boolean;
  32263. /**
  32264. * Defines if the texture contains multiview data
  32265. */
  32266. isMultiview: boolean;
  32267. /**
  32268. * Gets the URL used to load this texture
  32269. */
  32270. url: string;
  32271. /**
  32272. * Gets the sampling mode of the texture
  32273. */
  32274. samplingMode: number;
  32275. /**
  32276. * Gets a boolean indicating if the texture needs mipmaps generation
  32277. */
  32278. generateMipMaps: boolean;
  32279. /**
  32280. * Gets the number of samples used by the texture (WebGL2+ only)
  32281. */
  32282. samples: number;
  32283. /**
  32284. * Gets the type of the texture (int, float...)
  32285. */
  32286. type: number;
  32287. /**
  32288. * Gets the format of the texture (RGB, RGBA...)
  32289. */
  32290. format: number;
  32291. /**
  32292. * Observable called when the texture is loaded
  32293. */
  32294. onLoadedObservable: Observable<InternalTexture>;
  32295. /**
  32296. * Gets the width of the texture
  32297. */
  32298. width: number;
  32299. /**
  32300. * Gets the height of the texture
  32301. */
  32302. height: number;
  32303. /**
  32304. * Gets the depth of the texture
  32305. */
  32306. depth: number;
  32307. /**
  32308. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  32309. */
  32310. baseWidth: number;
  32311. /**
  32312. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  32313. */
  32314. baseHeight: number;
  32315. /**
  32316. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  32317. */
  32318. baseDepth: number;
  32319. /**
  32320. * Gets a boolean indicating if the texture is inverted on Y axis
  32321. */
  32322. invertY: boolean;
  32323. /** @hidden */
  32324. _invertVScale: boolean;
  32325. /** @hidden */
  32326. _associatedChannel: number;
  32327. /** @hidden */
  32328. _source: InternalTextureSource;
  32329. /** @hidden */
  32330. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  32331. /** @hidden */
  32332. _bufferView: Nullable<ArrayBufferView>;
  32333. /** @hidden */
  32334. _bufferViewArray: Nullable<ArrayBufferView[]>;
  32335. /** @hidden */
  32336. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  32337. /** @hidden */
  32338. _size: number;
  32339. /** @hidden */
  32340. _extension: string;
  32341. /** @hidden */
  32342. _files: Nullable<string[]>;
  32343. /** @hidden */
  32344. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  32345. /** @hidden */
  32346. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  32347. /** @hidden */
  32348. _framebuffer: Nullable<WebGLFramebuffer>;
  32349. /** @hidden */
  32350. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  32351. /** @hidden */
  32352. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  32353. /** @hidden */
  32354. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  32355. /** @hidden */
  32356. _attachments: Nullable<number[]>;
  32357. /** @hidden */
  32358. _cachedCoordinatesMode: Nullable<number>;
  32359. /** @hidden */
  32360. _cachedWrapU: Nullable<number>;
  32361. /** @hidden */
  32362. _cachedWrapV: Nullable<number>;
  32363. /** @hidden */
  32364. _cachedWrapR: Nullable<number>;
  32365. /** @hidden */
  32366. _cachedAnisotropicFilteringLevel: Nullable<number>;
  32367. /** @hidden */
  32368. _isDisabled: boolean;
  32369. /** @hidden */
  32370. _compression: Nullable<string>;
  32371. /** @hidden */
  32372. _generateStencilBuffer: boolean;
  32373. /** @hidden */
  32374. _generateDepthBuffer: boolean;
  32375. /** @hidden */
  32376. _comparisonFunction: number;
  32377. /** @hidden */
  32378. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  32379. /** @hidden */
  32380. _lodGenerationScale: number;
  32381. /** @hidden */
  32382. _lodGenerationOffset: number;
  32383. /** @hidden */
  32384. _depthStencilTexture: Nullable<InternalTexture>;
  32385. /** @hidden */
  32386. _colorTextureArray: Nullable<WebGLTexture>;
  32387. /** @hidden */
  32388. _depthStencilTextureArray: Nullable<WebGLTexture>;
  32389. /** @hidden */
  32390. _lodTextureHigh: Nullable<BaseTexture>;
  32391. /** @hidden */
  32392. _lodTextureMid: Nullable<BaseTexture>;
  32393. /** @hidden */
  32394. _lodTextureLow: Nullable<BaseTexture>;
  32395. /** @hidden */
  32396. _isRGBD: boolean;
  32397. /** @hidden */
  32398. _linearSpecularLOD: boolean;
  32399. /** @hidden */
  32400. _irradianceTexture: Nullable<BaseTexture>;
  32401. /** @hidden */
  32402. _webGLTexture: Nullable<WebGLTexture>;
  32403. /** @hidden */
  32404. _references: number;
  32405. private _engine;
  32406. /**
  32407. * Gets the Engine the texture belongs to.
  32408. * @returns The babylon engine
  32409. */
  32410. getEngine(): ThinEngine;
  32411. /**
  32412. * Gets the data source type of the texture
  32413. */
  32414. get source(): InternalTextureSource;
  32415. /**
  32416. * Creates a new InternalTexture
  32417. * @param engine defines the engine to use
  32418. * @param source defines the type of data that will be used
  32419. * @param delayAllocation if the texture allocation should be delayed (default: false)
  32420. */
  32421. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  32422. /**
  32423. * Increments the number of references (ie. the number of Texture that point to it)
  32424. */
  32425. incrementReferences(): void;
  32426. /**
  32427. * Change the size of the texture (not the size of the content)
  32428. * @param width defines the new width
  32429. * @param height defines the new height
  32430. * @param depth defines the new depth (1 by default)
  32431. */
  32432. updateSize(width: int, height: int, depth?: int): void;
  32433. /** @hidden */
  32434. _rebuild(): void;
  32435. /** @hidden */
  32436. _swapAndDie(target: InternalTexture): void;
  32437. /**
  32438. * Dispose the current allocated resources
  32439. */
  32440. dispose(): void;
  32441. }
  32442. }
  32443. declare module BABYLON {
  32444. /**
  32445. * Class used to work with sound analyzer using fast fourier transform (FFT)
  32446. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32447. */
  32448. export class Analyser {
  32449. /**
  32450. * Gets or sets the smoothing
  32451. * @ignorenaming
  32452. */
  32453. SMOOTHING: number;
  32454. /**
  32455. * Gets or sets the FFT table size
  32456. * @ignorenaming
  32457. */
  32458. FFT_SIZE: number;
  32459. /**
  32460. * Gets or sets the bar graph amplitude
  32461. * @ignorenaming
  32462. */
  32463. BARGRAPHAMPLITUDE: number;
  32464. /**
  32465. * Gets or sets the position of the debug canvas
  32466. * @ignorenaming
  32467. */
  32468. DEBUGCANVASPOS: {
  32469. x: number;
  32470. y: number;
  32471. };
  32472. /**
  32473. * Gets or sets the debug canvas size
  32474. * @ignorenaming
  32475. */
  32476. DEBUGCANVASSIZE: {
  32477. width: number;
  32478. height: number;
  32479. };
  32480. private _byteFreqs;
  32481. private _byteTime;
  32482. private _floatFreqs;
  32483. private _webAudioAnalyser;
  32484. private _debugCanvas;
  32485. private _debugCanvasContext;
  32486. private _scene;
  32487. private _registerFunc;
  32488. private _audioEngine;
  32489. /**
  32490. * Creates a new analyser
  32491. * @param scene defines hosting scene
  32492. */
  32493. constructor(scene: Scene);
  32494. /**
  32495. * Get the number of data values you will have to play with for the visualization
  32496. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  32497. * @returns a number
  32498. */
  32499. getFrequencyBinCount(): number;
  32500. /**
  32501. * Gets the current frequency data as a byte array
  32502. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  32503. * @returns a Uint8Array
  32504. */
  32505. getByteFrequencyData(): Uint8Array;
  32506. /**
  32507. * Gets the current waveform as a byte array
  32508. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  32509. * @returns a Uint8Array
  32510. */
  32511. getByteTimeDomainData(): Uint8Array;
  32512. /**
  32513. * Gets the current frequency data as a float array
  32514. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  32515. * @returns a Float32Array
  32516. */
  32517. getFloatFrequencyData(): Float32Array;
  32518. /**
  32519. * Renders the debug canvas
  32520. */
  32521. drawDebugCanvas(): void;
  32522. /**
  32523. * Stops rendering the debug canvas and removes it
  32524. */
  32525. stopDebugCanvas(): void;
  32526. /**
  32527. * Connects two audio nodes
  32528. * @param inputAudioNode defines first node to connect
  32529. * @param outputAudioNode defines second node to connect
  32530. */
  32531. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  32532. /**
  32533. * Releases all associated resources
  32534. */
  32535. dispose(): void;
  32536. }
  32537. }
  32538. declare module BABYLON {
  32539. /**
  32540. * This represents an audio engine and it is responsible
  32541. * to play, synchronize and analyse sounds throughout the application.
  32542. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32543. */
  32544. export interface IAudioEngine extends IDisposable {
  32545. /**
  32546. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  32547. */
  32548. readonly canUseWebAudio: boolean;
  32549. /**
  32550. * Gets the current AudioContext if available.
  32551. */
  32552. readonly audioContext: Nullable<AudioContext>;
  32553. /**
  32554. * The master gain node defines the global audio volume of your audio engine.
  32555. */
  32556. readonly masterGain: GainNode;
  32557. /**
  32558. * Gets whether or not mp3 are supported by your browser.
  32559. */
  32560. readonly isMP3supported: boolean;
  32561. /**
  32562. * Gets whether or not ogg are supported by your browser.
  32563. */
  32564. readonly isOGGsupported: boolean;
  32565. /**
  32566. * Defines if Babylon should emit a warning if WebAudio is not supported.
  32567. * @ignoreNaming
  32568. */
  32569. WarnedWebAudioUnsupported: boolean;
  32570. /**
  32571. * Defines if the audio engine relies on a custom unlocked button.
  32572. * In this case, the embedded button will not be displayed.
  32573. */
  32574. useCustomUnlockedButton: boolean;
  32575. /**
  32576. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  32577. */
  32578. readonly unlocked: boolean;
  32579. /**
  32580. * Event raised when audio has been unlocked on the browser.
  32581. */
  32582. onAudioUnlockedObservable: Observable<AudioEngine>;
  32583. /**
  32584. * Event raised when audio has been locked on the browser.
  32585. */
  32586. onAudioLockedObservable: Observable<AudioEngine>;
  32587. /**
  32588. * Flags the audio engine in Locked state.
  32589. * This happens due to new browser policies preventing audio to autoplay.
  32590. */
  32591. lock(): void;
  32592. /**
  32593. * Unlocks the audio engine once a user action has been done on the dom.
  32594. * This is helpful to resume play once browser policies have been satisfied.
  32595. */
  32596. unlock(): void;
  32597. }
  32598. /**
  32599. * This represents the default audio engine used in babylon.
  32600. * It is responsible to play, synchronize and analyse sounds throughout the application.
  32601. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32602. */
  32603. export class AudioEngine implements IAudioEngine {
  32604. private _audioContext;
  32605. private _audioContextInitialized;
  32606. private _muteButton;
  32607. private _hostElement;
  32608. /**
  32609. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  32610. */
  32611. canUseWebAudio: boolean;
  32612. /**
  32613. * The master gain node defines the global audio volume of your audio engine.
  32614. */
  32615. masterGain: GainNode;
  32616. /**
  32617. * Defines if Babylon should emit a warning if WebAudio is not supported.
  32618. * @ignoreNaming
  32619. */
  32620. WarnedWebAudioUnsupported: boolean;
  32621. /**
  32622. * Gets whether or not mp3 are supported by your browser.
  32623. */
  32624. isMP3supported: boolean;
  32625. /**
  32626. * Gets whether or not ogg are supported by your browser.
  32627. */
  32628. isOGGsupported: boolean;
  32629. /**
  32630. * Gets whether audio has been unlocked on the device.
  32631. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  32632. * a user interaction has happened.
  32633. */
  32634. unlocked: boolean;
  32635. /**
  32636. * Defines if the audio engine relies on a custom unlocked button.
  32637. * In this case, the embedded button will not be displayed.
  32638. */
  32639. useCustomUnlockedButton: boolean;
  32640. /**
  32641. * Event raised when audio has been unlocked on the browser.
  32642. */
  32643. onAudioUnlockedObservable: Observable<AudioEngine>;
  32644. /**
  32645. * Event raised when audio has been locked on the browser.
  32646. */
  32647. onAudioLockedObservable: Observable<AudioEngine>;
  32648. /**
  32649. * Gets the current AudioContext if available.
  32650. */
  32651. get audioContext(): Nullable<AudioContext>;
  32652. private _connectedAnalyser;
  32653. /**
  32654. * Instantiates a new audio engine.
  32655. *
  32656. * There should be only one per page as some browsers restrict the number
  32657. * of audio contexts you can create.
  32658. * @param hostElement defines the host element where to display the mute icon if necessary
  32659. */
  32660. constructor(hostElement?: Nullable<HTMLElement>);
  32661. /**
  32662. * Flags the audio engine in Locked state.
  32663. * This happens due to new browser policies preventing audio to autoplay.
  32664. */
  32665. lock(): void;
  32666. /**
  32667. * Unlocks the audio engine once a user action has been done on the dom.
  32668. * This is helpful to resume play once browser policies have been satisfied.
  32669. */
  32670. unlock(): void;
  32671. private _resumeAudioContext;
  32672. private _initializeAudioContext;
  32673. private _tryToRun;
  32674. private _triggerRunningState;
  32675. private _triggerSuspendedState;
  32676. private _displayMuteButton;
  32677. private _moveButtonToTopLeft;
  32678. private _onResize;
  32679. private _hideMuteButton;
  32680. /**
  32681. * Destroy and release the resources associated with the audio ccontext.
  32682. */
  32683. dispose(): void;
  32684. /**
  32685. * Gets the global volume sets on the master gain.
  32686. * @returns the global volume if set or -1 otherwise
  32687. */
  32688. getGlobalVolume(): number;
  32689. /**
  32690. * Sets the global volume of your experience (sets on the master gain).
  32691. * @param newVolume Defines the new global volume of the application
  32692. */
  32693. setGlobalVolume(newVolume: number): void;
  32694. /**
  32695. * Connect the audio engine to an audio analyser allowing some amazing
  32696. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  32697. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  32698. * @param analyser The analyser to connect to the engine
  32699. */
  32700. connectToAnalyser(analyser: Analyser): void;
  32701. }
  32702. }
  32703. declare module BABYLON {
  32704. /**
  32705. * Interface used to present a loading screen while loading a scene
  32706. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32707. */
  32708. export interface ILoadingScreen {
  32709. /**
  32710. * Function called to display the loading screen
  32711. */
  32712. displayLoadingUI: () => void;
  32713. /**
  32714. * Function called to hide the loading screen
  32715. */
  32716. hideLoadingUI: () => void;
  32717. /**
  32718. * Gets or sets the color to use for the background
  32719. */
  32720. loadingUIBackgroundColor: string;
  32721. /**
  32722. * Gets or sets the text to display while loading
  32723. */
  32724. loadingUIText: string;
  32725. }
  32726. /**
  32727. * Class used for the default loading screen
  32728. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32729. */
  32730. export class DefaultLoadingScreen implements ILoadingScreen {
  32731. private _renderingCanvas;
  32732. private _loadingText;
  32733. private _loadingDivBackgroundColor;
  32734. private _loadingDiv;
  32735. private _loadingTextDiv;
  32736. /** Gets or sets the logo url to use for the default loading screen */
  32737. static DefaultLogoUrl: string;
  32738. /** Gets or sets the spinner url to use for the default loading screen */
  32739. static DefaultSpinnerUrl: string;
  32740. /**
  32741. * Creates a new default loading screen
  32742. * @param _renderingCanvas defines the canvas used to render the scene
  32743. * @param _loadingText defines the default text to display
  32744. * @param _loadingDivBackgroundColor defines the default background color
  32745. */
  32746. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  32747. /**
  32748. * Function called to display the loading screen
  32749. */
  32750. displayLoadingUI(): void;
  32751. /**
  32752. * Function called to hide the loading screen
  32753. */
  32754. hideLoadingUI(): void;
  32755. /**
  32756. * Gets or sets the text to display while loading
  32757. */
  32758. set loadingUIText(text: string);
  32759. get loadingUIText(): string;
  32760. /**
  32761. * Gets or sets the color to use for the background
  32762. */
  32763. get loadingUIBackgroundColor(): string;
  32764. set loadingUIBackgroundColor(color: string);
  32765. private _resizeLoadingUI;
  32766. }
  32767. }
  32768. declare module BABYLON {
  32769. /**
  32770. * Interface for any object that can request an animation frame
  32771. */
  32772. export interface ICustomAnimationFrameRequester {
  32773. /**
  32774. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  32775. */
  32776. renderFunction?: Function;
  32777. /**
  32778. * Called to request the next frame to render to
  32779. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  32780. */
  32781. requestAnimationFrame: Function;
  32782. /**
  32783. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  32784. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  32785. */
  32786. requestID?: number;
  32787. }
  32788. }
  32789. declare module BABYLON {
  32790. /**
  32791. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  32792. */
  32793. export class PerformanceMonitor {
  32794. private _enabled;
  32795. private _rollingFrameTime;
  32796. private _lastFrameTimeMs;
  32797. /**
  32798. * constructor
  32799. * @param frameSampleSize The number of samples required to saturate the sliding window
  32800. */
  32801. constructor(frameSampleSize?: number);
  32802. /**
  32803. * Samples current frame
  32804. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  32805. */
  32806. sampleFrame(timeMs?: number): void;
  32807. /**
  32808. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  32809. */
  32810. get averageFrameTime(): number;
  32811. /**
  32812. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  32813. */
  32814. get averageFrameTimeVariance(): number;
  32815. /**
  32816. * Returns the frame time of the most recent frame
  32817. */
  32818. get instantaneousFrameTime(): number;
  32819. /**
  32820. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  32821. */
  32822. get averageFPS(): number;
  32823. /**
  32824. * Returns the average framerate in frames per second using the most recent frame time
  32825. */
  32826. get instantaneousFPS(): number;
  32827. /**
  32828. * Returns true if enough samples have been taken to completely fill the sliding window
  32829. */
  32830. get isSaturated(): boolean;
  32831. /**
  32832. * Enables contributions to the sliding window sample set
  32833. */
  32834. enable(): void;
  32835. /**
  32836. * Disables contributions to the sliding window sample set
  32837. * Samples will not be interpolated over the disabled period
  32838. */
  32839. disable(): void;
  32840. /**
  32841. * Returns true if sampling is enabled
  32842. */
  32843. get isEnabled(): boolean;
  32844. /**
  32845. * Resets performance monitor
  32846. */
  32847. reset(): void;
  32848. }
  32849. /**
  32850. * RollingAverage
  32851. *
  32852. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  32853. */
  32854. export class RollingAverage {
  32855. /**
  32856. * Current average
  32857. */
  32858. average: number;
  32859. /**
  32860. * Current variance
  32861. */
  32862. variance: number;
  32863. protected _samples: Array<number>;
  32864. protected _sampleCount: number;
  32865. protected _pos: number;
  32866. protected _m2: number;
  32867. /**
  32868. * constructor
  32869. * @param length The number of samples required to saturate the sliding window
  32870. */
  32871. constructor(length: number);
  32872. /**
  32873. * Adds a sample to the sample set
  32874. * @param v The sample value
  32875. */
  32876. add(v: number): void;
  32877. /**
  32878. * Returns previously added values or null if outside of history or outside the sliding window domain
  32879. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  32880. * @return Value previously recorded with add() or null if outside of range
  32881. */
  32882. history(i: number): number;
  32883. /**
  32884. * Returns true if enough samples have been taken to completely fill the sliding window
  32885. * @return true if sample-set saturated
  32886. */
  32887. isSaturated(): boolean;
  32888. /**
  32889. * Resets the rolling average (equivalent to 0 samples taken so far)
  32890. */
  32891. reset(): void;
  32892. /**
  32893. * Wraps a value around the sample range boundaries
  32894. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  32895. * @return Wrapped position in sample range
  32896. */
  32897. protected _wrapPosition(i: number): number;
  32898. }
  32899. }
  32900. declare module BABYLON {
  32901. /**
  32902. * This class is used to track a performance counter which is number based.
  32903. * The user has access to many properties which give statistics of different nature.
  32904. *
  32905. * The implementer can track two kinds of Performance Counter: time and count.
  32906. * 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.
  32907. * 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.
  32908. */
  32909. export class PerfCounter {
  32910. /**
  32911. * Gets or sets a global boolean to turn on and off all the counters
  32912. */
  32913. static Enabled: boolean;
  32914. /**
  32915. * Returns the smallest value ever
  32916. */
  32917. get min(): number;
  32918. /**
  32919. * Returns the biggest value ever
  32920. */
  32921. get max(): number;
  32922. /**
  32923. * Returns the average value since the performance counter is running
  32924. */
  32925. get average(): number;
  32926. /**
  32927. * Returns the average value of the last second the counter was monitored
  32928. */
  32929. get lastSecAverage(): number;
  32930. /**
  32931. * Returns the current value
  32932. */
  32933. get current(): number;
  32934. /**
  32935. * Gets the accumulated total
  32936. */
  32937. get total(): number;
  32938. /**
  32939. * Gets the total value count
  32940. */
  32941. get count(): number;
  32942. /**
  32943. * Creates a new counter
  32944. */
  32945. constructor();
  32946. /**
  32947. * Call this method to start monitoring a new frame.
  32948. * 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.
  32949. */
  32950. fetchNewFrame(): void;
  32951. /**
  32952. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  32953. * @param newCount the count value to add to the monitored count
  32954. * @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.
  32955. */
  32956. addCount(newCount: number, fetchResult: boolean): void;
  32957. /**
  32958. * Start monitoring this performance counter
  32959. */
  32960. beginMonitoring(): void;
  32961. /**
  32962. * Compute the time lapsed since the previous beginMonitoring() call.
  32963. * @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
  32964. */
  32965. endMonitoring(newFrame?: boolean): void;
  32966. private _fetchResult;
  32967. private _startMonitoringTime;
  32968. private _min;
  32969. private _max;
  32970. private _average;
  32971. private _current;
  32972. private _totalValueCount;
  32973. private _totalAccumulated;
  32974. private _lastSecAverage;
  32975. private _lastSecAccumulated;
  32976. private _lastSecTime;
  32977. private _lastSecValueCount;
  32978. }
  32979. }
  32980. declare module BABYLON {
  32981. interface ThinEngine {
  32982. /**
  32983. * Sets alpha constants used by some alpha blending modes
  32984. * @param r defines the red component
  32985. * @param g defines the green component
  32986. * @param b defines the blue component
  32987. * @param a defines the alpha component
  32988. */
  32989. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  32990. /**
  32991. * Sets the current alpha mode
  32992. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  32993. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  32994. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  32995. */
  32996. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  32997. /**
  32998. * Gets the current alpha mode
  32999. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  33000. * @returns the current alpha mode
  33001. */
  33002. getAlphaMode(): number;
  33003. /**
  33004. * Sets the current alpha equation
  33005. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  33006. */
  33007. setAlphaEquation(equation: number): void;
  33008. /**
  33009. * Gets the current alpha equation.
  33010. * @returns the current alpha equation
  33011. */
  33012. getAlphaEquation(): number;
  33013. }
  33014. }
  33015. declare module BABYLON {
  33016. /**
  33017. * Defines the interface used by display changed events
  33018. */
  33019. export interface IDisplayChangedEventArgs {
  33020. /** Gets the vrDisplay object (if any) */
  33021. vrDisplay: Nullable<any>;
  33022. /** Gets a boolean indicating if webVR is supported */
  33023. vrSupported: boolean;
  33024. }
  33025. /**
  33026. * Defines the interface used by objects containing a viewport (like a camera)
  33027. */
  33028. interface IViewportOwnerLike {
  33029. /**
  33030. * Gets or sets the viewport
  33031. */
  33032. viewport: IViewportLike;
  33033. }
  33034. /**
  33035. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  33036. */
  33037. export class Engine extends ThinEngine {
  33038. /** Defines that alpha blending is disabled */
  33039. static readonly ALPHA_DISABLE: number;
  33040. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  33041. static readonly ALPHA_ADD: number;
  33042. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  33043. static readonly ALPHA_COMBINE: number;
  33044. /** Defines that alpha blending to DEST - SRC * DEST */
  33045. static readonly ALPHA_SUBTRACT: number;
  33046. /** Defines that alpha blending to SRC * DEST */
  33047. static readonly ALPHA_MULTIPLY: number;
  33048. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  33049. static readonly ALPHA_MAXIMIZED: number;
  33050. /** Defines that alpha blending to SRC + DEST */
  33051. static readonly ALPHA_ONEONE: number;
  33052. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  33053. static readonly ALPHA_PREMULTIPLIED: number;
  33054. /**
  33055. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  33056. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  33057. */
  33058. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  33059. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  33060. static readonly ALPHA_INTERPOLATE: number;
  33061. /**
  33062. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  33063. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  33064. */
  33065. static readonly ALPHA_SCREENMODE: number;
  33066. /** Defines that the ressource is not delayed*/
  33067. static readonly DELAYLOADSTATE_NONE: number;
  33068. /** Defines that the ressource was successfully delay loaded */
  33069. static readonly DELAYLOADSTATE_LOADED: number;
  33070. /** Defines that the ressource is currently delay loading */
  33071. static readonly DELAYLOADSTATE_LOADING: number;
  33072. /** Defines that the ressource is delayed and has not started loading */
  33073. static readonly DELAYLOADSTATE_NOTLOADED: number;
  33074. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  33075. static readonly NEVER: number;
  33076. /** 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 */
  33077. static readonly ALWAYS: number;
  33078. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  33079. static readonly LESS: number;
  33080. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  33081. static readonly EQUAL: number;
  33082. /** 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 */
  33083. static readonly LEQUAL: number;
  33084. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  33085. static readonly GREATER: number;
  33086. /** 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 */
  33087. static readonly GEQUAL: number;
  33088. /** 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 */
  33089. static readonly NOTEQUAL: number;
  33090. /** Passed to stencilOperation to specify that stencil value must be kept */
  33091. static readonly KEEP: number;
  33092. /** Passed to stencilOperation to specify that stencil value must be replaced */
  33093. static readonly REPLACE: number;
  33094. /** Passed to stencilOperation to specify that stencil value must be incremented */
  33095. static readonly INCR: number;
  33096. /** Passed to stencilOperation to specify that stencil value must be decremented */
  33097. static readonly DECR: number;
  33098. /** Passed to stencilOperation to specify that stencil value must be inverted */
  33099. static readonly INVERT: number;
  33100. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  33101. static readonly INCR_WRAP: number;
  33102. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  33103. static readonly DECR_WRAP: number;
  33104. /** Texture is not repeating outside of 0..1 UVs */
  33105. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  33106. /** Texture is repeating outside of 0..1 UVs */
  33107. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  33108. /** Texture is repeating and mirrored */
  33109. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  33110. /** ALPHA */
  33111. static readonly TEXTUREFORMAT_ALPHA: number;
  33112. /** LUMINANCE */
  33113. static readonly TEXTUREFORMAT_LUMINANCE: number;
  33114. /** LUMINANCE_ALPHA */
  33115. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  33116. /** RGB */
  33117. static readonly TEXTUREFORMAT_RGB: number;
  33118. /** RGBA */
  33119. static readonly TEXTUREFORMAT_RGBA: number;
  33120. /** RED */
  33121. static readonly TEXTUREFORMAT_RED: number;
  33122. /** RED (2nd reference) */
  33123. static readonly TEXTUREFORMAT_R: number;
  33124. /** RG */
  33125. static readonly TEXTUREFORMAT_RG: number;
  33126. /** RED_INTEGER */
  33127. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  33128. /** RED_INTEGER (2nd reference) */
  33129. static readonly TEXTUREFORMAT_R_INTEGER: number;
  33130. /** RG_INTEGER */
  33131. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  33132. /** RGB_INTEGER */
  33133. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  33134. /** RGBA_INTEGER */
  33135. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  33136. /** UNSIGNED_BYTE */
  33137. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  33138. /** UNSIGNED_BYTE (2nd reference) */
  33139. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  33140. /** FLOAT */
  33141. static readonly TEXTURETYPE_FLOAT: number;
  33142. /** HALF_FLOAT */
  33143. static readonly TEXTURETYPE_HALF_FLOAT: number;
  33144. /** BYTE */
  33145. static readonly TEXTURETYPE_BYTE: number;
  33146. /** SHORT */
  33147. static readonly TEXTURETYPE_SHORT: number;
  33148. /** UNSIGNED_SHORT */
  33149. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  33150. /** INT */
  33151. static readonly TEXTURETYPE_INT: number;
  33152. /** UNSIGNED_INT */
  33153. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  33154. /** UNSIGNED_SHORT_4_4_4_4 */
  33155. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  33156. /** UNSIGNED_SHORT_5_5_5_1 */
  33157. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  33158. /** UNSIGNED_SHORT_5_6_5 */
  33159. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  33160. /** UNSIGNED_INT_2_10_10_10_REV */
  33161. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  33162. /** UNSIGNED_INT_24_8 */
  33163. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  33164. /** UNSIGNED_INT_10F_11F_11F_REV */
  33165. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  33166. /** UNSIGNED_INT_5_9_9_9_REV */
  33167. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  33168. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  33169. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  33170. /** nearest is mag = nearest and min = nearest and mip = linear */
  33171. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  33172. /** Bilinear is mag = linear and min = linear and mip = nearest */
  33173. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  33174. /** Trilinear is mag = linear and min = linear and mip = linear */
  33175. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  33176. /** nearest is mag = nearest and min = nearest and mip = linear */
  33177. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  33178. /** Bilinear is mag = linear and min = linear and mip = nearest */
  33179. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  33180. /** Trilinear is mag = linear and min = linear and mip = linear */
  33181. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  33182. /** mag = nearest and min = nearest and mip = nearest */
  33183. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  33184. /** mag = nearest and min = linear and mip = nearest */
  33185. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  33186. /** mag = nearest and min = linear and mip = linear */
  33187. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  33188. /** mag = nearest and min = linear and mip = none */
  33189. static readonly TEXTURE_NEAREST_LINEAR: number;
  33190. /** mag = nearest and min = nearest and mip = none */
  33191. static readonly TEXTURE_NEAREST_NEAREST: number;
  33192. /** mag = linear and min = nearest and mip = nearest */
  33193. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  33194. /** mag = linear and min = nearest and mip = linear */
  33195. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  33196. /** mag = linear and min = linear and mip = none */
  33197. static readonly TEXTURE_LINEAR_LINEAR: number;
  33198. /** mag = linear and min = nearest and mip = none */
  33199. static readonly TEXTURE_LINEAR_NEAREST: number;
  33200. /** Explicit coordinates mode */
  33201. static readonly TEXTURE_EXPLICIT_MODE: number;
  33202. /** Spherical coordinates mode */
  33203. static readonly TEXTURE_SPHERICAL_MODE: number;
  33204. /** Planar coordinates mode */
  33205. static readonly TEXTURE_PLANAR_MODE: number;
  33206. /** Cubic coordinates mode */
  33207. static readonly TEXTURE_CUBIC_MODE: number;
  33208. /** Projection coordinates mode */
  33209. static readonly TEXTURE_PROJECTION_MODE: number;
  33210. /** Skybox coordinates mode */
  33211. static readonly TEXTURE_SKYBOX_MODE: number;
  33212. /** Inverse Cubic coordinates mode */
  33213. static readonly TEXTURE_INVCUBIC_MODE: number;
  33214. /** Equirectangular coordinates mode */
  33215. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  33216. /** Equirectangular Fixed coordinates mode */
  33217. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  33218. /** Equirectangular Fixed Mirrored coordinates mode */
  33219. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  33220. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  33221. static readonly SCALEMODE_FLOOR: number;
  33222. /** Defines that texture rescaling will look for the nearest power of 2 size */
  33223. static readonly SCALEMODE_NEAREST: number;
  33224. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  33225. static readonly SCALEMODE_CEILING: number;
  33226. /**
  33227. * Returns the current npm package of the sdk
  33228. */
  33229. static get NpmPackage(): string;
  33230. /**
  33231. * Returns the current version of the framework
  33232. */
  33233. static get Version(): string;
  33234. /** Gets the list of created engines */
  33235. static get Instances(): Engine[];
  33236. /**
  33237. * Gets the latest created engine
  33238. */
  33239. static get LastCreatedEngine(): Nullable<Engine>;
  33240. /**
  33241. * Gets the latest created scene
  33242. */
  33243. static get LastCreatedScene(): Nullable<Scene>;
  33244. /**
  33245. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  33246. * @param flag defines which part of the materials must be marked as dirty
  33247. * @param predicate defines a predicate used to filter which materials should be affected
  33248. */
  33249. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  33250. /**
  33251. * Method called to create the default loading screen.
  33252. * This can be overriden in your own app.
  33253. * @param canvas The rendering canvas element
  33254. * @returns The loading screen
  33255. */
  33256. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  33257. /**
  33258. * Method called to create the default rescale post process on each engine.
  33259. */
  33260. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  33261. /**
  33262. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  33263. **/
  33264. enableOfflineSupport: boolean;
  33265. /**
  33266. * 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)
  33267. **/
  33268. disableManifestCheck: boolean;
  33269. /**
  33270. * Gets the list of created scenes
  33271. */
  33272. scenes: Scene[];
  33273. /**
  33274. * Event raised when a new scene is created
  33275. */
  33276. onNewSceneAddedObservable: Observable<Scene>;
  33277. /**
  33278. * Gets the list of created postprocesses
  33279. */
  33280. postProcesses: PostProcess[];
  33281. /**
  33282. * Gets a boolean indicating if the pointer is currently locked
  33283. */
  33284. isPointerLock: boolean;
  33285. /**
  33286. * Observable event triggered each time the rendering canvas is resized
  33287. */
  33288. onResizeObservable: Observable<Engine>;
  33289. /**
  33290. * Observable event triggered each time the canvas loses focus
  33291. */
  33292. onCanvasBlurObservable: Observable<Engine>;
  33293. /**
  33294. * Observable event triggered each time the canvas gains focus
  33295. */
  33296. onCanvasFocusObservable: Observable<Engine>;
  33297. /**
  33298. * Observable event triggered each time the canvas receives pointerout event
  33299. */
  33300. onCanvasPointerOutObservable: Observable<PointerEvent>;
  33301. /**
  33302. * Observable raised when the engine begins a new frame
  33303. */
  33304. onBeginFrameObservable: Observable<Engine>;
  33305. /**
  33306. * If set, will be used to request the next animation frame for the render loop
  33307. */
  33308. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  33309. /**
  33310. * Observable raised when the engine ends the current frame
  33311. */
  33312. onEndFrameObservable: Observable<Engine>;
  33313. /**
  33314. * Observable raised when the engine is about to compile a shader
  33315. */
  33316. onBeforeShaderCompilationObservable: Observable<Engine>;
  33317. /**
  33318. * Observable raised when the engine has jsut compiled a shader
  33319. */
  33320. onAfterShaderCompilationObservable: Observable<Engine>;
  33321. /**
  33322. * Gets the audio engine
  33323. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33324. * @ignorenaming
  33325. */
  33326. static audioEngine: IAudioEngine;
  33327. /**
  33328. * Default AudioEngine factory responsible of creating the Audio Engine.
  33329. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  33330. */
  33331. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  33332. /**
  33333. * Default offline support factory responsible of creating a tool used to store data locally.
  33334. * By default, this will create a Database object if the workload has been embedded.
  33335. */
  33336. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  33337. private _loadingScreen;
  33338. private _pointerLockRequested;
  33339. private _dummyFramebuffer;
  33340. private _rescalePostProcess;
  33341. private _deterministicLockstep;
  33342. private _lockstepMaxSteps;
  33343. private _timeStep;
  33344. protected get _supportsHardwareTextureRescaling(): boolean;
  33345. private _fps;
  33346. private _deltaTime;
  33347. /** @hidden */
  33348. _drawCalls: PerfCounter;
  33349. /** 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 */
  33350. canvasTabIndex: number;
  33351. /**
  33352. * Turn this value on if you want to pause FPS computation when in background
  33353. */
  33354. disablePerformanceMonitorInBackground: boolean;
  33355. private _performanceMonitor;
  33356. /**
  33357. * Gets the performance monitor attached to this engine
  33358. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  33359. */
  33360. get performanceMonitor(): PerformanceMonitor;
  33361. private _onFocus;
  33362. private _onBlur;
  33363. private _onCanvasPointerOut;
  33364. private _onCanvasBlur;
  33365. private _onCanvasFocus;
  33366. private _onFullscreenChange;
  33367. private _onPointerLockChange;
  33368. /**
  33369. * Gets the HTML element used to attach event listeners
  33370. * @returns a HTML element
  33371. */
  33372. getInputElement(): Nullable<HTMLElement>;
  33373. /**
  33374. * Creates a new engine
  33375. * @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
  33376. * @param antialias defines enable antialiasing (default: false)
  33377. * @param options defines further options to be sent to the getContext() function
  33378. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  33379. */
  33380. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  33381. /**
  33382. * Gets current aspect ratio
  33383. * @param viewportOwner defines the camera to use to get the aspect ratio
  33384. * @param useScreen defines if screen size must be used (or the current render target if any)
  33385. * @returns a number defining the aspect ratio
  33386. */
  33387. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  33388. /**
  33389. * Gets current screen aspect ratio
  33390. * @returns a number defining the aspect ratio
  33391. */
  33392. getScreenAspectRatio(): number;
  33393. /**
  33394. * Gets the client rect of the HTML canvas attached with the current webGL context
  33395. * @returns a client rectanglee
  33396. */
  33397. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  33398. /**
  33399. * Gets the client rect of the HTML element used for events
  33400. * @returns a client rectanglee
  33401. */
  33402. getInputElementClientRect(): Nullable<ClientRect>;
  33403. /**
  33404. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  33405. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33406. * @returns true if engine is in deterministic lock step mode
  33407. */
  33408. isDeterministicLockStep(): boolean;
  33409. /**
  33410. * Gets the max steps when engine is running in deterministic lock step
  33411. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33412. * @returns the max steps
  33413. */
  33414. getLockstepMaxSteps(): number;
  33415. /**
  33416. * Returns the time in ms between steps when using deterministic lock step.
  33417. * @returns time step in (ms)
  33418. */
  33419. getTimeStep(): number;
  33420. /**
  33421. * Force the mipmap generation for the given render target texture
  33422. * @param texture defines the render target texture to use
  33423. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  33424. */
  33425. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  33426. /** States */
  33427. /**
  33428. * Set various states to the webGL context
  33429. * @param culling defines backface culling state
  33430. * @param zOffset defines the value to apply to zOffset (0 by default)
  33431. * @param force defines if states must be applied even if cache is up to date
  33432. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  33433. */
  33434. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  33435. /**
  33436. * Set the z offset to apply to current rendering
  33437. * @param value defines the offset to apply
  33438. */
  33439. setZOffset(value: number): void;
  33440. /**
  33441. * Gets the current value of the zOffset
  33442. * @returns the current zOffset state
  33443. */
  33444. getZOffset(): number;
  33445. /**
  33446. * Enable or disable depth buffering
  33447. * @param enable defines the state to set
  33448. */
  33449. setDepthBuffer(enable: boolean): void;
  33450. /**
  33451. * Gets a boolean indicating if depth writing is enabled
  33452. * @returns the current depth writing state
  33453. */
  33454. getDepthWrite(): boolean;
  33455. /**
  33456. * Enable or disable depth writing
  33457. * @param enable defines the state to set
  33458. */
  33459. setDepthWrite(enable: boolean): void;
  33460. /**
  33461. * Gets a boolean indicating if stencil buffer is enabled
  33462. * @returns the current stencil buffer state
  33463. */
  33464. getStencilBuffer(): boolean;
  33465. /**
  33466. * Enable or disable the stencil buffer
  33467. * @param enable defines if the stencil buffer must be enabled or disabled
  33468. */
  33469. setStencilBuffer(enable: boolean): void;
  33470. /**
  33471. * Gets the current stencil mask
  33472. * @returns a number defining the new stencil mask to use
  33473. */
  33474. getStencilMask(): number;
  33475. /**
  33476. * Sets the current stencil mask
  33477. * @param mask defines the new stencil mask to use
  33478. */
  33479. setStencilMask(mask: number): void;
  33480. /**
  33481. * Gets the current stencil function
  33482. * @returns a number defining the stencil function to use
  33483. */
  33484. getStencilFunction(): number;
  33485. /**
  33486. * Gets the current stencil reference value
  33487. * @returns a number defining the stencil reference value to use
  33488. */
  33489. getStencilFunctionReference(): number;
  33490. /**
  33491. * Gets the current stencil mask
  33492. * @returns a number defining the stencil mask to use
  33493. */
  33494. getStencilFunctionMask(): number;
  33495. /**
  33496. * Sets the current stencil function
  33497. * @param stencilFunc defines the new stencil function to use
  33498. */
  33499. setStencilFunction(stencilFunc: number): void;
  33500. /**
  33501. * Sets the current stencil reference
  33502. * @param reference defines the new stencil reference to use
  33503. */
  33504. setStencilFunctionReference(reference: number): void;
  33505. /**
  33506. * Sets the current stencil mask
  33507. * @param mask defines the new stencil mask to use
  33508. */
  33509. setStencilFunctionMask(mask: number): void;
  33510. /**
  33511. * Gets the current stencil operation when stencil fails
  33512. * @returns a number defining stencil operation to use when stencil fails
  33513. */
  33514. getStencilOperationFail(): number;
  33515. /**
  33516. * Gets the current stencil operation when depth fails
  33517. * @returns a number defining stencil operation to use when depth fails
  33518. */
  33519. getStencilOperationDepthFail(): number;
  33520. /**
  33521. * Gets the current stencil operation when stencil passes
  33522. * @returns a number defining stencil operation to use when stencil passes
  33523. */
  33524. getStencilOperationPass(): number;
  33525. /**
  33526. * Sets the stencil operation to use when stencil fails
  33527. * @param operation defines the stencil operation to use when stencil fails
  33528. */
  33529. setStencilOperationFail(operation: number): void;
  33530. /**
  33531. * Sets the stencil operation to use when depth fails
  33532. * @param operation defines the stencil operation to use when depth fails
  33533. */
  33534. setStencilOperationDepthFail(operation: number): void;
  33535. /**
  33536. * Sets the stencil operation to use when stencil passes
  33537. * @param operation defines the stencil operation to use when stencil passes
  33538. */
  33539. setStencilOperationPass(operation: number): void;
  33540. /**
  33541. * Sets a boolean indicating if the dithering state is enabled or disabled
  33542. * @param value defines the dithering state
  33543. */
  33544. setDitheringState(value: boolean): void;
  33545. /**
  33546. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  33547. * @param value defines the rasterizer state
  33548. */
  33549. setRasterizerState(value: boolean): void;
  33550. /**
  33551. * Gets the current depth function
  33552. * @returns a number defining the depth function
  33553. */
  33554. getDepthFunction(): Nullable<number>;
  33555. /**
  33556. * Sets the current depth function
  33557. * @param depthFunc defines the function to use
  33558. */
  33559. setDepthFunction(depthFunc: number): void;
  33560. /**
  33561. * Sets the current depth function to GREATER
  33562. */
  33563. setDepthFunctionToGreater(): void;
  33564. /**
  33565. * Sets the current depth function to GEQUAL
  33566. */
  33567. setDepthFunctionToGreaterOrEqual(): void;
  33568. /**
  33569. * Sets the current depth function to LESS
  33570. */
  33571. setDepthFunctionToLess(): void;
  33572. /**
  33573. * Sets the current depth function to LEQUAL
  33574. */
  33575. setDepthFunctionToLessOrEqual(): void;
  33576. private _cachedStencilBuffer;
  33577. private _cachedStencilFunction;
  33578. private _cachedStencilMask;
  33579. private _cachedStencilOperationPass;
  33580. private _cachedStencilOperationFail;
  33581. private _cachedStencilOperationDepthFail;
  33582. private _cachedStencilReference;
  33583. /**
  33584. * Caches the the state of the stencil buffer
  33585. */
  33586. cacheStencilState(): void;
  33587. /**
  33588. * Restores the state of the stencil buffer
  33589. */
  33590. restoreStencilState(): void;
  33591. /**
  33592. * Directly set the WebGL Viewport
  33593. * @param x defines the x coordinate of the viewport (in screen space)
  33594. * @param y defines the y coordinate of the viewport (in screen space)
  33595. * @param width defines the width of the viewport (in screen space)
  33596. * @param height defines the height of the viewport (in screen space)
  33597. * @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
  33598. */
  33599. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  33600. /**
  33601. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  33602. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  33603. * @param y defines the y-coordinate of the corner of the clear rectangle
  33604. * @param width defines the width of the clear rectangle
  33605. * @param height defines the height of the clear rectangle
  33606. * @param clearColor defines the clear color
  33607. */
  33608. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  33609. /**
  33610. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  33611. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  33612. * @param y defines the y-coordinate of the corner of the clear rectangle
  33613. * @param width defines the width of the clear rectangle
  33614. * @param height defines the height of the clear rectangle
  33615. */
  33616. enableScissor(x: number, y: number, width: number, height: number): void;
  33617. /**
  33618. * Disable previously set scissor test rectangle
  33619. */
  33620. disableScissor(): void;
  33621. protected _reportDrawCall(): void;
  33622. /**
  33623. * Initializes a webVR display and starts listening to display change events
  33624. * The onVRDisplayChangedObservable will be notified upon these changes
  33625. * @returns The onVRDisplayChangedObservable
  33626. */
  33627. initWebVR(): Observable<IDisplayChangedEventArgs>;
  33628. /** @hidden */
  33629. _prepareVRComponent(): void;
  33630. /** @hidden */
  33631. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  33632. /** @hidden */
  33633. _submitVRFrame(): void;
  33634. /**
  33635. * Call this function to leave webVR mode
  33636. * Will do nothing if webVR is not supported or if there is no webVR device
  33637. * @see http://doc.babylonjs.com/how_to/webvr_camera
  33638. */
  33639. disableVR(): void;
  33640. /**
  33641. * Gets a boolean indicating that the system is in VR mode and is presenting
  33642. * @returns true if VR mode is engaged
  33643. */
  33644. isVRPresenting(): boolean;
  33645. /** @hidden */
  33646. _requestVRFrame(): void;
  33647. /** @hidden */
  33648. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  33649. /**
  33650. * Gets the source code of the vertex shader associated with a specific webGL program
  33651. * @param program defines the program to use
  33652. * @returns a string containing the source code of the vertex shader associated with the program
  33653. */
  33654. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  33655. /**
  33656. * Gets the source code of the fragment shader associated with a specific webGL program
  33657. * @param program defines the program to use
  33658. * @returns a string containing the source code of the fragment shader associated with the program
  33659. */
  33660. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  33661. /**
  33662. * Sets a depth stencil texture from a render target to the according uniform.
  33663. * @param channel The texture channel
  33664. * @param uniform The uniform to set
  33665. * @param texture The render target texture containing the depth stencil texture to apply
  33666. */
  33667. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  33668. /**
  33669. * Sets a texture to the webGL context from a postprocess
  33670. * @param channel defines the channel to use
  33671. * @param postProcess defines the source postprocess
  33672. */
  33673. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  33674. /**
  33675. * Binds the output of the passed in post process to the texture channel specified
  33676. * @param channel The channel the texture should be bound to
  33677. * @param postProcess The post process which's output should be bound
  33678. */
  33679. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  33680. /** @hidden */
  33681. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  33682. protected _rebuildBuffers(): void;
  33683. /** @hidden */
  33684. _renderFrame(): void;
  33685. _renderLoop(): void;
  33686. /** @hidden */
  33687. _renderViews(): boolean;
  33688. /**
  33689. * Toggle full screen mode
  33690. * @param requestPointerLock defines if a pointer lock should be requested from the user
  33691. */
  33692. switchFullscreen(requestPointerLock: boolean): void;
  33693. /**
  33694. * Enters full screen mode
  33695. * @param requestPointerLock defines if a pointer lock should be requested from the user
  33696. */
  33697. enterFullscreen(requestPointerLock: boolean): void;
  33698. /**
  33699. * Exits full screen mode
  33700. */
  33701. exitFullscreen(): void;
  33702. /**
  33703. * Enters Pointerlock mode
  33704. */
  33705. enterPointerlock(): void;
  33706. /**
  33707. * Exits Pointerlock mode
  33708. */
  33709. exitPointerlock(): void;
  33710. /**
  33711. * Begin a new frame
  33712. */
  33713. beginFrame(): void;
  33714. /**
  33715. * Enf the current frame
  33716. */
  33717. endFrame(): void;
  33718. resize(): void;
  33719. /**
  33720. * Set the compressed texture format to use, based on the formats you have, and the formats
  33721. * supported by the hardware / browser.
  33722. *
  33723. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  33724. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  33725. * to API arguments needed to compressed textures. This puts the burden on the container
  33726. * generator to house the arcane code for determining these for current & future formats.
  33727. *
  33728. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  33729. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  33730. *
  33731. * Note: The result of this call is not taken into account when a texture is base64.
  33732. *
  33733. * @param formatsAvailable defines the list of those format families you have created
  33734. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  33735. *
  33736. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  33737. * @returns The extension selected.
  33738. */
  33739. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  33740. /**
  33741. * Set the compressed texture extensions or file names to skip.
  33742. *
  33743. * @param skippedFiles defines the list of those texture files you want to skip
  33744. * Example: [".dds", ".env", "myfile.png"]
  33745. */
  33746. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  33747. /**
  33748. * Force a specific size of the canvas
  33749. * @param width defines the new canvas' width
  33750. * @param height defines the new canvas' height
  33751. */
  33752. setSize(width: number, height: number): void;
  33753. /**
  33754. * Updates a dynamic vertex buffer.
  33755. * @param vertexBuffer the vertex buffer to update
  33756. * @param data the data used to update the vertex buffer
  33757. * @param byteOffset the byte offset of the data
  33758. * @param byteLength the byte length of the data
  33759. */
  33760. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  33761. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  33762. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  33763. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  33764. _releaseTexture(texture: InternalTexture): void;
  33765. /**
  33766. * @hidden
  33767. * Rescales a texture
  33768. * @param source input texutre
  33769. * @param destination destination texture
  33770. * @param scene scene to use to render the resize
  33771. * @param internalFormat format to use when resizing
  33772. * @param onComplete callback to be called when resize has completed
  33773. */
  33774. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  33775. /**
  33776. * Gets the current framerate
  33777. * @returns a number representing the framerate
  33778. */
  33779. getFps(): number;
  33780. /**
  33781. * Gets the time spent between current and previous frame
  33782. * @returns a number representing the delta time in ms
  33783. */
  33784. getDeltaTime(): number;
  33785. private _measureFps;
  33786. /** @hidden */
  33787. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  33788. /**
  33789. * Update a dynamic index buffer
  33790. * @param indexBuffer defines the target index buffer
  33791. * @param indices defines the data to update
  33792. * @param offset defines the offset in the target index buffer where update should start
  33793. */
  33794. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  33795. /**
  33796. * Updates the sample count of a render target texture
  33797. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  33798. * @param texture defines the texture to update
  33799. * @param samples defines the sample count to set
  33800. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  33801. */
  33802. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  33803. /**
  33804. * Updates a depth texture Comparison Mode and Function.
  33805. * If the comparison Function is equal to 0, the mode will be set to none.
  33806. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  33807. * @param texture The texture to set the comparison function for
  33808. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  33809. */
  33810. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  33811. /**
  33812. * Creates a webGL buffer to use with instanciation
  33813. * @param capacity defines the size of the buffer
  33814. * @returns the webGL buffer
  33815. */
  33816. createInstancesBuffer(capacity: number): DataBuffer;
  33817. /**
  33818. * Delete a webGL buffer used with instanciation
  33819. * @param buffer defines the webGL buffer to delete
  33820. */
  33821. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  33822. /** @hidden */
  33823. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  33824. dispose(): void;
  33825. private _disableTouchAction;
  33826. /**
  33827. * Display the loading screen
  33828. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33829. */
  33830. displayLoadingUI(): void;
  33831. /**
  33832. * Hide the loading screen
  33833. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33834. */
  33835. hideLoadingUI(): void;
  33836. /**
  33837. * Gets the current loading screen object
  33838. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33839. */
  33840. get loadingScreen(): ILoadingScreen;
  33841. /**
  33842. * Sets the current loading screen object
  33843. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33844. */
  33845. set loadingScreen(loadingScreen: ILoadingScreen);
  33846. /**
  33847. * Sets the current loading screen text
  33848. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33849. */
  33850. set loadingUIText(text: string);
  33851. /**
  33852. * Sets the current loading screen background color
  33853. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33854. */
  33855. set loadingUIBackgroundColor(color: string);
  33856. /** Pointerlock and fullscreen */
  33857. /**
  33858. * Ask the browser to promote the current element to pointerlock mode
  33859. * @param element defines the DOM element to promote
  33860. */
  33861. static _RequestPointerlock(element: HTMLElement): void;
  33862. /**
  33863. * Asks the browser to exit pointerlock mode
  33864. */
  33865. static _ExitPointerlock(): void;
  33866. /**
  33867. * Ask the browser to promote the current element to fullscreen rendering mode
  33868. * @param element defines the DOM element to promote
  33869. */
  33870. static _RequestFullscreen(element: HTMLElement): void;
  33871. /**
  33872. * Asks the browser to exit fullscreen mode
  33873. */
  33874. static _ExitFullscreen(): void;
  33875. }
  33876. }
  33877. declare module BABYLON {
  33878. /**
  33879. * The engine store class is responsible to hold all the instances of Engine and Scene created
  33880. * during the life time of the application.
  33881. */
  33882. export class EngineStore {
  33883. /** Gets the list of created engines */
  33884. static Instances: Engine[];
  33885. /** @hidden */
  33886. static _LastCreatedScene: Nullable<Scene>;
  33887. /**
  33888. * Gets the latest created engine
  33889. */
  33890. static get LastCreatedEngine(): Nullable<Engine>;
  33891. /**
  33892. * Gets the latest created scene
  33893. */
  33894. static get LastCreatedScene(): Nullable<Scene>;
  33895. /**
  33896. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  33897. * @ignorenaming
  33898. */
  33899. static UseFallbackTexture: boolean;
  33900. /**
  33901. * Texture content used if a texture cannot loaded
  33902. * @ignorenaming
  33903. */
  33904. static FallbackTexture: string;
  33905. }
  33906. }
  33907. declare module BABYLON {
  33908. /**
  33909. * Helper class that provides a small promise polyfill
  33910. */
  33911. export class PromisePolyfill {
  33912. /**
  33913. * Static function used to check if the polyfill is required
  33914. * If this is the case then the function will inject the polyfill to window.Promise
  33915. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  33916. */
  33917. static Apply(force?: boolean): void;
  33918. }
  33919. }
  33920. declare module BABYLON {
  33921. /**
  33922. * Interface for screenshot methods with describe argument called `size` as object with options
  33923. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  33924. */
  33925. export interface IScreenshotSize {
  33926. /**
  33927. * number in pixels for canvas height
  33928. */
  33929. height?: number;
  33930. /**
  33931. * multiplier allowing render at a higher or lower resolution
  33932. * If value is defined then height and width will be ignored and taken from camera
  33933. */
  33934. precision?: number;
  33935. /**
  33936. * number in pixels for canvas width
  33937. */
  33938. width?: number;
  33939. }
  33940. }
  33941. declare module BABYLON {
  33942. interface IColor4Like {
  33943. r: float;
  33944. g: float;
  33945. b: float;
  33946. a: float;
  33947. }
  33948. /**
  33949. * Class containing a set of static utilities functions
  33950. */
  33951. export class Tools {
  33952. /**
  33953. * Gets or sets the base URL to use to load assets
  33954. */
  33955. static get BaseUrl(): string;
  33956. static set BaseUrl(value: string);
  33957. /**
  33958. * Enable/Disable Custom HTTP Request Headers globally.
  33959. * default = false
  33960. * @see CustomRequestHeaders
  33961. */
  33962. static UseCustomRequestHeaders: boolean;
  33963. /**
  33964. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  33965. * i.e. when loading files, where the server/service expects an Authorization header
  33966. */
  33967. static CustomRequestHeaders: {
  33968. [key: string]: string;
  33969. };
  33970. /**
  33971. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  33972. */
  33973. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  33974. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  33975. /**
  33976. * Default behaviour for cors in the application.
  33977. * It can be a string if the expected behavior is identical in the entire app.
  33978. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  33979. */
  33980. static CorsBehavior: string | ((url: string | string[]) => string);
  33981. /**
  33982. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  33983. * @ignorenaming
  33984. */
  33985. static get UseFallbackTexture(): boolean;
  33986. static set UseFallbackTexture(value: boolean);
  33987. /**
  33988. * Use this object to register external classes like custom textures or material
  33989. * to allow the laoders to instantiate them
  33990. */
  33991. static get RegisteredExternalClasses(): {
  33992. [key: string]: Object;
  33993. };
  33994. static set RegisteredExternalClasses(classes: {
  33995. [key: string]: Object;
  33996. });
  33997. /**
  33998. * Texture content used if a texture cannot loaded
  33999. * @ignorenaming
  34000. */
  34001. static get fallbackTexture(): string;
  34002. static set fallbackTexture(value: string);
  34003. /**
  34004. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  34005. * @param u defines the coordinate on X axis
  34006. * @param v defines the coordinate on Y axis
  34007. * @param width defines the width of the source data
  34008. * @param height defines the height of the source data
  34009. * @param pixels defines the source byte array
  34010. * @param color defines the output color
  34011. */
  34012. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  34013. /**
  34014. * Interpolates between a and b via alpha
  34015. * @param a The lower value (returned when alpha = 0)
  34016. * @param b The upper value (returned when alpha = 1)
  34017. * @param alpha The interpolation-factor
  34018. * @return The mixed value
  34019. */
  34020. static Mix(a: number, b: number, alpha: number): number;
  34021. /**
  34022. * Tries to instantiate a new object from a given class name
  34023. * @param className defines the class name to instantiate
  34024. * @returns the new object or null if the system was not able to do the instantiation
  34025. */
  34026. static Instantiate(className: string): any;
  34027. /**
  34028. * Provides a slice function that will work even on IE
  34029. * @param data defines the array to slice
  34030. * @param start defines the start of the data (optional)
  34031. * @param end defines the end of the data (optional)
  34032. * @returns the new sliced array
  34033. */
  34034. static Slice<T>(data: T, start?: number, end?: number): T;
  34035. /**
  34036. * Polyfill for setImmediate
  34037. * @param action defines the action to execute after the current execution block
  34038. */
  34039. static SetImmediate(action: () => void): void;
  34040. /**
  34041. * Function indicating if a number is an exponent of 2
  34042. * @param value defines the value to test
  34043. * @returns true if the value is an exponent of 2
  34044. */
  34045. static IsExponentOfTwo(value: number): boolean;
  34046. private static _tmpFloatArray;
  34047. /**
  34048. * Returns the nearest 32-bit single precision float representation of a Number
  34049. * @param value A Number. If the parameter is of a different type, it will get converted
  34050. * to a number or to NaN if it cannot be converted
  34051. * @returns number
  34052. */
  34053. static FloatRound(value: number): number;
  34054. /**
  34055. * Extracts the filename from a path
  34056. * @param path defines the path to use
  34057. * @returns the filename
  34058. */
  34059. static GetFilename(path: string): string;
  34060. /**
  34061. * Extracts the "folder" part of a path (everything before the filename).
  34062. * @param uri The URI to extract the info from
  34063. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  34064. * @returns The "folder" part of the path
  34065. */
  34066. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  34067. /**
  34068. * Extracts text content from a DOM element hierarchy
  34069. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  34070. */
  34071. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  34072. /**
  34073. * Convert an angle in radians to degrees
  34074. * @param angle defines the angle to convert
  34075. * @returns the angle in degrees
  34076. */
  34077. static ToDegrees(angle: number): number;
  34078. /**
  34079. * Convert an angle in degrees to radians
  34080. * @param angle defines the angle to convert
  34081. * @returns the angle in radians
  34082. */
  34083. static ToRadians(angle: number): number;
  34084. /**
  34085. * Returns an array if obj is not an array
  34086. * @param obj defines the object to evaluate as an array
  34087. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  34088. * @returns either obj directly if obj is an array or a new array containing obj
  34089. */
  34090. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  34091. /**
  34092. * Gets the pointer prefix to use
  34093. * @returns "pointer" if touch is enabled. Else returns "mouse"
  34094. */
  34095. static GetPointerPrefix(): string;
  34096. /**
  34097. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  34098. * @param url define the url we are trying
  34099. * @param element define the dom element where to configure the cors policy
  34100. */
  34101. static SetCorsBehavior(url: string | string[], element: {
  34102. crossOrigin: string | null;
  34103. }): void;
  34104. /**
  34105. * Removes unwanted characters from an url
  34106. * @param url defines the url to clean
  34107. * @returns the cleaned url
  34108. */
  34109. static CleanUrl(url: string): string;
  34110. /**
  34111. * Gets or sets a function used to pre-process url before using them to load assets
  34112. */
  34113. static get PreprocessUrl(): (url: string) => string;
  34114. static set PreprocessUrl(processor: (url: string) => string);
  34115. /**
  34116. * Loads an image as an HTMLImageElement.
  34117. * @param input url string, ArrayBuffer, or Blob to load
  34118. * @param onLoad callback called when the image successfully loads
  34119. * @param onError callback called when the image fails to load
  34120. * @param offlineProvider offline provider for caching
  34121. * @param mimeType optional mime type
  34122. * @returns the HTMLImageElement of the loaded image
  34123. */
  34124. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  34125. /**
  34126. * Loads a file from a url
  34127. * @param url url string, ArrayBuffer, or Blob to load
  34128. * @param onSuccess callback called when the file successfully loads
  34129. * @param onProgress callback called while file is loading (if the server supports this mode)
  34130. * @param offlineProvider defines the offline provider for caching
  34131. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  34132. * @param onError callback called when the file fails to load
  34133. * @returns a file request object
  34134. */
  34135. 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;
  34136. /**
  34137. * Loads a file from a url
  34138. * @param url the file url to load
  34139. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  34140. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  34141. */
  34142. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  34143. /**
  34144. * Load a script (identified by an url). When the url returns, the
  34145. * content of this file is added into a new script element, attached to the DOM (body element)
  34146. * @param scriptUrl defines the url of the script to laod
  34147. * @param onSuccess defines the callback called when the script is loaded
  34148. * @param onError defines the callback to call if an error occurs
  34149. * @param scriptId defines the id of the script element
  34150. */
  34151. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  34152. /**
  34153. * Load an asynchronous script (identified by an url). When the url returns, the
  34154. * content of this file is added into a new script element, attached to the DOM (body element)
  34155. * @param scriptUrl defines the url of the script to laod
  34156. * @param scriptId defines the id of the script element
  34157. * @returns a promise request object
  34158. */
  34159. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  34160. /**
  34161. * Loads a file from a blob
  34162. * @param fileToLoad defines the blob to use
  34163. * @param callback defines the callback to call when data is loaded
  34164. * @param progressCallback defines the callback to call during loading process
  34165. * @returns a file request object
  34166. */
  34167. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  34168. /**
  34169. * Reads a file from a File object
  34170. * @param file defines the file to load
  34171. * @param onSuccess defines the callback to call when data is loaded
  34172. * @param onProgress defines the callback to call during loading process
  34173. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  34174. * @param onError defines the callback to call when an error occurs
  34175. * @returns a file request object
  34176. */
  34177. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  34178. /**
  34179. * Creates a data url from a given string content
  34180. * @param content defines the content to convert
  34181. * @returns the new data url link
  34182. */
  34183. static FileAsURL(content: string): string;
  34184. /**
  34185. * Format the given number to a specific decimal format
  34186. * @param value defines the number to format
  34187. * @param decimals defines the number of decimals to use
  34188. * @returns the formatted string
  34189. */
  34190. static Format(value: number, decimals?: number): string;
  34191. /**
  34192. * Tries to copy an object by duplicating every property
  34193. * @param source defines the source object
  34194. * @param destination defines the target object
  34195. * @param doNotCopyList defines a list of properties to avoid
  34196. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  34197. */
  34198. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  34199. /**
  34200. * Gets a boolean indicating if the given object has no own property
  34201. * @param obj defines the object to test
  34202. * @returns true if object has no own property
  34203. */
  34204. static IsEmpty(obj: any): boolean;
  34205. /**
  34206. * Function used to register events at window level
  34207. * @param windowElement defines the Window object to use
  34208. * @param events defines the events to register
  34209. */
  34210. static RegisterTopRootEvents(windowElement: Window, events: {
  34211. name: string;
  34212. handler: Nullable<(e: FocusEvent) => any>;
  34213. }[]): void;
  34214. /**
  34215. * Function used to unregister events from window level
  34216. * @param windowElement defines the Window object to use
  34217. * @param events defines the events to unregister
  34218. */
  34219. static UnregisterTopRootEvents(windowElement: Window, events: {
  34220. name: string;
  34221. handler: Nullable<(e: FocusEvent) => any>;
  34222. }[]): void;
  34223. /**
  34224. * @ignore
  34225. */
  34226. static _ScreenshotCanvas: HTMLCanvasElement;
  34227. /**
  34228. * Dumps the current bound framebuffer
  34229. * @param width defines the rendering width
  34230. * @param height defines the rendering height
  34231. * @param engine defines the hosting engine
  34232. * @param successCallback defines the callback triggered once the data are available
  34233. * @param mimeType defines the mime type of the result
  34234. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  34235. */
  34236. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  34237. /**
  34238. * Converts the canvas data to blob.
  34239. * This acts as a polyfill for browsers not supporting the to blob function.
  34240. * @param canvas Defines the canvas to extract the data from
  34241. * @param successCallback Defines the callback triggered once the data are available
  34242. * @param mimeType Defines the mime type of the result
  34243. */
  34244. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  34245. /**
  34246. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  34247. * @param successCallback defines the callback triggered once the data are available
  34248. * @param mimeType defines the mime type of the result
  34249. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  34250. */
  34251. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  34252. /**
  34253. * Downloads a blob in the browser
  34254. * @param blob defines the blob to download
  34255. * @param fileName defines the name of the downloaded file
  34256. */
  34257. static Download(blob: Blob, fileName: string): void;
  34258. /**
  34259. * Captures a screenshot of the current rendering
  34260. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34261. * @param engine defines the rendering engine
  34262. * @param camera defines the source camera
  34263. * @param size This parameter can be set to a single number or to an object with the
  34264. * following (optional) properties: precision, width, height. If a single number is passed,
  34265. * it will be used for both width and height. If an object is passed, the screenshot size
  34266. * will be derived from the parameters. The precision property is a multiplier allowing
  34267. * rendering at a higher or lower resolution
  34268. * @param successCallback defines the callback receives a single parameter which contains the
  34269. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  34270. * src parameter of an <img> to display it
  34271. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  34272. * Check your browser for supported MIME types
  34273. */
  34274. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  34275. /**
  34276. * Captures a screenshot of the current rendering
  34277. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34278. * @param engine defines the rendering engine
  34279. * @param camera defines the source camera
  34280. * @param size This parameter can be set to a single number or to an object with the
  34281. * following (optional) properties: precision, width, height. If a single number is passed,
  34282. * it will be used for both width and height. If an object is passed, the screenshot size
  34283. * will be derived from the parameters. The precision property is a multiplier allowing
  34284. * rendering at a higher or lower resolution
  34285. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  34286. * Check your browser for supported MIME types
  34287. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  34288. * to the src parameter of an <img> to display it
  34289. */
  34290. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  34291. /**
  34292. * Generates an image screenshot from the specified camera.
  34293. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34294. * @param engine The engine to use for rendering
  34295. * @param camera The camera to use for rendering
  34296. * @param size This parameter can be set to a single number or to an object with the
  34297. * following (optional) properties: precision, width, height. If a single number is passed,
  34298. * it will be used for both width and height. If an object is passed, the screenshot size
  34299. * will be derived from the parameters. The precision property is a multiplier allowing
  34300. * rendering at a higher or lower resolution
  34301. * @param successCallback The callback receives a single parameter which contains the
  34302. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  34303. * src parameter of an <img> to display it
  34304. * @param mimeType The MIME type of the screenshot image (default: image/png).
  34305. * Check your browser for supported MIME types
  34306. * @param samples Texture samples (default: 1)
  34307. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  34308. * @param fileName A name for for the downloaded file.
  34309. */
  34310. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  34311. /**
  34312. * Generates an image screenshot from the specified camera.
  34313. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34314. * @param engine The engine to use for rendering
  34315. * @param camera The camera to use for rendering
  34316. * @param size This parameter can be set to a single number or to an object with the
  34317. * following (optional) properties: precision, width, height. If a single number is passed,
  34318. * it will be used for both width and height. If an object is passed, the screenshot size
  34319. * will be derived from the parameters. The precision property is a multiplier allowing
  34320. * rendering at a higher or lower resolution
  34321. * @param mimeType The MIME type of the screenshot image (default: image/png).
  34322. * Check your browser for supported MIME types
  34323. * @param samples Texture samples (default: 1)
  34324. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  34325. * @param fileName A name for for the downloaded file.
  34326. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  34327. * to the src parameter of an <img> to display it
  34328. */
  34329. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  34330. /**
  34331. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  34332. * Be aware Math.random() could cause collisions, but:
  34333. * "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"
  34334. * @returns a pseudo random id
  34335. */
  34336. static RandomId(): string;
  34337. /**
  34338. * Test if the given uri is a base64 string
  34339. * @param uri The uri to test
  34340. * @return True if the uri is a base64 string or false otherwise
  34341. */
  34342. static IsBase64(uri: string): boolean;
  34343. /**
  34344. * Decode the given base64 uri.
  34345. * @param uri The uri to decode
  34346. * @return The decoded base64 data.
  34347. */
  34348. static DecodeBase64(uri: string): ArrayBuffer;
  34349. /**
  34350. * Gets the absolute url.
  34351. * @param url the input url
  34352. * @return the absolute url
  34353. */
  34354. static GetAbsoluteUrl(url: string): string;
  34355. /**
  34356. * No log
  34357. */
  34358. static readonly NoneLogLevel: number;
  34359. /**
  34360. * Only message logs
  34361. */
  34362. static readonly MessageLogLevel: number;
  34363. /**
  34364. * Only warning logs
  34365. */
  34366. static readonly WarningLogLevel: number;
  34367. /**
  34368. * Only error logs
  34369. */
  34370. static readonly ErrorLogLevel: number;
  34371. /**
  34372. * All logs
  34373. */
  34374. static readonly AllLogLevel: number;
  34375. /**
  34376. * Gets a value indicating the number of loading errors
  34377. * @ignorenaming
  34378. */
  34379. static get errorsCount(): number;
  34380. /**
  34381. * Callback called when a new log is added
  34382. */
  34383. static OnNewCacheEntry: (entry: string) => void;
  34384. /**
  34385. * Log a message to the console
  34386. * @param message defines the message to log
  34387. */
  34388. static Log(message: string): void;
  34389. /**
  34390. * Write a warning message to the console
  34391. * @param message defines the message to log
  34392. */
  34393. static Warn(message: string): void;
  34394. /**
  34395. * Write an error message to the console
  34396. * @param message defines the message to log
  34397. */
  34398. static Error(message: string): void;
  34399. /**
  34400. * Gets current log cache (list of logs)
  34401. */
  34402. static get LogCache(): string;
  34403. /**
  34404. * Clears the log cache
  34405. */
  34406. static ClearLogCache(): void;
  34407. /**
  34408. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  34409. */
  34410. static set LogLevels(level: number);
  34411. /**
  34412. * Checks if the window object exists
  34413. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  34414. */
  34415. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  34416. /**
  34417. * No performance log
  34418. */
  34419. static readonly PerformanceNoneLogLevel: number;
  34420. /**
  34421. * Use user marks to log performance
  34422. */
  34423. static readonly PerformanceUserMarkLogLevel: number;
  34424. /**
  34425. * Log performance to the console
  34426. */
  34427. static readonly PerformanceConsoleLogLevel: number;
  34428. private static _performance;
  34429. /**
  34430. * Sets the current performance log level
  34431. */
  34432. static set PerformanceLogLevel(level: number);
  34433. private static _StartPerformanceCounterDisabled;
  34434. private static _EndPerformanceCounterDisabled;
  34435. private static _StartUserMark;
  34436. private static _EndUserMark;
  34437. private static _StartPerformanceConsole;
  34438. private static _EndPerformanceConsole;
  34439. /**
  34440. * Starts a performance counter
  34441. */
  34442. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  34443. /**
  34444. * Ends a specific performance coutner
  34445. */
  34446. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  34447. /**
  34448. * Gets either window.performance.now() if supported or Date.now() else
  34449. */
  34450. static get Now(): number;
  34451. /**
  34452. * This method will return the name of the class used to create the instance of the given object.
  34453. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  34454. * @param object the object to get the class name from
  34455. * @param isType defines if the object is actually a type
  34456. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  34457. */
  34458. static GetClassName(object: any, isType?: boolean): string;
  34459. /**
  34460. * Gets the first element of an array satisfying a given predicate
  34461. * @param array defines the array to browse
  34462. * @param predicate defines the predicate to use
  34463. * @returns null if not found or the element
  34464. */
  34465. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  34466. /**
  34467. * This method will return the name of the full name of the class, including its owning module (if any).
  34468. * 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).
  34469. * @param object the object to get the class name from
  34470. * @param isType defines if the object is actually a type
  34471. * @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.
  34472. * @ignorenaming
  34473. */
  34474. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  34475. /**
  34476. * Returns a promise that resolves after the given amount of time.
  34477. * @param delay Number of milliseconds to delay
  34478. * @returns Promise that resolves after the given amount of time
  34479. */
  34480. static DelayAsync(delay: number): Promise<void>;
  34481. /**
  34482. * Utility function to detect if the current user agent is Safari
  34483. * @returns whether or not the current user agent is safari
  34484. */
  34485. static IsSafari(): boolean;
  34486. }
  34487. /**
  34488. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  34489. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  34490. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  34491. * @param name The name of the class, case should be preserved
  34492. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  34493. */
  34494. export function className(name: string, module?: string): (target: Object) => void;
  34495. /**
  34496. * An implementation of a loop for asynchronous functions.
  34497. */
  34498. export class AsyncLoop {
  34499. /**
  34500. * Defines the number of iterations for the loop
  34501. */
  34502. iterations: number;
  34503. /**
  34504. * Defines the current index of the loop.
  34505. */
  34506. index: number;
  34507. private _done;
  34508. private _fn;
  34509. private _successCallback;
  34510. /**
  34511. * Constructor.
  34512. * @param iterations the number of iterations.
  34513. * @param func the function to run each iteration
  34514. * @param successCallback the callback that will be called upon succesful execution
  34515. * @param offset starting offset.
  34516. */
  34517. constructor(
  34518. /**
  34519. * Defines the number of iterations for the loop
  34520. */
  34521. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  34522. /**
  34523. * Execute the next iteration. Must be called after the last iteration was finished.
  34524. */
  34525. executeNext(): void;
  34526. /**
  34527. * Break the loop and run the success callback.
  34528. */
  34529. breakLoop(): void;
  34530. /**
  34531. * Create and run an async loop.
  34532. * @param iterations the number of iterations.
  34533. * @param fn the function to run each iteration
  34534. * @param successCallback the callback that will be called upon succesful execution
  34535. * @param offset starting offset.
  34536. * @returns the created async loop object
  34537. */
  34538. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  34539. /**
  34540. * A for-loop that will run a given number of iterations synchronous and the rest async.
  34541. * @param iterations total number of iterations
  34542. * @param syncedIterations number of synchronous iterations in each async iteration.
  34543. * @param fn the function to call each iteration.
  34544. * @param callback a success call back that will be called when iterating stops.
  34545. * @param breakFunction a break condition (optional)
  34546. * @param timeout timeout settings for the setTimeout function. default - 0.
  34547. * @returns the created async loop object
  34548. */
  34549. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  34550. }
  34551. }
  34552. declare module BABYLON {
  34553. /**
  34554. * This class implement a typical dictionary using a string as key and the generic type T as value.
  34555. * The underlying implementation relies on an associative array to ensure the best performances.
  34556. * The value can be anything including 'null' but except 'undefined'
  34557. */
  34558. export class StringDictionary<T> {
  34559. /**
  34560. * This will clear this dictionary and copy the content from the 'source' one.
  34561. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  34562. * @param source the dictionary to take the content from and copy to this dictionary
  34563. */
  34564. copyFrom(source: StringDictionary<T>): void;
  34565. /**
  34566. * Get a value based from its key
  34567. * @param key the given key to get the matching value from
  34568. * @return the value if found, otherwise undefined is returned
  34569. */
  34570. get(key: string): T | undefined;
  34571. /**
  34572. * Get a value from its key or add it if it doesn't exist.
  34573. * This method will ensure you that a given key/data will be present in the dictionary.
  34574. * @param key the given key to get the matching value from
  34575. * @param factory the factory that will create the value if the key is not present in the dictionary.
  34576. * The factory will only be invoked if there's no data for the given key.
  34577. * @return the value corresponding to the key.
  34578. */
  34579. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  34580. /**
  34581. * Get a value from its key if present in the dictionary otherwise add it
  34582. * @param key the key to get the value from
  34583. * @param val if there's no such key/value pair in the dictionary add it with this value
  34584. * @return the value corresponding to the key
  34585. */
  34586. getOrAdd(key: string, val: T): T;
  34587. /**
  34588. * Check if there's a given key in the dictionary
  34589. * @param key the key to check for
  34590. * @return true if the key is present, false otherwise
  34591. */
  34592. contains(key: string): boolean;
  34593. /**
  34594. * Add a new key and its corresponding value
  34595. * @param key the key to add
  34596. * @param value the value corresponding to the key
  34597. * @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
  34598. */
  34599. add(key: string, value: T): boolean;
  34600. /**
  34601. * Update a specific value associated to a key
  34602. * @param key defines the key to use
  34603. * @param value defines the value to store
  34604. * @returns true if the value was updated (or false if the key was not found)
  34605. */
  34606. set(key: string, value: T): boolean;
  34607. /**
  34608. * Get the element of the given key and remove it from the dictionary
  34609. * @param key defines the key to search
  34610. * @returns the value associated with the key or null if not found
  34611. */
  34612. getAndRemove(key: string): Nullable<T>;
  34613. /**
  34614. * Remove a key/value from the dictionary.
  34615. * @param key the key to remove
  34616. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  34617. */
  34618. remove(key: string): boolean;
  34619. /**
  34620. * Clear the whole content of the dictionary
  34621. */
  34622. clear(): void;
  34623. /**
  34624. * Gets the current count
  34625. */
  34626. get count(): number;
  34627. /**
  34628. * Execute a callback on each key/val of the dictionary.
  34629. * Note that you can remove any element in this dictionary in the callback implementation
  34630. * @param callback the callback to execute on a given key/value pair
  34631. */
  34632. forEach(callback: (key: string, val: T) => void): void;
  34633. /**
  34634. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  34635. * If the callback returns null or undefined the method will iterate to the next key/value pair
  34636. * Note that you can remove any element in this dictionary in the callback implementation
  34637. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  34638. * @returns the first item
  34639. */
  34640. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  34641. private _count;
  34642. private _data;
  34643. }
  34644. }
  34645. declare module BABYLON {
  34646. /** @hidden */
  34647. export interface ICollisionCoordinator {
  34648. createCollider(): Collider;
  34649. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  34650. init(scene: Scene): void;
  34651. }
  34652. /** @hidden */
  34653. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  34654. private _scene;
  34655. private _scaledPosition;
  34656. private _scaledVelocity;
  34657. private _finalPosition;
  34658. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  34659. createCollider(): Collider;
  34660. init(scene: Scene): void;
  34661. private _collideWithWorld;
  34662. }
  34663. }
  34664. declare module BABYLON {
  34665. /**
  34666. * Class used to manage all inputs for the scene.
  34667. */
  34668. export class InputManager {
  34669. /** The distance in pixel that you have to move to prevent some events */
  34670. static DragMovementThreshold: number;
  34671. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  34672. static LongPressDelay: number;
  34673. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  34674. static DoubleClickDelay: number;
  34675. /** If you need to check double click without raising a single click at first click, enable this flag */
  34676. static ExclusiveDoubleClickMode: boolean;
  34677. private _wheelEventName;
  34678. private _onPointerMove;
  34679. private _onPointerDown;
  34680. private _onPointerUp;
  34681. private _initClickEvent;
  34682. private _initActionManager;
  34683. private _delayedSimpleClick;
  34684. private _delayedSimpleClickTimeout;
  34685. private _previousDelayedSimpleClickTimeout;
  34686. private _meshPickProceed;
  34687. private _previousButtonPressed;
  34688. private _currentPickResult;
  34689. private _previousPickResult;
  34690. private _totalPointersPressed;
  34691. private _doubleClickOccured;
  34692. private _pointerOverMesh;
  34693. private _pickedDownMesh;
  34694. private _pickedUpMesh;
  34695. private _pointerX;
  34696. private _pointerY;
  34697. private _unTranslatedPointerX;
  34698. private _unTranslatedPointerY;
  34699. private _startingPointerPosition;
  34700. private _previousStartingPointerPosition;
  34701. private _startingPointerTime;
  34702. private _previousStartingPointerTime;
  34703. private _pointerCaptures;
  34704. private _onKeyDown;
  34705. private _onKeyUp;
  34706. private _onCanvasFocusObserver;
  34707. private _onCanvasBlurObserver;
  34708. private _scene;
  34709. /**
  34710. * Creates a new InputManager
  34711. * @param scene defines the hosting scene
  34712. */
  34713. constructor(scene: Scene);
  34714. /**
  34715. * Gets the mesh that is currently under the pointer
  34716. */
  34717. get meshUnderPointer(): Nullable<AbstractMesh>;
  34718. /**
  34719. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  34720. */
  34721. get unTranslatedPointer(): Vector2;
  34722. /**
  34723. * Gets or sets the current on-screen X position of the pointer
  34724. */
  34725. get pointerX(): number;
  34726. set pointerX(value: number);
  34727. /**
  34728. * Gets or sets the current on-screen Y position of the pointer
  34729. */
  34730. get pointerY(): number;
  34731. set pointerY(value: number);
  34732. private _updatePointerPosition;
  34733. private _processPointerMove;
  34734. private _setRayOnPointerInfo;
  34735. private _checkPrePointerObservable;
  34736. /**
  34737. * Use this method to simulate a pointer move on a mesh
  34738. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34739. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34740. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34741. */
  34742. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  34743. /**
  34744. * Use this method to simulate a pointer down on a mesh
  34745. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34746. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34747. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34748. */
  34749. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  34750. private _processPointerDown;
  34751. /** @hidden */
  34752. _isPointerSwiping(): boolean;
  34753. /**
  34754. * Use this method to simulate a pointer up on a mesh
  34755. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34756. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34757. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34758. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  34759. */
  34760. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  34761. private _processPointerUp;
  34762. /**
  34763. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  34764. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  34765. * @returns true if the pointer was captured
  34766. */
  34767. isPointerCaptured(pointerId?: number): boolean;
  34768. /**
  34769. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  34770. * @param attachUp defines if you want to attach events to pointerup
  34771. * @param attachDown defines if you want to attach events to pointerdown
  34772. * @param attachMove defines if you want to attach events to pointermove
  34773. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  34774. */
  34775. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  34776. /**
  34777. * Detaches all event handlers
  34778. */
  34779. detachControl(): void;
  34780. /**
  34781. * Force the value of meshUnderPointer
  34782. * @param mesh defines the mesh to use
  34783. */
  34784. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  34785. /**
  34786. * Gets the mesh under the pointer
  34787. * @returns a Mesh or null if no mesh is under the pointer
  34788. */
  34789. getPointerOverMesh(): Nullable<AbstractMesh>;
  34790. }
  34791. }
  34792. declare module BABYLON {
  34793. /**
  34794. * Helper class used to generate session unique ID
  34795. */
  34796. export class UniqueIdGenerator {
  34797. private static _UniqueIdCounter;
  34798. /**
  34799. * Gets an unique (relatively to the current scene) Id
  34800. */
  34801. static get UniqueId(): number;
  34802. }
  34803. }
  34804. declare module BABYLON {
  34805. /**
  34806. * This class defines the direct association between an animation and a target
  34807. */
  34808. export class TargetedAnimation {
  34809. /**
  34810. * Animation to perform
  34811. */
  34812. animation: Animation;
  34813. /**
  34814. * Target to animate
  34815. */
  34816. target: any;
  34817. /**
  34818. * Serialize the object
  34819. * @returns the JSON object representing the current entity
  34820. */
  34821. serialize(): any;
  34822. }
  34823. /**
  34824. * Use this class to create coordinated animations on multiple targets
  34825. */
  34826. export class AnimationGroup implements IDisposable {
  34827. /** The name of the animation group */
  34828. name: string;
  34829. private _scene;
  34830. private _targetedAnimations;
  34831. private _animatables;
  34832. private _from;
  34833. private _to;
  34834. private _isStarted;
  34835. private _isPaused;
  34836. private _speedRatio;
  34837. private _loopAnimation;
  34838. /**
  34839. * Gets or sets the unique id of the node
  34840. */
  34841. uniqueId: number;
  34842. /**
  34843. * This observable will notify when one animation have ended
  34844. */
  34845. onAnimationEndObservable: Observable<TargetedAnimation>;
  34846. /**
  34847. * Observer raised when one animation loops
  34848. */
  34849. onAnimationLoopObservable: Observable<TargetedAnimation>;
  34850. /**
  34851. * Observer raised when all animations have looped
  34852. */
  34853. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  34854. /**
  34855. * This observable will notify when all animations have ended.
  34856. */
  34857. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  34858. /**
  34859. * This observable will notify when all animations have paused.
  34860. */
  34861. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  34862. /**
  34863. * This observable will notify when all animations are playing.
  34864. */
  34865. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  34866. /**
  34867. * Gets the first frame
  34868. */
  34869. get from(): number;
  34870. /**
  34871. * Gets the last frame
  34872. */
  34873. get to(): number;
  34874. /**
  34875. * Define if the animations are started
  34876. */
  34877. get isStarted(): boolean;
  34878. /**
  34879. * Gets a value indicating that the current group is playing
  34880. */
  34881. get isPlaying(): boolean;
  34882. /**
  34883. * Gets or sets the speed ratio to use for all animations
  34884. */
  34885. get speedRatio(): number;
  34886. /**
  34887. * Gets or sets the speed ratio to use for all animations
  34888. */
  34889. set speedRatio(value: number);
  34890. /**
  34891. * Gets or sets if all animations should loop or not
  34892. */
  34893. get loopAnimation(): boolean;
  34894. set loopAnimation(value: boolean);
  34895. /**
  34896. * Gets the targeted animations for this animation group
  34897. */
  34898. get targetedAnimations(): Array<TargetedAnimation>;
  34899. /**
  34900. * returning the list of animatables controlled by this animation group.
  34901. */
  34902. get animatables(): Array<Animatable>;
  34903. /**
  34904. * Instantiates a new Animation Group.
  34905. * This helps managing several animations at once.
  34906. * @see http://doc.babylonjs.com/how_to/group
  34907. * @param name Defines the name of the group
  34908. * @param scene Defines the scene the group belongs to
  34909. */
  34910. constructor(
  34911. /** The name of the animation group */
  34912. name: string, scene?: Nullable<Scene>);
  34913. /**
  34914. * Add an animation (with its target) in the group
  34915. * @param animation defines the animation we want to add
  34916. * @param target defines the target of the animation
  34917. * @returns the TargetedAnimation object
  34918. */
  34919. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  34920. /**
  34921. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  34922. * It can add constant keys at begin or end
  34923. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  34924. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  34925. * @returns the animation group
  34926. */
  34927. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  34928. private _animationLoopCount;
  34929. private _animationLoopFlags;
  34930. private _processLoop;
  34931. /**
  34932. * Start all animations on given targets
  34933. * @param loop defines if animations must loop
  34934. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  34935. * @param from defines the from key (optional)
  34936. * @param to defines the to key (optional)
  34937. * @returns the current animation group
  34938. */
  34939. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  34940. /**
  34941. * Pause all animations
  34942. * @returns the animation group
  34943. */
  34944. pause(): AnimationGroup;
  34945. /**
  34946. * Play all animations to initial state
  34947. * This function will start() the animations if they were not started or will restart() them if they were paused
  34948. * @param loop defines if animations must loop
  34949. * @returns the animation group
  34950. */
  34951. play(loop?: boolean): AnimationGroup;
  34952. /**
  34953. * Reset all animations to initial state
  34954. * @returns the animation group
  34955. */
  34956. reset(): AnimationGroup;
  34957. /**
  34958. * Restart animations from key 0
  34959. * @returns the animation group
  34960. */
  34961. restart(): AnimationGroup;
  34962. /**
  34963. * Stop all animations
  34964. * @returns the animation group
  34965. */
  34966. stop(): AnimationGroup;
  34967. /**
  34968. * Set animation weight for all animatables
  34969. * @param weight defines the weight to use
  34970. * @return the animationGroup
  34971. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  34972. */
  34973. setWeightForAllAnimatables(weight: number): AnimationGroup;
  34974. /**
  34975. * Synchronize and normalize all animatables with a source animatable
  34976. * @param root defines the root animatable to synchronize with
  34977. * @return the animationGroup
  34978. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  34979. */
  34980. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  34981. /**
  34982. * Goes to a specific frame in this animation group
  34983. * @param frame the frame number to go to
  34984. * @return the animationGroup
  34985. */
  34986. goToFrame(frame: number): AnimationGroup;
  34987. /**
  34988. * Dispose all associated resources
  34989. */
  34990. dispose(): void;
  34991. private _checkAnimationGroupEnded;
  34992. /**
  34993. * Clone the current animation group and returns a copy
  34994. * @param newName defines the name of the new group
  34995. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  34996. * @returns the new aniamtion group
  34997. */
  34998. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  34999. /**
  35000. * Serializes the animationGroup to an object
  35001. * @returns Serialized object
  35002. */
  35003. serialize(): any;
  35004. /**
  35005. * Returns a new AnimationGroup object parsed from the source provided.
  35006. * @param parsedAnimationGroup defines the source
  35007. * @param scene defines the scene that will receive the animationGroup
  35008. * @returns a new AnimationGroup
  35009. */
  35010. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  35011. /**
  35012. * Returns the string "AnimationGroup"
  35013. * @returns "AnimationGroup"
  35014. */
  35015. getClassName(): string;
  35016. /**
  35017. * Creates a detailled string about the object
  35018. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  35019. * @returns a string representing the object
  35020. */
  35021. toString(fullDetails?: boolean): string;
  35022. }
  35023. }
  35024. declare module BABYLON {
  35025. /**
  35026. * Define an interface for all classes that will hold resources
  35027. */
  35028. export interface IDisposable {
  35029. /**
  35030. * Releases all held resources
  35031. */
  35032. dispose(): void;
  35033. }
  35034. /** Interface defining initialization parameters for Scene class */
  35035. export interface SceneOptions {
  35036. /**
  35037. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  35038. * It will improve performance when the number of geometries becomes important.
  35039. */
  35040. useGeometryUniqueIdsMap?: boolean;
  35041. /**
  35042. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  35043. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  35044. */
  35045. useMaterialMeshMap?: boolean;
  35046. /**
  35047. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  35048. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  35049. */
  35050. useClonedMeshMap?: boolean;
  35051. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  35052. virtual?: boolean;
  35053. }
  35054. /**
  35055. * Represents a scene to be rendered by the engine.
  35056. * @see http://doc.babylonjs.com/features/scene
  35057. */
  35058. export class Scene extends AbstractScene implements IAnimatable {
  35059. /** The fog is deactivated */
  35060. static readonly FOGMODE_NONE: number;
  35061. /** The fog density is following an exponential function */
  35062. static readonly FOGMODE_EXP: number;
  35063. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  35064. static readonly FOGMODE_EXP2: number;
  35065. /** The fog density is following a linear function. */
  35066. static readonly FOGMODE_LINEAR: number;
  35067. /**
  35068. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  35069. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35070. */
  35071. static MinDeltaTime: number;
  35072. /**
  35073. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  35074. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35075. */
  35076. static MaxDeltaTime: number;
  35077. /**
  35078. * Factory used to create the default material.
  35079. * @param name The name of the material to create
  35080. * @param scene The scene to create the material for
  35081. * @returns The default material
  35082. */
  35083. static DefaultMaterialFactory(scene: Scene): Material;
  35084. /**
  35085. * Factory used to create the a collision coordinator.
  35086. * @returns The collision coordinator
  35087. */
  35088. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  35089. /** @hidden */
  35090. _inputManager: InputManager;
  35091. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  35092. cameraToUseForPointers: Nullable<Camera>;
  35093. /** @hidden */
  35094. readonly _isScene: boolean;
  35095. /**
  35096. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  35097. */
  35098. autoClear: boolean;
  35099. /**
  35100. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  35101. */
  35102. autoClearDepthAndStencil: boolean;
  35103. /**
  35104. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  35105. */
  35106. clearColor: Color4;
  35107. /**
  35108. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  35109. */
  35110. ambientColor: Color3;
  35111. /**
  35112. * This is use to store the default BRDF lookup for PBR materials in your scene.
  35113. * It should only be one of the following (if not the default embedded one):
  35114. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  35115. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  35116. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  35117. * The material properties need to be setup according to the type of texture in use.
  35118. */
  35119. environmentBRDFTexture: BaseTexture;
  35120. /** @hidden */
  35121. protected _environmentTexture: Nullable<BaseTexture>;
  35122. /**
  35123. * Texture used in all pbr material as the reflection texture.
  35124. * As in the majority of the scene they are the same (exception for multi room and so on),
  35125. * this is easier to reference from here than from all the materials.
  35126. */
  35127. get 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 set here than in all the materials.
  35132. */
  35133. set environmentTexture(value: Nullable<BaseTexture>);
  35134. /** @hidden */
  35135. protected _environmentIntensity: number;
  35136. /**
  35137. * Intensity of the environment in all pbr material.
  35138. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  35139. * As in the majority of the scene they are the same (exception for multi room and so on),
  35140. * this is easier to reference from here than from all the materials.
  35141. */
  35142. get environmentIntensity(): number;
  35143. /**
  35144. * Intensity of the environment in all pbr material.
  35145. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  35146. * As in the majority of the scene they are the same (exception for multi room and so on),
  35147. * this is easier to set here than in all the materials.
  35148. */
  35149. set environmentIntensity(value: number);
  35150. /** @hidden */
  35151. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  35152. /**
  35153. * Default image processing configuration used either in the rendering
  35154. * Forward main pass or through the imageProcessingPostProcess if present.
  35155. * As in the majority of the scene they are the same (exception for multi camera),
  35156. * this is easier to reference from here than from all the materials and post process.
  35157. *
  35158. * No setter as we it is a shared configuration, you can set the values instead.
  35159. */
  35160. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  35161. private _forceWireframe;
  35162. /**
  35163. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  35164. */
  35165. set forceWireframe(value: boolean);
  35166. get forceWireframe(): boolean;
  35167. private _skipFrustumClipping;
  35168. /**
  35169. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  35170. */
  35171. set skipFrustumClipping(value: boolean);
  35172. get skipFrustumClipping(): boolean;
  35173. private _forcePointsCloud;
  35174. /**
  35175. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  35176. */
  35177. set forcePointsCloud(value: boolean);
  35178. get forcePointsCloud(): boolean;
  35179. /**
  35180. * Gets or sets the active clipplane 1
  35181. */
  35182. clipPlane: Nullable<Plane>;
  35183. /**
  35184. * Gets or sets the active clipplane 2
  35185. */
  35186. clipPlane2: Nullable<Plane>;
  35187. /**
  35188. * Gets or sets the active clipplane 3
  35189. */
  35190. clipPlane3: Nullable<Plane>;
  35191. /**
  35192. * Gets or sets the active clipplane 4
  35193. */
  35194. clipPlane4: Nullable<Plane>;
  35195. /**
  35196. * Gets or sets the active clipplane 5
  35197. */
  35198. clipPlane5: Nullable<Plane>;
  35199. /**
  35200. * Gets or sets the active clipplane 6
  35201. */
  35202. clipPlane6: Nullable<Plane>;
  35203. /**
  35204. * Gets or sets a boolean indicating if animations are enabled
  35205. */
  35206. animationsEnabled: boolean;
  35207. private _animationPropertiesOverride;
  35208. /**
  35209. * Gets or sets the animation properties override
  35210. */
  35211. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  35212. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  35213. /**
  35214. * Gets or sets a boolean indicating if a constant deltatime has to be used
  35215. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  35216. */
  35217. useConstantAnimationDeltaTime: boolean;
  35218. /**
  35219. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  35220. * Please note that it requires to run a ray cast through the scene on every frame
  35221. */
  35222. constantlyUpdateMeshUnderPointer: boolean;
  35223. /**
  35224. * Defines the HTML cursor to use when hovering over interactive elements
  35225. */
  35226. hoverCursor: string;
  35227. /**
  35228. * Defines the HTML default cursor to use (empty by default)
  35229. */
  35230. defaultCursor: string;
  35231. /**
  35232. * Defines whether cursors are handled by the scene.
  35233. */
  35234. doNotHandleCursors: boolean;
  35235. /**
  35236. * This is used to call preventDefault() on pointer down
  35237. * in order to block unwanted artifacts like system double clicks
  35238. */
  35239. preventDefaultOnPointerDown: boolean;
  35240. /**
  35241. * This is used to call preventDefault() on pointer up
  35242. * in order to block unwanted artifacts like system double clicks
  35243. */
  35244. preventDefaultOnPointerUp: boolean;
  35245. /**
  35246. * Gets or sets user defined metadata
  35247. */
  35248. metadata: any;
  35249. /**
  35250. * For internal use only. Please do not use.
  35251. */
  35252. reservedDataStore: any;
  35253. /**
  35254. * Gets the name of the plugin used to load this scene (null by default)
  35255. */
  35256. loadingPluginName: string;
  35257. /**
  35258. * Use this array to add regular expressions used to disable offline support for specific urls
  35259. */
  35260. disableOfflineSupportExceptionRules: RegExp[];
  35261. /**
  35262. * An event triggered when the scene is disposed.
  35263. */
  35264. onDisposeObservable: Observable<Scene>;
  35265. private _onDisposeObserver;
  35266. /** Sets a function to be executed when this scene is disposed. */
  35267. set onDispose(callback: () => void);
  35268. /**
  35269. * An event triggered before rendering the scene (right after animations and physics)
  35270. */
  35271. onBeforeRenderObservable: Observable<Scene>;
  35272. private _onBeforeRenderObserver;
  35273. /** Sets a function to be executed before rendering this scene */
  35274. set beforeRender(callback: Nullable<() => void>);
  35275. /**
  35276. * An event triggered after rendering the scene
  35277. */
  35278. onAfterRenderObservable: Observable<Scene>;
  35279. /**
  35280. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  35281. */
  35282. onAfterRenderCameraObservable: Observable<Camera>;
  35283. private _onAfterRenderObserver;
  35284. /** Sets a function to be executed after rendering this scene */
  35285. set afterRender(callback: Nullable<() => void>);
  35286. /**
  35287. * An event triggered before animating the scene
  35288. */
  35289. onBeforeAnimationsObservable: Observable<Scene>;
  35290. /**
  35291. * An event triggered after animations processing
  35292. */
  35293. onAfterAnimationsObservable: Observable<Scene>;
  35294. /**
  35295. * An event triggered before draw calls are ready to be sent
  35296. */
  35297. onBeforeDrawPhaseObservable: Observable<Scene>;
  35298. /**
  35299. * An event triggered after draw calls have been sent
  35300. */
  35301. onAfterDrawPhaseObservable: Observable<Scene>;
  35302. /**
  35303. * An event triggered when the scene is ready
  35304. */
  35305. onReadyObservable: Observable<Scene>;
  35306. /**
  35307. * An event triggered before rendering a camera
  35308. */
  35309. onBeforeCameraRenderObservable: Observable<Camera>;
  35310. private _onBeforeCameraRenderObserver;
  35311. /** Sets a function to be executed before rendering a camera*/
  35312. set beforeCameraRender(callback: () => void);
  35313. /**
  35314. * An event triggered after rendering a camera
  35315. */
  35316. onAfterCameraRenderObservable: Observable<Camera>;
  35317. private _onAfterCameraRenderObserver;
  35318. /** Sets a function to be executed after rendering a camera*/
  35319. set afterCameraRender(callback: () => void);
  35320. /**
  35321. * An event triggered when active meshes evaluation is about to start
  35322. */
  35323. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  35324. /**
  35325. * An event triggered when active meshes evaluation is done
  35326. */
  35327. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  35328. /**
  35329. * An event triggered when particles rendering is about to start
  35330. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  35331. */
  35332. onBeforeParticlesRenderingObservable: Observable<Scene>;
  35333. /**
  35334. * An event triggered when particles rendering is done
  35335. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  35336. */
  35337. onAfterParticlesRenderingObservable: Observable<Scene>;
  35338. /**
  35339. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  35340. */
  35341. onDataLoadedObservable: Observable<Scene>;
  35342. /**
  35343. * An event triggered when a camera is created
  35344. */
  35345. onNewCameraAddedObservable: Observable<Camera>;
  35346. /**
  35347. * An event triggered when a camera is removed
  35348. */
  35349. onCameraRemovedObservable: Observable<Camera>;
  35350. /**
  35351. * An event triggered when a light is created
  35352. */
  35353. onNewLightAddedObservable: Observable<Light>;
  35354. /**
  35355. * An event triggered when a light is removed
  35356. */
  35357. onLightRemovedObservable: Observable<Light>;
  35358. /**
  35359. * An event triggered when a geometry is created
  35360. */
  35361. onNewGeometryAddedObservable: Observable<Geometry>;
  35362. /**
  35363. * An event triggered when a geometry is removed
  35364. */
  35365. onGeometryRemovedObservable: Observable<Geometry>;
  35366. /**
  35367. * An event triggered when a transform node is created
  35368. */
  35369. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  35370. /**
  35371. * An event triggered when a transform node is removed
  35372. */
  35373. onTransformNodeRemovedObservable: Observable<TransformNode>;
  35374. /**
  35375. * An event triggered when a mesh is created
  35376. */
  35377. onNewMeshAddedObservable: Observable<AbstractMesh>;
  35378. /**
  35379. * An event triggered when a mesh is removed
  35380. */
  35381. onMeshRemovedObservable: Observable<AbstractMesh>;
  35382. /**
  35383. * An event triggered when a skeleton is created
  35384. */
  35385. onNewSkeletonAddedObservable: Observable<Skeleton>;
  35386. /**
  35387. * An event triggered when a skeleton is removed
  35388. */
  35389. onSkeletonRemovedObservable: Observable<Skeleton>;
  35390. /**
  35391. * An event triggered when a material is created
  35392. */
  35393. onNewMaterialAddedObservable: Observable<Material>;
  35394. /**
  35395. * An event triggered when a material is removed
  35396. */
  35397. onMaterialRemovedObservable: Observable<Material>;
  35398. /**
  35399. * An event triggered when a texture is created
  35400. */
  35401. onNewTextureAddedObservable: Observable<BaseTexture>;
  35402. /**
  35403. * An event triggered when a texture is removed
  35404. */
  35405. onTextureRemovedObservable: Observable<BaseTexture>;
  35406. /**
  35407. * An event triggered when render targets are about to be rendered
  35408. * Can happen multiple times per frame.
  35409. */
  35410. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  35411. /**
  35412. * An event triggered when render targets were rendered.
  35413. * Can happen multiple times per frame.
  35414. */
  35415. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  35416. /**
  35417. * An event triggered before calculating deterministic simulation step
  35418. */
  35419. onBeforeStepObservable: Observable<Scene>;
  35420. /**
  35421. * An event triggered after calculating deterministic simulation step
  35422. */
  35423. onAfterStepObservable: Observable<Scene>;
  35424. /**
  35425. * An event triggered when the activeCamera property is updated
  35426. */
  35427. onActiveCameraChanged: Observable<Scene>;
  35428. /**
  35429. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  35430. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  35431. * 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)
  35432. */
  35433. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  35434. /**
  35435. * This Observable will be triggered after 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. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  35440. /**
  35441. * This Observable will when a mesh has been imported into the scene.
  35442. */
  35443. onMeshImportedObservable: Observable<AbstractMesh>;
  35444. /**
  35445. * This Observable will when an animation file has been imported into the scene.
  35446. */
  35447. onAnimationFileImportedObservable: Observable<Scene>;
  35448. /**
  35449. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  35450. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  35451. */
  35452. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  35453. /** @hidden */
  35454. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  35455. /**
  35456. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  35457. */
  35458. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  35459. /**
  35460. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  35461. */
  35462. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  35463. /**
  35464. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  35465. */
  35466. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  35467. /** Callback called when a pointer move is detected */
  35468. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  35469. /** Callback called when a pointer down is detected */
  35470. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  35471. /** Callback called when a pointer up is detected */
  35472. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  35473. /** Callback called when a pointer pick is detected */
  35474. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  35475. /**
  35476. * 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).
  35477. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  35478. */
  35479. onPrePointerObservable: Observable<PointerInfoPre>;
  35480. /**
  35481. * Observable event triggered each time an input event is received from the rendering canvas
  35482. */
  35483. onPointerObservable: Observable<PointerInfo>;
  35484. /**
  35485. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  35486. */
  35487. get unTranslatedPointer(): Vector2;
  35488. /**
  35489. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  35490. */
  35491. static get DragMovementThreshold(): number;
  35492. static set DragMovementThreshold(value: number);
  35493. /**
  35494. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  35495. */
  35496. static get LongPressDelay(): number;
  35497. static set LongPressDelay(value: number);
  35498. /**
  35499. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  35500. */
  35501. static get DoubleClickDelay(): number;
  35502. static set DoubleClickDelay(value: number);
  35503. /** If you need to check double click without raising a single click at first click, enable this flag */
  35504. static get ExclusiveDoubleClickMode(): boolean;
  35505. static set ExclusiveDoubleClickMode(value: boolean);
  35506. /** @hidden */
  35507. _mirroredCameraPosition: Nullable<Vector3>;
  35508. /**
  35509. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  35510. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  35511. */
  35512. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  35513. /**
  35514. * Observable event triggered each time an keyboard event is received from the hosting window
  35515. */
  35516. onKeyboardObservable: Observable<KeyboardInfo>;
  35517. private _useRightHandedSystem;
  35518. /**
  35519. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  35520. */
  35521. set useRightHandedSystem(value: boolean);
  35522. get useRightHandedSystem(): boolean;
  35523. private _timeAccumulator;
  35524. private _currentStepId;
  35525. private _currentInternalStep;
  35526. /**
  35527. * Sets the step Id used by deterministic lock step
  35528. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35529. * @param newStepId defines the step Id
  35530. */
  35531. setStepId(newStepId: number): void;
  35532. /**
  35533. * Gets the step Id used by deterministic lock step
  35534. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35535. * @returns the step Id
  35536. */
  35537. getStepId(): number;
  35538. /**
  35539. * Gets the internal step used by deterministic lock step
  35540. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35541. * @returns the internal step
  35542. */
  35543. getInternalStep(): number;
  35544. private _fogEnabled;
  35545. /**
  35546. * Gets or sets a boolean indicating if fog is enabled on this scene
  35547. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35548. * (Default is true)
  35549. */
  35550. set fogEnabled(value: boolean);
  35551. get fogEnabled(): boolean;
  35552. private _fogMode;
  35553. /**
  35554. * Gets or sets the fog mode to use
  35555. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35556. * | mode | value |
  35557. * | --- | --- |
  35558. * | FOGMODE_NONE | 0 |
  35559. * | FOGMODE_EXP | 1 |
  35560. * | FOGMODE_EXP2 | 2 |
  35561. * | FOGMODE_LINEAR | 3 |
  35562. */
  35563. set fogMode(value: number);
  35564. get fogMode(): number;
  35565. /**
  35566. * Gets or sets the fog color to use
  35567. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35568. * (Default is Color3(0.2, 0.2, 0.3))
  35569. */
  35570. fogColor: Color3;
  35571. /**
  35572. * Gets or sets the fog density to use
  35573. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35574. * (Default is 0.1)
  35575. */
  35576. fogDensity: number;
  35577. /**
  35578. * Gets or sets the fog start distance to use
  35579. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35580. * (Default is 0)
  35581. */
  35582. fogStart: number;
  35583. /**
  35584. * Gets or sets the fog end distance to use
  35585. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35586. * (Default is 1000)
  35587. */
  35588. fogEnd: number;
  35589. private _shadowsEnabled;
  35590. /**
  35591. * Gets or sets a boolean indicating if shadows are enabled on this scene
  35592. */
  35593. set shadowsEnabled(value: boolean);
  35594. get shadowsEnabled(): boolean;
  35595. private _lightsEnabled;
  35596. /**
  35597. * Gets or sets a boolean indicating if lights are enabled on this scene
  35598. */
  35599. set lightsEnabled(value: boolean);
  35600. get lightsEnabled(): boolean;
  35601. /** All of the active cameras added to this scene. */
  35602. activeCameras: Camera[];
  35603. /** @hidden */
  35604. _activeCamera: Nullable<Camera>;
  35605. /** Gets or sets the current active camera */
  35606. get activeCamera(): Nullable<Camera>;
  35607. set activeCamera(value: Nullable<Camera>);
  35608. private _defaultMaterial;
  35609. /** The default material used on meshes when no material is affected */
  35610. get defaultMaterial(): Material;
  35611. /** The default material used on meshes when no material is affected */
  35612. set defaultMaterial(value: Material);
  35613. private _texturesEnabled;
  35614. /**
  35615. * Gets or sets a boolean indicating if textures are enabled on this scene
  35616. */
  35617. set texturesEnabled(value: boolean);
  35618. get texturesEnabled(): boolean;
  35619. /**
  35620. * Gets or sets a boolean indicating if particles are enabled on this scene
  35621. */
  35622. particlesEnabled: boolean;
  35623. /**
  35624. * Gets or sets a boolean indicating if sprites are enabled on this scene
  35625. */
  35626. spritesEnabled: boolean;
  35627. private _skeletonsEnabled;
  35628. /**
  35629. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  35630. */
  35631. set skeletonsEnabled(value: boolean);
  35632. get skeletonsEnabled(): boolean;
  35633. /**
  35634. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  35635. */
  35636. lensFlaresEnabled: boolean;
  35637. /**
  35638. * Gets or sets a boolean indicating if collisions are enabled on this scene
  35639. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  35640. */
  35641. collisionsEnabled: boolean;
  35642. private _collisionCoordinator;
  35643. /** @hidden */
  35644. get collisionCoordinator(): ICollisionCoordinator;
  35645. /**
  35646. * Defines the gravity applied to this scene (used only for collisions)
  35647. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  35648. */
  35649. gravity: Vector3;
  35650. /**
  35651. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  35652. */
  35653. postProcessesEnabled: boolean;
  35654. /**
  35655. * The list of postprocesses added to the scene
  35656. */
  35657. postProcesses: PostProcess[];
  35658. /**
  35659. * Gets the current postprocess manager
  35660. */
  35661. postProcessManager: PostProcessManager;
  35662. /**
  35663. * Gets or sets a boolean indicating if render targets are enabled on this scene
  35664. */
  35665. renderTargetsEnabled: boolean;
  35666. /**
  35667. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  35668. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  35669. */
  35670. dumpNextRenderTargets: boolean;
  35671. /**
  35672. * The list of user defined render targets added to the scene
  35673. */
  35674. customRenderTargets: RenderTargetTexture[];
  35675. /**
  35676. * Defines if texture loading must be delayed
  35677. * If true, textures will only be loaded when they need to be rendered
  35678. */
  35679. useDelayedTextureLoading: boolean;
  35680. /**
  35681. * Gets the list of meshes imported to the scene through SceneLoader
  35682. */
  35683. importedMeshesFiles: String[];
  35684. /**
  35685. * Gets or sets a boolean indicating if probes are enabled on this scene
  35686. */
  35687. probesEnabled: boolean;
  35688. /**
  35689. * Gets or sets the current offline provider to use to store scene data
  35690. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  35691. */
  35692. offlineProvider: IOfflineProvider;
  35693. /**
  35694. * Gets or sets the action manager associated with the scene
  35695. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  35696. */
  35697. actionManager: AbstractActionManager;
  35698. private _meshesForIntersections;
  35699. /**
  35700. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  35701. */
  35702. proceduralTexturesEnabled: boolean;
  35703. private _engine;
  35704. private _totalVertices;
  35705. /** @hidden */
  35706. _activeIndices: PerfCounter;
  35707. /** @hidden */
  35708. _activeParticles: PerfCounter;
  35709. /** @hidden */
  35710. _activeBones: PerfCounter;
  35711. private _animationRatio;
  35712. /** @hidden */
  35713. _animationTimeLast: number;
  35714. /** @hidden */
  35715. _animationTime: number;
  35716. /**
  35717. * Gets or sets a general scale for animation speed
  35718. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  35719. */
  35720. animationTimeScale: number;
  35721. /** @hidden */
  35722. _cachedMaterial: Nullable<Material>;
  35723. /** @hidden */
  35724. _cachedEffect: Nullable<Effect>;
  35725. /** @hidden */
  35726. _cachedVisibility: Nullable<number>;
  35727. private _renderId;
  35728. private _frameId;
  35729. private _executeWhenReadyTimeoutId;
  35730. private _intermediateRendering;
  35731. private _viewUpdateFlag;
  35732. private _projectionUpdateFlag;
  35733. /** @hidden */
  35734. _toBeDisposed: Nullable<IDisposable>[];
  35735. private _activeRequests;
  35736. /** @hidden */
  35737. _pendingData: any[];
  35738. private _isDisposed;
  35739. /**
  35740. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  35741. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  35742. */
  35743. dispatchAllSubMeshesOfActiveMeshes: boolean;
  35744. private _activeMeshes;
  35745. private _processedMaterials;
  35746. private _renderTargets;
  35747. /** @hidden */
  35748. _activeParticleSystems: SmartArray<IParticleSystem>;
  35749. private _activeSkeletons;
  35750. private _softwareSkinnedMeshes;
  35751. private _renderingManager;
  35752. /** @hidden */
  35753. _activeAnimatables: Animatable[];
  35754. private _transformMatrix;
  35755. private _sceneUbo;
  35756. /** @hidden */
  35757. _viewMatrix: Matrix;
  35758. private _projectionMatrix;
  35759. /** @hidden */
  35760. _forcedViewPosition: Nullable<Vector3>;
  35761. /** @hidden */
  35762. _frustumPlanes: Plane[];
  35763. /**
  35764. * Gets the list of frustum planes (built from the active camera)
  35765. */
  35766. get frustumPlanes(): Plane[];
  35767. /**
  35768. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  35769. * This is useful if there are more lights that the maximum simulteanous authorized
  35770. */
  35771. requireLightSorting: boolean;
  35772. /** @hidden */
  35773. readonly useMaterialMeshMap: boolean;
  35774. /** @hidden */
  35775. readonly useClonedMeshMap: boolean;
  35776. private _externalData;
  35777. private _uid;
  35778. /**
  35779. * @hidden
  35780. * Backing store of defined scene components.
  35781. */
  35782. _components: ISceneComponent[];
  35783. /**
  35784. * @hidden
  35785. * Backing store of defined scene components.
  35786. */
  35787. _serializableComponents: ISceneSerializableComponent[];
  35788. /**
  35789. * List of components to register on the next registration step.
  35790. */
  35791. private _transientComponents;
  35792. /**
  35793. * Registers the transient components if needed.
  35794. */
  35795. private _registerTransientComponents;
  35796. /**
  35797. * @hidden
  35798. * Add a component to the scene.
  35799. * Note that the ccomponent could be registered on th next frame if this is called after
  35800. * the register component stage.
  35801. * @param component Defines the component to add to the scene
  35802. */
  35803. _addComponent(component: ISceneComponent): void;
  35804. /**
  35805. * @hidden
  35806. * Gets a component from the scene.
  35807. * @param name defines the name of the component to retrieve
  35808. * @returns the component or null if not present
  35809. */
  35810. _getComponent(name: string): Nullable<ISceneComponent>;
  35811. /**
  35812. * @hidden
  35813. * Defines the actions happening before camera updates.
  35814. */
  35815. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  35816. /**
  35817. * @hidden
  35818. * Defines the actions happening before clear the canvas.
  35819. */
  35820. _beforeClearStage: Stage<SimpleStageAction>;
  35821. /**
  35822. * @hidden
  35823. * Defines the actions when collecting render targets for the frame.
  35824. */
  35825. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  35826. /**
  35827. * @hidden
  35828. * Defines the actions happening for one camera in the frame.
  35829. */
  35830. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  35831. /**
  35832. * @hidden
  35833. * Defines the actions happening during the per mesh ready checks.
  35834. */
  35835. _isReadyForMeshStage: Stage<MeshStageAction>;
  35836. /**
  35837. * @hidden
  35838. * Defines the actions happening before evaluate active mesh checks.
  35839. */
  35840. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  35841. /**
  35842. * @hidden
  35843. * Defines the actions happening during the evaluate sub mesh checks.
  35844. */
  35845. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  35846. /**
  35847. * @hidden
  35848. * Defines the actions happening during the active mesh stage.
  35849. */
  35850. _activeMeshStage: Stage<ActiveMeshStageAction>;
  35851. /**
  35852. * @hidden
  35853. * Defines the actions happening during the per camera render target step.
  35854. */
  35855. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  35856. /**
  35857. * @hidden
  35858. * Defines the actions happening just before the active camera is drawing.
  35859. */
  35860. _beforeCameraDrawStage: Stage<CameraStageAction>;
  35861. /**
  35862. * @hidden
  35863. * Defines the actions happening just before a render target is drawing.
  35864. */
  35865. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  35866. /**
  35867. * @hidden
  35868. * Defines the actions happening just before a rendering group is drawing.
  35869. */
  35870. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  35871. /**
  35872. * @hidden
  35873. * Defines the actions happening just before a mesh is drawing.
  35874. */
  35875. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  35876. /**
  35877. * @hidden
  35878. * Defines the actions happening just after a mesh has been drawn.
  35879. */
  35880. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  35881. /**
  35882. * @hidden
  35883. * Defines the actions happening just after a rendering group has been drawn.
  35884. */
  35885. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  35886. /**
  35887. * @hidden
  35888. * Defines the actions happening just after the active camera has been drawn.
  35889. */
  35890. _afterCameraDrawStage: Stage<CameraStageAction>;
  35891. /**
  35892. * @hidden
  35893. * Defines the actions happening just after a render target has been drawn.
  35894. */
  35895. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  35896. /**
  35897. * @hidden
  35898. * Defines the actions happening just after rendering all cameras and computing intersections.
  35899. */
  35900. _afterRenderStage: Stage<SimpleStageAction>;
  35901. /**
  35902. * @hidden
  35903. * Defines the actions happening when a pointer move event happens.
  35904. */
  35905. _pointerMoveStage: Stage<PointerMoveStageAction>;
  35906. /**
  35907. * @hidden
  35908. * Defines the actions happening when a pointer down event happens.
  35909. */
  35910. _pointerDownStage: Stage<PointerUpDownStageAction>;
  35911. /**
  35912. * @hidden
  35913. * Defines the actions happening when a pointer up event happens.
  35914. */
  35915. _pointerUpStage: Stage<PointerUpDownStageAction>;
  35916. /**
  35917. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  35918. */
  35919. private geometriesByUniqueId;
  35920. /**
  35921. * Creates a new Scene
  35922. * @param engine defines the engine to use to render this scene
  35923. * @param options defines the scene options
  35924. */
  35925. constructor(engine: Engine, options?: SceneOptions);
  35926. /**
  35927. * Gets a string idenfifying the name of the class
  35928. * @returns "Scene" string
  35929. */
  35930. getClassName(): string;
  35931. private _defaultMeshCandidates;
  35932. /**
  35933. * @hidden
  35934. */
  35935. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  35936. private _defaultSubMeshCandidates;
  35937. /**
  35938. * @hidden
  35939. */
  35940. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  35941. /**
  35942. * Sets the default candidate providers for the scene.
  35943. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  35944. * and getCollidingSubMeshCandidates to their default function
  35945. */
  35946. setDefaultCandidateProviders(): void;
  35947. /**
  35948. * Gets the mesh that is currently under the pointer
  35949. */
  35950. get meshUnderPointer(): Nullable<AbstractMesh>;
  35951. /**
  35952. * Gets or sets the current on-screen X position of the pointer
  35953. */
  35954. get pointerX(): number;
  35955. set pointerX(value: number);
  35956. /**
  35957. * Gets or sets the current on-screen Y position of the pointer
  35958. */
  35959. get pointerY(): number;
  35960. set pointerY(value: number);
  35961. /**
  35962. * Gets the cached material (ie. the latest rendered one)
  35963. * @returns the cached material
  35964. */
  35965. getCachedMaterial(): Nullable<Material>;
  35966. /**
  35967. * Gets the cached effect (ie. the latest rendered one)
  35968. * @returns the cached effect
  35969. */
  35970. getCachedEffect(): Nullable<Effect>;
  35971. /**
  35972. * Gets the cached visibility state (ie. the latest rendered one)
  35973. * @returns the cached visibility state
  35974. */
  35975. getCachedVisibility(): Nullable<number>;
  35976. /**
  35977. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  35978. * @param material defines the current material
  35979. * @param effect defines the current effect
  35980. * @param visibility defines the current visibility state
  35981. * @returns true if one parameter is not cached
  35982. */
  35983. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  35984. /**
  35985. * Gets the engine associated with the scene
  35986. * @returns an Engine
  35987. */
  35988. getEngine(): Engine;
  35989. /**
  35990. * Gets the total number of vertices rendered per frame
  35991. * @returns the total number of vertices rendered per frame
  35992. */
  35993. getTotalVertices(): number;
  35994. /**
  35995. * Gets the performance counter for total vertices
  35996. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  35997. */
  35998. get totalVerticesPerfCounter(): PerfCounter;
  35999. /**
  36000. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  36001. * @returns the total number of active indices rendered per frame
  36002. */
  36003. getActiveIndices(): number;
  36004. /**
  36005. * Gets the performance counter for active indices
  36006. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36007. */
  36008. get totalActiveIndicesPerfCounter(): PerfCounter;
  36009. /**
  36010. * Gets the total number of active particles rendered per frame
  36011. * @returns the total number of active particles rendered per frame
  36012. */
  36013. getActiveParticles(): number;
  36014. /**
  36015. * Gets the performance counter for active particles
  36016. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36017. */
  36018. get activeParticlesPerfCounter(): PerfCounter;
  36019. /**
  36020. * Gets the total number of active bones rendered per frame
  36021. * @returns the total number of active bones rendered per frame
  36022. */
  36023. getActiveBones(): number;
  36024. /**
  36025. * Gets the performance counter for active bones
  36026. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36027. */
  36028. get activeBonesPerfCounter(): PerfCounter;
  36029. /**
  36030. * Gets the array of active meshes
  36031. * @returns an array of AbstractMesh
  36032. */
  36033. getActiveMeshes(): SmartArray<AbstractMesh>;
  36034. /**
  36035. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  36036. * @returns a number
  36037. */
  36038. getAnimationRatio(): number;
  36039. /**
  36040. * Gets an unique Id for the current render phase
  36041. * @returns a number
  36042. */
  36043. getRenderId(): number;
  36044. /**
  36045. * Gets an unique Id for the current frame
  36046. * @returns a number
  36047. */
  36048. getFrameId(): number;
  36049. /** Call this function if you want to manually increment the render Id*/
  36050. incrementRenderId(): void;
  36051. private _createUbo;
  36052. /**
  36053. * Use this method to simulate a pointer move on a mesh
  36054. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36055. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36056. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36057. * @returns the current scene
  36058. */
  36059. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  36060. /**
  36061. * Use this method to simulate a pointer down on a mesh
  36062. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36063. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36064. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36065. * @returns the current scene
  36066. */
  36067. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  36068. /**
  36069. * Use this method to simulate a pointer up on a mesh
  36070. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36071. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36072. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36073. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  36074. * @returns the current scene
  36075. */
  36076. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  36077. /**
  36078. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  36079. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  36080. * @returns true if the pointer was captured
  36081. */
  36082. isPointerCaptured(pointerId?: number): boolean;
  36083. /**
  36084. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  36085. * @param attachUp defines if you want to attach events to pointerup
  36086. * @param attachDown defines if you want to attach events to pointerdown
  36087. * @param attachMove defines if you want to attach events to pointermove
  36088. */
  36089. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  36090. /** Detaches all event handlers*/
  36091. detachControl(): void;
  36092. /**
  36093. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  36094. * Delay loaded resources are not taking in account
  36095. * @return true if all required resources are ready
  36096. */
  36097. isReady(): boolean;
  36098. /** Resets all cached information relative to material (including effect and visibility) */
  36099. resetCachedMaterial(): void;
  36100. /**
  36101. * Registers a function to be called before every frame render
  36102. * @param func defines the function to register
  36103. */
  36104. registerBeforeRender(func: () => void): void;
  36105. /**
  36106. * Unregisters a function called before every frame render
  36107. * @param func defines the function to unregister
  36108. */
  36109. unregisterBeforeRender(func: () => void): void;
  36110. /**
  36111. * Registers a function to be called after every frame render
  36112. * @param func defines the function to register
  36113. */
  36114. registerAfterRender(func: () => void): void;
  36115. /**
  36116. * Unregisters a function called after every frame render
  36117. * @param func defines the function to unregister
  36118. */
  36119. unregisterAfterRender(func: () => void): void;
  36120. private _executeOnceBeforeRender;
  36121. /**
  36122. * The provided function will run before render once and will be disposed afterwards.
  36123. * A timeout delay can be provided so that the function will be executed in N ms.
  36124. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  36125. * @param func The function to be executed.
  36126. * @param timeout optional delay in ms
  36127. */
  36128. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  36129. /** @hidden */
  36130. _addPendingData(data: any): void;
  36131. /** @hidden */
  36132. _removePendingData(data: any): void;
  36133. /**
  36134. * Returns the number of items waiting to be loaded
  36135. * @returns the number of items waiting to be loaded
  36136. */
  36137. getWaitingItemsCount(): number;
  36138. /**
  36139. * Returns a boolean indicating if the scene is still loading data
  36140. */
  36141. get isLoading(): boolean;
  36142. /**
  36143. * Registers a function to be executed when the scene is ready
  36144. * @param {Function} func - the function to be executed
  36145. */
  36146. executeWhenReady(func: () => void): void;
  36147. /**
  36148. * Returns a promise that resolves when the scene is ready
  36149. * @returns A promise that resolves when the scene is ready
  36150. */
  36151. whenReadyAsync(): Promise<void>;
  36152. /** @hidden */
  36153. _checkIsReady(): void;
  36154. /**
  36155. * Gets all animatable attached to the scene
  36156. */
  36157. get animatables(): Animatable[];
  36158. /**
  36159. * Resets the last animation time frame.
  36160. * Useful to override when animations start running when loading a scene for the first time.
  36161. */
  36162. resetLastAnimationTimeFrame(): void;
  36163. /**
  36164. * Gets the current view matrix
  36165. * @returns a Matrix
  36166. */
  36167. getViewMatrix(): Matrix;
  36168. /**
  36169. * Gets the current projection matrix
  36170. * @returns a Matrix
  36171. */
  36172. getProjectionMatrix(): Matrix;
  36173. /**
  36174. * Gets the current transform matrix
  36175. * @returns a Matrix made of View * Projection
  36176. */
  36177. getTransformMatrix(): Matrix;
  36178. /**
  36179. * Sets the current transform matrix
  36180. * @param viewL defines the View matrix to use
  36181. * @param projectionL defines the Projection matrix to use
  36182. * @param viewR defines the right View matrix to use (if provided)
  36183. * @param projectionR defines the right Projection matrix to use (if provided)
  36184. */
  36185. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  36186. /**
  36187. * Gets the uniform buffer used to store scene data
  36188. * @returns a UniformBuffer
  36189. */
  36190. getSceneUniformBuffer(): UniformBuffer;
  36191. /**
  36192. * Gets an unique (relatively to the current scene) Id
  36193. * @returns an unique number for the scene
  36194. */
  36195. getUniqueId(): number;
  36196. /**
  36197. * Add a mesh to the list of scene's meshes
  36198. * @param newMesh defines the mesh to add
  36199. * @param recursive if all child meshes should also be added to the scene
  36200. */
  36201. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  36202. /**
  36203. * Remove a mesh for the list of scene's meshes
  36204. * @param toRemove defines the mesh to remove
  36205. * @param recursive if all child meshes should also be removed from the scene
  36206. * @returns the index where the mesh was in the mesh list
  36207. */
  36208. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  36209. /**
  36210. * Add a transform node to the list of scene's transform nodes
  36211. * @param newTransformNode defines the transform node to add
  36212. */
  36213. addTransformNode(newTransformNode: TransformNode): void;
  36214. /**
  36215. * Remove a transform node for the list of scene's transform nodes
  36216. * @param toRemove defines the transform node to remove
  36217. * @returns the index where the transform node was in the transform node list
  36218. */
  36219. removeTransformNode(toRemove: TransformNode): number;
  36220. /**
  36221. * Remove a skeleton for the list of scene's skeletons
  36222. * @param toRemove defines the skeleton to remove
  36223. * @returns the index where the skeleton was in the skeleton list
  36224. */
  36225. removeSkeleton(toRemove: Skeleton): number;
  36226. /**
  36227. * Remove a morph target for the list of scene's morph targets
  36228. * @param toRemove defines the morph target to remove
  36229. * @returns the index where the morph target was in the morph target list
  36230. */
  36231. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  36232. /**
  36233. * Remove a light for the list of scene's lights
  36234. * @param toRemove defines the light to remove
  36235. * @returns the index where the light was in the light list
  36236. */
  36237. removeLight(toRemove: Light): number;
  36238. /**
  36239. * Remove a camera for the list of scene's cameras
  36240. * @param toRemove defines the camera to remove
  36241. * @returns the index where the camera was in the camera list
  36242. */
  36243. removeCamera(toRemove: Camera): number;
  36244. /**
  36245. * Remove a particle system for the list of scene's particle systems
  36246. * @param toRemove defines the particle system to remove
  36247. * @returns the index where the particle system was in the particle system list
  36248. */
  36249. removeParticleSystem(toRemove: IParticleSystem): number;
  36250. /**
  36251. * Remove a animation for the list of scene's animations
  36252. * @param toRemove defines the animation to remove
  36253. * @returns the index where the animation was in the animation list
  36254. */
  36255. removeAnimation(toRemove: Animation): number;
  36256. /**
  36257. * Will stop the animation of the given target
  36258. * @param target - the target
  36259. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  36260. * @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)
  36261. */
  36262. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  36263. /**
  36264. * Removes the given animation group from this scene.
  36265. * @param toRemove The animation group to remove
  36266. * @returns The index of the removed animation group
  36267. */
  36268. removeAnimationGroup(toRemove: AnimationGroup): number;
  36269. /**
  36270. * Removes the given multi-material from this scene.
  36271. * @param toRemove The multi-material to remove
  36272. * @returns The index of the removed multi-material
  36273. */
  36274. removeMultiMaterial(toRemove: MultiMaterial): number;
  36275. /**
  36276. * Removes the given material from this scene.
  36277. * @param toRemove The material to remove
  36278. * @returns The index of the removed material
  36279. */
  36280. removeMaterial(toRemove: Material): number;
  36281. /**
  36282. * Removes the given action manager from this scene.
  36283. * @param toRemove The action manager to remove
  36284. * @returns The index of the removed action manager
  36285. */
  36286. removeActionManager(toRemove: AbstractActionManager): number;
  36287. /**
  36288. * Removes the given texture from this scene.
  36289. * @param toRemove The texture to remove
  36290. * @returns The index of the removed texture
  36291. */
  36292. removeTexture(toRemove: BaseTexture): number;
  36293. /**
  36294. * Adds the given light to this scene
  36295. * @param newLight The light to add
  36296. */
  36297. addLight(newLight: Light): void;
  36298. /**
  36299. * Sorts the list list based on light priorities
  36300. */
  36301. sortLightsByPriority(): void;
  36302. /**
  36303. * Adds the given camera to this scene
  36304. * @param newCamera The camera to add
  36305. */
  36306. addCamera(newCamera: Camera): void;
  36307. /**
  36308. * Adds the given skeleton to this scene
  36309. * @param newSkeleton The skeleton to add
  36310. */
  36311. addSkeleton(newSkeleton: Skeleton): void;
  36312. /**
  36313. * Adds the given particle system to this scene
  36314. * @param newParticleSystem The particle system to add
  36315. */
  36316. addParticleSystem(newParticleSystem: IParticleSystem): void;
  36317. /**
  36318. * Adds the given animation to this scene
  36319. * @param newAnimation The animation to add
  36320. */
  36321. addAnimation(newAnimation: Animation): void;
  36322. /**
  36323. * Adds the given animation group to this scene.
  36324. * @param newAnimationGroup The animation group to add
  36325. */
  36326. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  36327. /**
  36328. * Adds the given multi-material to this scene
  36329. * @param newMultiMaterial The multi-material to add
  36330. */
  36331. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  36332. /**
  36333. * Adds the given material to this scene
  36334. * @param newMaterial The material to add
  36335. */
  36336. addMaterial(newMaterial: Material): void;
  36337. /**
  36338. * Adds the given morph target to this scene
  36339. * @param newMorphTargetManager The morph target to add
  36340. */
  36341. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  36342. /**
  36343. * Adds the given geometry to this scene
  36344. * @param newGeometry The geometry to add
  36345. */
  36346. addGeometry(newGeometry: Geometry): void;
  36347. /**
  36348. * Adds the given action manager to this scene
  36349. * @param newActionManager The action manager to add
  36350. */
  36351. addActionManager(newActionManager: AbstractActionManager): void;
  36352. /**
  36353. * Adds the given texture to this scene.
  36354. * @param newTexture The texture to add
  36355. */
  36356. addTexture(newTexture: BaseTexture): void;
  36357. /**
  36358. * Switch active camera
  36359. * @param newCamera defines the new active camera
  36360. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  36361. */
  36362. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  36363. /**
  36364. * sets the active camera of the scene using its ID
  36365. * @param id defines the camera's ID
  36366. * @return the new active camera or null if none found.
  36367. */
  36368. setActiveCameraByID(id: string): Nullable<Camera>;
  36369. /**
  36370. * sets the active camera of the scene using its name
  36371. * @param name defines the camera's name
  36372. * @returns the new active camera or null if none found.
  36373. */
  36374. setActiveCameraByName(name: string): Nullable<Camera>;
  36375. /**
  36376. * get an animation group using its name
  36377. * @param name defines the material's name
  36378. * @return the animation group or null if none found.
  36379. */
  36380. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  36381. /**
  36382. * Get a material using its unique id
  36383. * @param uniqueId defines the material's unique id
  36384. * @return the material or null if none found.
  36385. */
  36386. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  36387. /**
  36388. * get a material using its id
  36389. * @param id defines the material's ID
  36390. * @return the material or null if none found.
  36391. */
  36392. getMaterialByID(id: string): Nullable<Material>;
  36393. /**
  36394. * Gets a the last added material using a given id
  36395. * @param id defines the material's ID
  36396. * @return the last material with the given id or null if none found.
  36397. */
  36398. getLastMaterialByID(id: string): Nullable<Material>;
  36399. /**
  36400. * Gets a material using its name
  36401. * @param name defines the material's name
  36402. * @return the material or null if none found.
  36403. */
  36404. getMaterialByName(name: string): Nullable<Material>;
  36405. /**
  36406. * Get a texture using its unique id
  36407. * @param uniqueId defines the texture's unique id
  36408. * @return the texture or null if none found.
  36409. */
  36410. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  36411. /**
  36412. * Gets a camera using its id
  36413. * @param id defines the id to look for
  36414. * @returns the camera or null if not found
  36415. */
  36416. getCameraByID(id: string): Nullable<Camera>;
  36417. /**
  36418. * Gets a camera using its unique id
  36419. * @param uniqueId defines the unique id to look for
  36420. * @returns the camera or null if not found
  36421. */
  36422. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  36423. /**
  36424. * Gets a camera using its name
  36425. * @param name defines the camera's name
  36426. * @return the camera or null if none found.
  36427. */
  36428. getCameraByName(name: string): Nullable<Camera>;
  36429. /**
  36430. * Gets a bone using its id
  36431. * @param id defines the bone's id
  36432. * @return the bone or null if not found
  36433. */
  36434. getBoneByID(id: string): Nullable<Bone>;
  36435. /**
  36436. * Gets a bone using its id
  36437. * @param name defines the bone's name
  36438. * @return the bone or null if not found
  36439. */
  36440. getBoneByName(name: string): Nullable<Bone>;
  36441. /**
  36442. * Gets a light node using its name
  36443. * @param name defines the the light's name
  36444. * @return the light or null if none found.
  36445. */
  36446. getLightByName(name: string): Nullable<Light>;
  36447. /**
  36448. * Gets a light node using its id
  36449. * @param id defines the light's id
  36450. * @return the light or null if none found.
  36451. */
  36452. getLightByID(id: string): Nullable<Light>;
  36453. /**
  36454. * Gets a light node using its scene-generated unique ID
  36455. * @param uniqueId defines the light's unique id
  36456. * @return the light or null if none found.
  36457. */
  36458. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  36459. /**
  36460. * Gets a particle system by id
  36461. * @param id defines the particle system id
  36462. * @return the corresponding system or null if none found
  36463. */
  36464. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  36465. /**
  36466. * Gets a geometry using its ID
  36467. * @param id defines the geometry's id
  36468. * @return the geometry or null if none found.
  36469. */
  36470. getGeometryByID(id: string): Nullable<Geometry>;
  36471. private _getGeometryByUniqueID;
  36472. /**
  36473. * Add a new geometry to this scene
  36474. * @param geometry defines the geometry to be added to the scene.
  36475. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  36476. * @return a boolean defining if the geometry was added or not
  36477. */
  36478. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  36479. /**
  36480. * Removes an existing geometry
  36481. * @param geometry defines the geometry to be removed from the scene
  36482. * @return a boolean defining if the geometry was removed or not
  36483. */
  36484. removeGeometry(geometry: Geometry): boolean;
  36485. /**
  36486. * Gets the list of geometries attached to the scene
  36487. * @returns an array of Geometry
  36488. */
  36489. getGeometries(): Geometry[];
  36490. /**
  36491. * Gets the first added mesh found of a given ID
  36492. * @param id defines the id to search for
  36493. * @return the mesh found or null if not found at all
  36494. */
  36495. getMeshByID(id: string): Nullable<AbstractMesh>;
  36496. /**
  36497. * Gets a list of meshes using their id
  36498. * @param id defines the id to search for
  36499. * @returns a list of meshes
  36500. */
  36501. getMeshesByID(id: string): Array<AbstractMesh>;
  36502. /**
  36503. * Gets the first added transform node found of a given ID
  36504. * @param id defines the id to search for
  36505. * @return the found transform node or null if not found at all.
  36506. */
  36507. getTransformNodeByID(id: string): Nullable<TransformNode>;
  36508. /**
  36509. * Gets a transform node with its auto-generated unique id
  36510. * @param uniqueId efines the unique id to search for
  36511. * @return the found transform node or null if not found at all.
  36512. */
  36513. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  36514. /**
  36515. * Gets a list of transform nodes using their id
  36516. * @param id defines the id to search for
  36517. * @returns a list of transform nodes
  36518. */
  36519. getTransformNodesByID(id: string): Array<TransformNode>;
  36520. /**
  36521. * Gets a mesh with its auto-generated unique id
  36522. * @param uniqueId defines the unique id to search for
  36523. * @return the found mesh or null if not found at all.
  36524. */
  36525. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  36526. /**
  36527. * Gets a the last added mesh using a given id
  36528. * @param id defines the id to search for
  36529. * @return the found mesh or null if not found at all.
  36530. */
  36531. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  36532. /**
  36533. * Gets a the last added node (Mesh, Camera, Light) using a given id
  36534. * @param id defines the id to search for
  36535. * @return the found node or null if not found at all
  36536. */
  36537. getLastEntryByID(id: string): Nullable<Node>;
  36538. /**
  36539. * Gets a 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. getNodeByID(id: string): Nullable<Node>;
  36544. /**
  36545. * Gets a node (Mesh, Camera, Light) using a given name
  36546. * @param name defines the name to search for
  36547. * @return the found node or null if not found at all.
  36548. */
  36549. getNodeByName(name: string): Nullable<Node>;
  36550. /**
  36551. * Gets a mesh using a given name
  36552. * @param name defines the name to search for
  36553. * @return the found mesh or null if not found at all.
  36554. */
  36555. getMeshByName(name: string): Nullable<AbstractMesh>;
  36556. /**
  36557. * Gets a transform node using a given name
  36558. * @param name defines the name to search for
  36559. * @return the found transform node or null if not found at all.
  36560. */
  36561. getTransformNodeByName(name: string): Nullable<TransformNode>;
  36562. /**
  36563. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  36564. * @param id defines the id to search for
  36565. * @return the found skeleton or null if not found at all.
  36566. */
  36567. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  36568. /**
  36569. * Gets a skeleton using a given auto generated unique id
  36570. * @param uniqueId defines the unique id to search for
  36571. * @return the found skeleton or null if not found at all.
  36572. */
  36573. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  36574. /**
  36575. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  36576. * @param id defines the id to search for
  36577. * @return the found skeleton or null if not found at all.
  36578. */
  36579. getSkeletonById(id: string): Nullable<Skeleton>;
  36580. /**
  36581. * Gets a skeleton using a given name
  36582. * @param name defines the name to search for
  36583. * @return the found skeleton or null if not found at all.
  36584. */
  36585. getSkeletonByName(name: string): Nullable<Skeleton>;
  36586. /**
  36587. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  36588. * @param id defines the id to search for
  36589. * @return the found morph target manager or null if not found at all.
  36590. */
  36591. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  36592. /**
  36593. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  36594. * @param id defines the id to search for
  36595. * @return the found morph target or null if not found at all.
  36596. */
  36597. getMorphTargetById(id: string): Nullable<MorphTarget>;
  36598. /**
  36599. * Gets a boolean indicating if the given mesh is active
  36600. * @param mesh defines the mesh to look for
  36601. * @returns true if the mesh is in the active list
  36602. */
  36603. isActiveMesh(mesh: AbstractMesh): boolean;
  36604. /**
  36605. * Return a unique id as a string which can serve as an identifier for the scene
  36606. */
  36607. get uid(): string;
  36608. /**
  36609. * Add an externaly attached data from its key.
  36610. * This method call will fail and return false, if such key already exists.
  36611. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  36612. * @param key the unique key that identifies the data
  36613. * @param data the data object to associate to the key for this Engine instance
  36614. * @return true if no such key were already present and the data was added successfully, false otherwise
  36615. */
  36616. addExternalData<T>(key: string, data: T): boolean;
  36617. /**
  36618. * Get an externaly attached data from its key
  36619. * @param key the unique key that identifies the data
  36620. * @return the associated data, if present (can be null), or undefined if not present
  36621. */
  36622. getExternalData<T>(key: string): Nullable<T>;
  36623. /**
  36624. * Get an externaly attached data from its key, create it using a factory if it's not already present
  36625. * @param key the unique key that identifies the data
  36626. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  36627. * @return the associated data, can be null if the factory returned null.
  36628. */
  36629. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  36630. /**
  36631. * Remove an externaly attached data from the Engine instance
  36632. * @param key the unique key that identifies the data
  36633. * @return true if the data was successfully removed, false if it doesn't exist
  36634. */
  36635. removeExternalData(key: string): boolean;
  36636. private _evaluateSubMesh;
  36637. /**
  36638. * Clear the processed materials smart array preventing retention point in material dispose.
  36639. */
  36640. freeProcessedMaterials(): void;
  36641. private _preventFreeActiveMeshesAndRenderingGroups;
  36642. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  36643. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  36644. * when disposing several meshes in a row or a hierarchy of meshes.
  36645. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  36646. */
  36647. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  36648. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  36649. /**
  36650. * Clear the active meshes smart array preventing retention point in mesh dispose.
  36651. */
  36652. freeActiveMeshes(): void;
  36653. /**
  36654. * Clear the info related to rendering groups preventing retention points during dispose.
  36655. */
  36656. freeRenderingGroups(): void;
  36657. /** @hidden */
  36658. _isInIntermediateRendering(): boolean;
  36659. /**
  36660. * Lambda returning the list of potentially active meshes.
  36661. */
  36662. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  36663. /**
  36664. * Lambda returning the list of potentially active sub meshes.
  36665. */
  36666. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  36667. /**
  36668. * Lambda returning the list of potentially intersecting sub meshes.
  36669. */
  36670. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  36671. /**
  36672. * Lambda returning the list of potentially colliding sub meshes.
  36673. */
  36674. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  36675. private _activeMeshesFrozen;
  36676. private _skipEvaluateActiveMeshesCompletely;
  36677. /**
  36678. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  36679. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  36680. * @returns the current scene
  36681. */
  36682. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  36683. /**
  36684. * Use this function to restart evaluating active meshes on every frame
  36685. * @returns the current scene
  36686. */
  36687. unfreezeActiveMeshes(): Scene;
  36688. private _evaluateActiveMeshes;
  36689. private _activeMesh;
  36690. /**
  36691. * Update the transform matrix to update from the current active camera
  36692. * @param force defines a boolean used to force the update even if cache is up to date
  36693. */
  36694. updateTransformMatrix(force?: boolean): void;
  36695. private _bindFrameBuffer;
  36696. /** @hidden */
  36697. _allowPostProcessClearColor: boolean;
  36698. /** @hidden */
  36699. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  36700. private _processSubCameras;
  36701. private _checkIntersections;
  36702. /** @hidden */
  36703. _advancePhysicsEngineStep(step: number): void;
  36704. /**
  36705. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  36706. */
  36707. getDeterministicFrameTime: () => number;
  36708. /** @hidden */
  36709. _animate(): void;
  36710. /** Execute all animations (for a frame) */
  36711. animate(): void;
  36712. /**
  36713. * Render the scene
  36714. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  36715. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  36716. */
  36717. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  36718. /**
  36719. * Freeze all materials
  36720. * A frozen material will not be updatable but should be faster to render
  36721. */
  36722. freezeMaterials(): void;
  36723. /**
  36724. * Unfreeze all materials
  36725. * A frozen material will not be updatable but should be faster to render
  36726. */
  36727. unfreezeMaterials(): void;
  36728. /**
  36729. * Releases all held ressources
  36730. */
  36731. dispose(): void;
  36732. /**
  36733. * Gets if the scene is already disposed
  36734. */
  36735. get isDisposed(): boolean;
  36736. /**
  36737. * Call this function to reduce memory footprint of the scene.
  36738. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  36739. */
  36740. clearCachedVertexData(): void;
  36741. /**
  36742. * This function will remove the local cached buffer data from texture.
  36743. * It will save memory but will prevent the texture from being rebuilt
  36744. */
  36745. cleanCachedTextureBuffer(): void;
  36746. /**
  36747. * Get the world extend vectors with an optional filter
  36748. *
  36749. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  36750. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  36751. */
  36752. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  36753. min: Vector3;
  36754. max: Vector3;
  36755. };
  36756. /**
  36757. * Creates a ray that can be used to pick in the scene
  36758. * @param x defines the x coordinate of the origin (on-screen)
  36759. * @param y defines the y coordinate of the origin (on-screen)
  36760. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  36761. * @param camera defines the camera to use for the picking
  36762. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  36763. * @returns a Ray
  36764. */
  36765. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  36766. /**
  36767. * Creates a ray that can be used to pick in the scene
  36768. * @param x defines the x coordinate of the origin (on-screen)
  36769. * @param y defines the y coordinate of the origin (on-screen)
  36770. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  36771. * @param result defines the ray where to store the picking ray
  36772. * @param camera defines the camera to use for the picking
  36773. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  36774. * @returns the current scene
  36775. */
  36776. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  36777. /**
  36778. * Creates a ray that can be used to pick in the scene
  36779. * @param x defines the x coordinate of the origin (on-screen)
  36780. * @param y defines the y coordinate of the origin (on-screen)
  36781. * @param camera defines the camera to use for the picking
  36782. * @returns a Ray
  36783. */
  36784. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  36785. /**
  36786. * Creates a ray that can be used to pick in the scene
  36787. * @param x defines the x coordinate of the origin (on-screen)
  36788. * @param y defines the y coordinate of the origin (on-screen)
  36789. * @param result defines the ray where to store the picking ray
  36790. * @param camera defines the camera to use for the picking
  36791. * @returns the current scene
  36792. */
  36793. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  36794. /** Launch a ray to try to pick a mesh in the scene
  36795. * @param x position on screen
  36796. * @param y position on screen
  36797. * @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
  36798. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  36799. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  36800. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  36801. * @returns a PickingInfo
  36802. */
  36803. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  36804. /** Use the given ray to pick a mesh in the scene
  36805. * @param ray The ray to use to pick meshes
  36806. * @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
  36807. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  36808. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  36809. * @returns a PickingInfo
  36810. */
  36811. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  36812. /**
  36813. * Launch a ray to try to pick a mesh in the scene
  36814. * @param x X position on screen
  36815. * @param y Y position on screen
  36816. * @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
  36817. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  36818. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  36819. * @returns an array of PickingInfo
  36820. */
  36821. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  36822. /**
  36823. * Launch a ray to try to pick a mesh in the scene
  36824. * @param ray Ray to use
  36825. * @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
  36826. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  36827. * @returns an array of PickingInfo
  36828. */
  36829. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  36830. /**
  36831. * Force the value of meshUnderPointer
  36832. * @param mesh defines the mesh to use
  36833. */
  36834. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  36835. /**
  36836. * Gets the mesh under the pointer
  36837. * @returns a Mesh or null if no mesh is under the pointer
  36838. */
  36839. getPointerOverMesh(): Nullable<AbstractMesh>;
  36840. /** @hidden */
  36841. _rebuildGeometries(): void;
  36842. /** @hidden */
  36843. _rebuildTextures(): void;
  36844. private _getByTags;
  36845. /**
  36846. * Get a list of meshes by tags
  36847. * @param tagsQuery defines the tags query to use
  36848. * @param forEach defines a predicate used to filter results
  36849. * @returns an array of Mesh
  36850. */
  36851. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  36852. /**
  36853. * Get a list of cameras by tags
  36854. * @param tagsQuery defines the tags query to use
  36855. * @param forEach defines a predicate used to filter results
  36856. * @returns an array of Camera
  36857. */
  36858. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  36859. /**
  36860. * Get a list of lights by tags
  36861. * @param tagsQuery defines the tags query to use
  36862. * @param forEach defines a predicate used to filter results
  36863. * @returns an array of Light
  36864. */
  36865. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  36866. /**
  36867. * Get a list of materials by tags
  36868. * @param tagsQuery defines the tags query to use
  36869. * @param forEach defines a predicate used to filter results
  36870. * @returns an array of Material
  36871. */
  36872. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  36873. /**
  36874. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  36875. * This allowed control for front to back rendering or reversly depending of the special needs.
  36876. *
  36877. * @param renderingGroupId The rendering group id corresponding to its index
  36878. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  36879. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  36880. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  36881. */
  36882. 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;
  36883. /**
  36884. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  36885. *
  36886. * @param renderingGroupId The rendering group id corresponding to its index
  36887. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  36888. * @param depth Automatically clears depth between groups if true and autoClear is true.
  36889. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  36890. */
  36891. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  36892. /**
  36893. * Gets the current auto clear configuration for one rendering group of the rendering
  36894. * manager.
  36895. * @param index the rendering group index to get the information for
  36896. * @returns The auto clear setup for the requested rendering group
  36897. */
  36898. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  36899. private _blockMaterialDirtyMechanism;
  36900. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  36901. get blockMaterialDirtyMechanism(): boolean;
  36902. set blockMaterialDirtyMechanism(value: boolean);
  36903. /**
  36904. * Will flag all materials as dirty to trigger new shader compilation
  36905. * @param flag defines the flag used to specify which material part must be marked as dirty
  36906. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  36907. */
  36908. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  36909. /** @hidden */
  36910. _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;
  36911. /** @hidden */
  36912. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  36913. /** @hidden */
  36914. _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;
  36915. /** @hidden */
  36916. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  36917. /** @hidden */
  36918. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  36919. /** @hidden */
  36920. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  36921. }
  36922. }
  36923. declare module BABYLON {
  36924. /**
  36925. * Set of assets to keep when moving a scene into an asset container.
  36926. */
  36927. export class KeepAssets extends AbstractScene {
  36928. }
  36929. /**
  36930. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  36931. */
  36932. export class InstantiatedEntries {
  36933. /**
  36934. * List of new root nodes (eg. nodes with no parent)
  36935. */
  36936. rootNodes: TransformNode[];
  36937. /**
  36938. * List of new skeletons
  36939. */
  36940. skeletons: Skeleton[];
  36941. /**
  36942. * List of new animation groups
  36943. */
  36944. animationGroups: AnimationGroup[];
  36945. }
  36946. /**
  36947. * Container with a set of assets that can be added or removed from a scene.
  36948. */
  36949. export class AssetContainer extends AbstractScene {
  36950. /**
  36951. * The scene the AssetContainer belongs to.
  36952. */
  36953. scene: Scene;
  36954. /**
  36955. * Instantiates an AssetContainer.
  36956. * @param scene The scene the AssetContainer belongs to.
  36957. */
  36958. constructor(scene: Scene);
  36959. /**
  36960. * Instantiate or clone all meshes and add the new ones to the scene.
  36961. * Skeletons and animation groups will all be cloned
  36962. * @param nameFunction defines an optional function used to get new names for clones
  36963. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  36964. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  36965. */
  36966. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  36967. /**
  36968. * Adds all the assets from the container to the scene.
  36969. */
  36970. addAllToScene(): void;
  36971. /**
  36972. * Removes all the assets in the container from the scene
  36973. */
  36974. removeAllFromScene(): void;
  36975. /**
  36976. * Disposes all the assets in the container
  36977. */
  36978. dispose(): void;
  36979. private _moveAssets;
  36980. /**
  36981. * Removes all the assets contained in the scene and adds them to the container.
  36982. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  36983. */
  36984. moveAllFromScene(keepAssets?: KeepAssets): void;
  36985. /**
  36986. * 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.
  36987. * @returns the root mesh
  36988. */
  36989. createRootMesh(): Mesh;
  36990. /**
  36991. * Merge animations from this asset container into a scene
  36992. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  36993. * @param animatables set of animatables to retarget to a node from the scene
  36994. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  36995. */
  36996. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): void;
  36997. }
  36998. }
  36999. declare module BABYLON {
  37000. /**
  37001. * Defines how the parser contract is defined.
  37002. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  37003. */
  37004. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  37005. /**
  37006. * Defines how the individual parser contract is defined.
  37007. * These parser can parse an individual asset
  37008. */
  37009. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  37010. /**
  37011. * Base class of the scene acting as a container for the different elements composing a scene.
  37012. * This class is dynamically extended by the different components of the scene increasing
  37013. * flexibility and reducing coupling
  37014. */
  37015. export abstract class AbstractScene {
  37016. /**
  37017. * Stores the list of available parsers in the application.
  37018. */
  37019. private static _BabylonFileParsers;
  37020. /**
  37021. * Stores the list of available individual parsers in the application.
  37022. */
  37023. private static _IndividualBabylonFileParsers;
  37024. /**
  37025. * Adds a parser in the list of available ones
  37026. * @param name Defines the name of the parser
  37027. * @param parser Defines the parser to add
  37028. */
  37029. static AddParser(name: string, parser: BabylonFileParser): void;
  37030. /**
  37031. * Gets a general parser from the list of avaialble ones
  37032. * @param name Defines the name of the parser
  37033. * @returns the requested parser or null
  37034. */
  37035. static GetParser(name: string): Nullable<BabylonFileParser>;
  37036. /**
  37037. * Adds n individual parser in the list of available ones
  37038. * @param name Defines the name of the parser
  37039. * @param parser Defines the parser to add
  37040. */
  37041. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  37042. /**
  37043. * Gets an individual parser from the list of avaialble ones
  37044. * @param name Defines the name of the parser
  37045. * @returns the requested parser or null
  37046. */
  37047. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  37048. /**
  37049. * Parser json data and populate both a scene and its associated container object
  37050. * @param jsonData Defines the data to parse
  37051. * @param scene Defines the scene to parse the data for
  37052. * @param container Defines the container attached to the parsing sequence
  37053. * @param rootUrl Defines the root url of the data
  37054. */
  37055. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  37056. /**
  37057. * Gets the list of root nodes (ie. nodes with no parent)
  37058. */
  37059. rootNodes: Node[];
  37060. /** All of the cameras added to this scene
  37061. * @see http://doc.babylonjs.com/babylon101/cameras
  37062. */
  37063. cameras: Camera[];
  37064. /**
  37065. * All of the lights added to this scene
  37066. * @see http://doc.babylonjs.com/babylon101/lights
  37067. */
  37068. lights: Light[];
  37069. /**
  37070. * All of the (abstract) meshes added to this scene
  37071. */
  37072. meshes: AbstractMesh[];
  37073. /**
  37074. * The list of skeletons added to the scene
  37075. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  37076. */
  37077. skeletons: Skeleton[];
  37078. /**
  37079. * All of the particle systems added to this scene
  37080. * @see http://doc.babylonjs.com/babylon101/particles
  37081. */
  37082. particleSystems: IParticleSystem[];
  37083. /**
  37084. * Gets a list of Animations associated with the scene
  37085. */
  37086. animations: Animation[];
  37087. /**
  37088. * All of the animation groups added to this scene
  37089. * @see http://doc.babylonjs.com/how_to/group
  37090. */
  37091. animationGroups: AnimationGroup[];
  37092. /**
  37093. * All of the multi-materials added to this scene
  37094. * @see http://doc.babylonjs.com/how_to/multi_materials
  37095. */
  37096. multiMaterials: MultiMaterial[];
  37097. /**
  37098. * All of the materials added to this scene
  37099. * In the context of a Scene, it is not supposed to be modified manually.
  37100. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  37101. * Note also that the order of the Material within the array is not significant and might change.
  37102. * @see http://doc.babylonjs.com/babylon101/materials
  37103. */
  37104. materials: Material[];
  37105. /**
  37106. * The list of morph target managers added to the scene
  37107. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  37108. */
  37109. morphTargetManagers: MorphTargetManager[];
  37110. /**
  37111. * The list of geometries used in the scene.
  37112. */
  37113. geometries: Geometry[];
  37114. /**
  37115. * All of the tranform nodes added to this scene
  37116. * In the context of a Scene, it is not supposed to be modified manually.
  37117. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  37118. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  37119. * @see http://doc.babylonjs.com/how_to/transformnode
  37120. */
  37121. transformNodes: TransformNode[];
  37122. /**
  37123. * ActionManagers available on the scene.
  37124. */
  37125. actionManagers: AbstractActionManager[];
  37126. /**
  37127. * Textures to keep.
  37128. */
  37129. textures: BaseTexture[];
  37130. /**
  37131. * Environment texture for the scene
  37132. */
  37133. environmentTexture: Nullable<BaseTexture>;
  37134. /**
  37135. * @returns all meshes, lights, cameras, transformNodes and bones
  37136. */
  37137. getNodes(): Array<Node>;
  37138. }
  37139. }
  37140. declare module BABYLON {
  37141. /**
  37142. * Interface used to define options for Sound class
  37143. */
  37144. export interface ISoundOptions {
  37145. /**
  37146. * Does the sound autoplay once loaded.
  37147. */
  37148. autoplay?: boolean;
  37149. /**
  37150. * Does the sound loop after it finishes playing once.
  37151. */
  37152. loop?: boolean;
  37153. /**
  37154. * Sound's volume
  37155. */
  37156. volume?: number;
  37157. /**
  37158. * Is it a spatial sound?
  37159. */
  37160. spatialSound?: boolean;
  37161. /**
  37162. * Maximum distance to hear that sound
  37163. */
  37164. maxDistance?: number;
  37165. /**
  37166. * Uses user defined attenuation function
  37167. */
  37168. useCustomAttenuation?: boolean;
  37169. /**
  37170. * Define the roll off factor of spatial sounds.
  37171. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37172. */
  37173. rolloffFactor?: number;
  37174. /**
  37175. * Define the reference distance the sound should be heard perfectly.
  37176. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37177. */
  37178. refDistance?: number;
  37179. /**
  37180. * Define the distance attenuation model the sound will follow.
  37181. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37182. */
  37183. distanceModel?: string;
  37184. /**
  37185. * Defines the playback speed (1 by default)
  37186. */
  37187. playbackRate?: number;
  37188. /**
  37189. * Defines if the sound is from a streaming source
  37190. */
  37191. streaming?: boolean;
  37192. /**
  37193. * Defines an optional length (in seconds) inside the sound file
  37194. */
  37195. length?: number;
  37196. /**
  37197. * Defines an optional offset (in seconds) inside the sound file
  37198. */
  37199. offset?: number;
  37200. /**
  37201. * If true, URLs will not be required to state the audio file codec to use.
  37202. */
  37203. skipCodecCheck?: boolean;
  37204. }
  37205. /**
  37206. * Defines a sound that can be played in the application.
  37207. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  37208. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37209. */
  37210. export class Sound {
  37211. /**
  37212. * The name of the sound in the scene.
  37213. */
  37214. name: string;
  37215. /**
  37216. * Does the sound autoplay once loaded.
  37217. */
  37218. autoplay: boolean;
  37219. /**
  37220. * Does the sound loop after it finishes playing once.
  37221. */
  37222. loop: boolean;
  37223. /**
  37224. * Does the sound use a custom attenuation curve to simulate the falloff
  37225. * happening when the source gets further away from the camera.
  37226. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  37227. */
  37228. useCustomAttenuation: boolean;
  37229. /**
  37230. * The sound track id this sound belongs to.
  37231. */
  37232. soundTrackId: number;
  37233. /**
  37234. * Is this sound currently played.
  37235. */
  37236. isPlaying: boolean;
  37237. /**
  37238. * Is this sound currently paused.
  37239. */
  37240. isPaused: boolean;
  37241. /**
  37242. * Does this sound enables spatial sound.
  37243. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37244. */
  37245. spatialSound: boolean;
  37246. /**
  37247. * Define the reference distance the sound should be heard perfectly.
  37248. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37249. */
  37250. refDistance: number;
  37251. /**
  37252. * Define the roll off factor of spatial sounds.
  37253. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37254. */
  37255. rolloffFactor: number;
  37256. /**
  37257. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  37258. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37259. */
  37260. maxDistance: number;
  37261. /**
  37262. * Define the distance attenuation model the sound will follow.
  37263. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37264. */
  37265. distanceModel: string;
  37266. /**
  37267. * @hidden
  37268. * Back Compat
  37269. **/
  37270. onended: () => any;
  37271. /**
  37272. * Observable event when the current playing sound finishes.
  37273. */
  37274. onEndedObservable: Observable<Sound>;
  37275. private _panningModel;
  37276. private _playbackRate;
  37277. private _streaming;
  37278. private _startTime;
  37279. private _startOffset;
  37280. private _position;
  37281. /** @hidden */
  37282. _positionInEmitterSpace: boolean;
  37283. private _localDirection;
  37284. private _volume;
  37285. private _isReadyToPlay;
  37286. private _isDirectional;
  37287. private _readyToPlayCallback;
  37288. private _audioBuffer;
  37289. private _soundSource;
  37290. private _streamingSource;
  37291. private _soundPanner;
  37292. private _soundGain;
  37293. private _inputAudioNode;
  37294. private _outputAudioNode;
  37295. private _coneInnerAngle;
  37296. private _coneOuterAngle;
  37297. private _coneOuterGain;
  37298. private _scene;
  37299. private _connectedTransformNode;
  37300. private _customAttenuationFunction;
  37301. private _registerFunc;
  37302. private _isOutputConnected;
  37303. private _htmlAudioElement;
  37304. private _urlType;
  37305. private _length?;
  37306. private _offset?;
  37307. /** @hidden */
  37308. static _SceneComponentInitialization: (scene: Scene) => void;
  37309. /**
  37310. * Create a sound and attach it to a scene
  37311. * @param name Name of your sound
  37312. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  37313. * @param scene defines the scene the sound belongs to
  37314. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  37315. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  37316. */
  37317. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  37318. /**
  37319. * Release the sound and its associated resources
  37320. */
  37321. dispose(): void;
  37322. /**
  37323. * Gets if the sounds is ready to be played or not.
  37324. * @returns true if ready, otherwise false
  37325. */
  37326. isReady(): boolean;
  37327. private _soundLoaded;
  37328. /**
  37329. * Sets the data of the sound from an audiobuffer
  37330. * @param audioBuffer The audioBuffer containing the data
  37331. */
  37332. setAudioBuffer(audioBuffer: AudioBuffer): void;
  37333. /**
  37334. * Updates the current sounds options such as maxdistance, loop...
  37335. * @param options A JSON object containing values named as the object properties
  37336. */
  37337. updateOptions(options: ISoundOptions): void;
  37338. private _createSpatialParameters;
  37339. private _updateSpatialParameters;
  37340. /**
  37341. * Switch the panning model to HRTF:
  37342. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  37343. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37344. */
  37345. switchPanningModelToHRTF(): void;
  37346. /**
  37347. * Switch the panning model to Equal Power:
  37348. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  37349. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37350. */
  37351. switchPanningModelToEqualPower(): void;
  37352. private _switchPanningModel;
  37353. /**
  37354. * Connect this sound to a sound track audio node like gain...
  37355. * @param soundTrackAudioNode the sound track audio node to connect to
  37356. */
  37357. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  37358. /**
  37359. * Transform this sound into a directional source
  37360. * @param coneInnerAngle Size of the inner cone in degree
  37361. * @param coneOuterAngle Size of the outer cone in degree
  37362. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  37363. */
  37364. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  37365. /**
  37366. * Gets or sets the inner angle for the directional cone.
  37367. */
  37368. get directionalConeInnerAngle(): number;
  37369. /**
  37370. * Gets or sets the inner angle for the directional cone.
  37371. */
  37372. set directionalConeInnerAngle(value: number);
  37373. /**
  37374. * Gets or sets the outer angle for the directional cone.
  37375. */
  37376. get directionalConeOuterAngle(): number;
  37377. /**
  37378. * Gets or sets the outer angle for the directional cone.
  37379. */
  37380. set directionalConeOuterAngle(value: number);
  37381. /**
  37382. * Sets the position of the emitter if spatial sound is enabled
  37383. * @param newPosition Defines the new posisiton
  37384. */
  37385. setPosition(newPosition: Vector3): void;
  37386. /**
  37387. * Sets the local direction of the emitter if spatial sound is enabled
  37388. * @param newLocalDirection Defines the new local direction
  37389. */
  37390. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  37391. private _updateDirection;
  37392. /** @hidden */
  37393. updateDistanceFromListener(): void;
  37394. /**
  37395. * Sets a new custom attenuation function for the sound.
  37396. * @param callback Defines the function used for the attenuation
  37397. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  37398. */
  37399. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  37400. /**
  37401. * Play the sound
  37402. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  37403. * @param offset (optional) Start the sound at a specific time in seconds
  37404. * @param length (optional) Sound duration (in seconds)
  37405. */
  37406. play(time?: number, offset?: number, length?: number): void;
  37407. private _onended;
  37408. /**
  37409. * Stop the sound
  37410. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  37411. */
  37412. stop(time?: number): void;
  37413. /**
  37414. * Put the sound in pause
  37415. */
  37416. pause(): void;
  37417. /**
  37418. * Sets a dedicated volume for this sounds
  37419. * @param newVolume Define the new volume of the sound
  37420. * @param time Define time for gradual change to new volume
  37421. */
  37422. setVolume(newVolume: number, time?: number): void;
  37423. /**
  37424. * Set the sound play back rate
  37425. * @param newPlaybackRate Define the playback rate the sound should be played at
  37426. */
  37427. setPlaybackRate(newPlaybackRate: number): void;
  37428. /**
  37429. * Gets the volume of the sound.
  37430. * @returns the volume of the sound
  37431. */
  37432. getVolume(): number;
  37433. /**
  37434. * Attach the sound to a dedicated mesh
  37435. * @param transformNode The transform node to connect the sound with
  37436. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  37437. */
  37438. attachToMesh(transformNode: TransformNode): void;
  37439. /**
  37440. * Detach the sound from the previously attached mesh
  37441. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  37442. */
  37443. detachFromMesh(): void;
  37444. private _onRegisterAfterWorldMatrixUpdate;
  37445. /**
  37446. * Clone the current sound in the scene.
  37447. * @returns the new sound clone
  37448. */
  37449. clone(): Nullable<Sound>;
  37450. /**
  37451. * Gets the current underlying audio buffer containing the data
  37452. * @returns the audio buffer
  37453. */
  37454. getAudioBuffer(): Nullable<AudioBuffer>;
  37455. /**
  37456. * Serializes the Sound in a JSON representation
  37457. * @returns the JSON representation of the sound
  37458. */
  37459. serialize(): any;
  37460. /**
  37461. * Parse a JSON representation of a sound to innstantiate in a given scene
  37462. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  37463. * @param scene Define the scene the new parsed sound should be created in
  37464. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  37465. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  37466. * @returns the newly parsed sound
  37467. */
  37468. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  37469. }
  37470. }
  37471. declare module BABYLON {
  37472. /**
  37473. * This defines an action helpful to play a defined sound on a triggered action.
  37474. */
  37475. export class PlaySoundAction extends Action {
  37476. private _sound;
  37477. /**
  37478. * Instantiate the action
  37479. * @param triggerOptions defines the trigger options
  37480. * @param sound defines the sound to play
  37481. * @param condition defines the trigger related conditions
  37482. */
  37483. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  37484. /** @hidden */
  37485. _prepare(): void;
  37486. /**
  37487. * Execute the action and play the sound.
  37488. */
  37489. execute(): void;
  37490. /**
  37491. * Serializes the actions and its related information.
  37492. * @param parent defines the object to serialize in
  37493. * @returns the serialized object
  37494. */
  37495. serialize(parent: any): any;
  37496. }
  37497. /**
  37498. * This defines an action helpful to stop a defined sound on a triggered action.
  37499. */
  37500. export class StopSoundAction extends Action {
  37501. private _sound;
  37502. /**
  37503. * Instantiate the action
  37504. * @param triggerOptions defines the trigger options
  37505. * @param sound defines the sound to stop
  37506. * @param condition defines the trigger related conditions
  37507. */
  37508. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  37509. /** @hidden */
  37510. _prepare(): void;
  37511. /**
  37512. * Execute the action and stop the sound.
  37513. */
  37514. execute(): void;
  37515. /**
  37516. * Serializes the actions and its related information.
  37517. * @param parent defines the object to serialize in
  37518. * @returns the serialized object
  37519. */
  37520. serialize(parent: any): any;
  37521. }
  37522. }
  37523. declare module BABYLON {
  37524. /**
  37525. * This defines an action responsible to change the value of a property
  37526. * by interpolating between its current value and the newly set one once triggered.
  37527. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  37528. */
  37529. export class InterpolateValueAction extends Action {
  37530. /**
  37531. * Defines the path of the property where the value should be interpolated
  37532. */
  37533. propertyPath: string;
  37534. /**
  37535. * Defines the target value at the end of the interpolation.
  37536. */
  37537. value: any;
  37538. /**
  37539. * Defines the time it will take for the property to interpolate to the value.
  37540. */
  37541. duration: number;
  37542. /**
  37543. * Defines if the other scene animations should be stopped when the action has been triggered
  37544. */
  37545. stopOtherAnimations?: boolean;
  37546. /**
  37547. * Defines a callback raised once the interpolation animation has been done.
  37548. */
  37549. onInterpolationDone?: () => void;
  37550. /**
  37551. * Observable triggered once the interpolation animation has been done.
  37552. */
  37553. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  37554. private _target;
  37555. private _effectiveTarget;
  37556. private _property;
  37557. /**
  37558. * Instantiate the action
  37559. * @param triggerOptions defines the trigger options
  37560. * @param target defines the object containing the value to interpolate
  37561. * @param propertyPath defines the path to the property in the target object
  37562. * @param value defines the target value at the end of the interpolation
  37563. * @param duration deines the time it will take for the property to interpolate to the value.
  37564. * @param condition defines the trigger related conditions
  37565. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  37566. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  37567. */
  37568. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  37569. /** @hidden */
  37570. _prepare(): void;
  37571. /**
  37572. * Execute the action starts the value interpolation.
  37573. */
  37574. execute(): void;
  37575. /**
  37576. * Serializes the actions and its related information.
  37577. * @param parent defines the object to serialize in
  37578. * @returns the serialized object
  37579. */
  37580. serialize(parent: any): any;
  37581. }
  37582. }
  37583. declare module BABYLON {
  37584. /**
  37585. * Options allowed during the creation of a sound track.
  37586. */
  37587. export interface ISoundTrackOptions {
  37588. /**
  37589. * The volume the sound track should take during creation
  37590. */
  37591. volume?: number;
  37592. /**
  37593. * Define if the sound track is the main sound track of the scene
  37594. */
  37595. mainTrack?: boolean;
  37596. }
  37597. /**
  37598. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  37599. * It will be also used in a future release to apply effects on a specific track.
  37600. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  37601. */
  37602. export class SoundTrack {
  37603. /**
  37604. * The unique identifier of the sound track in the scene.
  37605. */
  37606. id: number;
  37607. /**
  37608. * The list of sounds included in the sound track.
  37609. */
  37610. soundCollection: Array<Sound>;
  37611. private _outputAudioNode;
  37612. private _scene;
  37613. private _connectedAnalyser;
  37614. private _options;
  37615. private _isInitialized;
  37616. /**
  37617. * Creates a new sound track.
  37618. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  37619. * @param scene Define the scene the sound track belongs to
  37620. * @param options
  37621. */
  37622. constructor(scene: Scene, options?: ISoundTrackOptions);
  37623. private _initializeSoundTrackAudioGraph;
  37624. /**
  37625. * Release the sound track and its associated resources
  37626. */
  37627. dispose(): void;
  37628. /**
  37629. * Adds a sound to this sound track
  37630. * @param sound define the cound to add
  37631. * @ignoreNaming
  37632. */
  37633. AddSound(sound: Sound): void;
  37634. /**
  37635. * Removes a sound to this sound track
  37636. * @param sound define the cound to remove
  37637. * @ignoreNaming
  37638. */
  37639. RemoveSound(sound: Sound): void;
  37640. /**
  37641. * Set a global volume for the full sound track.
  37642. * @param newVolume Define the new volume of the sound track
  37643. */
  37644. setVolume(newVolume: number): void;
  37645. /**
  37646. * Switch the panning model to HRTF:
  37647. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  37648. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37649. */
  37650. switchPanningModelToHRTF(): void;
  37651. /**
  37652. * Switch the panning model to Equal Power:
  37653. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  37654. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37655. */
  37656. switchPanningModelToEqualPower(): void;
  37657. /**
  37658. * Connect the sound track to an audio analyser allowing some amazing
  37659. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  37660. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  37661. * @param analyser The analyser to connect to the engine
  37662. */
  37663. connectToAnalyser(analyser: Analyser): void;
  37664. }
  37665. }
  37666. declare module BABYLON {
  37667. interface AbstractScene {
  37668. /**
  37669. * The list of sounds used in the scene.
  37670. */
  37671. sounds: Nullable<Array<Sound>>;
  37672. }
  37673. interface Scene {
  37674. /**
  37675. * @hidden
  37676. * Backing field
  37677. */
  37678. _mainSoundTrack: SoundTrack;
  37679. /**
  37680. * The main sound track played by the scene.
  37681. * It cotains your primary collection of sounds.
  37682. */
  37683. mainSoundTrack: SoundTrack;
  37684. /**
  37685. * The list of sound tracks added to the scene
  37686. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37687. */
  37688. soundTracks: Nullable<Array<SoundTrack>>;
  37689. /**
  37690. * Gets a sound using a given name
  37691. * @param name defines the name to search for
  37692. * @return the found sound or null if not found at all.
  37693. */
  37694. getSoundByName(name: string): Nullable<Sound>;
  37695. /**
  37696. * Gets or sets if audio support is enabled
  37697. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37698. */
  37699. audioEnabled: boolean;
  37700. /**
  37701. * Gets or sets if audio will be output to headphones
  37702. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37703. */
  37704. headphone: boolean;
  37705. /**
  37706. * Gets or sets custom audio listener position provider
  37707. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37708. */
  37709. audioListenerPositionProvider: Nullable<() => Vector3>;
  37710. /**
  37711. * Gets or sets a refresh rate when using 3D audio positioning
  37712. */
  37713. audioPositioningRefreshRate: number;
  37714. }
  37715. /**
  37716. * Defines the sound scene component responsible to manage any sounds
  37717. * in a given scene.
  37718. */
  37719. export class AudioSceneComponent implements ISceneSerializableComponent {
  37720. /**
  37721. * The component name helpfull to identify the component in the list of scene components.
  37722. */
  37723. readonly name: string;
  37724. /**
  37725. * The scene the component belongs to.
  37726. */
  37727. scene: Scene;
  37728. private _audioEnabled;
  37729. /**
  37730. * Gets whether audio is enabled or not.
  37731. * Please use related enable/disable method to switch state.
  37732. */
  37733. get audioEnabled(): boolean;
  37734. private _headphone;
  37735. /**
  37736. * Gets whether audio is outputing to headphone or not.
  37737. * Please use the according Switch methods to change output.
  37738. */
  37739. get headphone(): boolean;
  37740. /**
  37741. * Gets or sets a refresh rate when using 3D audio positioning
  37742. */
  37743. audioPositioningRefreshRate: number;
  37744. private _audioListenerPositionProvider;
  37745. /**
  37746. * Gets the current audio listener position provider
  37747. */
  37748. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  37749. /**
  37750. * Sets a custom listener position for all sounds in the scene
  37751. * By default, this is the position of the first active camera
  37752. */
  37753. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  37754. /**
  37755. * Creates a new instance of the component for the given scene
  37756. * @param scene Defines the scene to register the component in
  37757. */
  37758. constructor(scene: Scene);
  37759. /**
  37760. * Registers the component in a given scene
  37761. */
  37762. register(): void;
  37763. /**
  37764. * Rebuilds the elements related to this component in case of
  37765. * context lost for instance.
  37766. */
  37767. rebuild(): void;
  37768. /**
  37769. * Serializes the component data to the specified json object
  37770. * @param serializationObject The object to serialize to
  37771. */
  37772. serialize(serializationObject: any): void;
  37773. /**
  37774. * Adds all the elements from the container to the scene
  37775. * @param container the container holding the elements
  37776. */
  37777. addFromContainer(container: AbstractScene): void;
  37778. /**
  37779. * Removes all the elements in the container from the scene
  37780. * @param container contains the elements to remove
  37781. * @param dispose if the removed element should be disposed (default: false)
  37782. */
  37783. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  37784. /**
  37785. * Disposes the component and the associated ressources.
  37786. */
  37787. dispose(): void;
  37788. /**
  37789. * Disables audio in the associated scene.
  37790. */
  37791. disableAudio(): void;
  37792. /**
  37793. * Enables audio in the associated scene.
  37794. */
  37795. enableAudio(): void;
  37796. /**
  37797. * Switch audio to headphone output.
  37798. */
  37799. switchAudioModeForHeadphones(): void;
  37800. /**
  37801. * Switch audio to normal speakers.
  37802. */
  37803. switchAudioModeForNormalSpeakers(): void;
  37804. private _cachedCameraDirection;
  37805. private _cachedCameraPosition;
  37806. private _lastCheck;
  37807. private _afterRender;
  37808. }
  37809. }
  37810. declare module BABYLON {
  37811. /**
  37812. * Wraps one or more Sound objects and selects one with random weight for playback.
  37813. */
  37814. export class WeightedSound {
  37815. /** When true a Sound will be selected and played when the current playing Sound completes. */
  37816. loop: boolean;
  37817. private _coneInnerAngle;
  37818. private _coneOuterAngle;
  37819. private _volume;
  37820. /** A Sound is currently playing. */
  37821. isPlaying: boolean;
  37822. /** A Sound is currently paused. */
  37823. isPaused: boolean;
  37824. private _sounds;
  37825. private _weights;
  37826. private _currentIndex?;
  37827. /**
  37828. * Creates a new WeightedSound from the list of sounds given.
  37829. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  37830. * @param sounds Array of Sounds that will be selected from.
  37831. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  37832. */
  37833. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  37834. /**
  37835. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  37836. */
  37837. get directionalConeInnerAngle(): number;
  37838. /**
  37839. * The size of cone in degress for a directional sound in which there will be no attenuation.
  37840. */
  37841. set directionalConeInnerAngle(value: number);
  37842. /**
  37843. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  37844. * Listener angles between innerAngle and outerAngle will falloff linearly.
  37845. */
  37846. get directionalConeOuterAngle(): number;
  37847. /**
  37848. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  37849. * Listener angles between innerAngle and outerAngle will falloff linearly.
  37850. */
  37851. set directionalConeOuterAngle(value: number);
  37852. /**
  37853. * Playback volume.
  37854. */
  37855. get volume(): number;
  37856. /**
  37857. * Playback volume.
  37858. */
  37859. set volume(value: number);
  37860. private _onended;
  37861. /**
  37862. * Suspend playback
  37863. */
  37864. pause(): void;
  37865. /**
  37866. * Stop playback
  37867. */
  37868. stop(): void;
  37869. /**
  37870. * Start playback.
  37871. * @param startOffset Position the clip head at a specific time in seconds.
  37872. */
  37873. play(startOffset?: number): void;
  37874. }
  37875. }
  37876. declare module BABYLON {
  37877. /**
  37878. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  37879. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  37880. */
  37881. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  37882. /**
  37883. * Gets the name of the behavior.
  37884. */
  37885. get name(): string;
  37886. /**
  37887. * The easing function used by animations
  37888. */
  37889. static EasingFunction: BackEase;
  37890. /**
  37891. * The easing mode used by animations
  37892. */
  37893. static EasingMode: number;
  37894. /**
  37895. * The duration of the animation, in milliseconds
  37896. */
  37897. transitionDuration: number;
  37898. /**
  37899. * Length of the distance animated by the transition when lower radius is reached
  37900. */
  37901. lowerRadiusTransitionRange: number;
  37902. /**
  37903. * Length of the distance animated by the transition when upper radius is reached
  37904. */
  37905. upperRadiusTransitionRange: number;
  37906. private _autoTransitionRange;
  37907. /**
  37908. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  37909. */
  37910. get autoTransitionRange(): boolean;
  37911. /**
  37912. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  37913. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  37914. */
  37915. set autoTransitionRange(value: boolean);
  37916. private _attachedCamera;
  37917. private _onAfterCheckInputsObserver;
  37918. private _onMeshTargetChangedObserver;
  37919. /**
  37920. * Initializes the behavior.
  37921. */
  37922. init(): void;
  37923. /**
  37924. * Attaches the behavior to its arc rotate camera.
  37925. * @param camera Defines the camera to attach the behavior to
  37926. */
  37927. attach(camera: ArcRotateCamera): void;
  37928. /**
  37929. * Detaches the behavior from its current arc rotate camera.
  37930. */
  37931. detach(): void;
  37932. private _radiusIsAnimating;
  37933. private _radiusBounceTransition;
  37934. private _animatables;
  37935. private _cachedWheelPrecision;
  37936. /**
  37937. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  37938. * @param radiusLimit The limit to check against.
  37939. * @return Bool to indicate if at limit.
  37940. */
  37941. private _isRadiusAtLimit;
  37942. /**
  37943. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  37944. * @param radiusDelta The delta by which to animate to. Can be negative.
  37945. */
  37946. private _applyBoundRadiusAnimation;
  37947. /**
  37948. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  37949. */
  37950. protected _clearAnimationLocks(): void;
  37951. /**
  37952. * Stops and removes all animations that have been applied to the camera
  37953. */
  37954. stopAllAnimations(): void;
  37955. }
  37956. }
  37957. declare module BABYLON {
  37958. /**
  37959. * 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.
  37960. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  37961. */
  37962. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  37963. /**
  37964. * Gets the name of the behavior.
  37965. */
  37966. get name(): string;
  37967. private _mode;
  37968. private _radiusScale;
  37969. private _positionScale;
  37970. private _defaultElevation;
  37971. private _elevationReturnTime;
  37972. private _elevationReturnWaitTime;
  37973. private _zoomStopsAnimation;
  37974. private _framingTime;
  37975. /**
  37976. * The easing function used by animations
  37977. */
  37978. static EasingFunction: ExponentialEase;
  37979. /**
  37980. * The easing mode used by animations
  37981. */
  37982. static EasingMode: number;
  37983. /**
  37984. * Sets the current mode used by the behavior
  37985. */
  37986. set mode(mode: number);
  37987. /**
  37988. * Gets current mode used by the behavior.
  37989. */
  37990. get mode(): number;
  37991. /**
  37992. * Sets the scale applied to the radius (1 by default)
  37993. */
  37994. set radiusScale(radius: number);
  37995. /**
  37996. * Gets the scale applied to the radius
  37997. */
  37998. get radiusScale(): number;
  37999. /**
  38000. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  38001. */
  38002. set positionScale(scale: number);
  38003. /**
  38004. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  38005. */
  38006. get positionScale(): number;
  38007. /**
  38008. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  38009. * behaviour is triggered, in radians.
  38010. */
  38011. set defaultElevation(elevation: number);
  38012. /**
  38013. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  38014. * behaviour is triggered, in radians.
  38015. */
  38016. get defaultElevation(): number;
  38017. /**
  38018. * Sets the time (in milliseconds) taken to return to the default beta position.
  38019. * Negative value indicates camera should not return to default.
  38020. */
  38021. set elevationReturnTime(speed: number);
  38022. /**
  38023. * Gets the time (in milliseconds) taken to return to the default beta position.
  38024. * Negative value indicates camera should not return to default.
  38025. */
  38026. get elevationReturnTime(): number;
  38027. /**
  38028. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  38029. */
  38030. set elevationReturnWaitTime(time: number);
  38031. /**
  38032. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  38033. */
  38034. get elevationReturnWaitTime(): number;
  38035. /**
  38036. * Sets the flag that indicates if user zooming should stop animation.
  38037. */
  38038. set zoomStopsAnimation(flag: boolean);
  38039. /**
  38040. * Gets the flag that indicates if user zooming should stop animation.
  38041. */
  38042. get zoomStopsAnimation(): boolean;
  38043. /**
  38044. * Sets the transition time when framing the mesh, in milliseconds
  38045. */
  38046. set framingTime(time: number);
  38047. /**
  38048. * Gets the transition time when framing the mesh, in milliseconds
  38049. */
  38050. get framingTime(): number;
  38051. /**
  38052. * Define if the behavior should automatically change the configured
  38053. * camera limits and sensibilities.
  38054. */
  38055. autoCorrectCameraLimitsAndSensibility: boolean;
  38056. private _onPrePointerObservableObserver;
  38057. private _onAfterCheckInputsObserver;
  38058. private _onMeshTargetChangedObserver;
  38059. private _attachedCamera;
  38060. private _isPointerDown;
  38061. private _lastInteractionTime;
  38062. /**
  38063. * Initializes the behavior.
  38064. */
  38065. init(): void;
  38066. /**
  38067. * Attaches the behavior to its arc rotate camera.
  38068. * @param camera Defines the camera to attach the behavior to
  38069. */
  38070. attach(camera: ArcRotateCamera): void;
  38071. /**
  38072. * Detaches the behavior from its current arc rotate camera.
  38073. */
  38074. detach(): void;
  38075. private _animatables;
  38076. private _betaIsAnimating;
  38077. private _betaTransition;
  38078. private _radiusTransition;
  38079. private _vectorTransition;
  38080. /**
  38081. * Targets the given mesh and updates zoom level accordingly.
  38082. * @param mesh The mesh to target.
  38083. * @param radius Optional. If a cached radius position already exists, overrides default.
  38084. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  38085. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38086. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38087. */
  38088. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38089. /**
  38090. * Targets the given mesh with its children and updates zoom level accordingly.
  38091. * @param mesh The mesh to target.
  38092. * @param radius Optional. If a cached radius position already exists, overrides default.
  38093. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  38094. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38095. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38096. */
  38097. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38098. /**
  38099. * Targets the given meshes with their children and updates zoom level accordingly.
  38100. * @param meshes The mesh to target.
  38101. * @param radius Optional. If a cached radius position already exists, overrides default.
  38102. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  38103. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38104. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38105. */
  38106. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38107. /**
  38108. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  38109. * @param minimumWorld Determines the smaller position of the bounding box extend
  38110. * @param maximumWorld Determines the bigger position of the bounding box extend
  38111. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38112. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38113. */
  38114. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38115. /**
  38116. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  38117. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  38118. * frustum width.
  38119. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  38120. * to fully enclose the mesh in the viewing frustum.
  38121. */
  38122. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  38123. /**
  38124. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  38125. * is automatically returned to its default position (expected to be above ground plane).
  38126. */
  38127. private _maintainCameraAboveGround;
  38128. /**
  38129. * Returns the frustum slope based on the canvas ratio and camera FOV
  38130. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  38131. */
  38132. private _getFrustumSlope;
  38133. /**
  38134. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  38135. */
  38136. private _clearAnimationLocks;
  38137. /**
  38138. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  38139. */
  38140. private _applyUserInteraction;
  38141. /**
  38142. * Stops and removes all animations that have been applied to the camera
  38143. */
  38144. stopAllAnimations(): void;
  38145. /**
  38146. * Gets a value indicating if the user is moving the camera
  38147. */
  38148. get isUserIsMoving(): boolean;
  38149. /**
  38150. * The camera can move all the way towards the mesh.
  38151. */
  38152. static IgnoreBoundsSizeMode: number;
  38153. /**
  38154. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  38155. */
  38156. static FitFrustumSidesMode: number;
  38157. }
  38158. }
  38159. declare module BABYLON {
  38160. /**
  38161. * Base class for Camera Pointer Inputs.
  38162. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  38163. * for example usage.
  38164. */
  38165. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  38166. /**
  38167. * Defines the camera the input is attached to.
  38168. */
  38169. abstract camera: Camera;
  38170. /**
  38171. * Whether keyboard modifier keys are pressed at time of last mouse event.
  38172. */
  38173. protected _altKey: boolean;
  38174. protected _ctrlKey: boolean;
  38175. protected _metaKey: boolean;
  38176. protected _shiftKey: boolean;
  38177. /**
  38178. * Which mouse buttons were pressed at time of last mouse event.
  38179. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  38180. */
  38181. protected _buttonsPressed: number;
  38182. /**
  38183. * Defines the buttons associated with the input to handle camera move.
  38184. */
  38185. buttons: number[];
  38186. /**
  38187. * Attach the input controls to a specific dom element to get the input from.
  38188. * @param element Defines the element the controls should be listened from
  38189. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38190. */
  38191. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38192. /**
  38193. * Detach the current controls from the specified dom element.
  38194. * @param element Defines the element to stop listening the inputs from
  38195. */
  38196. detachControl(element: Nullable<HTMLElement>): void;
  38197. /**
  38198. * Gets the class name of the current input.
  38199. * @returns the class name
  38200. */
  38201. getClassName(): string;
  38202. /**
  38203. * Get the friendly name associated with the input class.
  38204. * @returns the input friendly name
  38205. */
  38206. getSimpleName(): string;
  38207. /**
  38208. * Called on pointer POINTERDOUBLETAP event.
  38209. * Override this method to provide functionality on POINTERDOUBLETAP event.
  38210. */
  38211. protected onDoubleTap(type: string): void;
  38212. /**
  38213. * Called on pointer POINTERMOVE event if only a single touch is active.
  38214. * Override this method to provide functionality.
  38215. */
  38216. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  38217. /**
  38218. * Called on pointer POINTERMOVE event if multiple touches are active.
  38219. * Override this method to provide functionality.
  38220. */
  38221. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  38222. /**
  38223. * Called on JS contextmenu event.
  38224. * Override this method to provide functionality.
  38225. */
  38226. protected onContextMenu(evt: PointerEvent): void;
  38227. /**
  38228. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  38229. * press.
  38230. * Override this method to provide functionality.
  38231. */
  38232. protected onButtonDown(evt: PointerEvent): void;
  38233. /**
  38234. * Called each time a new POINTERUP event occurs. Ie, for each button
  38235. * release.
  38236. * Override this method to provide functionality.
  38237. */
  38238. protected onButtonUp(evt: PointerEvent): void;
  38239. /**
  38240. * Called when window becomes inactive.
  38241. * Override this method to provide functionality.
  38242. */
  38243. protected onLostFocus(): void;
  38244. private _pointerInput;
  38245. private _observer;
  38246. private _onLostFocus;
  38247. private pointA;
  38248. private pointB;
  38249. }
  38250. }
  38251. declare module BABYLON {
  38252. /**
  38253. * Manage the pointers inputs to control an arc rotate camera.
  38254. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38255. */
  38256. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  38257. /**
  38258. * Defines the camera the input is attached to.
  38259. */
  38260. camera: ArcRotateCamera;
  38261. /**
  38262. * Gets the class name of the current input.
  38263. * @returns the class name
  38264. */
  38265. getClassName(): string;
  38266. /**
  38267. * Defines the buttons associated with the input to handle camera move.
  38268. */
  38269. buttons: number[];
  38270. /**
  38271. * Defines the pointer angular sensibility along the X axis or how fast is
  38272. * the camera rotating.
  38273. */
  38274. angularSensibilityX: number;
  38275. /**
  38276. * Defines the pointer angular sensibility along the Y axis or how fast is
  38277. * the camera rotating.
  38278. */
  38279. angularSensibilityY: number;
  38280. /**
  38281. * Defines the pointer pinch precision or how fast is the camera zooming.
  38282. */
  38283. pinchPrecision: number;
  38284. /**
  38285. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  38286. * from 0.
  38287. * It defines the percentage of current camera.radius to use as delta when
  38288. * pinch zoom is used.
  38289. */
  38290. pinchDeltaPercentage: number;
  38291. /**
  38292. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  38293. * that any object in the plane at the camera's target point will scale
  38294. * perfectly with finger motion.
  38295. * Overrides pinchDeltaPercentage and pinchPrecision.
  38296. */
  38297. useNaturalPinchZoom: boolean;
  38298. /**
  38299. * Defines the pointer panning sensibility or how fast is the camera moving.
  38300. */
  38301. panningSensibility: number;
  38302. /**
  38303. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  38304. */
  38305. multiTouchPanning: boolean;
  38306. /**
  38307. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  38308. * zoom (pinch) through multitouch.
  38309. */
  38310. multiTouchPanAndZoom: boolean;
  38311. /**
  38312. * Revers pinch action direction.
  38313. */
  38314. pinchInwards: boolean;
  38315. private _isPanClick;
  38316. private _twoFingerActivityCount;
  38317. private _isPinching;
  38318. /**
  38319. * Called on pointer POINTERMOVE event if only a single touch is active.
  38320. */
  38321. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  38322. /**
  38323. * Called on pointer POINTERDOUBLETAP event.
  38324. */
  38325. protected onDoubleTap(type: string): void;
  38326. /**
  38327. * Called on pointer POINTERMOVE event if multiple touches are active.
  38328. */
  38329. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  38330. /**
  38331. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  38332. * press.
  38333. */
  38334. protected onButtonDown(evt: PointerEvent): void;
  38335. /**
  38336. * Called each time a new POINTERUP event occurs. Ie, for each button
  38337. * release.
  38338. */
  38339. protected onButtonUp(evt: PointerEvent): void;
  38340. /**
  38341. * Called when window becomes inactive.
  38342. */
  38343. protected onLostFocus(): void;
  38344. }
  38345. }
  38346. declare module BABYLON {
  38347. /**
  38348. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  38349. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38350. */
  38351. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  38352. /**
  38353. * Defines the camera the input is attached to.
  38354. */
  38355. camera: ArcRotateCamera;
  38356. /**
  38357. * Defines the list of key codes associated with the up action (increase alpha)
  38358. */
  38359. keysUp: number[];
  38360. /**
  38361. * Defines the list of key codes associated with the down action (decrease alpha)
  38362. */
  38363. keysDown: number[];
  38364. /**
  38365. * Defines the list of key codes associated with the left action (increase beta)
  38366. */
  38367. keysLeft: number[];
  38368. /**
  38369. * Defines the list of key codes associated with the right action (decrease beta)
  38370. */
  38371. keysRight: number[];
  38372. /**
  38373. * Defines the list of key codes associated with the reset action.
  38374. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  38375. */
  38376. keysReset: number[];
  38377. /**
  38378. * Defines the panning sensibility of the inputs.
  38379. * (How fast is the camera panning)
  38380. */
  38381. panningSensibility: number;
  38382. /**
  38383. * Defines the zooming sensibility of the inputs.
  38384. * (How fast is the camera zooming)
  38385. */
  38386. zoomingSensibility: number;
  38387. /**
  38388. * Defines whether maintaining the alt key down switch the movement mode from
  38389. * orientation to zoom.
  38390. */
  38391. useAltToZoom: boolean;
  38392. /**
  38393. * Rotation speed of the camera
  38394. */
  38395. angularSpeed: number;
  38396. private _keys;
  38397. private _ctrlPressed;
  38398. private _altPressed;
  38399. private _onCanvasBlurObserver;
  38400. private _onKeyboardObserver;
  38401. private _engine;
  38402. private _scene;
  38403. /**
  38404. * Attach the input controls to a specific dom element to get the input from.
  38405. * @param element Defines the element the controls should be listened from
  38406. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38407. */
  38408. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38409. /**
  38410. * Detach the current controls from the specified dom element.
  38411. * @param element Defines the element to stop listening the inputs from
  38412. */
  38413. detachControl(element: Nullable<HTMLElement>): void;
  38414. /**
  38415. * Update the current camera state depending on the inputs that have been used this frame.
  38416. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38417. */
  38418. checkInputs(): void;
  38419. /**
  38420. * Gets the class name of the current intput.
  38421. * @returns the class name
  38422. */
  38423. getClassName(): string;
  38424. /**
  38425. * Get the friendly name associated with the input class.
  38426. * @returns the input friendly name
  38427. */
  38428. getSimpleName(): string;
  38429. }
  38430. }
  38431. declare module BABYLON {
  38432. /**
  38433. * Manage the mouse wheel inputs to control an arc rotate camera.
  38434. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38435. */
  38436. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  38437. /**
  38438. * Defines the camera the input is attached to.
  38439. */
  38440. camera: ArcRotateCamera;
  38441. /**
  38442. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  38443. */
  38444. wheelPrecision: number;
  38445. /**
  38446. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  38447. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  38448. */
  38449. wheelDeltaPercentage: number;
  38450. private _wheel;
  38451. private _observer;
  38452. private computeDeltaFromMouseWheelLegacyEvent;
  38453. /**
  38454. * Attach the input controls to a specific dom element to get the input from.
  38455. * @param element Defines the element the controls should be listened from
  38456. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38457. */
  38458. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38459. /**
  38460. * Detach the current controls from the specified dom element.
  38461. * @param element Defines the element to stop listening the inputs from
  38462. */
  38463. detachControl(element: Nullable<HTMLElement>): void;
  38464. /**
  38465. * Gets the class name of the current intput.
  38466. * @returns the class name
  38467. */
  38468. getClassName(): string;
  38469. /**
  38470. * Get the friendly name associated with the input class.
  38471. * @returns the input friendly name
  38472. */
  38473. getSimpleName(): string;
  38474. }
  38475. }
  38476. declare module BABYLON {
  38477. /**
  38478. * Default Inputs manager for the ArcRotateCamera.
  38479. * It groups all the default supported inputs for ease of use.
  38480. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38481. */
  38482. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  38483. /**
  38484. * Instantiates a new ArcRotateCameraInputsManager.
  38485. * @param camera Defines the camera the inputs belong to
  38486. */
  38487. constructor(camera: ArcRotateCamera);
  38488. /**
  38489. * Add mouse wheel input support to the input manager.
  38490. * @returns the current input manager
  38491. */
  38492. addMouseWheel(): ArcRotateCameraInputsManager;
  38493. /**
  38494. * Add pointers input support to the input manager.
  38495. * @returns the current input manager
  38496. */
  38497. addPointers(): ArcRotateCameraInputsManager;
  38498. /**
  38499. * Add keyboard input support to the input manager.
  38500. * @returns the current input manager
  38501. */
  38502. addKeyboard(): ArcRotateCameraInputsManager;
  38503. }
  38504. }
  38505. declare module BABYLON {
  38506. /**
  38507. * This represents an orbital type of camera.
  38508. *
  38509. * 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.
  38510. * 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.
  38511. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  38512. */
  38513. export class ArcRotateCamera extends TargetCamera {
  38514. /**
  38515. * Defines the rotation angle of the camera along the longitudinal axis.
  38516. */
  38517. alpha: number;
  38518. /**
  38519. * Defines the rotation angle of the camera along the latitudinal axis.
  38520. */
  38521. beta: number;
  38522. /**
  38523. * Defines the radius of the camera from it s target point.
  38524. */
  38525. radius: number;
  38526. protected _target: Vector3;
  38527. protected _targetHost: Nullable<AbstractMesh>;
  38528. /**
  38529. * Defines the target point of the camera.
  38530. * The camera looks towards it form the radius distance.
  38531. */
  38532. get target(): Vector3;
  38533. set target(value: Vector3);
  38534. /**
  38535. * Define the current local position of the camera in the scene
  38536. */
  38537. get position(): Vector3;
  38538. set position(newPosition: Vector3);
  38539. protected _upVector: Vector3;
  38540. protected _upToYMatrix: Matrix;
  38541. protected _YToUpMatrix: Matrix;
  38542. /**
  38543. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  38544. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  38545. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  38546. */
  38547. set upVector(vec: Vector3);
  38548. get upVector(): Vector3;
  38549. /**
  38550. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  38551. */
  38552. setMatUp(): void;
  38553. /**
  38554. * Current inertia value on the longitudinal axis.
  38555. * The bigger this number the longer it will take for the camera to stop.
  38556. */
  38557. inertialAlphaOffset: number;
  38558. /**
  38559. * Current inertia value on the latitudinal axis.
  38560. * The bigger this number the longer it will take for the camera to stop.
  38561. */
  38562. inertialBetaOffset: number;
  38563. /**
  38564. * Current inertia value on the radius axis.
  38565. * The bigger this number the longer it will take for the camera to stop.
  38566. */
  38567. inertialRadiusOffset: number;
  38568. /**
  38569. * Minimum allowed angle on the longitudinal axis.
  38570. * This can help limiting how the Camera is able to move in the scene.
  38571. */
  38572. lowerAlphaLimit: Nullable<number>;
  38573. /**
  38574. * Maximum allowed angle on the longitudinal axis.
  38575. * This can help limiting how the Camera is able to move in the scene.
  38576. */
  38577. upperAlphaLimit: Nullable<number>;
  38578. /**
  38579. * Minimum allowed angle on the latitudinal axis.
  38580. * This can help limiting how the Camera is able to move in the scene.
  38581. */
  38582. lowerBetaLimit: number;
  38583. /**
  38584. * Maximum allowed angle on the latitudinal axis.
  38585. * This can help limiting how the Camera is able to move in the scene.
  38586. */
  38587. upperBetaLimit: number;
  38588. /**
  38589. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  38590. * This can help limiting how the Camera is able to move in the scene.
  38591. */
  38592. lowerRadiusLimit: Nullable<number>;
  38593. /**
  38594. * Maximum allowed distance of the camera to the target (The camera can not get further).
  38595. * This can help limiting how the Camera is able to move in the scene.
  38596. */
  38597. upperRadiusLimit: Nullable<number>;
  38598. /**
  38599. * Defines the current inertia value used during panning of the camera along the X axis.
  38600. */
  38601. inertialPanningX: number;
  38602. /**
  38603. * Defines the current inertia value used during panning of the camera along the Y axis.
  38604. */
  38605. inertialPanningY: number;
  38606. /**
  38607. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  38608. * Basically if your fingers moves away from more than this distance you will be considered
  38609. * in pinch mode.
  38610. */
  38611. pinchToPanMaxDistance: number;
  38612. /**
  38613. * Defines the maximum distance the camera can pan.
  38614. * This could help keeping the cammera always in your scene.
  38615. */
  38616. panningDistanceLimit: Nullable<number>;
  38617. /**
  38618. * Defines the target of the camera before paning.
  38619. */
  38620. panningOriginTarget: Vector3;
  38621. /**
  38622. * Defines the value of the inertia used during panning.
  38623. * 0 would mean stop inertia and one would mean no decelleration at all.
  38624. */
  38625. panningInertia: number;
  38626. /**
  38627. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  38628. */
  38629. get angularSensibilityX(): number;
  38630. set angularSensibilityX(value: number);
  38631. /**
  38632. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  38633. */
  38634. get angularSensibilityY(): number;
  38635. set angularSensibilityY(value: number);
  38636. /**
  38637. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  38638. */
  38639. get pinchPrecision(): number;
  38640. set pinchPrecision(value: number);
  38641. /**
  38642. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  38643. * It will be used instead of pinchDeltaPrecision if different from 0.
  38644. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  38645. */
  38646. get pinchDeltaPercentage(): number;
  38647. set pinchDeltaPercentage(value: number);
  38648. /**
  38649. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  38650. * and pinch delta percentage.
  38651. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  38652. * that any object in the plane at the camera's target point will scale
  38653. * perfectly with finger motion.
  38654. */
  38655. get useNaturalPinchZoom(): boolean;
  38656. set useNaturalPinchZoom(value: boolean);
  38657. /**
  38658. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  38659. */
  38660. get panningSensibility(): number;
  38661. set panningSensibility(value: number);
  38662. /**
  38663. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  38664. */
  38665. get keysUp(): number[];
  38666. set keysUp(value: number[]);
  38667. /**
  38668. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  38669. */
  38670. get keysDown(): number[];
  38671. set keysDown(value: number[]);
  38672. /**
  38673. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  38674. */
  38675. get keysLeft(): number[];
  38676. set keysLeft(value: number[]);
  38677. /**
  38678. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  38679. */
  38680. get keysRight(): number[];
  38681. set keysRight(value: number[]);
  38682. /**
  38683. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  38684. */
  38685. get wheelPrecision(): number;
  38686. set wheelPrecision(value: number);
  38687. /**
  38688. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  38689. * It will be used instead of pinchDeltaPrecision if different from 0.
  38690. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  38691. */
  38692. get wheelDeltaPercentage(): number;
  38693. set wheelDeltaPercentage(value: number);
  38694. /**
  38695. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  38696. */
  38697. zoomOnFactor: number;
  38698. /**
  38699. * Defines a screen offset for the camera position.
  38700. */
  38701. targetScreenOffset: Vector2;
  38702. /**
  38703. * Allows the camera to be completely reversed.
  38704. * If false the camera can not arrive upside down.
  38705. */
  38706. allowUpsideDown: boolean;
  38707. /**
  38708. * Define if double tap/click is used to restore the previously saved state of the camera.
  38709. */
  38710. useInputToRestoreState: boolean;
  38711. /** @hidden */
  38712. _viewMatrix: Matrix;
  38713. /** @hidden */
  38714. _useCtrlForPanning: boolean;
  38715. /** @hidden */
  38716. _panningMouseButton: number;
  38717. /**
  38718. * Defines the input associated to the camera.
  38719. */
  38720. inputs: ArcRotateCameraInputsManager;
  38721. /** @hidden */
  38722. _reset: () => void;
  38723. /**
  38724. * Defines the allowed panning axis.
  38725. */
  38726. panningAxis: Vector3;
  38727. protected _localDirection: Vector3;
  38728. protected _transformedDirection: Vector3;
  38729. private _bouncingBehavior;
  38730. /**
  38731. * Gets the bouncing behavior of the camera if it has been enabled.
  38732. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  38733. */
  38734. get bouncingBehavior(): Nullable<BouncingBehavior>;
  38735. /**
  38736. * Defines if the bouncing behavior of the camera is enabled on the camera.
  38737. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  38738. */
  38739. get useBouncingBehavior(): boolean;
  38740. set useBouncingBehavior(value: boolean);
  38741. private _framingBehavior;
  38742. /**
  38743. * Gets the framing behavior of the camera if it has been enabled.
  38744. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  38745. */
  38746. get framingBehavior(): Nullable<FramingBehavior>;
  38747. /**
  38748. * Defines if the framing behavior of the camera is enabled on the camera.
  38749. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  38750. */
  38751. get useFramingBehavior(): boolean;
  38752. set useFramingBehavior(value: boolean);
  38753. private _autoRotationBehavior;
  38754. /**
  38755. * Gets the auto rotation behavior of the camera if it has been enabled.
  38756. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  38757. */
  38758. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  38759. /**
  38760. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  38761. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  38762. */
  38763. get useAutoRotationBehavior(): boolean;
  38764. set useAutoRotationBehavior(value: boolean);
  38765. /**
  38766. * Observable triggered when the mesh target has been changed on the camera.
  38767. */
  38768. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  38769. /**
  38770. * Event raised when the camera is colliding with a mesh.
  38771. */
  38772. onCollide: (collidedMesh: AbstractMesh) => void;
  38773. /**
  38774. * Defines whether the camera should check collision with the objects oh the scene.
  38775. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  38776. */
  38777. checkCollisions: boolean;
  38778. /**
  38779. * Defines the collision radius of the camera.
  38780. * This simulates a sphere around the camera.
  38781. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  38782. */
  38783. collisionRadius: Vector3;
  38784. protected _collider: Collider;
  38785. protected _previousPosition: Vector3;
  38786. protected _collisionVelocity: Vector3;
  38787. protected _newPosition: Vector3;
  38788. protected _previousAlpha: number;
  38789. protected _previousBeta: number;
  38790. protected _previousRadius: number;
  38791. protected _collisionTriggered: boolean;
  38792. protected _targetBoundingCenter: Nullable<Vector3>;
  38793. private _computationVector;
  38794. /**
  38795. * Instantiates a new ArcRotateCamera in a given scene
  38796. * @param name Defines the name of the camera
  38797. * @param alpha Defines the camera rotation along the logitudinal axis
  38798. * @param beta Defines the camera rotation along the latitudinal axis
  38799. * @param radius Defines the camera distance from its target
  38800. * @param target Defines the camera target
  38801. * @param scene Defines the scene the camera belongs to
  38802. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  38803. */
  38804. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  38805. /** @hidden */
  38806. _initCache(): void;
  38807. /** @hidden */
  38808. _updateCache(ignoreParentClass?: boolean): void;
  38809. protected _getTargetPosition(): Vector3;
  38810. private _storedAlpha;
  38811. private _storedBeta;
  38812. private _storedRadius;
  38813. private _storedTarget;
  38814. private _storedTargetScreenOffset;
  38815. /**
  38816. * Stores the current state of the camera (alpha, beta, radius and target)
  38817. * @returns the camera itself
  38818. */
  38819. storeState(): Camera;
  38820. /**
  38821. * @hidden
  38822. * Restored camera state. You must call storeState() first
  38823. */
  38824. _restoreStateValues(): boolean;
  38825. /** @hidden */
  38826. _isSynchronizedViewMatrix(): boolean;
  38827. /**
  38828. * Attached controls to the current camera.
  38829. * @param element Defines the element the controls should be listened from
  38830. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38831. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  38832. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  38833. */
  38834. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  38835. /**
  38836. * Detach the current controls from the camera.
  38837. * The camera will stop reacting to inputs.
  38838. * @param element Defines the element to stop listening the inputs from
  38839. */
  38840. detachControl(element: HTMLElement): void;
  38841. /** @hidden */
  38842. _checkInputs(): void;
  38843. protected _checkLimits(): void;
  38844. /**
  38845. * Rebuilds angles (alpha, beta) and radius from the give position and target
  38846. */
  38847. rebuildAnglesAndRadius(): void;
  38848. /**
  38849. * Use a position to define the current camera related information like alpha, beta and radius
  38850. * @param position Defines the position to set the camera at
  38851. */
  38852. setPosition(position: Vector3): void;
  38853. /**
  38854. * Defines the target the camera should look at.
  38855. * This will automatically adapt alpha beta and radius to fit within the new target.
  38856. * @param target Defines the new target as a Vector or a mesh
  38857. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  38858. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  38859. */
  38860. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  38861. /** @hidden */
  38862. _getViewMatrix(): Matrix;
  38863. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  38864. /**
  38865. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  38866. * @param meshes Defines the mesh to zoom on
  38867. * @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)
  38868. */
  38869. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  38870. /**
  38871. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  38872. * The target will be changed but the radius
  38873. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  38874. * @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)
  38875. */
  38876. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  38877. min: Vector3;
  38878. max: Vector3;
  38879. distance: number;
  38880. }, doNotUpdateMaxZ?: boolean): void;
  38881. /**
  38882. * @override
  38883. * Override Camera.createRigCamera
  38884. */
  38885. createRigCamera(name: string, cameraIndex: number): Camera;
  38886. /**
  38887. * @hidden
  38888. * @override
  38889. * Override Camera._updateRigCameras
  38890. */
  38891. _updateRigCameras(): void;
  38892. /**
  38893. * Destroy the camera and release the current resources hold by it.
  38894. */
  38895. dispose(): void;
  38896. /**
  38897. * Gets the current object class name.
  38898. * @return the class name
  38899. */
  38900. getClassName(): string;
  38901. }
  38902. }
  38903. declare module BABYLON {
  38904. /**
  38905. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  38906. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  38907. */
  38908. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  38909. /**
  38910. * Gets the name of the behavior.
  38911. */
  38912. get name(): string;
  38913. private _zoomStopsAnimation;
  38914. private _idleRotationSpeed;
  38915. private _idleRotationWaitTime;
  38916. private _idleRotationSpinupTime;
  38917. /**
  38918. * Sets the flag that indicates if user zooming should stop animation.
  38919. */
  38920. set zoomStopsAnimation(flag: boolean);
  38921. /**
  38922. * Gets the flag that indicates if user zooming should stop animation.
  38923. */
  38924. get zoomStopsAnimation(): boolean;
  38925. /**
  38926. * Sets the default speed at which the camera rotates around the model.
  38927. */
  38928. set idleRotationSpeed(speed: number);
  38929. /**
  38930. * Gets the default speed at which the camera rotates around the model.
  38931. */
  38932. get idleRotationSpeed(): number;
  38933. /**
  38934. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  38935. */
  38936. set idleRotationWaitTime(time: number);
  38937. /**
  38938. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  38939. */
  38940. get idleRotationWaitTime(): number;
  38941. /**
  38942. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  38943. */
  38944. set idleRotationSpinupTime(time: number);
  38945. /**
  38946. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  38947. */
  38948. get idleRotationSpinupTime(): number;
  38949. /**
  38950. * Gets a value indicating if the camera is currently rotating because of this behavior
  38951. */
  38952. get rotationInProgress(): boolean;
  38953. private _onPrePointerObservableObserver;
  38954. private _onAfterCheckInputsObserver;
  38955. private _attachedCamera;
  38956. private _isPointerDown;
  38957. private _lastFrameTime;
  38958. private _lastInteractionTime;
  38959. private _cameraRotationSpeed;
  38960. /**
  38961. * Initializes the behavior.
  38962. */
  38963. init(): void;
  38964. /**
  38965. * Attaches the behavior to its arc rotate camera.
  38966. * @param camera Defines the camera to attach the behavior to
  38967. */
  38968. attach(camera: ArcRotateCamera): void;
  38969. /**
  38970. * Detaches the behavior from its current arc rotate camera.
  38971. */
  38972. detach(): void;
  38973. /**
  38974. * Returns true if user is scrolling.
  38975. * @return true if user is scrolling.
  38976. */
  38977. private _userIsZooming;
  38978. private _lastFrameRadius;
  38979. private _shouldAnimationStopForInteraction;
  38980. /**
  38981. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  38982. */
  38983. private _applyUserInteraction;
  38984. private _userIsMoving;
  38985. }
  38986. }
  38987. declare module BABYLON {
  38988. /**
  38989. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  38990. */
  38991. export class AttachToBoxBehavior implements Behavior<Mesh> {
  38992. private ui;
  38993. /**
  38994. * The name of the behavior
  38995. */
  38996. name: string;
  38997. /**
  38998. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  38999. */
  39000. distanceAwayFromFace: number;
  39001. /**
  39002. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  39003. */
  39004. distanceAwayFromBottomOfFace: number;
  39005. private _faceVectors;
  39006. private _target;
  39007. private _scene;
  39008. private _onRenderObserver;
  39009. private _tmpMatrix;
  39010. private _tmpVector;
  39011. /**
  39012. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  39013. * @param ui The transform node that should be attched to the mesh
  39014. */
  39015. constructor(ui: TransformNode);
  39016. /**
  39017. * Initializes the behavior
  39018. */
  39019. init(): void;
  39020. private _closestFace;
  39021. private _zeroVector;
  39022. private _lookAtTmpMatrix;
  39023. private _lookAtToRef;
  39024. /**
  39025. * Attaches the AttachToBoxBehavior to the passed in mesh
  39026. * @param target The mesh that the specified node will be attached to
  39027. */
  39028. attach(target: Mesh): void;
  39029. /**
  39030. * Detaches the behavior from the mesh
  39031. */
  39032. detach(): void;
  39033. }
  39034. }
  39035. declare module BABYLON {
  39036. /**
  39037. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  39038. */
  39039. export class FadeInOutBehavior implements Behavior<Mesh> {
  39040. /**
  39041. * Time in milliseconds to delay before fading in (Default: 0)
  39042. */
  39043. delay: number;
  39044. /**
  39045. * Time in milliseconds for the mesh to fade in (Default: 300)
  39046. */
  39047. fadeInTime: number;
  39048. private _millisecondsPerFrame;
  39049. private _hovered;
  39050. private _hoverValue;
  39051. private _ownerNode;
  39052. /**
  39053. * Instatiates the FadeInOutBehavior
  39054. */
  39055. constructor();
  39056. /**
  39057. * The name of the behavior
  39058. */
  39059. get name(): string;
  39060. /**
  39061. * Initializes the behavior
  39062. */
  39063. init(): void;
  39064. /**
  39065. * Attaches the fade behavior on the passed in mesh
  39066. * @param ownerNode The mesh that will be faded in/out once attached
  39067. */
  39068. attach(ownerNode: Mesh): void;
  39069. /**
  39070. * Detaches the behavior from the mesh
  39071. */
  39072. detach(): void;
  39073. /**
  39074. * Triggers the mesh to begin fading in or out
  39075. * @param value if the object should fade in or out (true to fade in)
  39076. */
  39077. fadeIn(value: boolean): void;
  39078. private _update;
  39079. private _setAllVisibility;
  39080. }
  39081. }
  39082. declare module BABYLON {
  39083. /**
  39084. * Class containing a set of static utilities functions for managing Pivots
  39085. * @hidden
  39086. */
  39087. export class PivotTools {
  39088. private static _PivotCached;
  39089. private static _OldPivotPoint;
  39090. private static _PivotTranslation;
  39091. private static _PivotTmpVector;
  39092. /** @hidden */
  39093. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  39094. /** @hidden */
  39095. static _RestorePivotPoint(mesh: AbstractMesh): void;
  39096. }
  39097. }
  39098. declare module BABYLON {
  39099. /**
  39100. * Class containing static functions to help procedurally build meshes
  39101. */
  39102. export class PlaneBuilder {
  39103. /**
  39104. * Creates a plane mesh
  39105. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  39106. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  39107. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  39108. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  39109. * * 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
  39110. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  39111. * @param name defines the name of the mesh
  39112. * @param options defines the options used to create the mesh
  39113. * @param scene defines the hosting scene
  39114. * @returns the plane mesh
  39115. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  39116. */
  39117. static CreatePlane(name: string, options: {
  39118. size?: number;
  39119. width?: number;
  39120. height?: number;
  39121. sideOrientation?: number;
  39122. frontUVs?: Vector4;
  39123. backUVs?: Vector4;
  39124. updatable?: boolean;
  39125. sourcePlane?: Plane;
  39126. }, scene?: Nullable<Scene>): Mesh;
  39127. }
  39128. }
  39129. declare module BABYLON {
  39130. /**
  39131. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  39132. */
  39133. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  39134. private static _AnyMouseID;
  39135. /**
  39136. * Abstract mesh the behavior is set on
  39137. */
  39138. attachedNode: AbstractMesh;
  39139. private _dragPlane;
  39140. private _scene;
  39141. private _pointerObserver;
  39142. private _beforeRenderObserver;
  39143. private static _planeScene;
  39144. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  39145. /**
  39146. * 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)
  39147. */
  39148. maxDragAngle: number;
  39149. /**
  39150. * @hidden
  39151. */
  39152. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  39153. /**
  39154. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  39155. */
  39156. currentDraggingPointerID: number;
  39157. /**
  39158. * The last position where the pointer hit the drag plane in world space
  39159. */
  39160. lastDragPosition: Vector3;
  39161. /**
  39162. * If the behavior is currently in a dragging state
  39163. */
  39164. dragging: boolean;
  39165. /**
  39166. * 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)
  39167. */
  39168. dragDeltaRatio: number;
  39169. /**
  39170. * If the drag plane orientation should be updated during the dragging (Default: true)
  39171. */
  39172. updateDragPlane: boolean;
  39173. private _debugMode;
  39174. private _moving;
  39175. /**
  39176. * Fires each time the attached mesh is dragged with the pointer
  39177. * * delta between last drag position and current drag position in world space
  39178. * * dragDistance along the drag axis
  39179. * * dragPlaneNormal normal of the current drag plane used during the drag
  39180. * * dragPlanePoint in world space where the drag intersects the drag plane
  39181. */
  39182. onDragObservable: Observable<{
  39183. delta: Vector3;
  39184. dragPlanePoint: Vector3;
  39185. dragPlaneNormal: Vector3;
  39186. dragDistance: number;
  39187. pointerId: number;
  39188. }>;
  39189. /**
  39190. * Fires each time a drag begins (eg. mouse down on mesh)
  39191. */
  39192. onDragStartObservable: Observable<{
  39193. dragPlanePoint: Vector3;
  39194. pointerId: number;
  39195. }>;
  39196. /**
  39197. * Fires each time a drag ends (eg. mouse release after drag)
  39198. */
  39199. onDragEndObservable: Observable<{
  39200. dragPlanePoint: Vector3;
  39201. pointerId: number;
  39202. }>;
  39203. /**
  39204. * If the attached mesh should be moved when dragged
  39205. */
  39206. moveAttached: boolean;
  39207. /**
  39208. * If the drag behavior will react to drag events (Default: true)
  39209. */
  39210. enabled: boolean;
  39211. /**
  39212. * If pointer events should start and release the drag (Default: true)
  39213. */
  39214. startAndReleaseDragOnPointerEvents: boolean;
  39215. /**
  39216. * If camera controls should be detached during the drag
  39217. */
  39218. detachCameraControls: boolean;
  39219. /**
  39220. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  39221. */
  39222. useObjectOrientationForDragging: boolean;
  39223. private _options;
  39224. /**
  39225. * Gets the options used by the behavior
  39226. */
  39227. get options(): {
  39228. dragAxis?: Vector3;
  39229. dragPlaneNormal?: Vector3;
  39230. };
  39231. /**
  39232. * Sets the options used by the behavior
  39233. */
  39234. set options(options: {
  39235. dragAxis?: Vector3;
  39236. dragPlaneNormal?: Vector3;
  39237. });
  39238. /**
  39239. * Creates a pointer drag behavior that can be attached to a mesh
  39240. * @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)
  39241. */
  39242. constructor(options?: {
  39243. dragAxis?: Vector3;
  39244. dragPlaneNormal?: Vector3;
  39245. });
  39246. /**
  39247. * Predicate to determine if it is valid to move the object to a new position when it is moved
  39248. */
  39249. validateDrag: (targetPosition: Vector3) => boolean;
  39250. /**
  39251. * The name of the behavior
  39252. */
  39253. get name(): string;
  39254. /**
  39255. * Initializes the behavior
  39256. */
  39257. init(): void;
  39258. private _tmpVector;
  39259. private _alternatePickedPoint;
  39260. private _worldDragAxis;
  39261. private _targetPosition;
  39262. private _attachedElement;
  39263. /**
  39264. * Attaches the drag behavior the passed in mesh
  39265. * @param ownerNode The mesh that will be dragged around once attached
  39266. * @param predicate Predicate to use for pick filtering
  39267. */
  39268. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  39269. /**
  39270. * Force relase the drag action by code.
  39271. */
  39272. releaseDrag(): void;
  39273. private _startDragRay;
  39274. private _lastPointerRay;
  39275. /**
  39276. * Simulates the start of a pointer drag event on the behavior
  39277. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  39278. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  39279. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  39280. */
  39281. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  39282. private _startDrag;
  39283. private _dragDelta;
  39284. private _moveDrag;
  39285. private _pickWithRayOnDragPlane;
  39286. private _pointA;
  39287. private _pointB;
  39288. private _pointC;
  39289. private _lineA;
  39290. private _lineB;
  39291. private _localAxis;
  39292. private _lookAt;
  39293. private _updateDragPlanePosition;
  39294. /**
  39295. * Detaches the behavior from the mesh
  39296. */
  39297. detach(): void;
  39298. }
  39299. }
  39300. declare module BABYLON {
  39301. /**
  39302. * A behavior that when attached to a mesh will allow the mesh to be scaled
  39303. */
  39304. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  39305. private _dragBehaviorA;
  39306. private _dragBehaviorB;
  39307. private _startDistance;
  39308. private _initialScale;
  39309. private _targetScale;
  39310. private _ownerNode;
  39311. private _sceneRenderObserver;
  39312. /**
  39313. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  39314. */
  39315. constructor();
  39316. /**
  39317. * The name of the behavior
  39318. */
  39319. get name(): string;
  39320. /**
  39321. * Initializes the behavior
  39322. */
  39323. init(): void;
  39324. private _getCurrentDistance;
  39325. /**
  39326. * Attaches the scale behavior the passed in mesh
  39327. * @param ownerNode The mesh that will be scaled around once attached
  39328. */
  39329. attach(ownerNode: Mesh): void;
  39330. /**
  39331. * Detaches the behavior from the mesh
  39332. */
  39333. detach(): void;
  39334. }
  39335. }
  39336. declare module BABYLON {
  39337. /**
  39338. * 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
  39339. */
  39340. export class SixDofDragBehavior implements Behavior<Mesh> {
  39341. private static _virtualScene;
  39342. private _ownerNode;
  39343. private _sceneRenderObserver;
  39344. private _scene;
  39345. private _targetPosition;
  39346. private _virtualOriginMesh;
  39347. private _virtualDragMesh;
  39348. private _pointerObserver;
  39349. private _moving;
  39350. private _startingOrientation;
  39351. /**
  39352. * 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)
  39353. */
  39354. private zDragFactor;
  39355. /**
  39356. * If the object should rotate to face the drag origin
  39357. */
  39358. rotateDraggedObject: boolean;
  39359. /**
  39360. * If the behavior is currently in a dragging state
  39361. */
  39362. dragging: boolean;
  39363. /**
  39364. * 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)
  39365. */
  39366. dragDeltaRatio: number;
  39367. /**
  39368. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  39369. */
  39370. currentDraggingPointerID: number;
  39371. /**
  39372. * If camera controls should be detached during the drag
  39373. */
  39374. detachCameraControls: boolean;
  39375. /**
  39376. * Fires each time a drag starts
  39377. */
  39378. onDragStartObservable: Observable<{}>;
  39379. /**
  39380. * Fires each time a drag ends (eg. mouse release after drag)
  39381. */
  39382. onDragEndObservable: Observable<{}>;
  39383. /**
  39384. * 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
  39385. */
  39386. constructor();
  39387. /**
  39388. * The name of the behavior
  39389. */
  39390. get name(): string;
  39391. /**
  39392. * Initializes the behavior
  39393. */
  39394. init(): void;
  39395. /**
  39396. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  39397. */
  39398. private get _pointerCamera();
  39399. /**
  39400. * Attaches the scale behavior the passed in mesh
  39401. * @param ownerNode The mesh that will be scaled around once attached
  39402. */
  39403. attach(ownerNode: Mesh): void;
  39404. /**
  39405. * Detaches the behavior from the mesh
  39406. */
  39407. detach(): void;
  39408. }
  39409. }
  39410. declare module BABYLON {
  39411. /**
  39412. * Class used to apply inverse kinematics to bones
  39413. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  39414. */
  39415. export class BoneIKController {
  39416. private static _tmpVecs;
  39417. private static _tmpQuat;
  39418. private static _tmpMats;
  39419. /**
  39420. * Gets or sets the target mesh
  39421. */
  39422. targetMesh: AbstractMesh;
  39423. /** Gets or sets the mesh used as pole */
  39424. poleTargetMesh: AbstractMesh;
  39425. /**
  39426. * Gets or sets the bone used as pole
  39427. */
  39428. poleTargetBone: Nullable<Bone>;
  39429. /**
  39430. * Gets or sets the target position
  39431. */
  39432. targetPosition: Vector3;
  39433. /**
  39434. * Gets or sets the pole target position
  39435. */
  39436. poleTargetPosition: Vector3;
  39437. /**
  39438. * Gets or sets the pole target local offset
  39439. */
  39440. poleTargetLocalOffset: Vector3;
  39441. /**
  39442. * Gets or sets the pole angle
  39443. */
  39444. poleAngle: number;
  39445. /**
  39446. * Gets or sets the mesh associated with the controller
  39447. */
  39448. mesh: AbstractMesh;
  39449. /**
  39450. * 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)
  39451. */
  39452. slerpAmount: number;
  39453. private _bone1Quat;
  39454. private _bone1Mat;
  39455. private _bone2Ang;
  39456. private _bone1;
  39457. private _bone2;
  39458. private _bone1Length;
  39459. private _bone2Length;
  39460. private _maxAngle;
  39461. private _maxReach;
  39462. private _rightHandedSystem;
  39463. private _bendAxis;
  39464. private _slerping;
  39465. private _adjustRoll;
  39466. /**
  39467. * Gets or sets maximum allowed angle
  39468. */
  39469. get maxAngle(): number;
  39470. set maxAngle(value: number);
  39471. /**
  39472. * Creates a new BoneIKController
  39473. * @param mesh defines the mesh to control
  39474. * @param bone defines the bone to control
  39475. * @param options defines options to set up the controller
  39476. */
  39477. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  39478. targetMesh?: AbstractMesh;
  39479. poleTargetMesh?: AbstractMesh;
  39480. poleTargetBone?: Bone;
  39481. poleTargetLocalOffset?: Vector3;
  39482. poleAngle?: number;
  39483. bendAxis?: Vector3;
  39484. maxAngle?: number;
  39485. slerpAmount?: number;
  39486. });
  39487. private _setMaxAngle;
  39488. /**
  39489. * Force the controller to update the bones
  39490. */
  39491. update(): void;
  39492. }
  39493. }
  39494. declare module BABYLON {
  39495. /**
  39496. * Class used to make a bone look toward a point in space
  39497. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  39498. */
  39499. export class BoneLookController {
  39500. private static _tmpVecs;
  39501. private static _tmpQuat;
  39502. private static _tmpMats;
  39503. /**
  39504. * The target Vector3 that the bone will look at
  39505. */
  39506. target: Vector3;
  39507. /**
  39508. * The mesh that the bone is attached to
  39509. */
  39510. mesh: AbstractMesh;
  39511. /**
  39512. * The bone that will be looking to the target
  39513. */
  39514. bone: Bone;
  39515. /**
  39516. * The up axis of the coordinate system that is used when the bone is rotated
  39517. */
  39518. upAxis: Vector3;
  39519. /**
  39520. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  39521. */
  39522. upAxisSpace: Space;
  39523. /**
  39524. * Used to make an adjustment to the yaw of the bone
  39525. */
  39526. adjustYaw: number;
  39527. /**
  39528. * Used to make an adjustment to the pitch of the bone
  39529. */
  39530. adjustPitch: number;
  39531. /**
  39532. * Used to make an adjustment to the roll of the bone
  39533. */
  39534. adjustRoll: number;
  39535. /**
  39536. * 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)
  39537. */
  39538. slerpAmount: number;
  39539. private _minYaw;
  39540. private _maxYaw;
  39541. private _minPitch;
  39542. private _maxPitch;
  39543. private _minYawSin;
  39544. private _minYawCos;
  39545. private _maxYawSin;
  39546. private _maxYawCos;
  39547. private _midYawConstraint;
  39548. private _minPitchTan;
  39549. private _maxPitchTan;
  39550. private _boneQuat;
  39551. private _slerping;
  39552. private _transformYawPitch;
  39553. private _transformYawPitchInv;
  39554. private _firstFrameSkipped;
  39555. private _yawRange;
  39556. private _fowardAxis;
  39557. /**
  39558. * Gets or sets the minimum yaw angle that the bone can look to
  39559. */
  39560. get minYaw(): number;
  39561. set minYaw(value: number);
  39562. /**
  39563. * Gets or sets the maximum yaw angle that the bone can look to
  39564. */
  39565. get maxYaw(): number;
  39566. set maxYaw(value: number);
  39567. /**
  39568. * Gets or sets the minimum pitch angle that the bone can look to
  39569. */
  39570. get minPitch(): number;
  39571. set minPitch(value: number);
  39572. /**
  39573. * Gets or sets the maximum pitch angle that the bone can look to
  39574. */
  39575. get maxPitch(): number;
  39576. set maxPitch(value: number);
  39577. /**
  39578. * Create a BoneLookController
  39579. * @param mesh the mesh that the bone belongs to
  39580. * @param bone the bone that will be looking to the target
  39581. * @param target the target Vector3 to look at
  39582. * @param options optional settings:
  39583. * * maxYaw: the maximum angle the bone will yaw to
  39584. * * minYaw: the minimum angle the bone will yaw to
  39585. * * maxPitch: the maximum angle the bone will pitch to
  39586. * * minPitch: the minimum angle the bone will yaw to
  39587. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  39588. * * upAxis: the up axis of the coordinate system
  39589. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  39590. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  39591. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  39592. * * adjustYaw: used to make an adjustment to the yaw of the bone
  39593. * * adjustPitch: used to make an adjustment to the pitch of the bone
  39594. * * adjustRoll: used to make an adjustment to the roll of the bone
  39595. **/
  39596. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  39597. maxYaw?: number;
  39598. minYaw?: number;
  39599. maxPitch?: number;
  39600. minPitch?: number;
  39601. slerpAmount?: number;
  39602. upAxis?: Vector3;
  39603. upAxisSpace?: Space;
  39604. yawAxis?: Vector3;
  39605. pitchAxis?: Vector3;
  39606. adjustYaw?: number;
  39607. adjustPitch?: number;
  39608. adjustRoll?: number;
  39609. });
  39610. /**
  39611. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  39612. */
  39613. update(): void;
  39614. private _getAngleDiff;
  39615. private _getAngleBetween;
  39616. private _isAngleBetween;
  39617. }
  39618. }
  39619. declare module BABYLON {
  39620. /**
  39621. * Manage the gamepad inputs to control an arc rotate camera.
  39622. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39623. */
  39624. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  39625. /**
  39626. * Defines the camera the input is attached to.
  39627. */
  39628. camera: ArcRotateCamera;
  39629. /**
  39630. * Defines the gamepad the input is gathering event from.
  39631. */
  39632. gamepad: Nullable<Gamepad>;
  39633. /**
  39634. * Defines the gamepad rotation sensiblity.
  39635. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  39636. */
  39637. gamepadRotationSensibility: number;
  39638. /**
  39639. * Defines the gamepad move sensiblity.
  39640. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  39641. */
  39642. gamepadMoveSensibility: number;
  39643. private _yAxisScale;
  39644. /**
  39645. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  39646. */
  39647. get invertYAxis(): boolean;
  39648. set invertYAxis(value: boolean);
  39649. private _onGamepadConnectedObserver;
  39650. private _onGamepadDisconnectedObserver;
  39651. /**
  39652. * Attach the input controls to a specific dom element to get the input from.
  39653. * @param element Defines the element the controls should be listened from
  39654. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39655. */
  39656. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39657. /**
  39658. * Detach the current controls from the specified dom element.
  39659. * @param element Defines the element to stop listening the inputs from
  39660. */
  39661. detachControl(element: Nullable<HTMLElement>): void;
  39662. /**
  39663. * Update the current camera state depending on the inputs that have been used this frame.
  39664. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39665. */
  39666. checkInputs(): void;
  39667. /**
  39668. * Gets the class name of the current intput.
  39669. * @returns the class name
  39670. */
  39671. getClassName(): string;
  39672. /**
  39673. * Get the friendly name associated with the input class.
  39674. * @returns the input friendly name
  39675. */
  39676. getSimpleName(): string;
  39677. }
  39678. }
  39679. declare module BABYLON {
  39680. interface ArcRotateCameraInputsManager {
  39681. /**
  39682. * Add orientation input support to the input manager.
  39683. * @returns the current input manager
  39684. */
  39685. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  39686. }
  39687. /**
  39688. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  39689. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39690. */
  39691. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  39692. /**
  39693. * Defines the camera the input is attached to.
  39694. */
  39695. camera: ArcRotateCamera;
  39696. /**
  39697. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  39698. */
  39699. alphaCorrection: number;
  39700. /**
  39701. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  39702. */
  39703. gammaCorrection: number;
  39704. private _alpha;
  39705. private _gamma;
  39706. private _dirty;
  39707. private _deviceOrientationHandler;
  39708. /**
  39709. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  39710. */
  39711. constructor();
  39712. /**
  39713. * Attach the input controls to a specific dom element to get the input from.
  39714. * @param element Defines the element the controls should be listened from
  39715. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39716. */
  39717. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39718. /** @hidden */
  39719. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  39720. /**
  39721. * Update the current camera state depending on the inputs that have been used this frame.
  39722. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39723. */
  39724. checkInputs(): void;
  39725. /**
  39726. * Detach the current controls from the specified dom element.
  39727. * @param element Defines the element to stop listening the inputs from
  39728. */
  39729. detachControl(element: Nullable<HTMLElement>): void;
  39730. /**
  39731. * Gets the class name of the current intput.
  39732. * @returns the class name
  39733. */
  39734. getClassName(): string;
  39735. /**
  39736. * Get the friendly name associated with the input class.
  39737. * @returns the input friendly name
  39738. */
  39739. getSimpleName(): string;
  39740. }
  39741. }
  39742. declare module BABYLON {
  39743. /**
  39744. * Listen to mouse events to control the camera.
  39745. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39746. */
  39747. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  39748. /**
  39749. * Defines the camera the input is attached to.
  39750. */
  39751. camera: FlyCamera;
  39752. /**
  39753. * Defines if touch is enabled. (Default is true.)
  39754. */
  39755. touchEnabled: boolean;
  39756. /**
  39757. * Defines the buttons associated with the input to handle camera rotation.
  39758. */
  39759. buttons: number[];
  39760. /**
  39761. * Assign buttons for Yaw control.
  39762. */
  39763. buttonsYaw: number[];
  39764. /**
  39765. * Assign buttons for Pitch control.
  39766. */
  39767. buttonsPitch: number[];
  39768. /**
  39769. * Assign buttons for Roll control.
  39770. */
  39771. buttonsRoll: number[];
  39772. /**
  39773. * Detect if any button is being pressed while mouse is moved.
  39774. * -1 = Mouse locked.
  39775. * 0 = Left button.
  39776. * 1 = Middle Button.
  39777. * 2 = Right Button.
  39778. */
  39779. activeButton: number;
  39780. /**
  39781. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  39782. * Higher values reduce its sensitivity.
  39783. */
  39784. angularSensibility: number;
  39785. private _mousemoveCallback;
  39786. private _observer;
  39787. private _rollObserver;
  39788. private previousPosition;
  39789. private noPreventDefault;
  39790. private element;
  39791. /**
  39792. * Listen to mouse events to control the camera.
  39793. * @param touchEnabled Define if touch is enabled. (Default is true.)
  39794. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39795. */
  39796. constructor(touchEnabled?: boolean);
  39797. /**
  39798. * Attach the mouse control to the HTML DOM element.
  39799. * @param element Defines the element that listens to the input events.
  39800. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  39801. */
  39802. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39803. /**
  39804. * Detach the current controls from the specified dom element.
  39805. * @param element Defines the element to stop listening the inputs from
  39806. */
  39807. detachControl(element: Nullable<HTMLElement>): void;
  39808. /**
  39809. * Gets the class name of the current input.
  39810. * @returns the class name.
  39811. */
  39812. getClassName(): string;
  39813. /**
  39814. * Get the friendly name associated with the input class.
  39815. * @returns the input's friendly name.
  39816. */
  39817. getSimpleName(): string;
  39818. private _pointerInput;
  39819. private _onMouseMove;
  39820. /**
  39821. * Rotate camera by mouse offset.
  39822. */
  39823. private rotateCamera;
  39824. }
  39825. }
  39826. declare module BABYLON {
  39827. /**
  39828. * Default Inputs manager for the FlyCamera.
  39829. * It groups all the default supported inputs for ease of use.
  39830. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39831. */
  39832. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  39833. /**
  39834. * Instantiates a new FlyCameraInputsManager.
  39835. * @param camera Defines the camera the inputs belong to.
  39836. */
  39837. constructor(camera: FlyCamera);
  39838. /**
  39839. * Add keyboard input support to the input manager.
  39840. * @returns the new FlyCameraKeyboardMoveInput().
  39841. */
  39842. addKeyboard(): FlyCameraInputsManager;
  39843. /**
  39844. * Add mouse input support to the input manager.
  39845. * @param touchEnabled Enable touch screen support.
  39846. * @returns the new FlyCameraMouseInput().
  39847. */
  39848. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  39849. }
  39850. }
  39851. declare module BABYLON {
  39852. /**
  39853. * This is a flying camera, designed for 3D movement and rotation in all directions,
  39854. * such as in a 3D Space Shooter or a Flight Simulator.
  39855. */
  39856. export class FlyCamera extends TargetCamera {
  39857. /**
  39858. * Define the collision ellipsoid of the camera.
  39859. * This is helpful for simulating a camera body, like a player's body.
  39860. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  39861. */
  39862. ellipsoid: Vector3;
  39863. /**
  39864. * Define an offset for the position of the ellipsoid around the camera.
  39865. * This can be helpful if the camera is attached away from the player's body center,
  39866. * such as at its head.
  39867. */
  39868. ellipsoidOffset: Vector3;
  39869. /**
  39870. * Enable or disable collisions of the camera with the rest of the scene objects.
  39871. */
  39872. checkCollisions: boolean;
  39873. /**
  39874. * Enable or disable gravity on the camera.
  39875. */
  39876. applyGravity: boolean;
  39877. /**
  39878. * Define the current direction the camera is moving to.
  39879. */
  39880. cameraDirection: Vector3;
  39881. /**
  39882. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  39883. * This overrides and empties cameraRotation.
  39884. */
  39885. rotationQuaternion: Quaternion;
  39886. /**
  39887. * Track Roll to maintain the wanted Rolling when looking around.
  39888. */
  39889. _trackRoll: number;
  39890. /**
  39891. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  39892. */
  39893. rollCorrect: number;
  39894. /**
  39895. * Mimic a banked turn, Rolling the camera when Yawing.
  39896. * It's recommended to use rollCorrect = 10 for faster banking correction.
  39897. */
  39898. bankedTurn: boolean;
  39899. /**
  39900. * Limit in radians for how much Roll banking will add. (Default: 90°)
  39901. */
  39902. bankedTurnLimit: number;
  39903. /**
  39904. * Value of 0 disables the banked Roll.
  39905. * Value of 1 is equal to the Yaw angle in radians.
  39906. */
  39907. bankedTurnMultiplier: number;
  39908. /**
  39909. * The inputs manager loads all the input sources, such as keyboard and mouse.
  39910. */
  39911. inputs: FlyCameraInputsManager;
  39912. /**
  39913. * Gets the input sensibility for mouse input.
  39914. * Higher values reduce sensitivity.
  39915. */
  39916. get angularSensibility(): number;
  39917. /**
  39918. * Sets the input sensibility for a mouse input.
  39919. * Higher values reduce sensitivity.
  39920. */
  39921. set angularSensibility(value: number);
  39922. /**
  39923. * Get the keys for camera movement forward.
  39924. */
  39925. get keysForward(): number[];
  39926. /**
  39927. * Set the keys for camera movement forward.
  39928. */
  39929. set keysForward(value: number[]);
  39930. /**
  39931. * Get the keys for camera movement backward.
  39932. */
  39933. get keysBackward(): number[];
  39934. set keysBackward(value: number[]);
  39935. /**
  39936. * Get the keys for camera movement up.
  39937. */
  39938. get keysUp(): number[];
  39939. /**
  39940. * Set the keys for camera movement up.
  39941. */
  39942. set keysUp(value: number[]);
  39943. /**
  39944. * Get the keys for camera movement down.
  39945. */
  39946. get keysDown(): number[];
  39947. /**
  39948. * Set the keys for camera movement down.
  39949. */
  39950. set keysDown(value: number[]);
  39951. /**
  39952. * Get the keys for camera movement left.
  39953. */
  39954. get keysLeft(): number[];
  39955. /**
  39956. * Set the keys for camera movement left.
  39957. */
  39958. set keysLeft(value: number[]);
  39959. /**
  39960. * Set the keys for camera movement right.
  39961. */
  39962. get keysRight(): number[];
  39963. /**
  39964. * Set the keys for camera movement right.
  39965. */
  39966. set keysRight(value: number[]);
  39967. /**
  39968. * Event raised when the camera collides with a mesh in the scene.
  39969. */
  39970. onCollide: (collidedMesh: AbstractMesh) => void;
  39971. private _collider;
  39972. private _needMoveForGravity;
  39973. private _oldPosition;
  39974. private _diffPosition;
  39975. private _newPosition;
  39976. /** @hidden */
  39977. _localDirection: Vector3;
  39978. /** @hidden */
  39979. _transformedDirection: Vector3;
  39980. /**
  39981. * Instantiates a FlyCamera.
  39982. * This is a flying camera, designed for 3D movement and rotation in all directions,
  39983. * such as in a 3D Space Shooter or a Flight Simulator.
  39984. * @param name Define the name of the camera in the scene.
  39985. * @param position Define the starting position of the camera in the scene.
  39986. * @param scene Define the scene the camera belongs to.
  39987. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  39988. */
  39989. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  39990. /**
  39991. * Attach a control to the HTML DOM element.
  39992. * @param element Defines the element that listens to the input events.
  39993. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  39994. */
  39995. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39996. /**
  39997. * Detach a control from the HTML DOM element.
  39998. * The camera will stop reacting to that input.
  39999. * @param element Defines the element that listens to the input events.
  40000. */
  40001. detachControl(element: HTMLElement): void;
  40002. private _collisionMask;
  40003. /**
  40004. * Get the mask that the camera ignores in collision events.
  40005. */
  40006. get collisionMask(): number;
  40007. /**
  40008. * Set the mask that the camera ignores in collision events.
  40009. */
  40010. set collisionMask(mask: number);
  40011. /** @hidden */
  40012. _collideWithWorld(displacement: Vector3): void;
  40013. /** @hidden */
  40014. private _onCollisionPositionChange;
  40015. /** @hidden */
  40016. _checkInputs(): void;
  40017. /** @hidden */
  40018. _decideIfNeedsToMove(): boolean;
  40019. /** @hidden */
  40020. _updatePosition(): void;
  40021. /**
  40022. * Restore the Roll to its target value at the rate specified.
  40023. * @param rate - Higher means slower restoring.
  40024. * @hidden
  40025. */
  40026. restoreRoll(rate: number): void;
  40027. /**
  40028. * Destroy the camera and release the current resources held by it.
  40029. */
  40030. dispose(): void;
  40031. /**
  40032. * Get the current object class name.
  40033. * @returns the class name.
  40034. */
  40035. getClassName(): string;
  40036. }
  40037. }
  40038. declare module BABYLON {
  40039. /**
  40040. * Listen to keyboard events to control the camera.
  40041. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40042. */
  40043. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  40044. /**
  40045. * Defines the camera the input is attached to.
  40046. */
  40047. camera: FlyCamera;
  40048. /**
  40049. * The list of keyboard keys used to control the forward move of the camera.
  40050. */
  40051. keysForward: number[];
  40052. /**
  40053. * The list of keyboard keys used to control the backward move of the camera.
  40054. */
  40055. keysBackward: number[];
  40056. /**
  40057. * The list of keyboard keys used to control the forward move of the camera.
  40058. */
  40059. keysUp: number[];
  40060. /**
  40061. * The list of keyboard keys used to control the backward move of the camera.
  40062. */
  40063. keysDown: number[];
  40064. /**
  40065. * The list of keyboard keys used to control the right strafe move of the camera.
  40066. */
  40067. keysRight: number[];
  40068. /**
  40069. * The list of keyboard keys used to control the left strafe move of the camera.
  40070. */
  40071. keysLeft: number[];
  40072. private _keys;
  40073. private _onCanvasBlurObserver;
  40074. private _onKeyboardObserver;
  40075. private _engine;
  40076. private _scene;
  40077. /**
  40078. * Attach the input controls to a specific dom element to get the input from.
  40079. * @param element Defines the element the controls should be listened from
  40080. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40081. */
  40082. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40083. /**
  40084. * Detach the current controls from the specified dom element.
  40085. * @param element Defines the element to stop listening the inputs from
  40086. */
  40087. detachControl(element: Nullable<HTMLElement>): void;
  40088. /**
  40089. * Gets the class name of the current intput.
  40090. * @returns the class name
  40091. */
  40092. getClassName(): string;
  40093. /** @hidden */
  40094. _onLostFocus(e: FocusEvent): void;
  40095. /**
  40096. * Get the friendly name associated with the input class.
  40097. * @returns the input friendly name
  40098. */
  40099. getSimpleName(): string;
  40100. /**
  40101. * Update the current camera state depending on the inputs that have been used this frame.
  40102. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40103. */
  40104. checkInputs(): void;
  40105. }
  40106. }
  40107. declare module BABYLON {
  40108. /**
  40109. * Manage the mouse wheel inputs to control a follow camera.
  40110. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40111. */
  40112. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  40113. /**
  40114. * Defines the camera the input is attached to.
  40115. */
  40116. camera: FollowCamera;
  40117. /**
  40118. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  40119. */
  40120. axisControlRadius: boolean;
  40121. /**
  40122. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  40123. */
  40124. axisControlHeight: boolean;
  40125. /**
  40126. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  40127. */
  40128. axisControlRotation: boolean;
  40129. /**
  40130. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  40131. * relation to mouseWheel events.
  40132. */
  40133. wheelPrecision: number;
  40134. /**
  40135. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  40136. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  40137. */
  40138. wheelDeltaPercentage: number;
  40139. private _wheel;
  40140. private _observer;
  40141. /**
  40142. * Attach the input controls to a specific dom element to get the input from.
  40143. * @param element Defines the element the controls should be listened from
  40144. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40145. */
  40146. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40147. /**
  40148. * Detach the current controls from the specified dom element.
  40149. * @param element Defines the element to stop listening the inputs from
  40150. */
  40151. detachControl(element: Nullable<HTMLElement>): void;
  40152. /**
  40153. * Gets the class name of the current intput.
  40154. * @returns the class name
  40155. */
  40156. getClassName(): string;
  40157. /**
  40158. * Get the friendly name associated with the input class.
  40159. * @returns the input friendly name
  40160. */
  40161. getSimpleName(): string;
  40162. }
  40163. }
  40164. declare module BABYLON {
  40165. /**
  40166. * Manage the pointers inputs to control an follow camera.
  40167. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40168. */
  40169. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  40170. /**
  40171. * Defines the camera the input is attached to.
  40172. */
  40173. camera: FollowCamera;
  40174. /**
  40175. * Gets the class name of the current input.
  40176. * @returns the class name
  40177. */
  40178. getClassName(): string;
  40179. /**
  40180. * Defines the pointer angular sensibility along the X axis or how fast is
  40181. * the camera rotating.
  40182. * A negative number will reverse the axis direction.
  40183. */
  40184. angularSensibilityX: number;
  40185. /**
  40186. * Defines the pointer angular sensibility along the Y axis or how fast is
  40187. * the camera rotating.
  40188. * A negative number will reverse the axis direction.
  40189. */
  40190. angularSensibilityY: number;
  40191. /**
  40192. * Defines the pointer pinch precision or how fast is the camera zooming.
  40193. * A negative number will reverse the axis direction.
  40194. */
  40195. pinchPrecision: number;
  40196. /**
  40197. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  40198. * from 0.
  40199. * It defines the percentage of current camera.radius to use as delta when
  40200. * pinch zoom is used.
  40201. */
  40202. pinchDeltaPercentage: number;
  40203. /**
  40204. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  40205. */
  40206. axisXControlRadius: boolean;
  40207. /**
  40208. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  40209. */
  40210. axisXControlHeight: boolean;
  40211. /**
  40212. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  40213. */
  40214. axisXControlRotation: boolean;
  40215. /**
  40216. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  40217. */
  40218. axisYControlRadius: boolean;
  40219. /**
  40220. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  40221. */
  40222. axisYControlHeight: boolean;
  40223. /**
  40224. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  40225. */
  40226. axisYControlRotation: boolean;
  40227. /**
  40228. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  40229. */
  40230. axisPinchControlRadius: boolean;
  40231. /**
  40232. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  40233. */
  40234. axisPinchControlHeight: boolean;
  40235. /**
  40236. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  40237. */
  40238. axisPinchControlRotation: boolean;
  40239. /**
  40240. * Log error messages if basic misconfiguration has occurred.
  40241. */
  40242. warningEnable: boolean;
  40243. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  40244. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  40245. private _warningCounter;
  40246. private _warning;
  40247. }
  40248. }
  40249. declare module BABYLON {
  40250. /**
  40251. * Default Inputs manager for the FollowCamera.
  40252. * It groups all the default supported inputs for ease of use.
  40253. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40254. */
  40255. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  40256. /**
  40257. * Instantiates a new FollowCameraInputsManager.
  40258. * @param camera Defines the camera the inputs belong to
  40259. */
  40260. constructor(camera: FollowCamera);
  40261. /**
  40262. * Add keyboard input support to the input manager.
  40263. * @returns the current input manager
  40264. */
  40265. addKeyboard(): FollowCameraInputsManager;
  40266. /**
  40267. * Add mouse wheel input support to the input manager.
  40268. * @returns the current input manager
  40269. */
  40270. addMouseWheel(): FollowCameraInputsManager;
  40271. /**
  40272. * Add pointers input support to the input manager.
  40273. * @returns the current input manager
  40274. */
  40275. addPointers(): FollowCameraInputsManager;
  40276. /**
  40277. * Add orientation input support to the input manager.
  40278. * @returns the current input manager
  40279. */
  40280. addVRDeviceOrientation(): FollowCameraInputsManager;
  40281. }
  40282. }
  40283. declare module BABYLON {
  40284. /**
  40285. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  40286. * an arc rotate version arcFollowCamera are available.
  40287. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40288. */
  40289. export class FollowCamera extends TargetCamera {
  40290. /**
  40291. * Distance the follow camera should follow an object at
  40292. */
  40293. radius: number;
  40294. /**
  40295. * Minimum allowed distance of the camera to the axis of rotation
  40296. * (The camera can not get closer).
  40297. * This can help limiting how the Camera is able to move in the scene.
  40298. */
  40299. lowerRadiusLimit: Nullable<number>;
  40300. /**
  40301. * Maximum allowed distance of the camera to the axis of rotation
  40302. * (The camera can not get further).
  40303. * This can help limiting how the Camera is able to move in the scene.
  40304. */
  40305. upperRadiusLimit: Nullable<number>;
  40306. /**
  40307. * Define a rotation offset between the camera and the object it follows
  40308. */
  40309. rotationOffset: number;
  40310. /**
  40311. * Minimum allowed angle to camera position relative to target object.
  40312. * This can help limiting how the Camera is able to move in the scene.
  40313. */
  40314. lowerRotationOffsetLimit: Nullable<number>;
  40315. /**
  40316. * Maximum allowed angle to camera position relative to target object.
  40317. * This can help limiting how the Camera is able to move in the scene.
  40318. */
  40319. upperRotationOffsetLimit: Nullable<number>;
  40320. /**
  40321. * Define a height offset between the camera and the object it follows.
  40322. * It can help following an object from the top (like a car chaing a plane)
  40323. */
  40324. heightOffset: number;
  40325. /**
  40326. * Minimum allowed height of camera position relative to target object.
  40327. * This can help limiting how the Camera is able to move in the scene.
  40328. */
  40329. lowerHeightOffsetLimit: Nullable<number>;
  40330. /**
  40331. * Maximum allowed height of camera position relative to target object.
  40332. * This can help limiting how the Camera is able to move in the scene.
  40333. */
  40334. upperHeightOffsetLimit: Nullable<number>;
  40335. /**
  40336. * Define how fast the camera can accelerate to follow it s target.
  40337. */
  40338. cameraAcceleration: number;
  40339. /**
  40340. * Define the speed limit of the camera following an object.
  40341. */
  40342. maxCameraSpeed: number;
  40343. /**
  40344. * Define the target of the camera.
  40345. */
  40346. lockedTarget: Nullable<AbstractMesh>;
  40347. /**
  40348. * Defines the input associated with the camera.
  40349. */
  40350. inputs: FollowCameraInputsManager;
  40351. /**
  40352. * Instantiates the follow camera.
  40353. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40354. * @param name Define the name of the camera in the scene
  40355. * @param position Define the position of the camera
  40356. * @param scene Define the scene the camera belong to
  40357. * @param lockedTarget Define the target of the camera
  40358. */
  40359. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  40360. private _follow;
  40361. /**
  40362. * Attached controls to the current camera.
  40363. * @param element Defines the element the controls should be listened from
  40364. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40365. */
  40366. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40367. /**
  40368. * Detach the current controls from the camera.
  40369. * The camera will stop reacting to inputs.
  40370. * @param element Defines the element to stop listening the inputs from
  40371. */
  40372. detachControl(element: HTMLElement): void;
  40373. /** @hidden */
  40374. _checkInputs(): void;
  40375. private _checkLimits;
  40376. /**
  40377. * Gets the camera class name.
  40378. * @returns the class name
  40379. */
  40380. getClassName(): string;
  40381. }
  40382. /**
  40383. * Arc Rotate version of the follow camera.
  40384. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  40385. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40386. */
  40387. export class ArcFollowCamera extends TargetCamera {
  40388. /** The longitudinal angle of the camera */
  40389. alpha: number;
  40390. /** The latitudinal angle of the camera */
  40391. beta: number;
  40392. /** The radius of the camera from its target */
  40393. radius: number;
  40394. /** Define the camera target (the messh it should follow) */
  40395. target: Nullable<AbstractMesh>;
  40396. private _cartesianCoordinates;
  40397. /**
  40398. * Instantiates a new ArcFollowCamera
  40399. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40400. * @param name Define the name of the camera
  40401. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  40402. * @param beta Define the rotation angle of the camera around the elevation axis
  40403. * @param radius Define the radius of the camera from its target point
  40404. * @param target Define the target of the camera
  40405. * @param scene Define the scene the camera belongs to
  40406. */
  40407. constructor(name: string,
  40408. /** The longitudinal angle of the camera */
  40409. alpha: number,
  40410. /** The latitudinal angle of the camera */
  40411. beta: number,
  40412. /** The radius of the camera from its target */
  40413. radius: number,
  40414. /** Define the camera target (the messh it should follow) */
  40415. target: Nullable<AbstractMesh>, scene: Scene);
  40416. private _follow;
  40417. /** @hidden */
  40418. _checkInputs(): void;
  40419. /**
  40420. * Returns the class name of the object.
  40421. * It is mostly used internally for serialization purposes.
  40422. */
  40423. getClassName(): string;
  40424. }
  40425. }
  40426. declare module BABYLON {
  40427. /**
  40428. * Manage the keyboard inputs to control the movement of a follow camera.
  40429. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40430. */
  40431. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  40432. /**
  40433. * Defines the camera the input is attached to.
  40434. */
  40435. camera: FollowCamera;
  40436. /**
  40437. * Defines the list of key codes associated with the up action (increase heightOffset)
  40438. */
  40439. keysHeightOffsetIncr: number[];
  40440. /**
  40441. * Defines the list of key codes associated with the down action (decrease heightOffset)
  40442. */
  40443. keysHeightOffsetDecr: number[];
  40444. /**
  40445. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  40446. */
  40447. keysHeightOffsetModifierAlt: boolean;
  40448. /**
  40449. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  40450. */
  40451. keysHeightOffsetModifierCtrl: boolean;
  40452. /**
  40453. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  40454. */
  40455. keysHeightOffsetModifierShift: boolean;
  40456. /**
  40457. * Defines the list of key codes associated with the left action (increase rotationOffset)
  40458. */
  40459. keysRotationOffsetIncr: number[];
  40460. /**
  40461. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  40462. */
  40463. keysRotationOffsetDecr: number[];
  40464. /**
  40465. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  40466. */
  40467. keysRotationOffsetModifierAlt: boolean;
  40468. /**
  40469. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  40470. */
  40471. keysRotationOffsetModifierCtrl: boolean;
  40472. /**
  40473. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  40474. */
  40475. keysRotationOffsetModifierShift: boolean;
  40476. /**
  40477. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  40478. */
  40479. keysRadiusIncr: number[];
  40480. /**
  40481. * Defines the list of key codes associated with the zoom-out action (increase radius)
  40482. */
  40483. keysRadiusDecr: number[];
  40484. /**
  40485. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  40486. */
  40487. keysRadiusModifierAlt: boolean;
  40488. /**
  40489. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  40490. */
  40491. keysRadiusModifierCtrl: boolean;
  40492. /**
  40493. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  40494. */
  40495. keysRadiusModifierShift: boolean;
  40496. /**
  40497. * Defines the rate of change of heightOffset.
  40498. */
  40499. heightSensibility: number;
  40500. /**
  40501. * Defines the rate of change of rotationOffset.
  40502. */
  40503. rotationSensibility: number;
  40504. /**
  40505. * Defines the rate of change of radius.
  40506. */
  40507. radiusSensibility: number;
  40508. private _keys;
  40509. private _ctrlPressed;
  40510. private _altPressed;
  40511. private _shiftPressed;
  40512. private _onCanvasBlurObserver;
  40513. private _onKeyboardObserver;
  40514. private _engine;
  40515. private _scene;
  40516. /**
  40517. * Attach the input controls to a specific dom element to get the input from.
  40518. * @param element Defines the element the controls should be listened from
  40519. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40520. */
  40521. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40522. /**
  40523. * Detach the current controls from the specified dom element.
  40524. * @param element Defines the element to stop listening the inputs from
  40525. */
  40526. detachControl(element: Nullable<HTMLElement>): void;
  40527. /**
  40528. * Update the current camera state depending on the inputs that have been used this frame.
  40529. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40530. */
  40531. checkInputs(): void;
  40532. /**
  40533. * Gets the class name of the current input.
  40534. * @returns the class name
  40535. */
  40536. getClassName(): string;
  40537. /**
  40538. * Get the friendly name associated with the input class.
  40539. * @returns the input friendly name
  40540. */
  40541. getSimpleName(): string;
  40542. /**
  40543. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  40544. * allow modification of the heightOffset value.
  40545. */
  40546. private _modifierHeightOffset;
  40547. /**
  40548. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  40549. * allow modification of the rotationOffset value.
  40550. */
  40551. private _modifierRotationOffset;
  40552. /**
  40553. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  40554. * allow modification of the radius value.
  40555. */
  40556. private _modifierRadius;
  40557. }
  40558. }
  40559. declare module BABYLON {
  40560. interface FreeCameraInputsManager {
  40561. /**
  40562. * @hidden
  40563. */
  40564. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  40565. /**
  40566. * Add orientation input support to the input manager.
  40567. * @returns the current input manager
  40568. */
  40569. addDeviceOrientation(): FreeCameraInputsManager;
  40570. }
  40571. /**
  40572. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  40573. * Screen rotation is taken into account.
  40574. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40575. */
  40576. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  40577. private _camera;
  40578. private _screenOrientationAngle;
  40579. private _constantTranform;
  40580. private _screenQuaternion;
  40581. private _alpha;
  40582. private _beta;
  40583. private _gamma;
  40584. /**
  40585. * Can be used to detect if a device orientation sensor is available on a device
  40586. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  40587. * @returns a promise that will resolve on orientation change
  40588. */
  40589. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  40590. /**
  40591. * @hidden
  40592. */
  40593. _onDeviceOrientationChangedObservable: Observable<void>;
  40594. /**
  40595. * Instantiates a new input
  40596. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40597. */
  40598. constructor();
  40599. /**
  40600. * Define the camera controlled by the input.
  40601. */
  40602. get camera(): FreeCamera;
  40603. set camera(camera: FreeCamera);
  40604. /**
  40605. * Attach the input controls to a specific dom element to get the input from.
  40606. * @param element Defines the element the controls should be listened from
  40607. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40608. */
  40609. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40610. private _orientationChanged;
  40611. private _deviceOrientation;
  40612. /**
  40613. * Detach the current controls from the specified dom element.
  40614. * @param element Defines the element to stop listening the inputs from
  40615. */
  40616. detachControl(element: Nullable<HTMLElement>): void;
  40617. /**
  40618. * Update the current camera state depending on the inputs that have been used this frame.
  40619. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40620. */
  40621. checkInputs(): void;
  40622. /**
  40623. * Gets the class name of the current intput.
  40624. * @returns the class name
  40625. */
  40626. getClassName(): string;
  40627. /**
  40628. * Get the friendly name associated with the input class.
  40629. * @returns the input friendly name
  40630. */
  40631. getSimpleName(): string;
  40632. }
  40633. }
  40634. declare module BABYLON {
  40635. /**
  40636. * Manage the gamepad inputs to control a free camera.
  40637. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40638. */
  40639. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  40640. /**
  40641. * Define the camera the input is attached to.
  40642. */
  40643. camera: FreeCamera;
  40644. /**
  40645. * Define the Gamepad controlling the input
  40646. */
  40647. gamepad: Nullable<Gamepad>;
  40648. /**
  40649. * Defines the gamepad rotation sensiblity.
  40650. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  40651. */
  40652. gamepadAngularSensibility: number;
  40653. /**
  40654. * Defines the gamepad move sensiblity.
  40655. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  40656. */
  40657. gamepadMoveSensibility: number;
  40658. private _yAxisScale;
  40659. /**
  40660. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  40661. */
  40662. get invertYAxis(): boolean;
  40663. set invertYAxis(value: boolean);
  40664. private _onGamepadConnectedObserver;
  40665. private _onGamepadDisconnectedObserver;
  40666. private _cameraTransform;
  40667. private _deltaTransform;
  40668. private _vector3;
  40669. private _vector2;
  40670. /**
  40671. * Attach the input controls to a specific dom element to get the input from.
  40672. * @param element Defines the element the controls should be listened from
  40673. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40674. */
  40675. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40676. /**
  40677. * Detach the current controls from the specified dom element.
  40678. * @param element Defines the element to stop listening the inputs from
  40679. */
  40680. detachControl(element: Nullable<HTMLElement>): void;
  40681. /**
  40682. * Update the current camera state depending on the inputs that have been used this frame.
  40683. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40684. */
  40685. checkInputs(): void;
  40686. /**
  40687. * Gets the class name of the current intput.
  40688. * @returns the class name
  40689. */
  40690. getClassName(): string;
  40691. /**
  40692. * Get the friendly name associated with the input class.
  40693. * @returns the input friendly name
  40694. */
  40695. getSimpleName(): string;
  40696. }
  40697. }
  40698. declare module BABYLON {
  40699. /**
  40700. * Defines the potential axis of a Joystick
  40701. */
  40702. export enum JoystickAxis {
  40703. /** X axis */
  40704. X = 0,
  40705. /** Y axis */
  40706. Y = 1,
  40707. /** Z axis */
  40708. Z = 2
  40709. }
  40710. /**
  40711. * Class used to define virtual joystick (used in touch mode)
  40712. */
  40713. export class VirtualJoystick {
  40714. /**
  40715. * Gets or sets a boolean indicating that left and right values must be inverted
  40716. */
  40717. reverseLeftRight: boolean;
  40718. /**
  40719. * Gets or sets a boolean indicating that up and down values must be inverted
  40720. */
  40721. reverseUpDown: boolean;
  40722. /**
  40723. * Gets the offset value for the position (ie. the change of the position value)
  40724. */
  40725. deltaPosition: Vector3;
  40726. /**
  40727. * Gets a boolean indicating if the virtual joystick was pressed
  40728. */
  40729. pressed: boolean;
  40730. /**
  40731. * Canvas the virtual joystick will render onto, default z-index of this is 5
  40732. */
  40733. static Canvas: Nullable<HTMLCanvasElement>;
  40734. private static _globalJoystickIndex;
  40735. private static vjCanvasContext;
  40736. private static vjCanvasWidth;
  40737. private static vjCanvasHeight;
  40738. private static halfWidth;
  40739. private _action;
  40740. private _axisTargetedByLeftAndRight;
  40741. private _axisTargetedByUpAndDown;
  40742. private _joystickSensibility;
  40743. private _inversedSensibility;
  40744. private _joystickPointerID;
  40745. private _joystickColor;
  40746. private _joystickPointerPos;
  40747. private _joystickPreviousPointerPos;
  40748. private _joystickPointerStartPos;
  40749. private _deltaJoystickVector;
  40750. private _leftJoystick;
  40751. private _touches;
  40752. private _onPointerDownHandlerRef;
  40753. private _onPointerMoveHandlerRef;
  40754. private _onPointerUpHandlerRef;
  40755. private _onResize;
  40756. /**
  40757. * Creates a new virtual joystick
  40758. * @param leftJoystick defines that the joystick is for left hand (false by default)
  40759. */
  40760. constructor(leftJoystick?: boolean);
  40761. /**
  40762. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  40763. * @param newJoystickSensibility defines the new sensibility
  40764. */
  40765. setJoystickSensibility(newJoystickSensibility: number): void;
  40766. private _onPointerDown;
  40767. private _onPointerMove;
  40768. private _onPointerUp;
  40769. /**
  40770. * Change the color of the virtual joystick
  40771. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  40772. */
  40773. setJoystickColor(newColor: string): void;
  40774. /**
  40775. * Defines a callback to call when the joystick is touched
  40776. * @param action defines the callback
  40777. */
  40778. setActionOnTouch(action: () => any): void;
  40779. /**
  40780. * Defines which axis you'd like to control for left & right
  40781. * @param axis defines the axis to use
  40782. */
  40783. setAxisForLeftRight(axis: JoystickAxis): void;
  40784. /**
  40785. * Defines which axis you'd like to control for up & down
  40786. * @param axis defines the axis to use
  40787. */
  40788. setAxisForUpDown(axis: JoystickAxis): void;
  40789. private _drawVirtualJoystick;
  40790. /**
  40791. * Release internal HTML canvas
  40792. */
  40793. releaseCanvas(): void;
  40794. }
  40795. }
  40796. declare module BABYLON {
  40797. interface FreeCameraInputsManager {
  40798. /**
  40799. * Add virtual joystick input support to the input manager.
  40800. * @returns the current input manager
  40801. */
  40802. addVirtualJoystick(): FreeCameraInputsManager;
  40803. }
  40804. /**
  40805. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  40806. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40807. */
  40808. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  40809. /**
  40810. * Defines the camera the input is attached to.
  40811. */
  40812. camera: FreeCamera;
  40813. private _leftjoystick;
  40814. private _rightjoystick;
  40815. /**
  40816. * Gets the left stick of the virtual joystick.
  40817. * @returns The virtual Joystick
  40818. */
  40819. getLeftJoystick(): VirtualJoystick;
  40820. /**
  40821. * Gets the right stick of the virtual joystick.
  40822. * @returns The virtual Joystick
  40823. */
  40824. getRightJoystick(): VirtualJoystick;
  40825. /**
  40826. * Update the current camera state depending on the inputs that have been used this frame.
  40827. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40828. */
  40829. checkInputs(): void;
  40830. /**
  40831. * Attach the input controls to a specific dom element to get the input from.
  40832. * @param element Defines the element the controls should be listened from
  40833. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40834. */
  40835. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40836. /**
  40837. * Detach the current controls from the specified dom element.
  40838. * @param element Defines the element to stop listening the inputs from
  40839. */
  40840. detachControl(element: Nullable<HTMLElement>): void;
  40841. /**
  40842. * Gets the class name of the current intput.
  40843. * @returns the class name
  40844. */
  40845. getClassName(): string;
  40846. /**
  40847. * Get the friendly name associated with the input class.
  40848. * @returns the input friendly name
  40849. */
  40850. getSimpleName(): string;
  40851. }
  40852. }
  40853. declare module BABYLON {
  40854. /**
  40855. * This represents a FPS type of camera controlled by touch.
  40856. * This is like a universal camera minus the Gamepad controls.
  40857. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40858. */
  40859. export class TouchCamera extends FreeCamera {
  40860. /**
  40861. * Defines the touch sensibility for rotation.
  40862. * The higher the faster.
  40863. */
  40864. get touchAngularSensibility(): number;
  40865. set touchAngularSensibility(value: number);
  40866. /**
  40867. * Defines the touch sensibility for move.
  40868. * The higher the faster.
  40869. */
  40870. get touchMoveSensibility(): number;
  40871. set touchMoveSensibility(value: number);
  40872. /**
  40873. * Instantiates a new touch camera.
  40874. * This represents a FPS type of camera controlled by touch.
  40875. * This is like a universal camera minus the Gamepad controls.
  40876. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40877. * @param name Define the name of the camera in the scene
  40878. * @param position Define the start position of the camera in the scene
  40879. * @param scene Define the scene the camera belongs to
  40880. */
  40881. constructor(name: string, position: Vector3, scene: Scene);
  40882. /**
  40883. * Gets the current object class name.
  40884. * @return the class name
  40885. */
  40886. getClassName(): string;
  40887. /** @hidden */
  40888. _setupInputs(): void;
  40889. }
  40890. }
  40891. declare module BABYLON {
  40892. /**
  40893. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  40894. * being tilted forward or back and left or right.
  40895. */
  40896. export class DeviceOrientationCamera extends FreeCamera {
  40897. private _initialQuaternion;
  40898. private _quaternionCache;
  40899. private _tmpDragQuaternion;
  40900. private _disablePointerInputWhenUsingDeviceOrientation;
  40901. /**
  40902. * Creates a new device orientation camera
  40903. * @param name The name of the camera
  40904. * @param position The start position camera
  40905. * @param scene The scene the camera belongs to
  40906. */
  40907. constructor(name: string, position: Vector3, scene: Scene);
  40908. /**
  40909. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  40910. */
  40911. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  40912. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  40913. private _dragFactor;
  40914. /**
  40915. * Enabled turning on the y axis when the orientation sensor is active
  40916. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  40917. */
  40918. enableHorizontalDragging(dragFactor?: number): void;
  40919. /**
  40920. * Gets the current instance class name ("DeviceOrientationCamera").
  40921. * This helps avoiding instanceof at run time.
  40922. * @returns the class name
  40923. */
  40924. getClassName(): string;
  40925. /**
  40926. * @hidden
  40927. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  40928. */
  40929. _checkInputs(): void;
  40930. /**
  40931. * Reset the camera to its default orientation on the specified axis only.
  40932. * @param axis The axis to reset
  40933. */
  40934. resetToCurrentRotation(axis?: Axis): void;
  40935. }
  40936. }
  40937. declare module BABYLON {
  40938. /**
  40939. * Defines supported buttons for XBox360 compatible gamepads
  40940. */
  40941. export enum Xbox360Button {
  40942. /** A */
  40943. A = 0,
  40944. /** B */
  40945. B = 1,
  40946. /** X */
  40947. X = 2,
  40948. /** Y */
  40949. Y = 3,
  40950. /** Start */
  40951. Start = 4,
  40952. /** Back */
  40953. Back = 5,
  40954. /** Left button */
  40955. LB = 6,
  40956. /** Right button */
  40957. RB = 7,
  40958. /** Left stick */
  40959. LeftStick = 8,
  40960. /** Right stick */
  40961. RightStick = 9
  40962. }
  40963. /** Defines values for XBox360 DPad */
  40964. export enum Xbox360Dpad {
  40965. /** Up */
  40966. Up = 0,
  40967. /** Down */
  40968. Down = 1,
  40969. /** Left */
  40970. Left = 2,
  40971. /** Right */
  40972. Right = 3
  40973. }
  40974. /**
  40975. * Defines a XBox360 gamepad
  40976. */
  40977. export class Xbox360Pad extends Gamepad {
  40978. private _leftTrigger;
  40979. private _rightTrigger;
  40980. private _onlefttriggerchanged;
  40981. private _onrighttriggerchanged;
  40982. private _onbuttondown;
  40983. private _onbuttonup;
  40984. private _ondpaddown;
  40985. private _ondpadup;
  40986. /** Observable raised when a button is pressed */
  40987. onButtonDownObservable: Observable<Xbox360Button>;
  40988. /** Observable raised when a button is released */
  40989. onButtonUpObservable: Observable<Xbox360Button>;
  40990. /** Observable raised when a pad is pressed */
  40991. onPadDownObservable: Observable<Xbox360Dpad>;
  40992. /** Observable raised when a pad is released */
  40993. onPadUpObservable: Observable<Xbox360Dpad>;
  40994. private _buttonA;
  40995. private _buttonB;
  40996. private _buttonX;
  40997. private _buttonY;
  40998. private _buttonBack;
  40999. private _buttonStart;
  41000. private _buttonLB;
  41001. private _buttonRB;
  41002. private _buttonLeftStick;
  41003. private _buttonRightStick;
  41004. private _dPadUp;
  41005. private _dPadDown;
  41006. private _dPadLeft;
  41007. private _dPadRight;
  41008. private _isXboxOnePad;
  41009. /**
  41010. * Creates a new XBox360 gamepad object
  41011. * @param id defines the id of this gamepad
  41012. * @param index defines its index
  41013. * @param gamepad defines the internal HTML gamepad object
  41014. * @param xboxOne defines if it is a XBox One gamepad
  41015. */
  41016. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  41017. /**
  41018. * Defines the callback to call when left trigger is pressed
  41019. * @param callback defines the callback to use
  41020. */
  41021. onlefttriggerchanged(callback: (value: number) => void): void;
  41022. /**
  41023. * Defines the callback to call when right trigger is pressed
  41024. * @param callback defines the callback to use
  41025. */
  41026. onrighttriggerchanged(callback: (value: number) => void): void;
  41027. /**
  41028. * Gets the left trigger value
  41029. */
  41030. get leftTrigger(): number;
  41031. /**
  41032. * Sets the left trigger value
  41033. */
  41034. set leftTrigger(newValue: number);
  41035. /**
  41036. * Gets the right trigger value
  41037. */
  41038. get rightTrigger(): number;
  41039. /**
  41040. * Sets the right trigger value
  41041. */
  41042. set rightTrigger(newValue: number);
  41043. /**
  41044. * Defines the callback to call when a button is pressed
  41045. * @param callback defines the callback to use
  41046. */
  41047. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  41048. /**
  41049. * Defines the callback to call when a button is released
  41050. * @param callback defines the callback to use
  41051. */
  41052. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  41053. /**
  41054. * Defines the callback to call when a pad is pressed
  41055. * @param callback defines the callback to use
  41056. */
  41057. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  41058. /**
  41059. * Defines the callback to call when a pad is released
  41060. * @param callback defines the callback to use
  41061. */
  41062. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  41063. private _setButtonValue;
  41064. private _setDPadValue;
  41065. /**
  41066. * Gets the value of the `A` button
  41067. */
  41068. get buttonA(): number;
  41069. /**
  41070. * Sets the value of the `A` button
  41071. */
  41072. set buttonA(value: number);
  41073. /**
  41074. * Gets the value of the `B` button
  41075. */
  41076. get buttonB(): number;
  41077. /**
  41078. * Sets the value of the `B` button
  41079. */
  41080. set buttonB(value: number);
  41081. /**
  41082. * Gets the value of the `X` button
  41083. */
  41084. get buttonX(): number;
  41085. /**
  41086. * Sets the value of the `X` button
  41087. */
  41088. set buttonX(value: number);
  41089. /**
  41090. * Gets the value of the `Y` button
  41091. */
  41092. get buttonY(): number;
  41093. /**
  41094. * Sets the value of the `Y` button
  41095. */
  41096. set buttonY(value: number);
  41097. /**
  41098. * Gets the value of the `Start` button
  41099. */
  41100. get buttonStart(): number;
  41101. /**
  41102. * Sets the value of the `Start` button
  41103. */
  41104. set buttonStart(value: number);
  41105. /**
  41106. * Gets the value of the `Back` button
  41107. */
  41108. get buttonBack(): number;
  41109. /**
  41110. * Sets the value of the `Back` button
  41111. */
  41112. set buttonBack(value: number);
  41113. /**
  41114. * Gets the value of the `Left` button
  41115. */
  41116. get buttonLB(): number;
  41117. /**
  41118. * Sets the value of the `Left` button
  41119. */
  41120. set buttonLB(value: number);
  41121. /**
  41122. * Gets the value of the `Right` button
  41123. */
  41124. get buttonRB(): number;
  41125. /**
  41126. * Sets the value of the `Right` button
  41127. */
  41128. set buttonRB(value: number);
  41129. /**
  41130. * Gets the value of the Left joystick
  41131. */
  41132. get buttonLeftStick(): number;
  41133. /**
  41134. * Sets the value of the Left joystick
  41135. */
  41136. set buttonLeftStick(value: number);
  41137. /**
  41138. * Gets the value of the Right joystick
  41139. */
  41140. get buttonRightStick(): number;
  41141. /**
  41142. * Sets the value of the Right joystick
  41143. */
  41144. set buttonRightStick(value: number);
  41145. /**
  41146. * Gets the value of D-pad up
  41147. */
  41148. get dPadUp(): number;
  41149. /**
  41150. * Sets the value of D-pad up
  41151. */
  41152. set dPadUp(value: number);
  41153. /**
  41154. * Gets the value of D-pad down
  41155. */
  41156. get dPadDown(): number;
  41157. /**
  41158. * Sets the value of D-pad down
  41159. */
  41160. set dPadDown(value: number);
  41161. /**
  41162. * Gets the value of D-pad left
  41163. */
  41164. get dPadLeft(): number;
  41165. /**
  41166. * Sets the value of D-pad left
  41167. */
  41168. set dPadLeft(value: number);
  41169. /**
  41170. * Gets the value of D-pad right
  41171. */
  41172. get dPadRight(): number;
  41173. /**
  41174. * Sets the value of D-pad right
  41175. */
  41176. set dPadRight(value: number);
  41177. /**
  41178. * Force the gamepad to synchronize with device values
  41179. */
  41180. update(): void;
  41181. /**
  41182. * Disposes the gamepad
  41183. */
  41184. dispose(): void;
  41185. }
  41186. }
  41187. declare module BABYLON {
  41188. /**
  41189. * Defines supported buttons for DualShock compatible gamepads
  41190. */
  41191. export enum DualShockButton {
  41192. /** Cross */
  41193. Cross = 0,
  41194. /** Circle */
  41195. Circle = 1,
  41196. /** Square */
  41197. Square = 2,
  41198. /** Triangle */
  41199. Triangle = 3,
  41200. /** Options */
  41201. Options = 4,
  41202. /** Share */
  41203. Share = 5,
  41204. /** L1 */
  41205. L1 = 6,
  41206. /** R1 */
  41207. R1 = 7,
  41208. /** Left stick */
  41209. LeftStick = 8,
  41210. /** Right stick */
  41211. RightStick = 9
  41212. }
  41213. /** Defines values for DualShock DPad */
  41214. export enum DualShockDpad {
  41215. /** Up */
  41216. Up = 0,
  41217. /** Down */
  41218. Down = 1,
  41219. /** Left */
  41220. Left = 2,
  41221. /** Right */
  41222. Right = 3
  41223. }
  41224. /**
  41225. * Defines a DualShock gamepad
  41226. */
  41227. export class DualShockPad extends Gamepad {
  41228. private _leftTrigger;
  41229. private _rightTrigger;
  41230. private _onlefttriggerchanged;
  41231. private _onrighttriggerchanged;
  41232. private _onbuttondown;
  41233. private _onbuttonup;
  41234. private _ondpaddown;
  41235. private _ondpadup;
  41236. /** Observable raised when a button is pressed */
  41237. onButtonDownObservable: Observable<DualShockButton>;
  41238. /** Observable raised when a button is released */
  41239. onButtonUpObservable: Observable<DualShockButton>;
  41240. /** Observable raised when a pad is pressed */
  41241. onPadDownObservable: Observable<DualShockDpad>;
  41242. /** Observable raised when a pad is released */
  41243. onPadUpObservable: Observable<DualShockDpad>;
  41244. private _buttonCross;
  41245. private _buttonCircle;
  41246. private _buttonSquare;
  41247. private _buttonTriangle;
  41248. private _buttonShare;
  41249. private _buttonOptions;
  41250. private _buttonL1;
  41251. private _buttonR1;
  41252. private _buttonLeftStick;
  41253. private _buttonRightStick;
  41254. private _dPadUp;
  41255. private _dPadDown;
  41256. private _dPadLeft;
  41257. private _dPadRight;
  41258. /**
  41259. * Creates a new DualShock gamepad object
  41260. * @param id defines the id of this gamepad
  41261. * @param index defines its index
  41262. * @param gamepad defines the internal HTML gamepad object
  41263. */
  41264. constructor(id: string, index: number, gamepad: any);
  41265. /**
  41266. * Defines the callback to call when left trigger is pressed
  41267. * @param callback defines the callback to use
  41268. */
  41269. onlefttriggerchanged(callback: (value: number) => void): void;
  41270. /**
  41271. * Defines the callback to call when right trigger is pressed
  41272. * @param callback defines the callback to use
  41273. */
  41274. onrighttriggerchanged(callback: (value: number) => void): void;
  41275. /**
  41276. * Gets the left trigger value
  41277. */
  41278. get leftTrigger(): number;
  41279. /**
  41280. * Sets the left trigger value
  41281. */
  41282. set leftTrigger(newValue: number);
  41283. /**
  41284. * Gets the right trigger value
  41285. */
  41286. get rightTrigger(): number;
  41287. /**
  41288. * Sets the right trigger value
  41289. */
  41290. set rightTrigger(newValue: number);
  41291. /**
  41292. * Defines the callback to call when a button is pressed
  41293. * @param callback defines the callback to use
  41294. */
  41295. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  41296. /**
  41297. * Defines the callback to call when a button is released
  41298. * @param callback defines the callback to use
  41299. */
  41300. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  41301. /**
  41302. * Defines the callback to call when a pad is pressed
  41303. * @param callback defines the callback to use
  41304. */
  41305. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  41306. /**
  41307. * Defines the callback to call when a pad is released
  41308. * @param callback defines the callback to use
  41309. */
  41310. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  41311. private _setButtonValue;
  41312. private _setDPadValue;
  41313. /**
  41314. * Gets the value of the `Cross` button
  41315. */
  41316. get buttonCross(): number;
  41317. /**
  41318. * Sets the value of the `Cross` button
  41319. */
  41320. set buttonCross(value: number);
  41321. /**
  41322. * Gets the value of the `Circle` button
  41323. */
  41324. get buttonCircle(): number;
  41325. /**
  41326. * Sets the value of the `Circle` button
  41327. */
  41328. set buttonCircle(value: number);
  41329. /**
  41330. * Gets the value of the `Square` button
  41331. */
  41332. get buttonSquare(): number;
  41333. /**
  41334. * Sets the value of the `Square` button
  41335. */
  41336. set buttonSquare(value: number);
  41337. /**
  41338. * Gets the value of the `Triangle` button
  41339. */
  41340. get buttonTriangle(): number;
  41341. /**
  41342. * Sets the value of the `Triangle` button
  41343. */
  41344. set buttonTriangle(value: number);
  41345. /**
  41346. * Gets the value of the `Options` button
  41347. */
  41348. get buttonOptions(): number;
  41349. /**
  41350. * Sets the value of the `Options` button
  41351. */
  41352. set buttonOptions(value: number);
  41353. /**
  41354. * Gets the value of the `Share` button
  41355. */
  41356. get buttonShare(): number;
  41357. /**
  41358. * Sets the value of the `Share` button
  41359. */
  41360. set buttonShare(value: number);
  41361. /**
  41362. * Gets the value of the `L1` button
  41363. */
  41364. get buttonL1(): number;
  41365. /**
  41366. * Sets the value of the `L1` button
  41367. */
  41368. set buttonL1(value: number);
  41369. /**
  41370. * Gets the value of the `R1` button
  41371. */
  41372. get buttonR1(): number;
  41373. /**
  41374. * Sets the value of the `R1` button
  41375. */
  41376. set buttonR1(value: number);
  41377. /**
  41378. * Gets the value of the Left joystick
  41379. */
  41380. get buttonLeftStick(): number;
  41381. /**
  41382. * Sets the value of the Left joystick
  41383. */
  41384. set buttonLeftStick(value: number);
  41385. /**
  41386. * Gets the value of the Right joystick
  41387. */
  41388. get buttonRightStick(): number;
  41389. /**
  41390. * Sets the value of the Right joystick
  41391. */
  41392. set buttonRightStick(value: number);
  41393. /**
  41394. * Gets the value of D-pad up
  41395. */
  41396. get dPadUp(): number;
  41397. /**
  41398. * Sets the value of D-pad up
  41399. */
  41400. set dPadUp(value: number);
  41401. /**
  41402. * Gets the value of D-pad down
  41403. */
  41404. get dPadDown(): number;
  41405. /**
  41406. * Sets the value of D-pad down
  41407. */
  41408. set dPadDown(value: number);
  41409. /**
  41410. * Gets the value of D-pad left
  41411. */
  41412. get dPadLeft(): number;
  41413. /**
  41414. * Sets the value of D-pad left
  41415. */
  41416. set dPadLeft(value: number);
  41417. /**
  41418. * Gets the value of D-pad right
  41419. */
  41420. get dPadRight(): number;
  41421. /**
  41422. * Sets the value of D-pad right
  41423. */
  41424. set dPadRight(value: number);
  41425. /**
  41426. * Force the gamepad to synchronize with device values
  41427. */
  41428. update(): void;
  41429. /**
  41430. * Disposes the gamepad
  41431. */
  41432. dispose(): void;
  41433. }
  41434. }
  41435. declare module BABYLON {
  41436. /**
  41437. * Manager for handling gamepads
  41438. */
  41439. export class GamepadManager {
  41440. private _scene?;
  41441. private _babylonGamepads;
  41442. private _oneGamepadConnected;
  41443. /** @hidden */
  41444. _isMonitoring: boolean;
  41445. private _gamepadEventSupported;
  41446. private _gamepadSupport?;
  41447. /**
  41448. * observable to be triggered when the gamepad controller has been connected
  41449. */
  41450. onGamepadConnectedObservable: Observable<Gamepad>;
  41451. /**
  41452. * observable to be triggered when the gamepad controller has been disconnected
  41453. */
  41454. onGamepadDisconnectedObservable: Observable<Gamepad>;
  41455. private _onGamepadConnectedEvent;
  41456. private _onGamepadDisconnectedEvent;
  41457. /**
  41458. * Initializes the gamepad manager
  41459. * @param _scene BabylonJS scene
  41460. */
  41461. constructor(_scene?: Scene | undefined);
  41462. /**
  41463. * The gamepads in the game pad manager
  41464. */
  41465. get gamepads(): Gamepad[];
  41466. /**
  41467. * Get the gamepad controllers based on type
  41468. * @param type The type of gamepad controller
  41469. * @returns Nullable gamepad
  41470. */
  41471. getGamepadByType(type?: number): Nullable<Gamepad>;
  41472. /**
  41473. * Disposes the gamepad manager
  41474. */
  41475. dispose(): void;
  41476. private _addNewGamepad;
  41477. private _startMonitoringGamepads;
  41478. private _stopMonitoringGamepads;
  41479. /** @hidden */
  41480. _checkGamepadsStatus(): void;
  41481. private _updateGamepadObjects;
  41482. }
  41483. }
  41484. declare module BABYLON {
  41485. interface Scene {
  41486. /** @hidden */
  41487. _gamepadManager: Nullable<GamepadManager>;
  41488. /**
  41489. * Gets the gamepad manager associated with the scene
  41490. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  41491. */
  41492. gamepadManager: GamepadManager;
  41493. }
  41494. /**
  41495. * Interface representing a free camera inputs manager
  41496. */
  41497. interface FreeCameraInputsManager {
  41498. /**
  41499. * Adds gamepad input support to the FreeCameraInputsManager.
  41500. * @returns the FreeCameraInputsManager
  41501. */
  41502. addGamepad(): FreeCameraInputsManager;
  41503. }
  41504. /**
  41505. * Interface representing an arc rotate camera inputs manager
  41506. */
  41507. interface ArcRotateCameraInputsManager {
  41508. /**
  41509. * Adds gamepad input support to the ArcRotateCamera InputManager.
  41510. * @returns the camera inputs manager
  41511. */
  41512. addGamepad(): ArcRotateCameraInputsManager;
  41513. }
  41514. /**
  41515. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  41516. */
  41517. export class GamepadSystemSceneComponent implements ISceneComponent {
  41518. /**
  41519. * The component name helpfull to identify the component in the list of scene components.
  41520. */
  41521. readonly name: string;
  41522. /**
  41523. * The scene the component belongs to.
  41524. */
  41525. scene: Scene;
  41526. /**
  41527. * Creates a new instance of the component for the given scene
  41528. * @param scene Defines the scene to register the component in
  41529. */
  41530. constructor(scene: Scene);
  41531. /**
  41532. * Registers the component in a given scene
  41533. */
  41534. register(): void;
  41535. /**
  41536. * Rebuilds the elements related to this component in case of
  41537. * context lost for instance.
  41538. */
  41539. rebuild(): void;
  41540. /**
  41541. * Disposes the component and the associated ressources
  41542. */
  41543. dispose(): void;
  41544. private _beforeCameraUpdate;
  41545. }
  41546. }
  41547. declare module BABYLON {
  41548. /**
  41549. * 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,
  41550. * which still works and will still be found in many Playgrounds.
  41551. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41552. */
  41553. export class UniversalCamera extends TouchCamera {
  41554. /**
  41555. * Defines the gamepad rotation sensiblity.
  41556. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  41557. */
  41558. get gamepadAngularSensibility(): number;
  41559. set gamepadAngularSensibility(value: number);
  41560. /**
  41561. * Defines the gamepad move sensiblity.
  41562. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  41563. */
  41564. get gamepadMoveSensibility(): number;
  41565. set gamepadMoveSensibility(value: number);
  41566. /**
  41567. * 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,
  41568. * which still works and will still be found in many Playgrounds.
  41569. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41570. * @param name Define the name of the camera in the scene
  41571. * @param position Define the start position of the camera in the scene
  41572. * @param scene Define the scene the camera belongs to
  41573. */
  41574. constructor(name: string, position: Vector3, scene: Scene);
  41575. /**
  41576. * Gets the current object class name.
  41577. * @return the class name
  41578. */
  41579. getClassName(): string;
  41580. }
  41581. }
  41582. declare module BABYLON {
  41583. /**
  41584. * This represents a FPS type of camera. This is only here for back compat purpose.
  41585. * Please use the UniversalCamera instead as both are identical.
  41586. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41587. */
  41588. export class GamepadCamera extends UniversalCamera {
  41589. /**
  41590. * Instantiates a new Gamepad Camera
  41591. * This represents a FPS type of camera. This is only here for back compat purpose.
  41592. * Please use the UniversalCamera instead as both are identical.
  41593. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41594. * @param name Define the name of the camera in the scene
  41595. * @param position Define the start position of the camera in the scene
  41596. * @param scene Define the scene the camera belongs to
  41597. */
  41598. constructor(name: string, position: Vector3, scene: Scene);
  41599. /**
  41600. * Gets the current object class name.
  41601. * @return the class name
  41602. */
  41603. getClassName(): string;
  41604. }
  41605. }
  41606. declare module BABYLON {
  41607. /** @hidden */
  41608. export var passPixelShader: {
  41609. name: string;
  41610. shader: string;
  41611. };
  41612. }
  41613. declare module BABYLON {
  41614. /** @hidden */
  41615. export var passCubePixelShader: {
  41616. name: string;
  41617. shader: string;
  41618. };
  41619. }
  41620. declare module BABYLON {
  41621. /**
  41622. * PassPostProcess which produces an output the same as it's input
  41623. */
  41624. export class PassPostProcess extends PostProcess {
  41625. /**
  41626. * Creates the PassPostProcess
  41627. * @param name The name of the effect.
  41628. * @param options The required width/height ratio to downsize to before computing the render pass.
  41629. * @param camera The camera to apply the render pass to.
  41630. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  41631. * @param engine The engine which the post process will be applied. (default: current engine)
  41632. * @param reusable If the post process can be reused on the same frame. (default: false)
  41633. * @param textureType The type of texture to be used when performing the post processing.
  41634. * @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)
  41635. */
  41636. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  41637. }
  41638. /**
  41639. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  41640. */
  41641. export class PassCubePostProcess extends PostProcess {
  41642. private _face;
  41643. /**
  41644. * Gets or sets the cube face to display.
  41645. * * 0 is +X
  41646. * * 1 is -X
  41647. * * 2 is +Y
  41648. * * 3 is -Y
  41649. * * 4 is +Z
  41650. * * 5 is -Z
  41651. */
  41652. get face(): number;
  41653. set face(value: number);
  41654. /**
  41655. * Creates the PassCubePostProcess
  41656. * @param name The name of the effect.
  41657. * @param options The required width/height ratio to downsize to before computing the render pass.
  41658. * @param camera The camera to apply the render pass to.
  41659. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  41660. * @param engine The engine which the post process will be applied. (default: current engine)
  41661. * @param reusable If the post process can be reused on the same frame. (default: false)
  41662. * @param textureType The type of texture to be used when performing the post processing.
  41663. * @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)
  41664. */
  41665. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  41666. }
  41667. }
  41668. declare module BABYLON {
  41669. /** @hidden */
  41670. export var anaglyphPixelShader: {
  41671. name: string;
  41672. shader: string;
  41673. };
  41674. }
  41675. declare module BABYLON {
  41676. /**
  41677. * Postprocess used to generate anaglyphic rendering
  41678. */
  41679. export class AnaglyphPostProcess extends PostProcess {
  41680. private _passedProcess;
  41681. /**
  41682. * Creates a new AnaglyphPostProcess
  41683. * @param name defines postprocess name
  41684. * @param options defines creation options or target ratio scale
  41685. * @param rigCameras defines cameras using this postprocess
  41686. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  41687. * @param engine defines hosting engine
  41688. * @param reusable defines if the postprocess will be reused multiple times per frame
  41689. */
  41690. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  41691. }
  41692. }
  41693. declare module BABYLON {
  41694. /**
  41695. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  41696. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41697. */
  41698. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  41699. /**
  41700. * Creates a new AnaglyphArcRotateCamera
  41701. * @param name defines camera name
  41702. * @param alpha defines alpha angle (in radians)
  41703. * @param beta defines beta angle (in radians)
  41704. * @param radius defines radius
  41705. * @param target defines camera target
  41706. * @param interaxialDistance defines distance between each color axis
  41707. * @param scene defines the hosting scene
  41708. */
  41709. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  41710. /**
  41711. * Gets camera class name
  41712. * @returns AnaglyphArcRotateCamera
  41713. */
  41714. getClassName(): string;
  41715. }
  41716. }
  41717. declare module BABYLON {
  41718. /**
  41719. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  41720. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41721. */
  41722. export class AnaglyphFreeCamera extends FreeCamera {
  41723. /**
  41724. * Creates a new AnaglyphFreeCamera
  41725. * @param name defines camera name
  41726. * @param position defines initial position
  41727. * @param interaxialDistance defines distance between each color axis
  41728. * @param scene defines the hosting scene
  41729. */
  41730. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  41731. /**
  41732. * Gets camera class name
  41733. * @returns AnaglyphFreeCamera
  41734. */
  41735. getClassName(): string;
  41736. }
  41737. }
  41738. declare module BABYLON {
  41739. /**
  41740. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  41741. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41742. */
  41743. export class AnaglyphGamepadCamera extends GamepadCamera {
  41744. /**
  41745. * Creates a new AnaglyphGamepadCamera
  41746. * @param name defines camera name
  41747. * @param position defines initial position
  41748. * @param interaxialDistance defines distance between each color axis
  41749. * @param scene defines the hosting scene
  41750. */
  41751. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  41752. /**
  41753. * Gets camera class name
  41754. * @returns AnaglyphGamepadCamera
  41755. */
  41756. getClassName(): string;
  41757. }
  41758. }
  41759. declare module BABYLON {
  41760. /**
  41761. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  41762. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41763. */
  41764. export class AnaglyphUniversalCamera extends UniversalCamera {
  41765. /**
  41766. * Creates a new AnaglyphUniversalCamera
  41767. * @param name defines camera name
  41768. * @param position defines initial position
  41769. * @param interaxialDistance defines distance between each color axis
  41770. * @param scene defines the hosting scene
  41771. */
  41772. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  41773. /**
  41774. * Gets camera class name
  41775. * @returns AnaglyphUniversalCamera
  41776. */
  41777. getClassName(): string;
  41778. }
  41779. }
  41780. declare module BABYLON {
  41781. /** @hidden */
  41782. export var stereoscopicInterlacePixelShader: {
  41783. name: string;
  41784. shader: string;
  41785. };
  41786. }
  41787. declare module BABYLON {
  41788. /**
  41789. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  41790. */
  41791. export class StereoscopicInterlacePostProcessI extends PostProcess {
  41792. private _stepSize;
  41793. private _passedProcess;
  41794. /**
  41795. * Initializes a StereoscopicInterlacePostProcessI
  41796. * @param name The name of the effect.
  41797. * @param rigCameras The rig cameras to be appled to the post process
  41798. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  41799. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  41800. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  41801. * @param engine The engine which the post process will be applied. (default: current engine)
  41802. * @param reusable If the post process can be reused on the same frame. (default: false)
  41803. */
  41804. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  41805. }
  41806. /**
  41807. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  41808. */
  41809. export class StereoscopicInterlacePostProcess extends PostProcess {
  41810. private _stepSize;
  41811. private _passedProcess;
  41812. /**
  41813. * Initializes a StereoscopicInterlacePostProcess
  41814. * @param name The name of the effect.
  41815. * @param rigCameras The rig cameras to be appled to the post process
  41816. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  41817. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  41818. * @param engine The engine which the post process will be applied. (default: current engine)
  41819. * @param reusable If the post process can be reused on the same frame. (default: false)
  41820. */
  41821. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  41822. }
  41823. }
  41824. declare module BABYLON {
  41825. /**
  41826. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  41827. * @see http://doc.babylonjs.com/features/cameras
  41828. */
  41829. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  41830. /**
  41831. * Creates a new StereoscopicArcRotateCamera
  41832. * @param name defines camera name
  41833. * @param alpha defines alpha angle (in radians)
  41834. * @param beta defines beta angle (in radians)
  41835. * @param radius defines radius
  41836. * @param target defines camera target
  41837. * @param interaxialDistance defines distance between each color axis
  41838. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41839. * @param scene defines the hosting scene
  41840. */
  41841. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41842. /**
  41843. * Gets camera class name
  41844. * @returns StereoscopicArcRotateCamera
  41845. */
  41846. getClassName(): string;
  41847. }
  41848. }
  41849. declare module BABYLON {
  41850. /**
  41851. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  41852. * @see http://doc.babylonjs.com/features/cameras
  41853. */
  41854. export class StereoscopicFreeCamera extends FreeCamera {
  41855. /**
  41856. * Creates a new StereoscopicFreeCamera
  41857. * @param name defines camera name
  41858. * @param position defines initial position
  41859. * @param interaxialDistance defines distance between each color axis
  41860. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41861. * @param scene defines the hosting scene
  41862. */
  41863. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41864. /**
  41865. * Gets camera class name
  41866. * @returns StereoscopicFreeCamera
  41867. */
  41868. getClassName(): string;
  41869. }
  41870. }
  41871. declare module BABYLON {
  41872. /**
  41873. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  41874. * @see http://doc.babylonjs.com/features/cameras
  41875. */
  41876. export class StereoscopicGamepadCamera extends GamepadCamera {
  41877. /**
  41878. * Creates a new StereoscopicGamepadCamera
  41879. * @param name defines camera name
  41880. * @param position defines initial position
  41881. * @param interaxialDistance defines distance between each color axis
  41882. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41883. * @param scene defines the hosting scene
  41884. */
  41885. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41886. /**
  41887. * Gets camera class name
  41888. * @returns StereoscopicGamepadCamera
  41889. */
  41890. getClassName(): string;
  41891. }
  41892. }
  41893. declare module BABYLON {
  41894. /**
  41895. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  41896. * @see http://doc.babylonjs.com/features/cameras
  41897. */
  41898. export class StereoscopicUniversalCamera extends UniversalCamera {
  41899. /**
  41900. * Creates a new StereoscopicUniversalCamera
  41901. * @param name defines camera name
  41902. * @param position defines initial position
  41903. * @param interaxialDistance defines distance between each color axis
  41904. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41905. * @param scene defines the hosting scene
  41906. */
  41907. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41908. /**
  41909. * Gets camera class name
  41910. * @returns StereoscopicUniversalCamera
  41911. */
  41912. getClassName(): string;
  41913. }
  41914. }
  41915. declare module BABYLON {
  41916. /**
  41917. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  41918. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  41919. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  41920. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  41921. */
  41922. export class VirtualJoysticksCamera extends FreeCamera {
  41923. /**
  41924. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  41925. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  41926. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  41927. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  41928. * @param name Define the name of the camera in the scene
  41929. * @param position Define the start position of the camera in the scene
  41930. * @param scene Define the scene the camera belongs to
  41931. */
  41932. constructor(name: string, position: Vector3, scene: Scene);
  41933. /**
  41934. * Gets the current object class name.
  41935. * @return the class name
  41936. */
  41937. getClassName(): string;
  41938. }
  41939. }
  41940. declare module BABYLON {
  41941. /**
  41942. * This represents all the required metrics to create a VR camera.
  41943. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  41944. */
  41945. export class VRCameraMetrics {
  41946. /**
  41947. * Define the horizontal resolution off the screen.
  41948. */
  41949. hResolution: number;
  41950. /**
  41951. * Define the vertical resolution off the screen.
  41952. */
  41953. vResolution: number;
  41954. /**
  41955. * Define the horizontal screen size.
  41956. */
  41957. hScreenSize: number;
  41958. /**
  41959. * Define the vertical screen size.
  41960. */
  41961. vScreenSize: number;
  41962. /**
  41963. * Define the vertical screen center position.
  41964. */
  41965. vScreenCenter: number;
  41966. /**
  41967. * Define the distance of the eyes to the screen.
  41968. */
  41969. eyeToScreenDistance: number;
  41970. /**
  41971. * Define the distance between both lenses
  41972. */
  41973. lensSeparationDistance: number;
  41974. /**
  41975. * Define the distance between both viewer's eyes.
  41976. */
  41977. interpupillaryDistance: number;
  41978. /**
  41979. * Define the distortion factor of the VR postprocess.
  41980. * Please, touch with care.
  41981. */
  41982. distortionK: number[];
  41983. /**
  41984. * Define the chromatic aberration correction factors for the VR post process.
  41985. */
  41986. chromaAbCorrection: number[];
  41987. /**
  41988. * Define the scale factor of the post process.
  41989. * The smaller the better but the slower.
  41990. */
  41991. postProcessScaleFactor: number;
  41992. /**
  41993. * Define an offset for the lens center.
  41994. */
  41995. lensCenterOffset: number;
  41996. /**
  41997. * Define if the current vr camera should compensate the distortion of the lense or not.
  41998. */
  41999. compensateDistortion: boolean;
  42000. /**
  42001. * Defines if multiview should be enabled when rendering (Default: false)
  42002. */
  42003. multiviewEnabled: boolean;
  42004. /**
  42005. * Gets the rendering aspect ratio based on the provided resolutions.
  42006. */
  42007. get aspectRatio(): number;
  42008. /**
  42009. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  42010. */
  42011. get aspectRatioFov(): number;
  42012. /**
  42013. * @hidden
  42014. */
  42015. get leftHMatrix(): Matrix;
  42016. /**
  42017. * @hidden
  42018. */
  42019. get rightHMatrix(): Matrix;
  42020. /**
  42021. * @hidden
  42022. */
  42023. get leftPreViewMatrix(): Matrix;
  42024. /**
  42025. * @hidden
  42026. */
  42027. get rightPreViewMatrix(): Matrix;
  42028. /**
  42029. * Get the default VRMetrics based on the most generic setup.
  42030. * @returns the default vr metrics
  42031. */
  42032. static GetDefault(): VRCameraMetrics;
  42033. }
  42034. }
  42035. declare module BABYLON {
  42036. /** @hidden */
  42037. export var vrDistortionCorrectionPixelShader: {
  42038. name: string;
  42039. shader: string;
  42040. };
  42041. }
  42042. declare module BABYLON {
  42043. /**
  42044. * VRDistortionCorrectionPostProcess used for mobile VR
  42045. */
  42046. export class VRDistortionCorrectionPostProcess extends PostProcess {
  42047. private _isRightEye;
  42048. private _distortionFactors;
  42049. private _postProcessScaleFactor;
  42050. private _lensCenterOffset;
  42051. private _scaleIn;
  42052. private _scaleFactor;
  42053. private _lensCenter;
  42054. /**
  42055. * Initializes the VRDistortionCorrectionPostProcess
  42056. * @param name The name of the effect.
  42057. * @param camera The camera to apply the render pass to.
  42058. * @param isRightEye If this is for the right eye distortion
  42059. * @param vrMetrics All the required metrics for the VR camera
  42060. */
  42061. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  42062. }
  42063. }
  42064. declare module BABYLON {
  42065. /**
  42066. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  42067. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  42068. */
  42069. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  42070. /**
  42071. * Creates a new VRDeviceOrientationArcRotateCamera
  42072. * @param name defines camera name
  42073. * @param alpha defines the camera rotation along the logitudinal axis
  42074. * @param beta defines the camera rotation along the latitudinal axis
  42075. * @param radius defines the camera distance from its target
  42076. * @param target defines the camera target
  42077. * @param scene defines the scene the camera belongs to
  42078. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  42079. * @param vrCameraMetrics defines the vr metrics associated to the camera
  42080. */
  42081. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  42082. /**
  42083. * Gets camera class name
  42084. * @returns VRDeviceOrientationArcRotateCamera
  42085. */
  42086. getClassName(): string;
  42087. }
  42088. }
  42089. declare module BABYLON {
  42090. /**
  42091. * Camera used to simulate VR rendering (based on FreeCamera)
  42092. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  42093. */
  42094. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  42095. /**
  42096. * Creates a new VRDeviceOrientationFreeCamera
  42097. * @param name defines camera name
  42098. * @param position defines the start position of the camera
  42099. * @param scene defines the scene the camera belongs to
  42100. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  42101. * @param vrCameraMetrics defines the vr metrics associated to the camera
  42102. */
  42103. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  42104. /**
  42105. * Gets camera class name
  42106. * @returns VRDeviceOrientationFreeCamera
  42107. */
  42108. getClassName(): string;
  42109. }
  42110. }
  42111. declare module BABYLON {
  42112. /**
  42113. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  42114. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  42115. */
  42116. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  42117. /**
  42118. * Creates a new VRDeviceOrientationGamepadCamera
  42119. * @param name defines camera name
  42120. * @param position defines the start position of the camera
  42121. * @param scene defines the scene the camera belongs to
  42122. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  42123. * @param vrCameraMetrics defines the vr metrics associated to the camera
  42124. */
  42125. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  42126. /**
  42127. * Gets camera class name
  42128. * @returns VRDeviceOrientationGamepadCamera
  42129. */
  42130. getClassName(): string;
  42131. }
  42132. }
  42133. declare module BABYLON {
  42134. /** @hidden */
  42135. export var imageProcessingPixelShader: {
  42136. name: string;
  42137. shader: string;
  42138. };
  42139. }
  42140. declare module BABYLON {
  42141. /**
  42142. * ImageProcessingPostProcess
  42143. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  42144. */
  42145. export class ImageProcessingPostProcess extends PostProcess {
  42146. /**
  42147. * Default configuration related to image processing available in the PBR Material.
  42148. */
  42149. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  42150. /**
  42151. * Gets the image processing configuration used either in this material.
  42152. */
  42153. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  42154. /**
  42155. * Sets the Default image processing configuration used either in the this material.
  42156. *
  42157. * If sets to null, the scene one is in use.
  42158. */
  42159. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  42160. /**
  42161. * Keep track of the image processing observer to allow dispose and replace.
  42162. */
  42163. private _imageProcessingObserver;
  42164. /**
  42165. * Attaches a new image processing configuration to the PBR Material.
  42166. * @param configuration
  42167. */
  42168. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  42169. /**
  42170. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  42171. */
  42172. get colorCurves(): Nullable<ColorCurves>;
  42173. /**
  42174. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  42175. */
  42176. set colorCurves(value: Nullable<ColorCurves>);
  42177. /**
  42178. * Gets wether the color curves effect is enabled.
  42179. */
  42180. get colorCurvesEnabled(): boolean;
  42181. /**
  42182. * Sets wether the color curves effect is enabled.
  42183. */
  42184. set colorCurvesEnabled(value: boolean);
  42185. /**
  42186. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  42187. */
  42188. get colorGradingTexture(): Nullable<BaseTexture>;
  42189. /**
  42190. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  42191. */
  42192. set colorGradingTexture(value: Nullable<BaseTexture>);
  42193. /**
  42194. * Gets wether the color grading effect is enabled.
  42195. */
  42196. get colorGradingEnabled(): boolean;
  42197. /**
  42198. * Gets wether the color grading effect is enabled.
  42199. */
  42200. set colorGradingEnabled(value: boolean);
  42201. /**
  42202. * Gets exposure used in the effect.
  42203. */
  42204. get exposure(): number;
  42205. /**
  42206. * Sets exposure used in the effect.
  42207. */
  42208. set exposure(value: number);
  42209. /**
  42210. * Gets wether tonemapping is enabled or not.
  42211. */
  42212. get toneMappingEnabled(): boolean;
  42213. /**
  42214. * Sets wether tonemapping is enabled or not
  42215. */
  42216. set toneMappingEnabled(value: boolean);
  42217. /**
  42218. * Gets the type of tone mapping effect.
  42219. */
  42220. get toneMappingType(): number;
  42221. /**
  42222. * Sets the type of tone mapping effect.
  42223. */
  42224. set toneMappingType(value: number);
  42225. /**
  42226. * Gets contrast used in the effect.
  42227. */
  42228. get contrast(): number;
  42229. /**
  42230. * Sets contrast used in the effect.
  42231. */
  42232. set contrast(value: number);
  42233. /**
  42234. * Gets Vignette stretch size.
  42235. */
  42236. get vignetteStretch(): number;
  42237. /**
  42238. * Sets Vignette stretch size.
  42239. */
  42240. set vignetteStretch(value: number);
  42241. /**
  42242. * Gets Vignette centre X Offset.
  42243. */
  42244. get vignetteCentreX(): number;
  42245. /**
  42246. * Sets Vignette centre X Offset.
  42247. */
  42248. set vignetteCentreX(value: number);
  42249. /**
  42250. * Gets Vignette centre Y Offset.
  42251. */
  42252. get vignetteCentreY(): number;
  42253. /**
  42254. * Sets Vignette centre Y Offset.
  42255. */
  42256. set vignetteCentreY(value: number);
  42257. /**
  42258. * Gets Vignette weight or intensity of the vignette effect.
  42259. */
  42260. get vignetteWeight(): number;
  42261. /**
  42262. * Sets Vignette weight or intensity of the vignette effect.
  42263. */
  42264. set vignetteWeight(value: number);
  42265. /**
  42266. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  42267. * if vignetteEnabled is set to true.
  42268. */
  42269. get vignetteColor(): Color4;
  42270. /**
  42271. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  42272. * if vignetteEnabled is set to true.
  42273. */
  42274. set vignetteColor(value: Color4);
  42275. /**
  42276. * Gets Camera field of view used by the Vignette effect.
  42277. */
  42278. get vignetteCameraFov(): number;
  42279. /**
  42280. * Sets Camera field of view used by the Vignette effect.
  42281. */
  42282. set vignetteCameraFov(value: number);
  42283. /**
  42284. * Gets the vignette blend mode allowing different kind of effect.
  42285. */
  42286. get vignetteBlendMode(): number;
  42287. /**
  42288. * Sets the vignette blend mode allowing different kind of effect.
  42289. */
  42290. set vignetteBlendMode(value: number);
  42291. /**
  42292. * Gets wether the vignette effect is enabled.
  42293. */
  42294. get vignetteEnabled(): boolean;
  42295. /**
  42296. * Sets wether the vignette effect is enabled.
  42297. */
  42298. set vignetteEnabled(value: boolean);
  42299. private _fromLinearSpace;
  42300. /**
  42301. * Gets wether the input of the processing is in Gamma or Linear Space.
  42302. */
  42303. get fromLinearSpace(): boolean;
  42304. /**
  42305. * Sets wether the input of the processing is in Gamma or Linear Space.
  42306. */
  42307. set fromLinearSpace(value: boolean);
  42308. /**
  42309. * Defines cache preventing GC.
  42310. */
  42311. private _defines;
  42312. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  42313. /**
  42314. * "ImageProcessingPostProcess"
  42315. * @returns "ImageProcessingPostProcess"
  42316. */
  42317. getClassName(): string;
  42318. protected _updateParameters(): void;
  42319. dispose(camera?: Camera): void;
  42320. }
  42321. }
  42322. declare module BABYLON {
  42323. /**
  42324. * Class containing static functions to help procedurally build meshes
  42325. */
  42326. export class GroundBuilder {
  42327. /**
  42328. * Creates a ground mesh
  42329. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  42330. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  42331. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42332. * @param name defines the name of the mesh
  42333. * @param options defines the options used to create the mesh
  42334. * @param scene defines the hosting scene
  42335. * @returns the ground mesh
  42336. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  42337. */
  42338. static CreateGround(name: string, options: {
  42339. width?: number;
  42340. height?: number;
  42341. subdivisions?: number;
  42342. subdivisionsX?: number;
  42343. subdivisionsY?: number;
  42344. updatable?: boolean;
  42345. }, scene: any): Mesh;
  42346. /**
  42347. * Creates a tiled ground mesh
  42348. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  42349. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  42350. * * 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
  42351. * * 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
  42352. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42353. * @param name defines the name of the mesh
  42354. * @param options defines the options used to create the mesh
  42355. * @param scene defines the hosting scene
  42356. * @returns the tiled ground mesh
  42357. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  42358. */
  42359. static CreateTiledGround(name: string, options: {
  42360. xmin: number;
  42361. zmin: number;
  42362. xmax: number;
  42363. zmax: number;
  42364. subdivisions?: {
  42365. w: number;
  42366. h: number;
  42367. };
  42368. precision?: {
  42369. w: number;
  42370. h: number;
  42371. };
  42372. updatable?: boolean;
  42373. }, scene?: Nullable<Scene>): Mesh;
  42374. /**
  42375. * Creates a ground mesh from a height map
  42376. * * The parameter `url` sets the URL of the height map image resource.
  42377. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  42378. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  42379. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  42380. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  42381. * * 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.
  42382. * * 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).
  42383. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  42384. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42385. * @param name defines the name of the mesh
  42386. * @param url defines the url to the height map
  42387. * @param options defines the options used to create the mesh
  42388. * @param scene defines the hosting scene
  42389. * @returns the ground mesh
  42390. * @see https://doc.babylonjs.com/babylon101/height_map
  42391. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  42392. */
  42393. static CreateGroundFromHeightMap(name: string, url: string, options: {
  42394. width?: number;
  42395. height?: number;
  42396. subdivisions?: number;
  42397. minHeight?: number;
  42398. maxHeight?: number;
  42399. colorFilter?: Color3;
  42400. alphaFilter?: number;
  42401. updatable?: boolean;
  42402. onReady?: (mesh: GroundMesh) => void;
  42403. }, scene?: Nullable<Scene>): GroundMesh;
  42404. }
  42405. }
  42406. declare module BABYLON {
  42407. /**
  42408. * Class containing static functions to help procedurally build meshes
  42409. */
  42410. export class TorusBuilder {
  42411. /**
  42412. * Creates a torus mesh
  42413. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  42414. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  42415. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  42416. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42417. * * 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
  42418. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42419. * @param name defines the name of the mesh
  42420. * @param options defines the options used to create the mesh
  42421. * @param scene defines the hosting scene
  42422. * @returns the torus mesh
  42423. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  42424. */
  42425. static CreateTorus(name: string, options: {
  42426. diameter?: number;
  42427. thickness?: number;
  42428. tessellation?: number;
  42429. updatable?: boolean;
  42430. sideOrientation?: number;
  42431. frontUVs?: Vector4;
  42432. backUVs?: Vector4;
  42433. }, scene: any): Mesh;
  42434. }
  42435. }
  42436. declare module BABYLON {
  42437. /**
  42438. * Class containing static functions to help procedurally build meshes
  42439. */
  42440. export class CylinderBuilder {
  42441. /**
  42442. * Creates a cylinder or a cone mesh
  42443. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  42444. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  42445. * * 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.
  42446. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  42447. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  42448. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  42449. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  42450. * * 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).
  42451. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  42452. * * 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).
  42453. * * 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
  42454. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  42455. * * 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
  42456. * * 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.
  42457. * * If `enclose` is false, a ring surface is one element.
  42458. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  42459. * * 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
  42460. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42461. * * 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
  42462. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42463. * @param name defines the name of the mesh
  42464. * @param options defines the options used to create the mesh
  42465. * @param scene defines the hosting scene
  42466. * @returns the cylinder mesh
  42467. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  42468. */
  42469. static CreateCylinder(name: string, options: {
  42470. height?: number;
  42471. diameterTop?: number;
  42472. diameterBottom?: number;
  42473. diameter?: number;
  42474. tessellation?: number;
  42475. subdivisions?: number;
  42476. arc?: number;
  42477. faceColors?: Color4[];
  42478. faceUV?: Vector4[];
  42479. updatable?: boolean;
  42480. hasRings?: boolean;
  42481. enclose?: boolean;
  42482. cap?: number;
  42483. sideOrientation?: number;
  42484. frontUVs?: Vector4;
  42485. backUVs?: Vector4;
  42486. }, scene: any): Mesh;
  42487. }
  42488. }
  42489. declare module BABYLON {
  42490. /**
  42491. * States of the webXR experience
  42492. */
  42493. export enum WebXRState {
  42494. /**
  42495. * Transitioning to being in XR mode
  42496. */
  42497. ENTERING_XR = 0,
  42498. /**
  42499. * Transitioning to non XR mode
  42500. */
  42501. EXITING_XR = 1,
  42502. /**
  42503. * In XR mode and presenting
  42504. */
  42505. IN_XR = 2,
  42506. /**
  42507. * Not entered XR mode
  42508. */
  42509. NOT_IN_XR = 3
  42510. }
  42511. /**
  42512. * Abstraction of the XR render target
  42513. */
  42514. export interface WebXRRenderTarget extends IDisposable {
  42515. /**
  42516. * xrpresent context of the canvas which can be used to display/mirror xr content
  42517. */
  42518. canvasContext: WebGLRenderingContext;
  42519. /**
  42520. * xr layer for the canvas
  42521. */
  42522. xrLayer: Nullable<XRWebGLLayer>;
  42523. /**
  42524. * Initializes the xr layer for the session
  42525. * @param xrSession xr session
  42526. * @returns a promise that will resolve once the XR Layer has been created
  42527. */
  42528. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  42529. }
  42530. }
  42531. declare module BABYLON {
  42532. /**
  42533. * COnfiguration object for WebXR output canvas
  42534. */
  42535. export class WebXRManagedOutputCanvasOptions {
  42536. /**
  42537. * Options for this XR Layer output
  42538. */
  42539. canvasOptions?: XRWebGLLayerOptions;
  42540. /**
  42541. * CSS styling for a newly created canvas (if not provided)
  42542. */
  42543. newCanvasCssStyle?: string;
  42544. /**
  42545. * An optional canvas in case you wish to create it yourself and provide it here.
  42546. * If not provided, a new canvas will be created
  42547. */
  42548. canvasElement?: HTMLCanvasElement;
  42549. /**
  42550. * Get the default values of the configuration object
  42551. * @returns default values of this configuration object
  42552. */
  42553. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  42554. }
  42555. /**
  42556. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  42557. */
  42558. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  42559. private _options;
  42560. private _engine;
  42561. private _canvas;
  42562. /**
  42563. * Rendering context of the canvas which can be used to display/mirror xr content
  42564. */
  42565. canvasContext: WebGLRenderingContext;
  42566. /**
  42567. * xr layer for the canvas
  42568. */
  42569. xrLayer: Nullable<XRWebGLLayer>;
  42570. /**
  42571. * Initializes the xr layer for the session
  42572. * @param xrSession xr session
  42573. * @returns a promise that will resolve once the XR Layer has been created
  42574. */
  42575. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  42576. /**
  42577. * Initializes the canvas to be added/removed upon entering/exiting xr
  42578. * @param _xrSessionManager The XR Session manager
  42579. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  42580. */
  42581. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  42582. /**
  42583. * Disposes of the object
  42584. */
  42585. dispose(): void;
  42586. private _setManagedOutputCanvas;
  42587. private _addCanvas;
  42588. private _removeCanvas;
  42589. }
  42590. }
  42591. declare module BABYLON {
  42592. /**
  42593. * Manages an XRSession to work with Babylon's engine
  42594. * @see https://doc.babylonjs.com/how_to/webxr
  42595. */
  42596. export class WebXRSessionManager implements IDisposable {
  42597. /** The scene which the session should be created for */
  42598. scene: Scene;
  42599. /**
  42600. * Fires every time a new xrFrame arrives which can be used to update the camera
  42601. */
  42602. onXRFrameObservable: Observable<XRFrame>;
  42603. /**
  42604. * Fires when the xr session is ended either by the device or manually done
  42605. */
  42606. onXRSessionEnded: Observable<any>;
  42607. /**
  42608. * Fires when the xr session is ended either by the device or manually done
  42609. */
  42610. onXRSessionInit: Observable<XRSession>;
  42611. /**
  42612. * Fires when the reference space changed
  42613. */
  42614. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  42615. /**
  42616. * Underlying xr session
  42617. */
  42618. session: XRSession;
  42619. /**
  42620. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  42621. * or get the offset the player is currently at.
  42622. */
  42623. viewerReferenceSpace: XRReferenceSpace;
  42624. private _referenceSpace;
  42625. /**
  42626. * The current reference space used in this session. This reference space can constantly change!
  42627. * It is mainly used to offset the camera's position.
  42628. */
  42629. get referenceSpace(): XRReferenceSpace;
  42630. /**
  42631. * Set a new reference space and triggers the observable
  42632. */
  42633. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  42634. /**
  42635. * The base reference space from which the session started. good if you want to reset your
  42636. * reference space
  42637. */
  42638. baseReferenceSpace: XRReferenceSpace;
  42639. /**
  42640. * Used just in case of a failure to initialize an immersive session.
  42641. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  42642. */
  42643. defaultHeightCompensation: number;
  42644. /**
  42645. * Current XR frame
  42646. */
  42647. currentFrame: Nullable<XRFrame>;
  42648. /** WebXR timestamp updated every frame */
  42649. currentTimestamp: number;
  42650. private _xrNavigator;
  42651. private baseLayer;
  42652. private _rttProvider;
  42653. private _sessionEnded;
  42654. /**
  42655. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  42656. * @param scene The scene which the session should be created for
  42657. */
  42658. constructor(
  42659. /** The scene which the session should be created for */
  42660. scene: Scene);
  42661. /**
  42662. * Initializes the manager
  42663. * After initialization enterXR can be called to start an XR session
  42664. * @returns Promise which resolves after it is initialized
  42665. */
  42666. initializeAsync(): Promise<void>;
  42667. /**
  42668. * Initializes an xr session
  42669. * @param xrSessionMode mode to initialize
  42670. * @param xrSessionInit defines optional and required values to pass to the session builder
  42671. * @returns a promise which will resolve once the session has been initialized
  42672. */
  42673. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  42674. /**
  42675. * Sets the reference space on the xr session
  42676. * @param referenceSpaceType space to set
  42677. * @returns a promise that will resolve once the reference space has been set
  42678. */
  42679. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  42680. /**
  42681. * Resets the reference space to the one started the session
  42682. */
  42683. resetReferenceSpace(): void;
  42684. /**
  42685. * Updates the render state of the session
  42686. * @param state state to set
  42687. * @returns a promise that resolves once the render state has been updated
  42688. */
  42689. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  42690. /**
  42691. * Starts rendering to the xr layer
  42692. */
  42693. runXRRenderLoop(): void;
  42694. /**
  42695. * Gets the correct render target texture to be rendered this frame for this eye
  42696. * @param eye the eye for which to get the render target
  42697. * @returns the render target for the specified eye
  42698. */
  42699. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  42700. /**
  42701. * Stops the xrSession and restores the renderloop
  42702. * @returns Promise which resolves after it exits XR
  42703. */
  42704. exitXRAsync(): Promise<void>;
  42705. /**
  42706. * Checks if a session would be supported for the creation options specified
  42707. * @param sessionMode session mode to check if supported eg. immersive-vr
  42708. * @returns A Promise that resolves to true if supported and false if not
  42709. */
  42710. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  42711. /**
  42712. * Creates a WebXRRenderTarget object for the XR session
  42713. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  42714. * @param options optional options to provide when creating a new render target
  42715. * @returns a WebXR render target to which the session can render
  42716. */
  42717. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  42718. /**
  42719. * @hidden
  42720. * Converts the render layer of xrSession to a render target
  42721. * @param session session to create render target for
  42722. * @param scene scene the new render target should be created for
  42723. * @param baseLayer the webgl layer to create the render target for
  42724. */
  42725. static _CreateRenderTargetTextureFromSession(_session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  42726. /**
  42727. * Disposes of the session manager
  42728. */
  42729. dispose(): void;
  42730. /**
  42731. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  42732. * @param sessionMode defines the session to test
  42733. * @returns a promise with boolean as final value
  42734. */
  42735. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  42736. }
  42737. }
  42738. declare module BABYLON {
  42739. /**
  42740. * WebXR Camera which holds the views for the xrSession
  42741. * @see https://doc.babylonjs.com/how_to/webxr_camera
  42742. */
  42743. export class WebXRCamera extends FreeCamera {
  42744. private _xrSessionManager;
  42745. private _firstFrame;
  42746. private _referenceQuaternion;
  42747. private _referencedPosition;
  42748. private _xrInvPositionCache;
  42749. private _xrInvQuaternionCache;
  42750. /**
  42751. * Should position compensation execute on first frame.
  42752. * This is used when copying the position from a native (non XR) camera
  42753. */
  42754. compensateOnFirstFrame: boolean;
  42755. /**
  42756. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  42757. * @param name the name of the camera
  42758. * @param scene the scene to add the camera to
  42759. * @param _xrSessionManager a constructed xr session manager
  42760. */
  42761. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  42762. /**
  42763. * Return the user's height, unrelated to the current ground.
  42764. * This will be the y position of this camera, when ground level is 0.
  42765. */
  42766. get realWorldHeight(): number;
  42767. /** @hidden */
  42768. _updateForDualEyeDebugging(): void;
  42769. /**
  42770. * Sets this camera's transformation based on a non-vr camera
  42771. * @param otherCamera the non-vr camera to copy the transformation from
  42772. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  42773. */
  42774. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  42775. private _updateFromXRSession;
  42776. private _updateNumberOfRigCameras;
  42777. private _updateReferenceSpace;
  42778. private _updateReferenceSpaceOffset;
  42779. }
  42780. }
  42781. declare module BABYLON {
  42782. /**
  42783. * Defining the interface required for a (webxr) feature
  42784. */
  42785. export interface IWebXRFeature extends IDisposable {
  42786. /**
  42787. * Is this feature attached
  42788. */
  42789. attached: boolean;
  42790. /**
  42791. * Should auto-attach be disabled?
  42792. */
  42793. disableAutoAttach: boolean;
  42794. /**
  42795. * Attach the feature to the session
  42796. * Will usually be called by the features manager
  42797. *
  42798. * @param force should attachment be forced (even when already attached)
  42799. * @returns true if successful.
  42800. */
  42801. attach(force?: boolean): boolean;
  42802. /**
  42803. * Detach the feature from the session
  42804. * Will usually be called by the features manager
  42805. *
  42806. * @returns true if successful.
  42807. */
  42808. detach(): boolean;
  42809. }
  42810. /**
  42811. * A list of the currently available features without referencing them
  42812. */
  42813. export class WebXRFeatureName {
  42814. /**
  42815. * The name of the hit test feature
  42816. */
  42817. static HIT_TEST: string;
  42818. /**
  42819. * The name of the anchor system feature
  42820. */
  42821. static ANCHOR_SYSTEM: string;
  42822. /**
  42823. * The name of the background remover feature
  42824. */
  42825. static BACKGROUND_REMOVER: string;
  42826. /**
  42827. * The name of the pointer selection feature
  42828. */
  42829. static POINTER_SELECTION: string;
  42830. /**
  42831. * The name of the teleportation feature
  42832. */
  42833. static TELEPORTATION: string;
  42834. /**
  42835. * The name of the plane detection feature
  42836. */
  42837. static PLANE_DETECTION: string;
  42838. /**
  42839. * physics impostors for xr controllers feature
  42840. */
  42841. static PHYSICS_CONTROLLERS: string;
  42842. }
  42843. /**
  42844. * Defining the constructor of a feature. Used to register the modules.
  42845. */
  42846. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  42847. /**
  42848. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  42849. * It is mainly used in AR sessions.
  42850. *
  42851. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  42852. */
  42853. export class WebXRFeaturesManager implements IDisposable {
  42854. private _xrSessionManager;
  42855. private static readonly _AvailableFeatures;
  42856. /**
  42857. * Used to register a module. After calling this function a developer can use this feature in the scene.
  42858. * Mainly used internally.
  42859. *
  42860. * @param featureName the name of the feature to register
  42861. * @param constructorFunction the function used to construct the module
  42862. * @param version the (babylon) version of the module
  42863. * @param stable is that a stable version of this module
  42864. */
  42865. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  42866. /**
  42867. * Returns a constructor of a specific feature.
  42868. *
  42869. * @param featureName the name of the feature to construct
  42870. * @param version the version of the feature to load
  42871. * @param xrSessionManager the xrSessionManager. Used to construct the module
  42872. * @param options optional options provided to the module.
  42873. * @returns a function that, when called, will return a new instance of this feature
  42874. */
  42875. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  42876. /**
  42877. * Return the latest unstable version of this feature
  42878. * @param featureName the name of the feature to search
  42879. * @returns the version number. if not found will return -1
  42880. */
  42881. static GetLatestVersionOfFeature(featureName: string): number;
  42882. /**
  42883. * Return the latest stable version of this feature
  42884. * @param featureName the name of the feature to search
  42885. * @returns the version number. if not found will return -1
  42886. */
  42887. static GetStableVersionOfFeature(featureName: string): number;
  42888. /**
  42889. * Can be used to return the list of features currently registered
  42890. *
  42891. * @returns an Array of available features
  42892. */
  42893. static GetAvailableFeatures(): string[];
  42894. /**
  42895. * Gets the versions available for a specific feature
  42896. * @param featureName the name of the feature
  42897. * @returns an array with the available versions
  42898. */
  42899. static GetAvailableVersions(featureName: string): string[];
  42900. private _features;
  42901. /**
  42902. * constructs a new features manages.
  42903. *
  42904. * @param _xrSessionManager an instance of WebXRSessionManager
  42905. */
  42906. constructor(_xrSessionManager: WebXRSessionManager);
  42907. /**
  42908. * 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.
  42909. * 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.
  42910. *
  42911. * @param featureName the name of the feature to load or the class of the feature
  42912. * @param version optional version to load. if not provided the latest version will be enabled
  42913. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  42914. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  42915. * @returns a new constructed feature or throws an error if feature not found.
  42916. */
  42917. enableFeature(featureName: string | {
  42918. Name: string;
  42919. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  42920. /**
  42921. * Used to disable an already-enabled feature
  42922. * The feature will be disposed and will be recreated once enabled.
  42923. * @param featureName the feature to disable
  42924. * @returns true if disable was successful
  42925. */
  42926. disableFeature(featureName: string | {
  42927. Name: string;
  42928. }): boolean;
  42929. /**
  42930. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  42931. * Can be used during a session to start a feature
  42932. * @param featureName the name of feature to attach
  42933. */
  42934. attachFeature(featureName: string): void;
  42935. /**
  42936. * Can be used inside a session or when the session ends to detach a specific feature
  42937. * @param featureName the name of the feature to detach
  42938. */
  42939. detachFeature(featureName: string): void;
  42940. /**
  42941. * Get the list of enabled features
  42942. * @returns an array of enabled features
  42943. */
  42944. getEnabledFeatures(): string[];
  42945. /**
  42946. * get the implementation of an enabled feature.
  42947. * @param featureName the name of the feature to load
  42948. * @returns the feature class, if found
  42949. */
  42950. getEnabledFeature(featureName: string): IWebXRFeature;
  42951. /**
  42952. * dispose this features manager
  42953. */
  42954. dispose(): void;
  42955. }
  42956. }
  42957. declare module BABYLON {
  42958. /**
  42959. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  42960. * @see https://doc.babylonjs.com/how_to/webxr
  42961. */
  42962. export class WebXRExperienceHelper implements IDisposable {
  42963. private scene;
  42964. /**
  42965. * Camera used to render xr content
  42966. */
  42967. camera: WebXRCamera;
  42968. /**
  42969. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  42970. */
  42971. state: WebXRState;
  42972. private _setState;
  42973. /**
  42974. * Fires when the state of the experience helper has changed
  42975. */
  42976. onStateChangedObservable: Observable<WebXRState>;
  42977. /**
  42978. * Observers registered here will be triggered after the camera's initial transformation is set
  42979. * This can be used to set a different ground level or an extra rotation.
  42980. *
  42981. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  42982. * to the position set after this observable is done executing.
  42983. */
  42984. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  42985. /** Session manager used to keep track of xr session */
  42986. sessionManager: WebXRSessionManager;
  42987. /** A features manager for this xr session */
  42988. featuresManager: WebXRFeaturesManager;
  42989. private _nonVRCamera;
  42990. private _originalSceneAutoClear;
  42991. private _supported;
  42992. /**
  42993. * Creates the experience helper
  42994. * @param scene the scene to attach the experience helper to
  42995. * @returns a promise for the experience helper
  42996. */
  42997. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  42998. /**
  42999. * Creates a WebXRExperienceHelper
  43000. * @param scene The scene the helper should be created in
  43001. */
  43002. private constructor();
  43003. /**
  43004. * Exits XR mode and returns the scene to its original state
  43005. * @returns promise that resolves after xr mode has exited
  43006. */
  43007. exitXRAsync(): Promise<void>;
  43008. /**
  43009. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  43010. * @param sessionMode options for the XR session
  43011. * @param referenceSpaceType frame of reference of the XR session
  43012. * @param renderTarget the output canvas that will be used to enter XR mode
  43013. * @returns promise that resolves after xr mode has entered
  43014. */
  43015. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget): Promise<WebXRSessionManager>;
  43016. /**
  43017. * Disposes of the experience helper
  43018. */
  43019. dispose(): void;
  43020. private _nonXRToXRCamera;
  43021. }
  43022. }
  43023. declare module BABYLON {
  43024. /**
  43025. * X-Y values for axes in WebXR
  43026. */
  43027. export interface IWebXRMotionControllerAxesValue {
  43028. /**
  43029. * The value of the x axis
  43030. */
  43031. x: number;
  43032. /**
  43033. * The value of the y-axis
  43034. */
  43035. y: number;
  43036. }
  43037. /**
  43038. * changed / previous values for the values of this component
  43039. */
  43040. export interface IWebXRMotionControllerComponentChangesValues<T> {
  43041. /**
  43042. * current (this frame) value
  43043. */
  43044. current: T;
  43045. /**
  43046. * previous (last change) value
  43047. */
  43048. previous: T;
  43049. }
  43050. /**
  43051. * Represents changes in the component between current frame and last values recorded
  43052. */
  43053. export interface IWebXRMotionControllerComponentChanges {
  43054. /**
  43055. * will be populated with previous and current values if touched changed
  43056. */
  43057. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  43058. /**
  43059. * will be populated with previous and current values if pressed changed
  43060. */
  43061. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  43062. /**
  43063. * will be populated with previous and current values if value changed
  43064. */
  43065. value?: IWebXRMotionControllerComponentChangesValues<number>;
  43066. /**
  43067. * will be populated with previous and current values if axes changed
  43068. */
  43069. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  43070. }
  43071. /**
  43072. * This class represents a single component (for example button or thumbstick) of a motion controller
  43073. */
  43074. export class WebXRControllerComponent implements IDisposable {
  43075. /**
  43076. * the id of this component
  43077. */
  43078. id: string;
  43079. /**
  43080. * the type of the component
  43081. */
  43082. type: MotionControllerComponentType;
  43083. private _buttonIndex;
  43084. private _axesIndices;
  43085. /**
  43086. * Thumbstick component type
  43087. */
  43088. static THUMBSTICK: MotionControllerComponentType;
  43089. /**
  43090. * Touchpad component type
  43091. */
  43092. static TOUCHPAD: MotionControllerComponentType;
  43093. /**
  43094. * trigger component type
  43095. */
  43096. static TRIGGER: MotionControllerComponentType;
  43097. /**
  43098. * squeeze component type
  43099. */
  43100. static SQUEEZE: MotionControllerComponentType;
  43101. /**
  43102. * button component type
  43103. */
  43104. static BUTTON: MotionControllerComponentType;
  43105. /**
  43106. * Observers registered here will be triggered when the state of a button changes
  43107. * State change is either pressed / touched / value
  43108. */
  43109. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  43110. /**
  43111. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  43112. * the axes data changes
  43113. */
  43114. onAxisValueChangedObservable: Observable<{
  43115. x: number;
  43116. y: number;
  43117. }>;
  43118. private _currentValue;
  43119. private _touched;
  43120. private _pressed;
  43121. private _axes;
  43122. private _changes;
  43123. private _hasChanges;
  43124. /**
  43125. * Return whether or not the component changed the last frame
  43126. */
  43127. get hasChanges(): boolean;
  43128. /**
  43129. * Creates a new component for a motion controller.
  43130. * It is created by the motion controller itself
  43131. *
  43132. * @param id the id of this component
  43133. * @param type the type of the component
  43134. * @param _buttonIndex index in the buttons array of the gamepad
  43135. * @param _axesIndices indices of the values in the axes array of the gamepad
  43136. */
  43137. constructor(
  43138. /**
  43139. * the id of this component
  43140. */
  43141. id: string,
  43142. /**
  43143. * the type of the component
  43144. */
  43145. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  43146. /**
  43147. * Get the current value of this component
  43148. */
  43149. get value(): number;
  43150. /**
  43151. * is the button currently pressed
  43152. */
  43153. get pressed(): boolean;
  43154. /**
  43155. * is the button currently touched
  43156. */
  43157. get touched(): boolean;
  43158. /**
  43159. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  43160. */
  43161. get axes(): IWebXRMotionControllerAxesValue;
  43162. /**
  43163. * Get the changes. Elements will be populated only if they changed with their previous and current value
  43164. */
  43165. get changes(): IWebXRMotionControllerComponentChanges;
  43166. /**
  43167. * Is this component a button (hence - pressable)
  43168. * @returns true if can be pressed
  43169. */
  43170. isButton(): boolean;
  43171. /**
  43172. * Are there axes correlating to this component
  43173. * @return true is axes data is available
  43174. */
  43175. isAxes(): boolean;
  43176. /**
  43177. * update this component using the gamepad object it is in. Called on every frame
  43178. * @param nativeController the native gamepad controller object
  43179. */
  43180. update(nativeController: IMinimalMotionControllerObject): void;
  43181. /**
  43182. * Dispose this component
  43183. */
  43184. dispose(): void;
  43185. }
  43186. }
  43187. declare module BABYLON {
  43188. /**
  43189. * Class used to represent data loading progression
  43190. */
  43191. export class SceneLoaderProgressEvent {
  43192. /** defines if data length to load can be evaluated */
  43193. readonly lengthComputable: boolean;
  43194. /** defines the loaded data length */
  43195. readonly loaded: number;
  43196. /** defines the data length to load */
  43197. readonly total: number;
  43198. /**
  43199. * Create a new progress event
  43200. * @param lengthComputable defines if data length to load can be evaluated
  43201. * @param loaded defines the loaded data length
  43202. * @param total defines the data length to load
  43203. */
  43204. constructor(
  43205. /** defines if data length to load can be evaluated */
  43206. lengthComputable: boolean,
  43207. /** defines the loaded data length */
  43208. loaded: number,
  43209. /** defines the data length to load */
  43210. total: number);
  43211. /**
  43212. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  43213. * @param event defines the source event
  43214. * @returns a new SceneLoaderProgressEvent
  43215. */
  43216. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  43217. }
  43218. /**
  43219. * Interface used by SceneLoader plugins to define supported file extensions
  43220. */
  43221. export interface ISceneLoaderPluginExtensions {
  43222. /**
  43223. * Defines the list of supported extensions
  43224. */
  43225. [extension: string]: {
  43226. isBinary: boolean;
  43227. };
  43228. }
  43229. /**
  43230. * Interface used by SceneLoader plugin factory
  43231. */
  43232. export interface ISceneLoaderPluginFactory {
  43233. /**
  43234. * Defines the name of the factory
  43235. */
  43236. name: string;
  43237. /**
  43238. * Function called to create a new plugin
  43239. * @return the new plugin
  43240. */
  43241. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  43242. /**
  43243. * The callback that returns true if the data can be directly loaded.
  43244. * @param data string containing the file data
  43245. * @returns if the data can be loaded directly
  43246. */
  43247. canDirectLoad?(data: string): boolean;
  43248. }
  43249. /**
  43250. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  43251. */
  43252. export interface ISceneLoaderPluginBase {
  43253. /**
  43254. * The friendly name of this plugin.
  43255. */
  43256. name: string;
  43257. /**
  43258. * The file extensions supported by this plugin.
  43259. */
  43260. extensions: string | ISceneLoaderPluginExtensions;
  43261. /**
  43262. * The callback called when loading from a url.
  43263. * @param scene scene loading this url
  43264. * @param url url to load
  43265. * @param onSuccess callback called when the file successfully loads
  43266. * @param onProgress callback called while file is loading (if the server supports this mode)
  43267. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  43268. * @param onError callback called when the file fails to load
  43269. * @returns a file request object
  43270. */
  43271. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  43272. /**
  43273. * The callback called when loading from a file object.
  43274. * @param scene scene loading this file
  43275. * @param file defines the file to load
  43276. * @param onSuccess defines the callback to call when data is loaded
  43277. * @param onProgress defines the callback to call during loading process
  43278. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  43279. * @param onError defines the callback to call when an error occurs
  43280. * @returns a file request object
  43281. */
  43282. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  43283. /**
  43284. * The callback that returns true if the data can be directly loaded.
  43285. * @param data string containing the file data
  43286. * @returns if the data can be loaded directly
  43287. */
  43288. canDirectLoad?(data: string): boolean;
  43289. /**
  43290. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  43291. * @param scene scene loading this data
  43292. * @param data string containing the data
  43293. * @returns data to pass to the plugin
  43294. */
  43295. directLoad?(scene: Scene, data: string): any;
  43296. /**
  43297. * The callback that allows custom handling of the root url based on the response url.
  43298. * @param rootUrl the original root url
  43299. * @param responseURL the response url if available
  43300. * @returns the new root url
  43301. */
  43302. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  43303. }
  43304. /**
  43305. * Interface used to define a SceneLoader plugin
  43306. */
  43307. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  43308. /**
  43309. * Import meshes into a scene.
  43310. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43311. * @param scene The scene to import into
  43312. * @param data The data to import
  43313. * @param rootUrl The root url for scene and resources
  43314. * @param meshes The meshes array to import into
  43315. * @param particleSystems The particle systems array to import into
  43316. * @param skeletons The skeletons array to import into
  43317. * @param onError The callback when import fails
  43318. * @returns True if successful or false otherwise
  43319. */
  43320. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  43321. /**
  43322. * Load into a scene.
  43323. * @param scene The scene to load into
  43324. * @param data The data to import
  43325. * @param rootUrl The root url for scene and resources
  43326. * @param onError The callback when import fails
  43327. * @returns True if successful or false otherwise
  43328. */
  43329. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  43330. /**
  43331. * Load into an asset container.
  43332. * @param scene The scene to load into
  43333. * @param data The data to import
  43334. * @param rootUrl The root url for scene and resources
  43335. * @param onError The callback when import fails
  43336. * @returns The loaded asset container
  43337. */
  43338. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  43339. }
  43340. /**
  43341. * Interface used to define an async SceneLoader plugin
  43342. */
  43343. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  43344. /**
  43345. * Import meshes into a scene.
  43346. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43347. * @param scene The scene to import into
  43348. * @param data The data to import
  43349. * @param rootUrl The root url for scene and resources
  43350. * @param onProgress The callback when the load progresses
  43351. * @param fileName Defines the name of the file to load
  43352. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  43353. */
  43354. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  43355. meshes: AbstractMesh[];
  43356. particleSystems: IParticleSystem[];
  43357. skeletons: Skeleton[];
  43358. animationGroups: AnimationGroup[];
  43359. }>;
  43360. /**
  43361. * Load into a scene.
  43362. * @param scene The scene to load into
  43363. * @param data The data to import
  43364. * @param rootUrl The root url for scene and resources
  43365. * @param onProgress The callback when the load progresses
  43366. * @param fileName Defines the name of the file to load
  43367. * @returns Nothing
  43368. */
  43369. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  43370. /**
  43371. * Load into an asset container.
  43372. * @param scene The scene to load into
  43373. * @param data The data to import
  43374. * @param rootUrl The root url for scene and resources
  43375. * @param onProgress The callback when the load progresses
  43376. * @param fileName Defines the name of the file to load
  43377. * @returns The loaded asset container
  43378. */
  43379. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  43380. }
  43381. /**
  43382. * Mode that determines how to handle old animation groups before loading new ones.
  43383. */
  43384. export enum SceneLoaderAnimationGroupLoadingMode {
  43385. /**
  43386. * Reset all old animations to initial state then dispose them.
  43387. */
  43388. Clean = 0,
  43389. /**
  43390. * Stop all old animations.
  43391. */
  43392. Stop = 1,
  43393. /**
  43394. * Restart old animations from first frame.
  43395. */
  43396. Sync = 2,
  43397. /**
  43398. * Old animations remains untouched.
  43399. */
  43400. NoSync = 3
  43401. }
  43402. /**
  43403. * Class used to load scene from various file formats using registered plugins
  43404. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  43405. */
  43406. export class SceneLoader {
  43407. /**
  43408. * No logging while loading
  43409. */
  43410. static readonly NO_LOGGING: number;
  43411. /**
  43412. * Minimal logging while loading
  43413. */
  43414. static readonly MINIMAL_LOGGING: number;
  43415. /**
  43416. * Summary logging while loading
  43417. */
  43418. static readonly SUMMARY_LOGGING: number;
  43419. /**
  43420. * Detailled logging while loading
  43421. */
  43422. static readonly DETAILED_LOGGING: number;
  43423. /**
  43424. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  43425. */
  43426. static get ForceFullSceneLoadingForIncremental(): boolean;
  43427. static set ForceFullSceneLoadingForIncremental(value: boolean);
  43428. /**
  43429. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  43430. */
  43431. static get ShowLoadingScreen(): boolean;
  43432. static set ShowLoadingScreen(value: boolean);
  43433. /**
  43434. * Defines the current logging level (while loading the scene)
  43435. * @ignorenaming
  43436. */
  43437. static get loggingLevel(): number;
  43438. static set loggingLevel(value: number);
  43439. /**
  43440. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  43441. */
  43442. static get CleanBoneMatrixWeights(): boolean;
  43443. static set CleanBoneMatrixWeights(value: boolean);
  43444. /**
  43445. * Event raised when a plugin is used to load a scene
  43446. */
  43447. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  43448. private static _registeredPlugins;
  43449. private static _getDefaultPlugin;
  43450. private static _getPluginForExtension;
  43451. private static _getPluginForDirectLoad;
  43452. private static _getPluginForFilename;
  43453. private static _getDirectLoad;
  43454. private static _loadData;
  43455. private static _getFileInfo;
  43456. /**
  43457. * Gets a plugin that can load the given extension
  43458. * @param extension defines the extension to load
  43459. * @returns a plugin or null if none works
  43460. */
  43461. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  43462. /**
  43463. * Gets a boolean indicating that the given extension can be loaded
  43464. * @param extension defines the extension to load
  43465. * @returns true if the extension is supported
  43466. */
  43467. static IsPluginForExtensionAvailable(extension: string): boolean;
  43468. /**
  43469. * Adds a new plugin to the list of registered plugins
  43470. * @param plugin defines the plugin to add
  43471. */
  43472. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  43473. /**
  43474. * Import meshes into a scene
  43475. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43476. * @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)
  43477. * @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)
  43478. * @param scene the instance of BABYLON.Scene to append to
  43479. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  43480. * @param onProgress a callback with a progress event for each file being loaded
  43481. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43482. * @param pluginExtension the extension used to determine the plugin
  43483. * @returns The loaded plugin
  43484. */
  43485. 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>;
  43486. /**
  43487. * Import meshes into a scene
  43488. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43489. * @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)
  43490. * @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)
  43491. * @param scene the instance of BABYLON.Scene to append to
  43492. * @param onProgress a callback with a progress event for each file being loaded
  43493. * @param pluginExtension the extension used to determine the plugin
  43494. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  43495. */
  43496. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  43497. meshes: AbstractMesh[];
  43498. particleSystems: IParticleSystem[];
  43499. skeletons: Skeleton[];
  43500. animationGroups: AnimationGroup[];
  43501. }>;
  43502. /**
  43503. * Load a scene
  43504. * @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)
  43505. * @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)
  43506. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43507. * @param onSuccess a callback with the scene when import succeeds
  43508. * @param onProgress a callback with a progress event for each file being loaded
  43509. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43510. * @param pluginExtension the extension used to determine the plugin
  43511. * @returns The loaded plugin
  43512. */
  43513. 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>;
  43514. /**
  43515. * Load a scene
  43516. * @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)
  43517. * @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)
  43518. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43519. * @param onProgress a callback with a progress event for each file being loaded
  43520. * @param pluginExtension the extension used to determine the plugin
  43521. * @returns The loaded scene
  43522. */
  43523. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43524. /**
  43525. * Append a scene
  43526. * @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)
  43527. * @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)
  43528. * @param scene is the instance of BABYLON.Scene to append to
  43529. * @param onSuccess a callback with the scene when import succeeds
  43530. * @param onProgress a callback with a progress event for each file being loaded
  43531. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43532. * @param pluginExtension the extension used to determine the plugin
  43533. * @returns The loaded plugin
  43534. */
  43535. 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>;
  43536. /**
  43537. * Append a scene
  43538. * @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)
  43539. * @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)
  43540. * @param scene is the instance of BABYLON.Scene to append to
  43541. * @param onProgress a callback with a progress event for each file being loaded
  43542. * @param pluginExtension the extension used to determine the plugin
  43543. * @returns The given scene
  43544. */
  43545. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43546. /**
  43547. * Load a scene into an asset container
  43548. * @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)
  43549. * @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)
  43550. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  43551. * @param onSuccess a callback with the scene when import succeeds
  43552. * @param onProgress a callback with a progress event for each file being loaded
  43553. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43554. * @param pluginExtension the extension used to determine the plugin
  43555. * @returns The loaded plugin
  43556. */
  43557. 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>;
  43558. /**
  43559. * Load a scene into an asset container
  43560. * @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)
  43561. * @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)
  43562. * @param scene is the instance of Scene to append to
  43563. * @param onProgress a callback with a progress event for each file being loaded
  43564. * @param pluginExtension the extension used to determine the plugin
  43565. * @returns The loaded asset container
  43566. */
  43567. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  43568. /**
  43569. * Import animations from a file into a scene
  43570. * @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)
  43571. * @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)
  43572. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  43573. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  43574. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  43575. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  43576. * @param onSuccess a callback with the scene when import succeeds
  43577. * @param onProgress a callback with a progress event for each file being loaded
  43578. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43579. */
  43580. 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;
  43581. /**
  43582. * Import animations from a file into a scene
  43583. * @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)
  43584. * @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)
  43585. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  43586. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  43587. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  43588. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  43589. * @param onSuccess a callback with the scene when import succeeds
  43590. * @param onProgress a callback with a progress event for each file being loaded
  43591. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43592. * @returns the updated scene with imported animations
  43593. */
  43594. 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>;
  43595. }
  43596. }
  43597. declare module BABYLON {
  43598. /**
  43599. * Handness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  43600. */
  43601. export type MotionControllerHandness = "none" | "left" | "right";
  43602. /**
  43603. * The type of components available in motion controllers.
  43604. * This is not the name of the component.
  43605. */
  43606. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  43607. /**
  43608. * The state of a controller component
  43609. */
  43610. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  43611. /**
  43612. * The schema of motion controller layout.
  43613. * No object will be initialized using this interface
  43614. * This is used just to define the profile.
  43615. */
  43616. export interface IMotionControllerLayout {
  43617. /**
  43618. * Defines the main button component id
  43619. */
  43620. selectComponentId: string;
  43621. /**
  43622. * Available components (unsorted)
  43623. */
  43624. components: {
  43625. /**
  43626. * A map of component Ids
  43627. */
  43628. [componentId: string]: {
  43629. /**
  43630. * The type of input the component outputs
  43631. */
  43632. type: MotionControllerComponentType;
  43633. /**
  43634. * The indices of this component in the gamepad object
  43635. */
  43636. gamepadIndices: {
  43637. /**
  43638. * Index of button
  43639. */
  43640. button?: number;
  43641. /**
  43642. * If available, index of x-axis
  43643. */
  43644. xAxis?: number;
  43645. /**
  43646. * If available, index of y-axis
  43647. */
  43648. yAxis?: number;
  43649. };
  43650. /**
  43651. * The mesh's root node name
  43652. */
  43653. rootNodeName: string;
  43654. /**
  43655. * Animation definitions for this model
  43656. */
  43657. visualResponses: {
  43658. [stateKey: string]: {
  43659. /**
  43660. * What property will be animated
  43661. */
  43662. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  43663. /**
  43664. * What states influence this visual reponse
  43665. */
  43666. states: MotionControllerComponentStateType[];
  43667. /**
  43668. * Type of animation - movement or visibility
  43669. */
  43670. valueNodeProperty: "transform" | "visibility";
  43671. /**
  43672. * Base node name to move. Its position will be calculated according to the min and max nodes
  43673. */
  43674. valueNodeName?: string;
  43675. /**
  43676. * Minimum movement node
  43677. */
  43678. minNodeName?: string;
  43679. /**
  43680. * Max movement node
  43681. */
  43682. maxNodeName?: string;
  43683. };
  43684. };
  43685. /**
  43686. * If touch enabled, what is the name of node to display user feedback
  43687. */
  43688. touchPointNodeName?: string;
  43689. };
  43690. };
  43691. /**
  43692. * Is it xr standard mapping or not
  43693. */
  43694. gamepadMapping: "" | "xr-standard";
  43695. /**
  43696. * Base root node of this entire model
  43697. */
  43698. rootNodeName: string;
  43699. /**
  43700. * Path to load the assets. Usually relative to the base path
  43701. */
  43702. assetPath: string;
  43703. }
  43704. /**
  43705. * A definition for the layout map in the input profile
  43706. */
  43707. export interface IMotionControllerLayoutMap {
  43708. /**
  43709. * Layouts with handness type as a key
  43710. */
  43711. [handness: string]: IMotionControllerLayout;
  43712. }
  43713. /**
  43714. * The XR Input profile schema
  43715. * Profiles can be found here:
  43716. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  43717. */
  43718. export interface IMotionControllerProfile {
  43719. /**
  43720. * The id of this profile
  43721. * correlates to the profile(s) in the xrInput.profiles array
  43722. */
  43723. profileId: string;
  43724. /**
  43725. * fallback profiles for this profileId
  43726. */
  43727. fallbackProfileIds: string[];
  43728. /**
  43729. * The layout map, with handness as key
  43730. */
  43731. layouts: IMotionControllerLayoutMap;
  43732. }
  43733. /**
  43734. * A helper-interface for the 3 meshes needed for controller button animation
  43735. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  43736. */
  43737. export interface IMotionControllerButtonMeshMap {
  43738. /**
  43739. * The mesh that will be changed when value changes
  43740. */
  43741. valueMesh: AbstractMesh;
  43742. /**
  43743. * the mesh that defines the pressed value mesh position.
  43744. * This is used to find the max-position of this button
  43745. */
  43746. pressedMesh: AbstractMesh;
  43747. /**
  43748. * the mesh that defines the unpressed value mesh position.
  43749. * This is used to find the min (or initial) position of this button
  43750. */
  43751. unpressedMesh: AbstractMesh;
  43752. }
  43753. /**
  43754. * A helper-interface for the 3 meshes needed for controller axis animation.
  43755. * This will be expanded when touchpad animations are fully supported
  43756. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  43757. */
  43758. export interface IMotionControllerMeshMap {
  43759. /**
  43760. * The mesh that will be changed when axis value changes
  43761. */
  43762. valueMesh: AbstractMesh;
  43763. /**
  43764. * the mesh that defines the minimum value mesh position.
  43765. */
  43766. minMesh?: AbstractMesh;
  43767. /**
  43768. * the mesh that defines the maximum value mesh position.
  43769. */
  43770. maxMesh?: AbstractMesh;
  43771. }
  43772. /**
  43773. * The elements needed for change-detection of the gamepad objects in motion controllers
  43774. */
  43775. export interface IMinimalMotionControllerObject {
  43776. /**
  43777. * An array of available buttons
  43778. */
  43779. buttons: Array<{
  43780. /**
  43781. * Value of the button/trigger
  43782. */
  43783. value: number;
  43784. /**
  43785. * If the button/trigger is currently touched
  43786. */
  43787. touched: boolean;
  43788. /**
  43789. * If the button/trigger is currently pressed
  43790. */
  43791. pressed: boolean;
  43792. }>;
  43793. /**
  43794. * Available axes of this controller
  43795. */
  43796. axes: number[];
  43797. }
  43798. /**
  43799. * An Abstract Motion controller
  43800. * This class receives an xrInput and a profile layout and uses those to initialize the components
  43801. * Each component has an observable to check for changes in value and state
  43802. */
  43803. export abstract class WebXRAbstractMotionController implements IDisposable {
  43804. protected scene: Scene;
  43805. protected layout: IMotionControllerLayout;
  43806. /**
  43807. * The gamepad object correlating to this controller
  43808. */
  43809. gamepadObject: IMinimalMotionControllerObject;
  43810. /**
  43811. * handness (left/right/none) of this controller
  43812. */
  43813. handness: MotionControllerHandness;
  43814. /**
  43815. * The profile id of this motion controller
  43816. */
  43817. abstract profileId: string;
  43818. /**
  43819. * A map of components (WebXRControllerComponent) in this motion controller
  43820. * Components have a ComponentType and can also have both button and axis definitions
  43821. */
  43822. readonly components: {
  43823. [id: string]: WebXRControllerComponent;
  43824. };
  43825. /**
  43826. * Observers registered here will be triggered when the model of this controller is done loading
  43827. */
  43828. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  43829. /**
  43830. * The root mesh of the model. It is null if the model was not yet initialized
  43831. */
  43832. rootMesh: Nullable<AbstractMesh>;
  43833. /**
  43834. * Disable the model's animation. Can be set at any time.
  43835. */
  43836. disableAnimation: boolean;
  43837. private _modelReady;
  43838. /**
  43839. * constructs a new abstract motion controller
  43840. * @param scene the scene to which the model of the controller will be added
  43841. * @param layout The profile layout to load
  43842. * @param gamepadObject The gamepad object correlating to this controller
  43843. * @param handness handness (left/right/none) of this controller
  43844. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  43845. */
  43846. constructor(scene: Scene, layout: IMotionControllerLayout,
  43847. /**
  43848. * The gamepad object correlating to this controller
  43849. */
  43850. gamepadObject: IMinimalMotionControllerObject,
  43851. /**
  43852. * handness (left/right/none) of this controller
  43853. */
  43854. handness: MotionControllerHandness, _doNotLoadControllerMesh?: boolean);
  43855. private _initComponent;
  43856. /**
  43857. * Update this model using the current XRFrame
  43858. * @param xrFrame the current xr frame to use and update the model
  43859. */
  43860. updateFromXRFrame(xrFrame: XRFrame): void;
  43861. /**
  43862. * Get the list of components available in this motion controller
  43863. * @returns an array of strings correlating to available components
  43864. */
  43865. getComponentIds(): string[];
  43866. /**
  43867. * Get the main (Select) component of this controller as defined in the layout
  43868. * @returns the main component of this controller
  43869. */
  43870. getMainComponent(): WebXRControllerComponent;
  43871. /**
  43872. * get a component based an its component id as defined in layout.components
  43873. * @param id the id of the component
  43874. * @returns the component correlates to the id or undefined if not found
  43875. */
  43876. getComponent(id: string): WebXRControllerComponent;
  43877. /**
  43878. * Get the first component of specific type
  43879. * @param type type of component to find
  43880. * @return a controller component or null if not found
  43881. */
  43882. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  43883. /**
  43884. * Returns all components of specific type
  43885. * @param type the type to search for
  43886. * @return an array of components with this type
  43887. */
  43888. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  43889. /**
  43890. * Loads the model correlating to this controller
  43891. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  43892. * @returns A promise fulfilled with the result of the model loading
  43893. */
  43894. loadModel(): Promise<boolean>;
  43895. /**
  43896. * Update the model itself with the current frame data
  43897. * @param xrFrame the frame to use for updating the model mesh
  43898. */
  43899. protected updateModel(xrFrame: XRFrame): void;
  43900. /**
  43901. * Moves the axis on the controller mesh based on its current state
  43902. * @param axis the index of the axis
  43903. * @param axisValue the value of the axis which determines the meshes new position
  43904. * @hidden
  43905. */
  43906. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  43907. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh;
  43908. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh;
  43909. private _getGenericFilenameAndPath;
  43910. private _getGenericParentMesh;
  43911. /**
  43912. * Get the filename and path for this controller's model
  43913. * @returns a map of filename and path
  43914. */
  43915. protected abstract _getFilenameAndPath(): {
  43916. filename: string;
  43917. path: string;
  43918. };
  43919. /**
  43920. * This function will be called after the model was successfully loaded and can be used
  43921. * for mesh transformations before it is available for the user
  43922. * @param meshes the loaded meshes
  43923. */
  43924. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  43925. /**
  43926. * Set the root mesh for this controller. Important for the WebXR controller class
  43927. * @param meshes the loaded meshes
  43928. */
  43929. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  43930. /**
  43931. * A function executed each frame that updates the mesh (if needed)
  43932. * @param xrFrame the current xrFrame
  43933. */
  43934. protected abstract _updateModel(xrFrame: XRFrame): void;
  43935. /**
  43936. * This function is called before the mesh is loaded. It checks for loading constraints.
  43937. * For example, this function can check if the GLB loader is available
  43938. * If this function returns false, the generic controller will be loaded instead
  43939. * @returns Is the client ready to load the mesh
  43940. */
  43941. protected abstract _getModelLoadingConstraints(): boolean;
  43942. /**
  43943. * Dispose this controller, the model mesh and all its components
  43944. */
  43945. dispose(): void;
  43946. }
  43947. }
  43948. declare module BABYLON {
  43949. /**
  43950. * A generic trigger-only motion controller for WebXR
  43951. */
  43952. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  43953. /**
  43954. * Static version of the profile id of this controller
  43955. */
  43956. static ProfileId: string;
  43957. profileId: string;
  43958. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  43959. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  43960. protected _updateModel(): void;
  43961. protected _getFilenameAndPath(): {
  43962. filename: string;
  43963. path: string;
  43964. };
  43965. protected _setRootMesh(meshes: AbstractMesh[]): void;
  43966. protected _getModelLoadingConstraints(): boolean;
  43967. }
  43968. }
  43969. declare module BABYLON {
  43970. /**
  43971. * Class containing static functions to help procedurally build meshes
  43972. */
  43973. export class SphereBuilder {
  43974. /**
  43975. * Creates a sphere mesh
  43976. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  43977. * * 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`)
  43978. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  43979. * * 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
  43980. * * 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)
  43981. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43982. * * 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
  43983. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43984. * @param name defines the name of the mesh
  43985. * @param options defines the options used to create the mesh
  43986. * @param scene defines the hosting scene
  43987. * @returns the sphere mesh
  43988. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  43989. */
  43990. static CreateSphere(name: string, options: {
  43991. segments?: number;
  43992. diameter?: number;
  43993. diameterX?: number;
  43994. diameterY?: number;
  43995. diameterZ?: number;
  43996. arc?: number;
  43997. slice?: number;
  43998. sideOrientation?: number;
  43999. frontUVs?: Vector4;
  44000. backUVs?: Vector4;
  44001. updatable?: boolean;
  44002. }, scene?: Nullable<Scene>): Mesh;
  44003. }
  44004. }
  44005. declare module BABYLON {
  44006. /**
  44007. * A profiled motion controller has its profile loaded from an online repository.
  44008. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  44009. */
  44010. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  44011. private _repositoryUrl;
  44012. /**
  44013. * The profile ID of this controller. Will be populated when the controller initializes.
  44014. */
  44015. profileId: string;
  44016. private _buttonMeshMapping;
  44017. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  44018. protected _getFilenameAndPath(): {
  44019. filename: string;
  44020. path: string;
  44021. };
  44022. private _touchDots;
  44023. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  44024. protected _setRootMesh(meshes: AbstractMesh[]): void;
  44025. protected _updateModel(_xrFrame: XRFrame): void;
  44026. protected _getModelLoadingConstraints(): boolean;
  44027. dispose(): void;
  44028. }
  44029. }
  44030. declare module BABYLON {
  44031. /**
  44032. * A construction function type to create a new controller based on an xrInput object
  44033. */
  44034. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  44035. /**
  44036. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  44037. *
  44038. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  44039. * it should be replaced with auto-loaded controllers.
  44040. *
  44041. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  44042. */
  44043. export class WebXRMotionControllerManager {
  44044. /**
  44045. * The base URL of the online controller repository. Can be changed at any time.
  44046. */
  44047. static BaseRepositoryUrl: string;
  44048. /**
  44049. * Use the online repository, or use only locally-defined controllers
  44050. */
  44051. static UseOnlineRepository: boolean;
  44052. /**
  44053. * Which repository gets priority - local or online
  44054. */
  44055. static PrioritizeOnlineRepository: boolean;
  44056. private static _AvailableControllers;
  44057. private static _Fallbacks;
  44058. /**
  44059. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  44060. *
  44061. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  44062. *
  44063. * @param type the profile type to register
  44064. * @param constructFunction the function to be called when loading this profile
  44065. */
  44066. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  44067. /**
  44068. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  44069. * The order of search:
  44070. *
  44071. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  44072. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  44073. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  44074. * 4) return the generic trigger controller if none were found
  44075. *
  44076. * @param xrInput the xrInput to which a new controller is initialized
  44077. * @param scene the scene to which the model will be added
  44078. * @param forceProfile force a certain profile for this controller
  44079. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  44080. */
  44081. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  44082. private static _LoadProfilesFromAvailableControllers;
  44083. private static _ProfilesList;
  44084. private static _ProfileLoadingPromises;
  44085. private static _LoadProfileFromRepository;
  44086. /**
  44087. * Clear the cache used for profile loading and reload when requested again
  44088. */
  44089. static ClearProfilesCache(): void;
  44090. /**
  44091. * Will update the list of profiles available in the repository
  44092. * @return a promise that resolves to a map of profiles available online
  44093. */
  44094. static UpdateProfilesList(): Promise<{
  44095. [profile: string]: string;
  44096. }>;
  44097. /**
  44098. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  44099. * @param profileId the profile to which a fallback needs to be found
  44100. * @return an array with corresponding fallback profiles
  44101. */
  44102. static FindFallbackWithProfileId(profileId: string): string[];
  44103. /**
  44104. * Register a fallback to a specific profile.
  44105. * @param profileId the profileId that will receive the fallbacks
  44106. * @param fallbacks A list of fallback profiles
  44107. */
  44108. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  44109. /**
  44110. * Register the default fallbacks.
  44111. * This function is called automatically when this file is imported.
  44112. */
  44113. static DefaultFallbacks(): void;
  44114. }
  44115. }
  44116. declare module BABYLON {
  44117. /**
  44118. * Configuration options for the WebXR controller creation
  44119. */
  44120. export interface IWebXRControllerOptions {
  44121. /**
  44122. * Force a specific controller type for this controller.
  44123. * This can be used when creating your own profile or when testing different controllers
  44124. */
  44125. forceControllerProfile?: string;
  44126. /**
  44127. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  44128. */
  44129. doNotLoadControllerMesh?: boolean;
  44130. /**
  44131. * Should the controller mesh be animated when a user interacts with it
  44132. * The pressed buttons / thumbstick and touchpad animations will be disabled
  44133. */
  44134. disableMotionControllerAnimation?: boolean;
  44135. }
  44136. /**
  44137. * Represents an XR controller
  44138. */
  44139. export class WebXRInputSource {
  44140. private _scene;
  44141. /** The underlying input source for the controller */
  44142. inputSource: XRInputSource;
  44143. private _options;
  44144. /**
  44145. * 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
  44146. */
  44147. grip?: AbstractMesh;
  44148. /**
  44149. * Pointer which can be used to select objects or attach a visible laser to
  44150. */
  44151. pointer: AbstractMesh;
  44152. /**
  44153. * If available, this is the gamepad object related to this controller.
  44154. * Using this object it is possible to get click events and trackpad changes of the
  44155. * webxr controller that is currently being used.
  44156. */
  44157. motionController?: WebXRAbstractMotionController;
  44158. /**
  44159. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  44160. */
  44161. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  44162. /**
  44163. * Will be triggered when the mesh associated with the motion controller is done loading.
  44164. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  44165. * A shortened version of controller -> motion controller -> on mesh loaded.
  44166. */
  44167. onMeshLoadedObservable: Observable<AbstractMesh>;
  44168. /**
  44169. * Event that fires when the controller is removed/disposed.
  44170. * The object provided as event data is this controller, after associated assets were disposed.
  44171. * uniqueId is still available.
  44172. */
  44173. onDisposeObservable: Observable<WebXRInputSource>;
  44174. private _tmpQuaternion;
  44175. private _tmpVector;
  44176. private _uniqueId;
  44177. /**
  44178. * Creates the controller
  44179. * @see https://doc.babylonjs.com/how_to/webxr
  44180. * @param _scene the scene which the controller should be associated to
  44181. * @param inputSource the underlying input source for the controller
  44182. * @param _options options for this controller creation
  44183. */
  44184. constructor(_scene: Scene,
  44185. /** The underlying input source for the controller */
  44186. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  44187. /**
  44188. * Get this controllers unique id
  44189. */
  44190. get uniqueId(): string;
  44191. /**
  44192. * Updates the controller pose based on the given XRFrame
  44193. * @param xrFrame xr frame to update the pose with
  44194. * @param referenceSpace reference space to use
  44195. */
  44196. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  44197. /**
  44198. * Gets a world space ray coming from the pointer or grip
  44199. * @param result the resulting ray
  44200. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  44201. */
  44202. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  44203. /**
  44204. * Disposes of the object
  44205. */
  44206. dispose(): void;
  44207. }
  44208. }
  44209. declare module BABYLON {
  44210. /**
  44211. * The schema for initialization options of the XR Input class
  44212. */
  44213. export interface IWebXRInputOptions {
  44214. /**
  44215. * If set to true no model will be automatically loaded
  44216. */
  44217. doNotLoadControllerMeshes?: boolean;
  44218. /**
  44219. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  44220. * If not found, the xr input profile data will be used.
  44221. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  44222. */
  44223. forceInputProfile?: string;
  44224. /**
  44225. * Do not send a request to the controlle repository to load the profile.
  44226. *
  44227. * Instead, use the controllers available in babylon itself.
  44228. */
  44229. disableOnlineControllerRepository?: boolean;
  44230. /**
  44231. * A custom URL for the controllers repository
  44232. */
  44233. customControllersRepositoryURL?: string;
  44234. /**
  44235. * Should the controller model's components not move according to the user input
  44236. */
  44237. disableControllerAnimation?: boolean;
  44238. }
  44239. /**
  44240. * XR input used to track XR inputs such as controllers/rays
  44241. */
  44242. export class WebXRInput implements IDisposable {
  44243. /**
  44244. * the xr session manager for this session
  44245. */
  44246. xrSessionManager: WebXRSessionManager;
  44247. /**
  44248. * the WebXR camera for this session. Mainly used for teleportation
  44249. */
  44250. xrCamera: WebXRCamera;
  44251. private readonly options;
  44252. /**
  44253. * XR controllers being tracked
  44254. */
  44255. controllers: Array<WebXRInputSource>;
  44256. private _frameObserver;
  44257. private _sessionEndedObserver;
  44258. private _sessionInitObserver;
  44259. /**
  44260. * Event when a controller has been connected/added
  44261. */
  44262. onControllerAddedObservable: Observable<WebXRInputSource>;
  44263. /**
  44264. * Event when a controller has been removed/disconnected
  44265. */
  44266. onControllerRemovedObservable: Observable<WebXRInputSource>;
  44267. /**
  44268. * Initializes the WebXRInput
  44269. * @param xrSessionManager the xr session manager for this session
  44270. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  44271. * @param options = initialization options for this xr input
  44272. */
  44273. constructor(
  44274. /**
  44275. * the xr session manager for this session
  44276. */
  44277. xrSessionManager: WebXRSessionManager,
  44278. /**
  44279. * the WebXR camera for this session. Mainly used for teleportation
  44280. */
  44281. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  44282. private _onInputSourcesChange;
  44283. private _addAndRemoveControllers;
  44284. /**
  44285. * Disposes of the object
  44286. */
  44287. dispose(): void;
  44288. }
  44289. }
  44290. declare module BABYLON {
  44291. /**
  44292. * This is the base class for all WebXR features.
  44293. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  44294. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  44295. */
  44296. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  44297. protected _xrSessionManager: WebXRSessionManager;
  44298. /**
  44299. * Construct a new (abstract) webxr feature
  44300. * @param _xrSessionManager the xr session manager for this feature
  44301. */
  44302. constructor(_xrSessionManager: WebXRSessionManager);
  44303. private _attached;
  44304. private _removeOnDetach;
  44305. /**
  44306. * Is this feature attached
  44307. */
  44308. get attached(): boolean;
  44309. /**
  44310. * Should auto-attach be disabled?
  44311. */
  44312. disableAutoAttach: boolean;
  44313. /**
  44314. * attach this feature
  44315. *
  44316. * @param force should attachment be forced (even when already attached)
  44317. * @returns true if successful, false is failed or already attached
  44318. */
  44319. attach(force?: boolean): boolean;
  44320. /**
  44321. * detach this feature.
  44322. *
  44323. * @returns true if successful, false if failed or already detached
  44324. */
  44325. detach(): boolean;
  44326. /**
  44327. * Dispose this feature and all of the resources attached
  44328. */
  44329. dispose(): void;
  44330. /**
  44331. * Code in this function will be executed on each xrFrame received from the browser.
  44332. * This function will not execute after the feature is detached.
  44333. * @param _xrFrame the current frame
  44334. */
  44335. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  44336. /**
  44337. * This is used to register callbacks that will automatically be removed when detach is called.
  44338. * @param observable the observable to which the observer will be attached
  44339. * @param callback the callback to register
  44340. */
  44341. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  44342. }
  44343. }
  44344. declare module BABYLON {
  44345. /**
  44346. * Renders a layer on top of an existing scene
  44347. */
  44348. export class UtilityLayerRenderer implements IDisposable {
  44349. /** the original scene that will be rendered on top of */
  44350. originalScene: Scene;
  44351. private _pointerCaptures;
  44352. private _lastPointerEvents;
  44353. private static _DefaultUtilityLayer;
  44354. private static _DefaultKeepDepthUtilityLayer;
  44355. private _sharedGizmoLight;
  44356. private _renderCamera;
  44357. /**
  44358. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  44359. * @returns the camera that is used when rendering the utility layer
  44360. */
  44361. getRenderCamera(): Camera;
  44362. /**
  44363. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  44364. * @param cam the camera that should be used when rendering the utility layer
  44365. */
  44366. setRenderCamera(cam: Nullable<Camera>): void;
  44367. /**
  44368. * @hidden
  44369. * Light which used by gizmos to get light shading
  44370. */
  44371. _getSharedGizmoLight(): HemisphericLight;
  44372. /**
  44373. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  44374. */
  44375. pickUtilitySceneFirst: boolean;
  44376. /**
  44377. * 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)
  44378. */
  44379. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  44380. /**
  44381. * 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)
  44382. */
  44383. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  44384. /**
  44385. * The scene that is rendered on top of the original scene
  44386. */
  44387. utilityLayerScene: Scene;
  44388. /**
  44389. * If the utility layer should automatically be rendered on top of existing scene
  44390. */
  44391. shouldRender: boolean;
  44392. /**
  44393. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  44394. */
  44395. onlyCheckPointerDownEvents: boolean;
  44396. /**
  44397. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  44398. */
  44399. processAllEvents: boolean;
  44400. /**
  44401. * Observable raised when the pointer move from the utility layer scene to the main scene
  44402. */
  44403. onPointerOutObservable: Observable<number>;
  44404. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  44405. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  44406. private _afterRenderObserver;
  44407. private _sceneDisposeObserver;
  44408. private _originalPointerObserver;
  44409. /**
  44410. * Instantiates a UtilityLayerRenderer
  44411. * @param originalScene the original scene that will be rendered on top of
  44412. * @param handleEvents boolean indicating if the utility layer should handle events
  44413. */
  44414. constructor(
  44415. /** the original scene that will be rendered on top of */
  44416. originalScene: Scene, handleEvents?: boolean);
  44417. private _notifyObservers;
  44418. /**
  44419. * Renders the utility layers scene on top of the original scene
  44420. */
  44421. render(): void;
  44422. /**
  44423. * Disposes of the renderer
  44424. */
  44425. dispose(): void;
  44426. private _updateCamera;
  44427. }
  44428. }
  44429. declare module BABYLON {
  44430. /**
  44431. * Options interface for the pointer selection module
  44432. */
  44433. export interface IWebXRControllerPointerSelectionOptions {
  44434. /**
  44435. * the xr input to use with this pointer selection
  44436. */
  44437. xrInput: WebXRInput;
  44438. /**
  44439. * Different button type to use instead of the main component
  44440. */
  44441. overrideButtonId?: string;
  44442. /**
  44443. * The amount of time in miliseconds it takes between pick found something to a pointer down event.
  44444. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  44445. * 3000 means 3 seconds between pointing at something and selecting it
  44446. */
  44447. timeToSelect?: number;
  44448. /**
  44449. * 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)
  44450. * If not disabled, the last picked point will be used to execute a pointer up event
  44451. * If disabled, pointer up event will be triggered right after the pointer down event.
  44452. * Used in screen and gaze target ray mode only
  44453. */
  44454. disablePointerUpOnTouchOut: boolean;
  44455. /**
  44456. * For gaze mode (time to select instead of press)
  44457. */
  44458. forceGazeMode: boolean;
  44459. /**
  44460. * 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
  44461. * to start a new countdown to the pointer down event.
  44462. * Defaults to 1.
  44463. */
  44464. gazeModePointerMovedFactor?: number;
  44465. /**
  44466. * Should meshes created here be added to a utility layer or the main scene
  44467. */
  44468. useUtilityLayer?: boolean;
  44469. /**
  44470. * if provided, this scene will be used to render meshes.
  44471. */
  44472. customUtilityLayerScene?: Scene;
  44473. }
  44474. /**
  44475. * A module that will enable pointer selection for motion controllers of XR Input Sources
  44476. */
  44477. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  44478. private readonly _options;
  44479. /**
  44480. * The module's name
  44481. */
  44482. static readonly Name: string;
  44483. /**
  44484. * The (Babylon) version of this module.
  44485. * This is an integer representing the implementation version.
  44486. * This number does not correspond to the webxr specs version
  44487. */
  44488. static readonly Version: number;
  44489. /**
  44490. * This color will be set to the laser pointer when selection is triggered
  44491. */
  44492. laserPointerPickedColor: Color3;
  44493. /**
  44494. * This color will be applied to the selection ring when selection is triggered
  44495. */
  44496. selectionMeshPickedColor: Color3;
  44497. /**
  44498. * default color of the selection ring
  44499. */
  44500. selectionMeshDefaultColor: Color3;
  44501. /**
  44502. * Default color of the laser pointer
  44503. */
  44504. lasterPointerDefaultColor: Color3;
  44505. /**
  44506. * Should the laser pointer be displayed
  44507. */
  44508. displayLaserPointer: boolean;
  44509. /**
  44510. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  44511. */
  44512. displaySelectionMesh: boolean;
  44513. /**
  44514. * Disable lighting on the laser pointer (so it will always be visible)
  44515. */
  44516. disablePointerLighting: boolean;
  44517. /**
  44518. * Disable lighting on the selection mesh (so it will always be visible)
  44519. */
  44520. disableSelectionMeshLighting: boolean;
  44521. private static _idCounter;
  44522. private _tmpRay;
  44523. private _controllers;
  44524. private _scene;
  44525. /**
  44526. * constructs a new background remover module
  44527. * @param _xrSessionManager the session manager for this module
  44528. * @param _options read-only options to be used in this module
  44529. */
  44530. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  44531. /**
  44532. * attach this feature
  44533. * Will usually be called by the features manager
  44534. *
  44535. * @returns true if successful.
  44536. */
  44537. attach(): boolean;
  44538. /**
  44539. * detach this feature.
  44540. * Will usually be called by the features manager
  44541. *
  44542. * @returns true if successful.
  44543. */
  44544. detach(): boolean;
  44545. /**
  44546. * Get the xr controller that correlates to the pointer id in the pointer event
  44547. *
  44548. * @param id the pointer id to search for
  44549. * @returns the controller that correlates to this id or null if not found
  44550. */
  44551. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  44552. protected _onXRFrame(_xrFrame: XRFrame): void;
  44553. private _attachController;
  44554. private _attachScreenRayMode;
  44555. private _attachGazeMode;
  44556. private _tmpVectorForPickCompare;
  44557. private _pickingMoved;
  44558. private _attachTrackedPointerRayMode;
  44559. private _detachController;
  44560. private _generateNewMeshPair;
  44561. private _convertNormalToDirectionOfRay;
  44562. private _updatePointerDistance;
  44563. }
  44564. }
  44565. declare module BABYLON {
  44566. /**
  44567. * Button which can be used to enter a different mode of XR
  44568. */
  44569. export class WebXREnterExitUIButton {
  44570. /** button element */
  44571. element: HTMLElement;
  44572. /** XR initialization options for the button */
  44573. sessionMode: XRSessionMode;
  44574. /** Reference space type */
  44575. referenceSpaceType: XRReferenceSpaceType;
  44576. /**
  44577. * Creates a WebXREnterExitUIButton
  44578. * @param element button element
  44579. * @param sessionMode XR initialization session mode
  44580. * @param referenceSpaceType the type of reference space to be used
  44581. */
  44582. constructor(
  44583. /** button element */
  44584. element: HTMLElement,
  44585. /** XR initialization options for the button */
  44586. sessionMode: XRSessionMode,
  44587. /** Reference space type */
  44588. referenceSpaceType: XRReferenceSpaceType);
  44589. /**
  44590. * Overwritable function which can be used to update the button's visuals when the state changes
  44591. * @param activeButton the current active button in the UI
  44592. */
  44593. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  44594. }
  44595. /**
  44596. * Options to create the webXR UI
  44597. */
  44598. export class WebXREnterExitUIOptions {
  44599. /**
  44600. * Context to enter xr with
  44601. */
  44602. renderTarget?: Nullable<WebXRRenderTarget>;
  44603. /**
  44604. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  44605. */
  44606. customButtons?: Array<WebXREnterExitUIButton>;
  44607. /**
  44608. * A session mode to use when creating the default button.
  44609. * Default is immersive-vr
  44610. */
  44611. sessionMode?: XRSessionMode;
  44612. /**
  44613. * A reference space type to use when creating the default button.
  44614. * Default is local-floor
  44615. */
  44616. referenceSpaceType?: XRReferenceSpaceType;
  44617. }
  44618. /**
  44619. * UI to allow the user to enter/exit XR mode
  44620. */
  44621. export class WebXREnterExitUI implements IDisposable {
  44622. private scene;
  44623. /** version of the options passed to this UI */
  44624. options: WebXREnterExitUIOptions;
  44625. private _overlay;
  44626. private _buttons;
  44627. private _activeButton;
  44628. /**
  44629. * Fired every time the active button is changed.
  44630. *
  44631. * When xr is entered via a button that launches xr that button will be the callback parameter
  44632. *
  44633. * When exiting xr the callback parameter will be null)
  44634. */
  44635. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  44636. /**
  44637. * Creates UI to allow the user to enter/exit XR mode
  44638. * @param scene the scene to add the ui to
  44639. * @param helper the xr experience helper to enter/exit xr with
  44640. * @param options options to configure the UI
  44641. * @returns the created ui
  44642. */
  44643. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  44644. /**
  44645. *
  44646. * @param scene babylon scene object to use
  44647. * @param options (read-only) version of the options passed to this UI
  44648. */
  44649. private constructor();
  44650. private _updateButtons;
  44651. /**
  44652. * Disposes of the object
  44653. */
  44654. dispose(): void;
  44655. }
  44656. }
  44657. declare module BABYLON {
  44658. /**
  44659. * Class containing static functions to help procedurally build meshes
  44660. */
  44661. export class LinesBuilder {
  44662. /**
  44663. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  44664. * * 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
  44665. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  44666. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  44667. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  44668. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  44669. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  44670. * * 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
  44671. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  44672. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44673. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  44674. * @param name defines the name of the new line system
  44675. * @param options defines the options used to create the line system
  44676. * @param scene defines the hosting scene
  44677. * @returns a new line system mesh
  44678. */
  44679. static CreateLineSystem(name: string, options: {
  44680. lines: Vector3[][];
  44681. updatable?: boolean;
  44682. instance?: Nullable<LinesMesh>;
  44683. colors?: Nullable<Color4[][]>;
  44684. useVertexAlpha?: boolean;
  44685. }, scene: Nullable<Scene>): LinesMesh;
  44686. /**
  44687. * Creates a line mesh
  44688. * 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
  44689. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  44690. * * The parameter `points` is an array successive Vector3
  44691. * * 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
  44692. * * The optional parameter `colors` is an array of successive Color4, one per line point
  44693. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  44694. * * When updating an instance, remember that only point positions can change, not the number of points
  44695. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44696. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  44697. * @param name defines the name of the new line system
  44698. * @param options defines the options used to create the line system
  44699. * @param scene defines the hosting scene
  44700. * @returns a new line mesh
  44701. */
  44702. static CreateLines(name: string, options: {
  44703. points: Vector3[];
  44704. updatable?: boolean;
  44705. instance?: Nullable<LinesMesh>;
  44706. colors?: Color4[];
  44707. useVertexAlpha?: boolean;
  44708. }, scene?: Nullable<Scene>): LinesMesh;
  44709. /**
  44710. * Creates a dashed line mesh
  44711. * * 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
  44712. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  44713. * * The parameter `points` is an array successive Vector3
  44714. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  44715. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  44716. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  44717. * * 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
  44718. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  44719. * * When updating an instance, remember that only point positions can change, not the number of points
  44720. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44721. * @param name defines the name of the mesh
  44722. * @param options defines the options used to create the mesh
  44723. * @param scene defines the hosting scene
  44724. * @returns the dashed line mesh
  44725. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  44726. */
  44727. static CreateDashedLines(name: string, options: {
  44728. points: Vector3[];
  44729. dashSize?: number;
  44730. gapSize?: number;
  44731. dashNb?: number;
  44732. updatable?: boolean;
  44733. instance?: LinesMesh;
  44734. useVertexAlpha?: boolean;
  44735. }, scene?: Nullable<Scene>): LinesMesh;
  44736. }
  44737. }
  44738. declare module BABYLON {
  44739. /**
  44740. * The options container for the teleportation module
  44741. */
  44742. export interface IWebXRTeleportationOptions {
  44743. /**
  44744. * Babylon XR Input class for controller
  44745. */
  44746. xrInput: WebXRInput;
  44747. /**
  44748. * A list of meshes to use as floor meshes.
  44749. * Meshes can be added and removed after initializing the feature using the
  44750. * addFloorMesh and removeFloorMesh functions
  44751. * If empty, rotation will still work
  44752. */
  44753. floorMeshes?: AbstractMesh[];
  44754. /**
  44755. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  44756. * If you want to support rotation, make sure your mesh has a direction indicator.
  44757. *
  44758. * When left untouched, the default mesh will be initialized.
  44759. */
  44760. teleportationTargetMesh?: AbstractMesh;
  44761. /**
  44762. * Values to configure the default target mesh
  44763. */
  44764. defaultTargetMeshOptions?: {
  44765. /**
  44766. * Fill color of the teleportation area
  44767. */
  44768. teleportationFillColor?: string;
  44769. /**
  44770. * Border color for the teleportation area
  44771. */
  44772. teleportationBorderColor?: string;
  44773. /**
  44774. * Disable the mesh's animation sequence
  44775. */
  44776. disableAnimation?: boolean;
  44777. /**
  44778. * Disable lighting on the material or the ring and arrow
  44779. */
  44780. disableLighting?: boolean;
  44781. /**
  44782. * Override the default material of the torus and arrow
  44783. */
  44784. torusArrowMaterial?: Material;
  44785. };
  44786. /**
  44787. * Disable using the thumbstick and use the main component (usuallly trigger) on long press.
  44788. * This will be automatically true if the controller doesnt have a thumbstick or touchpad.
  44789. */
  44790. useMainComponentOnly?: boolean;
  44791. /**
  44792. * If main component is used (no thumbstick), how long should the "long press" take before teleporting
  44793. */
  44794. timeToTeleport?: number;
  44795. /**
  44796. * Should meshes created here be added to a utility layer or the main scene
  44797. */
  44798. useUtilityLayer?: boolean;
  44799. /**
  44800. * if provided, this scene will be used to render meshes.
  44801. */
  44802. customUtilityLayerScene?: Scene;
  44803. }
  44804. /**
  44805. * This is a teleportation feature to be used with webxr-enabled motion controllers.
  44806. * When enabled and attached, the feature will allow a user to move aroundand rotate in the scene using
  44807. * the input of the attached controllers.
  44808. */
  44809. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  44810. private _options;
  44811. /**
  44812. * The module's name
  44813. */
  44814. static readonly Name: string;
  44815. /**
  44816. * The (Babylon) version of this module.
  44817. * This is an integer representing the implementation version.
  44818. * This number does not correspond to the webxr specs version
  44819. */
  44820. static readonly Version: number;
  44821. /**
  44822. * Is rotation enabled when moving forward?
  44823. * Disabling this feature will prevent the user from deciding the direction when teleporting
  44824. */
  44825. rotationEnabled: boolean;
  44826. /**
  44827. * Should the module support parabolic ray on top of direct ray
  44828. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  44829. * Very helpful when moving between floors / different heights
  44830. */
  44831. parabolicRayEnabled: boolean;
  44832. /**
  44833. * The distance from the user to the inspection point in the direction of the controller
  44834. * A higher number will allow the user to move further
  44835. * defaults to 5 (meters, in xr units)
  44836. */
  44837. parabolicCheckRadius: number;
  44838. /**
  44839. * How much rotation should be applied when rotating right and left
  44840. */
  44841. rotationAngle: number;
  44842. /**
  44843. * Is movement backwards enabled
  44844. */
  44845. backwardsMovementEnabled: boolean;
  44846. /**
  44847. * Distance to travel when moving backwards
  44848. */
  44849. backwardsTeleportationDistance: number;
  44850. /**
  44851. * Add a new mesh to the floor meshes array
  44852. * @param mesh the mesh to use as floor mesh
  44853. */
  44854. addFloorMesh(mesh: AbstractMesh): void;
  44855. /**
  44856. * Remove a mesh from the floor meshes array
  44857. * @param mesh the mesh to remove
  44858. */
  44859. removeFloorMesh(mesh: AbstractMesh): void;
  44860. /**
  44861. * Remove a mesh from the floor meshes array using its name
  44862. * @param name the mesh name to remove
  44863. */
  44864. removeFloorMeshByName(name: string): void;
  44865. private _tmpRay;
  44866. private _tmpVector;
  44867. private _floorMeshes;
  44868. private _controllers;
  44869. /**
  44870. * constructs a new anchor system
  44871. * @param _xrSessionManager an instance of WebXRSessionManager
  44872. * @param _options configuration object for this feature
  44873. */
  44874. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  44875. private _selectionFeature;
  44876. /**
  44877. * This function sets a selection feature that will be disabled when
  44878. * the forward ray is shown and will be reattached when hidden.
  44879. * This is used to remove the selection rays when moving.
  44880. * @param selectionFeature the feature to disable when forward movement is enabled
  44881. */
  44882. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  44883. attach(): boolean;
  44884. detach(): boolean;
  44885. dispose(): void;
  44886. protected _onXRFrame(_xrFrame: XRFrame): void;
  44887. private _currentTeleportationControllerId;
  44888. private _attachController;
  44889. private _teleportForward;
  44890. private _detachController;
  44891. private createDefaultTargetMesh;
  44892. private setTargetMeshVisibility;
  44893. private setTargetMeshPosition;
  44894. private _quadraticBezierCurve;
  44895. private _showParabolicPath;
  44896. }
  44897. }
  44898. declare module BABYLON {
  44899. /**
  44900. * Options for the default xr helper
  44901. */
  44902. export class WebXRDefaultExperienceOptions {
  44903. /**
  44904. * Floor meshes that will be used for teleporting
  44905. */
  44906. floorMeshes?: Array<AbstractMesh>;
  44907. /**
  44908. * Enable or disable default UI to enter XR
  44909. */
  44910. disableDefaultUI?: boolean;
  44911. /**
  44912. * optional configuration for the output canvas
  44913. */
  44914. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  44915. /**
  44916. * optional UI options. This can be used among other to change session mode and reference space type
  44917. */
  44918. uiOptions?: WebXREnterExitUIOptions;
  44919. /**
  44920. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  44921. */
  44922. inputOptions?: IWebXRInputOptions;
  44923. /**
  44924. * Should teleportation not initialize. defaults to false.
  44925. */
  44926. disableTeleportation?: boolean;
  44927. /**
  44928. * If set to true, the first frame will not be used to reset position
  44929. * The first frame is mainly used when copying transformation from the old camera
  44930. * Mainly used in AR
  44931. */
  44932. ignoreNativeCameraTransformation?: boolean;
  44933. /**
  44934. * When loading teleportation and pointer select, use stable versions instead of latest.
  44935. */
  44936. useStablePlugins?: boolean;
  44937. }
  44938. /**
  44939. * Default experience which provides a similar setup to the previous webVRExperience
  44940. */
  44941. export class WebXRDefaultExperience {
  44942. /**
  44943. * Base experience
  44944. */
  44945. baseExperience: WebXRExperienceHelper;
  44946. /**
  44947. * Input experience extension
  44948. */
  44949. input: WebXRInput;
  44950. /**
  44951. * Enables laser pointer and selection
  44952. */
  44953. pointerSelection: WebXRControllerPointerSelection;
  44954. /**
  44955. * Enables teleportation
  44956. */
  44957. teleportation: WebXRMotionControllerTeleportation;
  44958. /**
  44959. * Enables ui for entering/exiting xr
  44960. */
  44961. enterExitUI: WebXREnterExitUI;
  44962. /**
  44963. * Default target xr should render to
  44964. */
  44965. renderTarget: WebXRRenderTarget;
  44966. /**
  44967. * Creates the default xr experience
  44968. * @param scene scene
  44969. * @param options options for basic configuration
  44970. * @returns resulting WebXRDefaultExperience
  44971. */
  44972. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  44973. private constructor();
  44974. /**
  44975. * DIsposes of the experience helper
  44976. */
  44977. dispose(): void;
  44978. }
  44979. }
  44980. declare module BABYLON {
  44981. /**
  44982. * Options to modify the vr teleportation behavior.
  44983. */
  44984. export interface VRTeleportationOptions {
  44985. /**
  44986. * The name of the mesh which should be used as the teleportation floor. (default: null)
  44987. */
  44988. floorMeshName?: string;
  44989. /**
  44990. * A list of meshes to be used as the teleportation floor. (default: empty)
  44991. */
  44992. floorMeshes?: Mesh[];
  44993. /**
  44994. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  44995. */
  44996. teleportationMode?: number;
  44997. /**
  44998. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  44999. */
  45000. teleportationTime?: number;
  45001. /**
  45002. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  45003. */
  45004. teleportationSpeed?: number;
  45005. /**
  45006. * The easing function used in the animation or null for Linear. (default CircleEase)
  45007. */
  45008. easingFunction?: EasingFunction;
  45009. }
  45010. /**
  45011. * Options to modify the vr experience helper's behavior.
  45012. */
  45013. export interface VRExperienceHelperOptions extends WebVROptions {
  45014. /**
  45015. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  45016. */
  45017. createDeviceOrientationCamera?: boolean;
  45018. /**
  45019. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  45020. */
  45021. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  45022. /**
  45023. * Uses the main button on the controller to toggle the laser casted. (default: true)
  45024. */
  45025. laserToggle?: boolean;
  45026. /**
  45027. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  45028. */
  45029. floorMeshes?: Mesh[];
  45030. /**
  45031. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  45032. */
  45033. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  45034. /**
  45035. * Defines if WebXR should be used instead of WebVR (if available)
  45036. */
  45037. useXR?: boolean;
  45038. }
  45039. /**
  45040. * Event containing information after VR has been entered
  45041. */
  45042. export class OnAfterEnteringVRObservableEvent {
  45043. /**
  45044. * If entering vr was successful
  45045. */
  45046. success: boolean;
  45047. }
  45048. /**
  45049. * Helps to quickly add VR support to an existing scene.
  45050. * See http://doc.babylonjs.com/how_to/webvr_helper
  45051. */
  45052. export class VRExperienceHelper {
  45053. /** Options to modify the vr experience helper's behavior. */
  45054. webVROptions: VRExperienceHelperOptions;
  45055. private _scene;
  45056. private _position;
  45057. private _btnVR;
  45058. private _btnVRDisplayed;
  45059. private _webVRsupported;
  45060. private _webVRready;
  45061. private _webVRrequesting;
  45062. private _webVRpresenting;
  45063. private _hasEnteredVR;
  45064. private _fullscreenVRpresenting;
  45065. private _inputElement;
  45066. private _webVRCamera;
  45067. private _vrDeviceOrientationCamera;
  45068. private _deviceOrientationCamera;
  45069. private _existingCamera;
  45070. private _onKeyDown;
  45071. private _onVrDisplayPresentChange;
  45072. private _onVRDisplayChanged;
  45073. private _onVRRequestPresentStart;
  45074. private _onVRRequestPresentComplete;
  45075. /**
  45076. * 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)
  45077. */
  45078. enableGazeEvenWhenNoPointerLock: boolean;
  45079. /**
  45080. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  45081. */
  45082. exitVROnDoubleTap: boolean;
  45083. /**
  45084. * Observable raised right before entering VR.
  45085. */
  45086. onEnteringVRObservable: Observable<VRExperienceHelper>;
  45087. /**
  45088. * Observable raised when entering VR has completed.
  45089. */
  45090. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  45091. /**
  45092. * Observable raised when exiting VR.
  45093. */
  45094. onExitingVRObservable: Observable<VRExperienceHelper>;
  45095. /**
  45096. * Observable raised when controller mesh is loaded.
  45097. */
  45098. onControllerMeshLoadedObservable: Observable<WebVRController>;
  45099. /** Return this.onEnteringVRObservable
  45100. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  45101. */
  45102. get onEnteringVR(): Observable<VRExperienceHelper>;
  45103. /** Return this.onExitingVRObservable
  45104. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  45105. */
  45106. get onExitingVR(): Observable<VRExperienceHelper>;
  45107. /** Return this.onControllerMeshLoadedObservable
  45108. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  45109. */
  45110. get onControllerMeshLoaded(): Observable<WebVRController>;
  45111. private _rayLength;
  45112. private _useCustomVRButton;
  45113. private _teleportationRequested;
  45114. private _teleportActive;
  45115. private _floorMeshName;
  45116. private _floorMeshesCollection;
  45117. private _teleportationMode;
  45118. private _teleportationTime;
  45119. private _teleportationSpeed;
  45120. private _teleportationEasing;
  45121. private _rotationAllowed;
  45122. private _teleportBackwardsVector;
  45123. private _teleportationTarget;
  45124. private _isDefaultTeleportationTarget;
  45125. private _postProcessMove;
  45126. private _teleportationFillColor;
  45127. private _teleportationBorderColor;
  45128. private _rotationAngle;
  45129. private _haloCenter;
  45130. private _cameraGazer;
  45131. private _padSensibilityUp;
  45132. private _padSensibilityDown;
  45133. private _leftController;
  45134. private _rightController;
  45135. private _gazeColor;
  45136. private _laserColor;
  45137. private _pickedLaserColor;
  45138. private _pickedGazeColor;
  45139. /**
  45140. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  45141. */
  45142. onNewMeshSelected: Observable<AbstractMesh>;
  45143. /**
  45144. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  45145. * This observable will provide the mesh and the controller used to select the mesh
  45146. */
  45147. onMeshSelectedWithController: Observable<{
  45148. mesh: AbstractMesh;
  45149. controller: WebVRController;
  45150. }>;
  45151. /**
  45152. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  45153. */
  45154. onNewMeshPicked: Observable<PickingInfo>;
  45155. private _circleEase;
  45156. /**
  45157. * Observable raised before camera teleportation
  45158. */
  45159. onBeforeCameraTeleport: Observable<Vector3>;
  45160. /**
  45161. * Observable raised after camera teleportation
  45162. */
  45163. onAfterCameraTeleport: Observable<Vector3>;
  45164. /**
  45165. * Observable raised when current selected mesh gets unselected
  45166. */
  45167. onSelectedMeshUnselected: Observable<AbstractMesh>;
  45168. private _raySelectionPredicate;
  45169. /**
  45170. * To be optionaly changed by user to define custom ray selection
  45171. */
  45172. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  45173. /**
  45174. * To be optionaly changed by user to define custom selection logic (after ray selection)
  45175. */
  45176. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  45177. /**
  45178. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  45179. */
  45180. teleportationEnabled: boolean;
  45181. private _defaultHeight;
  45182. private _teleportationInitialized;
  45183. private _interactionsEnabled;
  45184. private _interactionsRequested;
  45185. private _displayGaze;
  45186. private _displayLaserPointer;
  45187. /**
  45188. * The mesh used to display where the user is going to teleport.
  45189. */
  45190. get teleportationTarget(): Mesh;
  45191. /**
  45192. * Sets the mesh to be used to display where the user is going to teleport.
  45193. */
  45194. set teleportationTarget(value: Mesh);
  45195. /**
  45196. * 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
  45197. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  45198. * See http://doc.babylonjs.com/resources/baking_transformations
  45199. */
  45200. get gazeTrackerMesh(): Mesh;
  45201. set gazeTrackerMesh(value: Mesh);
  45202. /**
  45203. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  45204. */
  45205. updateGazeTrackerScale: boolean;
  45206. /**
  45207. * If the gaze trackers color should be updated when selecting meshes
  45208. */
  45209. updateGazeTrackerColor: boolean;
  45210. /**
  45211. * If the controller laser color should be updated when selecting meshes
  45212. */
  45213. updateControllerLaserColor: boolean;
  45214. /**
  45215. * The gaze tracking mesh corresponding to the left controller
  45216. */
  45217. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  45218. /**
  45219. * The gaze tracking mesh corresponding to the right controller
  45220. */
  45221. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  45222. /**
  45223. * If the ray of the gaze should be displayed.
  45224. */
  45225. get displayGaze(): boolean;
  45226. /**
  45227. * Sets if the ray of the gaze should be displayed.
  45228. */
  45229. set displayGaze(value: boolean);
  45230. /**
  45231. * If the ray of the LaserPointer should be displayed.
  45232. */
  45233. get displayLaserPointer(): boolean;
  45234. /**
  45235. * Sets if the ray of the LaserPointer should be displayed.
  45236. */
  45237. set displayLaserPointer(value: boolean);
  45238. /**
  45239. * The deviceOrientationCamera used as the camera when not in VR.
  45240. */
  45241. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  45242. /**
  45243. * Based on the current WebVR support, returns the current VR camera used.
  45244. */
  45245. get currentVRCamera(): Nullable<Camera>;
  45246. /**
  45247. * The webVRCamera which is used when in VR.
  45248. */
  45249. get webVRCamera(): WebVRFreeCamera;
  45250. /**
  45251. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  45252. */
  45253. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  45254. /**
  45255. * The html button that is used to trigger entering into VR.
  45256. */
  45257. get vrButton(): Nullable<HTMLButtonElement>;
  45258. private get _teleportationRequestInitiated();
  45259. /**
  45260. * Defines whether or not Pointer lock should be requested when switching to
  45261. * full screen.
  45262. */
  45263. requestPointerLockOnFullScreen: boolean;
  45264. /**
  45265. * If asking to force XR, this will be populated with the default xr experience
  45266. */
  45267. xr: WebXRDefaultExperience;
  45268. /**
  45269. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  45270. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  45271. */
  45272. xrTestDone: boolean;
  45273. /**
  45274. * Instantiates a VRExperienceHelper.
  45275. * Helps to quickly add VR support to an existing scene.
  45276. * @param scene The scene the VRExperienceHelper belongs to.
  45277. * @param webVROptions Options to modify the vr experience helper's behavior.
  45278. */
  45279. constructor(scene: Scene,
  45280. /** Options to modify the vr experience helper's behavior. */
  45281. webVROptions?: VRExperienceHelperOptions);
  45282. private completeVRInit;
  45283. private _onDefaultMeshLoaded;
  45284. private _onResize;
  45285. private _onFullscreenChange;
  45286. /**
  45287. * Gets a value indicating if we are currently in VR mode.
  45288. */
  45289. get isInVRMode(): boolean;
  45290. private onVrDisplayPresentChange;
  45291. private onVRDisplayChanged;
  45292. private moveButtonToBottomRight;
  45293. private displayVRButton;
  45294. private updateButtonVisibility;
  45295. private _cachedAngularSensibility;
  45296. /**
  45297. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  45298. * Otherwise, will use the fullscreen API.
  45299. */
  45300. enterVR(): void;
  45301. /**
  45302. * Attempt to exit VR, or fullscreen.
  45303. */
  45304. exitVR(): void;
  45305. /**
  45306. * The position of the vr experience helper.
  45307. */
  45308. get position(): Vector3;
  45309. /**
  45310. * Sets the position of the vr experience helper.
  45311. */
  45312. set position(value: Vector3);
  45313. /**
  45314. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  45315. */
  45316. enableInteractions(): void;
  45317. private get _noControllerIsActive();
  45318. private beforeRender;
  45319. private _isTeleportationFloor;
  45320. /**
  45321. * Adds a floor mesh to be used for teleportation.
  45322. * @param floorMesh the mesh to be used for teleportation.
  45323. */
  45324. addFloorMesh(floorMesh: Mesh): void;
  45325. /**
  45326. * Removes a floor mesh from being used for teleportation.
  45327. * @param floorMesh the mesh to be removed.
  45328. */
  45329. removeFloorMesh(floorMesh: Mesh): void;
  45330. /**
  45331. * Enables interactions and teleportation using the VR controllers and gaze.
  45332. * @param vrTeleportationOptions options to modify teleportation behavior.
  45333. */
  45334. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  45335. private _onNewGamepadConnected;
  45336. private _tryEnableInteractionOnController;
  45337. private _onNewGamepadDisconnected;
  45338. private _enableInteractionOnController;
  45339. private _checkTeleportWithRay;
  45340. private _checkRotate;
  45341. private _checkTeleportBackwards;
  45342. private _enableTeleportationOnController;
  45343. private _createTeleportationCircles;
  45344. private _displayTeleportationTarget;
  45345. private _hideTeleportationTarget;
  45346. private _rotateCamera;
  45347. private _moveTeleportationSelectorTo;
  45348. private _workingVector;
  45349. private _workingQuaternion;
  45350. private _workingMatrix;
  45351. /**
  45352. * Time Constant Teleportation Mode
  45353. */
  45354. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  45355. /**
  45356. * Speed Constant Teleportation Mode
  45357. */
  45358. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  45359. /**
  45360. * Teleports the users feet to the desired location
  45361. * @param location The location where the user's feet should be placed
  45362. */
  45363. teleportCamera(location: Vector3): void;
  45364. private _convertNormalToDirectionOfRay;
  45365. private _castRayAndSelectObject;
  45366. private _notifySelectedMeshUnselected;
  45367. /**
  45368. * Permanently set new colors for the laser pointer
  45369. * @param color the new laser color
  45370. * @param pickedColor the new laser color when picked mesh detected
  45371. */
  45372. setLaserColor(color: Color3, pickedColor?: Color3): void;
  45373. /**
  45374. * Set lighting enabled / disabled on the laser pointer of both controllers
  45375. * @param enabled should the lighting be enabled on the laser pointer
  45376. */
  45377. setLaserLightingState(enabled?: boolean): void;
  45378. /**
  45379. * Permanently set new colors for the gaze pointer
  45380. * @param color the new gaze color
  45381. * @param pickedColor the new gaze color when picked mesh detected
  45382. */
  45383. setGazeColor(color: Color3, pickedColor?: Color3): void;
  45384. /**
  45385. * Sets the color of the laser ray from the vr controllers.
  45386. * @param color new color for the ray.
  45387. */
  45388. changeLaserColor(color: Color3): void;
  45389. /**
  45390. * Sets the color of the ray from the vr headsets gaze.
  45391. * @param color new color for the ray.
  45392. */
  45393. changeGazeColor(color: Color3): void;
  45394. /**
  45395. * Exits VR and disposes of the vr experience helper
  45396. */
  45397. dispose(): void;
  45398. /**
  45399. * Gets the name of the VRExperienceHelper class
  45400. * @returns "VRExperienceHelper"
  45401. */
  45402. getClassName(): string;
  45403. }
  45404. }
  45405. declare module BABYLON {
  45406. /**
  45407. * Contains an array of blocks representing the octree
  45408. */
  45409. export interface IOctreeContainer<T> {
  45410. /**
  45411. * Blocks within the octree
  45412. */
  45413. blocks: Array<OctreeBlock<T>>;
  45414. }
  45415. /**
  45416. * Class used to store a cell in an octree
  45417. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45418. */
  45419. export class OctreeBlock<T> {
  45420. /**
  45421. * Gets the content of the current block
  45422. */
  45423. entries: T[];
  45424. /**
  45425. * Gets the list of block children
  45426. */
  45427. blocks: Array<OctreeBlock<T>>;
  45428. private _depth;
  45429. private _maxDepth;
  45430. private _capacity;
  45431. private _minPoint;
  45432. private _maxPoint;
  45433. private _boundingVectors;
  45434. private _creationFunc;
  45435. /**
  45436. * Creates a new block
  45437. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  45438. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  45439. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  45440. * @param depth defines the current depth of this block in the octree
  45441. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  45442. * @param creationFunc defines a callback to call when an element is added to the block
  45443. */
  45444. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  45445. /**
  45446. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  45447. */
  45448. get capacity(): number;
  45449. /**
  45450. * Gets the minimum vector (in world space) of the block's bounding box
  45451. */
  45452. get minPoint(): Vector3;
  45453. /**
  45454. * Gets the maximum vector (in world space) of the block's bounding box
  45455. */
  45456. get maxPoint(): Vector3;
  45457. /**
  45458. * Add a new element to this block
  45459. * @param entry defines the element to add
  45460. */
  45461. addEntry(entry: T): void;
  45462. /**
  45463. * Remove an element from this block
  45464. * @param entry defines the element to remove
  45465. */
  45466. removeEntry(entry: T): void;
  45467. /**
  45468. * Add an array of elements to this block
  45469. * @param entries defines the array of elements to add
  45470. */
  45471. addEntries(entries: T[]): void;
  45472. /**
  45473. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  45474. * @param frustumPlanes defines the frustum planes to test
  45475. * @param selection defines the array to store current content if selection is positive
  45476. * @param allowDuplicate defines if the selection array can contains duplicated entries
  45477. */
  45478. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  45479. /**
  45480. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  45481. * @param sphereCenter defines the bounding sphere center
  45482. * @param sphereRadius defines the bounding sphere radius
  45483. * @param selection defines the array to store current content if selection is positive
  45484. * @param allowDuplicate defines if the selection array can contains duplicated entries
  45485. */
  45486. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  45487. /**
  45488. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  45489. * @param ray defines the ray to test with
  45490. * @param selection defines the array to store current content if selection is positive
  45491. */
  45492. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  45493. /**
  45494. * Subdivide the content into child blocks (this block will then be empty)
  45495. */
  45496. createInnerBlocks(): void;
  45497. /**
  45498. * @hidden
  45499. */
  45500. 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;
  45501. }
  45502. }
  45503. declare module BABYLON {
  45504. /**
  45505. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  45506. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45507. */
  45508. export class Octree<T> {
  45509. /** 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.) */
  45510. maxDepth: number;
  45511. /**
  45512. * Blocks within the octree containing objects
  45513. */
  45514. blocks: Array<OctreeBlock<T>>;
  45515. /**
  45516. * Content stored in the octree
  45517. */
  45518. dynamicContent: T[];
  45519. private _maxBlockCapacity;
  45520. private _selectionContent;
  45521. private _creationFunc;
  45522. /**
  45523. * Creates a octree
  45524. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45525. * @param creationFunc function to be used to instatiate the octree
  45526. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  45527. * @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.)
  45528. */
  45529. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  45530. /** 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.) */
  45531. maxDepth?: number);
  45532. /**
  45533. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  45534. * @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);
  45535. * @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);
  45536. * @param entries meshes to be added to the octree blocks
  45537. */
  45538. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  45539. /**
  45540. * Adds a mesh to the octree
  45541. * @param entry Mesh to add to the octree
  45542. */
  45543. addMesh(entry: T): void;
  45544. /**
  45545. * Remove an element from the octree
  45546. * @param entry defines the element to remove
  45547. */
  45548. removeMesh(entry: T): void;
  45549. /**
  45550. * Selects an array of meshes within the frustum
  45551. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  45552. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  45553. * @returns array of meshes within the frustum
  45554. */
  45555. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  45556. /**
  45557. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  45558. * @param sphereCenter defines the bounding sphere center
  45559. * @param sphereRadius defines the bounding sphere radius
  45560. * @param allowDuplicate defines if the selection array can contains duplicated entries
  45561. * @returns an array of objects that intersect the sphere
  45562. */
  45563. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  45564. /**
  45565. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  45566. * @param ray defines the ray to test with
  45567. * @returns array of intersected objects
  45568. */
  45569. intersectsRay(ray: Ray): SmartArray<T>;
  45570. /**
  45571. * Adds a mesh into the octree block if it intersects the block
  45572. */
  45573. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  45574. /**
  45575. * Adds a submesh into the octree block if it intersects the block
  45576. */
  45577. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  45578. }
  45579. }
  45580. declare module BABYLON {
  45581. interface Scene {
  45582. /**
  45583. * @hidden
  45584. * Backing Filed
  45585. */
  45586. _selectionOctree: Octree<AbstractMesh>;
  45587. /**
  45588. * Gets the octree used to boost mesh selection (picking)
  45589. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45590. */
  45591. selectionOctree: Octree<AbstractMesh>;
  45592. /**
  45593. * Creates or updates the octree used to boost selection (picking)
  45594. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45595. * @param maxCapacity defines the maximum capacity per leaf
  45596. * @param maxDepth defines the maximum depth of the octree
  45597. * @returns an octree of AbstractMesh
  45598. */
  45599. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  45600. }
  45601. interface AbstractMesh {
  45602. /**
  45603. * @hidden
  45604. * Backing Field
  45605. */
  45606. _submeshesOctree: Octree<SubMesh>;
  45607. /**
  45608. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  45609. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  45610. * @param maxCapacity defines the maximum size of each block (64 by default)
  45611. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  45612. * @returns the new octree
  45613. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  45614. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45615. */
  45616. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  45617. }
  45618. /**
  45619. * Defines the octree scene component responsible to manage any octrees
  45620. * in a given scene.
  45621. */
  45622. export class OctreeSceneComponent {
  45623. /**
  45624. * The component name help to identify the component in the list of scene components.
  45625. */
  45626. readonly name: string;
  45627. /**
  45628. * The scene the component belongs to.
  45629. */
  45630. scene: Scene;
  45631. /**
  45632. * Indicates if the meshes have been checked to make sure they are isEnabled()
  45633. */
  45634. readonly checksIsEnabled: boolean;
  45635. /**
  45636. * Creates a new instance of the component for the given scene
  45637. * @param scene Defines the scene to register the component in
  45638. */
  45639. constructor(scene: Scene);
  45640. /**
  45641. * Registers the component in a given scene
  45642. */
  45643. register(): void;
  45644. /**
  45645. * Return the list of active meshes
  45646. * @returns the list of active meshes
  45647. */
  45648. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  45649. /**
  45650. * Return the list of active sub meshes
  45651. * @param mesh The mesh to get the candidates sub meshes from
  45652. * @returns the list of active sub meshes
  45653. */
  45654. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  45655. private _tempRay;
  45656. /**
  45657. * Return the list of sub meshes intersecting with a given local ray
  45658. * @param mesh defines the mesh to find the submesh for
  45659. * @param localRay defines the ray in local space
  45660. * @returns the list of intersecting sub meshes
  45661. */
  45662. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  45663. /**
  45664. * Return the list of sub meshes colliding with a collider
  45665. * @param mesh defines the mesh to find the submesh for
  45666. * @param collider defines the collider to evaluate the collision against
  45667. * @returns the list of colliding sub meshes
  45668. */
  45669. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  45670. /**
  45671. * Rebuilds the elements related to this component in case of
  45672. * context lost for instance.
  45673. */
  45674. rebuild(): void;
  45675. /**
  45676. * Disposes the component and the associated ressources.
  45677. */
  45678. dispose(): void;
  45679. }
  45680. }
  45681. declare module BABYLON {
  45682. /**
  45683. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  45684. */
  45685. export class Gizmo implements IDisposable {
  45686. /** The utility layer the gizmo will be added to */
  45687. gizmoLayer: UtilityLayerRenderer;
  45688. /**
  45689. * The root mesh of the gizmo
  45690. */
  45691. _rootMesh: Mesh;
  45692. private _attachedMesh;
  45693. /**
  45694. * Ratio for the scale of the gizmo (Default: 1)
  45695. */
  45696. scaleRatio: number;
  45697. /**
  45698. * If a custom mesh has been set (Default: false)
  45699. */
  45700. protected _customMeshSet: boolean;
  45701. /**
  45702. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  45703. * * When set, interactions will be enabled
  45704. */
  45705. get attachedMesh(): Nullable<AbstractMesh>;
  45706. set attachedMesh(value: Nullable<AbstractMesh>);
  45707. /**
  45708. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  45709. * @param mesh The mesh to replace the default mesh of the gizmo
  45710. */
  45711. setCustomMesh(mesh: Mesh): void;
  45712. /**
  45713. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  45714. */
  45715. updateGizmoRotationToMatchAttachedMesh: boolean;
  45716. /**
  45717. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  45718. */
  45719. updateGizmoPositionToMatchAttachedMesh: boolean;
  45720. /**
  45721. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  45722. */
  45723. updateScale: boolean;
  45724. protected _interactionsEnabled: boolean;
  45725. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45726. private _beforeRenderObserver;
  45727. private _tempVector;
  45728. /**
  45729. * Creates a gizmo
  45730. * @param gizmoLayer The utility layer the gizmo will be added to
  45731. */
  45732. constructor(
  45733. /** The utility layer the gizmo will be added to */
  45734. gizmoLayer?: UtilityLayerRenderer);
  45735. /**
  45736. * Updates the gizmo to match the attached mesh's position/rotation
  45737. */
  45738. protected _update(): void;
  45739. /**
  45740. * Disposes of the gizmo
  45741. */
  45742. dispose(): void;
  45743. }
  45744. }
  45745. declare module BABYLON {
  45746. /**
  45747. * Single plane drag gizmo
  45748. */
  45749. export class PlaneDragGizmo extends Gizmo {
  45750. /**
  45751. * Drag behavior responsible for the gizmos dragging interactions
  45752. */
  45753. dragBehavior: PointerDragBehavior;
  45754. private _pointerObserver;
  45755. /**
  45756. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45757. */
  45758. snapDistance: number;
  45759. /**
  45760. * Event that fires each time the gizmo snaps to a new location.
  45761. * * snapDistance is the the change in distance
  45762. */
  45763. onSnapObservable: Observable<{
  45764. snapDistance: number;
  45765. }>;
  45766. private _plane;
  45767. private _coloredMaterial;
  45768. private _hoverMaterial;
  45769. private _isEnabled;
  45770. private _parent;
  45771. /** @hidden */
  45772. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  45773. /** @hidden */
  45774. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  45775. /**
  45776. * Creates a PlaneDragGizmo
  45777. * @param gizmoLayer The utility layer the gizmo will be added to
  45778. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  45779. * @param color The color of the gizmo
  45780. */
  45781. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  45782. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45783. /**
  45784. * If the gizmo is enabled
  45785. */
  45786. set isEnabled(value: boolean);
  45787. get isEnabled(): boolean;
  45788. /**
  45789. * Disposes of the gizmo
  45790. */
  45791. dispose(): void;
  45792. }
  45793. }
  45794. declare module BABYLON {
  45795. /**
  45796. * Gizmo that enables dragging a mesh along 3 axis
  45797. */
  45798. export class PositionGizmo extends Gizmo {
  45799. /**
  45800. * Internal gizmo used for interactions on the x axis
  45801. */
  45802. xGizmo: AxisDragGizmo;
  45803. /**
  45804. * Internal gizmo used for interactions on the y axis
  45805. */
  45806. yGizmo: AxisDragGizmo;
  45807. /**
  45808. * Internal gizmo used for interactions on the z axis
  45809. */
  45810. zGizmo: AxisDragGizmo;
  45811. /**
  45812. * Internal gizmo used for interactions on the yz plane
  45813. */
  45814. xPlaneGizmo: PlaneDragGizmo;
  45815. /**
  45816. * Internal gizmo used for interactions on the xz plane
  45817. */
  45818. yPlaneGizmo: PlaneDragGizmo;
  45819. /**
  45820. * Internal gizmo used for interactions on the xy plane
  45821. */
  45822. zPlaneGizmo: PlaneDragGizmo;
  45823. /**
  45824. * private variables
  45825. */
  45826. private _meshAttached;
  45827. private _updateGizmoRotationToMatchAttachedMesh;
  45828. private _snapDistance;
  45829. private _scaleRatio;
  45830. /** Fires an event when any of it's sub gizmos are dragged */
  45831. onDragStartObservable: Observable<unknown>;
  45832. /** Fires an event when any of it's sub gizmos are released from dragging */
  45833. onDragEndObservable: Observable<unknown>;
  45834. /**
  45835. * If set to true, planar drag is enabled
  45836. */
  45837. private _planarGizmoEnabled;
  45838. get attachedMesh(): Nullable<AbstractMesh>;
  45839. set attachedMesh(mesh: Nullable<AbstractMesh>);
  45840. /**
  45841. * Creates a PositionGizmo
  45842. * @param gizmoLayer The utility layer the gizmo will be added to
  45843. */
  45844. constructor(gizmoLayer?: UtilityLayerRenderer);
  45845. /**
  45846. * If the planar drag gizmo is enabled
  45847. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  45848. */
  45849. set planarGizmoEnabled(value: boolean);
  45850. get planarGizmoEnabled(): boolean;
  45851. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  45852. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  45853. /**
  45854. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45855. */
  45856. set snapDistance(value: number);
  45857. get snapDistance(): number;
  45858. /**
  45859. * Ratio for the scale of the gizmo (Default: 1)
  45860. */
  45861. set scaleRatio(value: number);
  45862. get scaleRatio(): number;
  45863. /**
  45864. * Disposes of the gizmo
  45865. */
  45866. dispose(): void;
  45867. /**
  45868. * CustomMeshes are not supported by this gizmo
  45869. * @param mesh The mesh to replace the default mesh of the gizmo
  45870. */
  45871. setCustomMesh(mesh: Mesh): void;
  45872. }
  45873. }
  45874. declare module BABYLON {
  45875. /**
  45876. * Single axis drag gizmo
  45877. */
  45878. export class AxisDragGizmo extends Gizmo {
  45879. /**
  45880. * Drag behavior responsible for the gizmos dragging interactions
  45881. */
  45882. dragBehavior: PointerDragBehavior;
  45883. private _pointerObserver;
  45884. /**
  45885. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45886. */
  45887. snapDistance: number;
  45888. /**
  45889. * Event that fires each time the gizmo snaps to a new location.
  45890. * * snapDistance is the the change in distance
  45891. */
  45892. onSnapObservable: Observable<{
  45893. snapDistance: number;
  45894. }>;
  45895. private _isEnabled;
  45896. private _parent;
  45897. private _arrow;
  45898. private _coloredMaterial;
  45899. private _hoverMaterial;
  45900. /** @hidden */
  45901. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  45902. /** @hidden */
  45903. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  45904. /**
  45905. * Creates an AxisDragGizmo
  45906. * @param gizmoLayer The utility layer the gizmo will be added to
  45907. * @param dragAxis The axis which the gizmo will be able to drag on
  45908. * @param color The color of the gizmo
  45909. */
  45910. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  45911. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45912. /**
  45913. * If the gizmo is enabled
  45914. */
  45915. set isEnabled(value: boolean);
  45916. get isEnabled(): boolean;
  45917. /**
  45918. * Disposes of the gizmo
  45919. */
  45920. dispose(): void;
  45921. }
  45922. }
  45923. declare module BABYLON.Debug {
  45924. /**
  45925. * The Axes viewer will show 3 axes in a specific point in space
  45926. */
  45927. export class AxesViewer {
  45928. private _xAxis;
  45929. private _yAxis;
  45930. private _zAxis;
  45931. private _scaleLinesFactor;
  45932. private _instanced;
  45933. /**
  45934. * Gets the hosting scene
  45935. */
  45936. scene: Scene;
  45937. /**
  45938. * Gets or sets a number used to scale line length
  45939. */
  45940. scaleLines: number;
  45941. /** Gets the node hierarchy used to render x-axis */
  45942. get xAxis(): TransformNode;
  45943. /** Gets the node hierarchy used to render y-axis */
  45944. get yAxis(): TransformNode;
  45945. /** Gets the node hierarchy used to render z-axis */
  45946. get zAxis(): TransformNode;
  45947. /**
  45948. * Creates a new AxesViewer
  45949. * @param scene defines the hosting scene
  45950. * @param scaleLines defines a number used to scale line length (1 by default)
  45951. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  45952. * @param xAxis defines the node hierarchy used to render the x-axis
  45953. * @param yAxis defines the node hierarchy used to render the y-axis
  45954. * @param zAxis defines the node hierarchy used to render the z-axis
  45955. */
  45956. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  45957. /**
  45958. * Force the viewer to update
  45959. * @param position defines the position of the viewer
  45960. * @param xaxis defines the x axis of the viewer
  45961. * @param yaxis defines the y axis of the viewer
  45962. * @param zaxis defines the z axis of the viewer
  45963. */
  45964. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  45965. /**
  45966. * Creates an instance of this axes viewer.
  45967. * @returns a new axes viewer with instanced meshes
  45968. */
  45969. createInstance(): AxesViewer;
  45970. /** Releases resources */
  45971. dispose(): void;
  45972. private static _SetRenderingGroupId;
  45973. }
  45974. }
  45975. declare module BABYLON.Debug {
  45976. /**
  45977. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  45978. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  45979. */
  45980. export class BoneAxesViewer extends AxesViewer {
  45981. /**
  45982. * Gets or sets the target mesh where to display the axes viewer
  45983. */
  45984. mesh: Nullable<Mesh>;
  45985. /**
  45986. * Gets or sets the target bone where to display the axes viewer
  45987. */
  45988. bone: Nullable<Bone>;
  45989. /** Gets current position */
  45990. pos: Vector3;
  45991. /** Gets direction of X axis */
  45992. xaxis: Vector3;
  45993. /** Gets direction of Y axis */
  45994. yaxis: Vector3;
  45995. /** Gets direction of Z axis */
  45996. zaxis: Vector3;
  45997. /**
  45998. * Creates a new BoneAxesViewer
  45999. * @param scene defines the hosting scene
  46000. * @param bone defines the target bone
  46001. * @param mesh defines the target mesh
  46002. * @param scaleLines defines a scaling factor for line length (1 by default)
  46003. */
  46004. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  46005. /**
  46006. * Force the viewer to update
  46007. */
  46008. update(): void;
  46009. /** Releases resources */
  46010. dispose(): void;
  46011. }
  46012. }
  46013. declare module BABYLON {
  46014. /**
  46015. * Interface used to define scene explorer extensibility option
  46016. */
  46017. export interface IExplorerExtensibilityOption {
  46018. /**
  46019. * Define the option label
  46020. */
  46021. label: string;
  46022. /**
  46023. * Defines the action to execute on click
  46024. */
  46025. action: (entity: any) => void;
  46026. }
  46027. /**
  46028. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  46029. */
  46030. export interface IExplorerExtensibilityGroup {
  46031. /**
  46032. * Defines a predicate to test if a given type mut be extended
  46033. */
  46034. predicate: (entity: any) => boolean;
  46035. /**
  46036. * Gets the list of options added to a type
  46037. */
  46038. entries: IExplorerExtensibilityOption[];
  46039. }
  46040. /**
  46041. * Interface used to define the options to use to create the Inspector
  46042. */
  46043. export interface IInspectorOptions {
  46044. /**
  46045. * Display in overlay mode (default: false)
  46046. */
  46047. overlay?: boolean;
  46048. /**
  46049. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  46050. */
  46051. globalRoot?: HTMLElement;
  46052. /**
  46053. * Display the Scene explorer
  46054. */
  46055. showExplorer?: boolean;
  46056. /**
  46057. * Display the property inspector
  46058. */
  46059. showInspector?: boolean;
  46060. /**
  46061. * Display in embed mode (both panes on the right)
  46062. */
  46063. embedMode?: boolean;
  46064. /**
  46065. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  46066. */
  46067. handleResize?: boolean;
  46068. /**
  46069. * Allow the panes to popup (default: true)
  46070. */
  46071. enablePopup?: boolean;
  46072. /**
  46073. * Allow the panes to be closed by users (default: true)
  46074. */
  46075. enableClose?: boolean;
  46076. /**
  46077. * Optional list of extensibility entries
  46078. */
  46079. explorerExtensibility?: IExplorerExtensibilityGroup[];
  46080. /**
  46081. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  46082. */
  46083. inspectorURL?: string;
  46084. /**
  46085. * Optional initial tab (default to DebugLayerTab.Properties)
  46086. */
  46087. initialTab?: DebugLayerTab;
  46088. }
  46089. interface Scene {
  46090. /**
  46091. * @hidden
  46092. * Backing field
  46093. */
  46094. _debugLayer: DebugLayer;
  46095. /**
  46096. * Gets the debug layer (aka Inspector) associated with the scene
  46097. * @see http://doc.babylonjs.com/features/playground_debuglayer
  46098. */
  46099. debugLayer: DebugLayer;
  46100. }
  46101. /**
  46102. * Enum of inspector action tab
  46103. */
  46104. export enum DebugLayerTab {
  46105. /**
  46106. * Properties tag (default)
  46107. */
  46108. Properties = 0,
  46109. /**
  46110. * Debug tab
  46111. */
  46112. Debug = 1,
  46113. /**
  46114. * Statistics tab
  46115. */
  46116. Statistics = 2,
  46117. /**
  46118. * Tools tab
  46119. */
  46120. Tools = 3,
  46121. /**
  46122. * Settings tab
  46123. */
  46124. Settings = 4
  46125. }
  46126. /**
  46127. * The debug layer (aka Inspector) is the go to tool in order to better understand
  46128. * what is happening in your scene
  46129. * @see http://doc.babylonjs.com/features/playground_debuglayer
  46130. */
  46131. export class DebugLayer {
  46132. /**
  46133. * Define the url to get the inspector script from.
  46134. * By default it uses the babylonjs CDN.
  46135. * @ignoreNaming
  46136. */
  46137. static InspectorURL: string;
  46138. private _scene;
  46139. private BJSINSPECTOR;
  46140. private _onPropertyChangedObservable?;
  46141. /**
  46142. * Observable triggered when a property is changed through the inspector.
  46143. */
  46144. get onPropertyChangedObservable(): any;
  46145. /**
  46146. * Instantiates a new debug layer.
  46147. * The debug layer (aka Inspector) is the go to tool in order to better understand
  46148. * what is happening in your scene
  46149. * @see http://doc.babylonjs.com/features/playground_debuglayer
  46150. * @param scene Defines the scene to inspect
  46151. */
  46152. constructor(scene: Scene);
  46153. /** Creates the inspector window. */
  46154. private _createInspector;
  46155. /**
  46156. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  46157. * @param entity defines the entity to select
  46158. * @param lineContainerTitle defines the specific block to highlight
  46159. */
  46160. select(entity: any, lineContainerTitle?: string): void;
  46161. /** Get the inspector from bundle or global */
  46162. private _getGlobalInspector;
  46163. /**
  46164. * Get if the inspector is visible or not.
  46165. * @returns true if visible otherwise, false
  46166. */
  46167. isVisible(): boolean;
  46168. /**
  46169. * Hide the inspector and close its window.
  46170. */
  46171. hide(): void;
  46172. /**
  46173. * Launch the debugLayer.
  46174. * @param config Define the configuration of the inspector
  46175. * @return a promise fulfilled when the debug layer is visible
  46176. */
  46177. show(config?: IInspectorOptions): Promise<DebugLayer>;
  46178. }
  46179. }
  46180. declare module BABYLON {
  46181. /**
  46182. * Class containing static functions to help procedurally build meshes
  46183. */
  46184. export class BoxBuilder {
  46185. /**
  46186. * Creates a box mesh
  46187. * * The parameter `size` sets the size (float) of each box side (default 1)
  46188. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  46189. * * 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)
  46190. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  46191. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46192. * * 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
  46193. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46194. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  46195. * @param name defines the name of the mesh
  46196. * @param options defines the options used to create the mesh
  46197. * @param scene defines the hosting scene
  46198. * @returns the box mesh
  46199. */
  46200. static CreateBox(name: string, options: {
  46201. size?: number;
  46202. width?: number;
  46203. height?: number;
  46204. depth?: number;
  46205. faceUV?: Vector4[];
  46206. faceColors?: Color4[];
  46207. sideOrientation?: number;
  46208. frontUVs?: Vector4;
  46209. backUVs?: Vector4;
  46210. wrap?: boolean;
  46211. topBaseAt?: number;
  46212. bottomBaseAt?: number;
  46213. updatable?: boolean;
  46214. }, scene?: Nullable<Scene>): Mesh;
  46215. }
  46216. }
  46217. declare module BABYLON.Debug {
  46218. /**
  46219. * Used to show the physics impostor around the specific mesh
  46220. */
  46221. export class PhysicsViewer {
  46222. /** @hidden */
  46223. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  46224. /** @hidden */
  46225. protected _meshes: Array<Nullable<AbstractMesh>>;
  46226. /** @hidden */
  46227. protected _scene: Nullable<Scene>;
  46228. /** @hidden */
  46229. protected _numMeshes: number;
  46230. /** @hidden */
  46231. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  46232. private _renderFunction;
  46233. private _utilityLayer;
  46234. private _debugBoxMesh;
  46235. private _debugSphereMesh;
  46236. private _debugCylinderMesh;
  46237. private _debugMaterial;
  46238. private _debugMeshMeshes;
  46239. /**
  46240. * Creates a new PhysicsViewer
  46241. * @param scene defines the hosting scene
  46242. */
  46243. constructor(scene: Scene);
  46244. /** @hidden */
  46245. protected _updateDebugMeshes(): void;
  46246. /**
  46247. * Renders a specified physic impostor
  46248. * @param impostor defines the impostor to render
  46249. * @param targetMesh defines the mesh represented by the impostor
  46250. * @returns the new debug mesh used to render the impostor
  46251. */
  46252. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  46253. /**
  46254. * Hides a specified physic impostor
  46255. * @param impostor defines the impostor to hide
  46256. */
  46257. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  46258. private _getDebugMaterial;
  46259. private _getDebugBoxMesh;
  46260. private _getDebugSphereMesh;
  46261. private _getDebugCylinderMesh;
  46262. private _getDebugMeshMesh;
  46263. private _getDebugMesh;
  46264. /** Releases all resources */
  46265. dispose(): void;
  46266. }
  46267. }
  46268. declare module BABYLON {
  46269. /**
  46270. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  46271. * in order to better appreciate the issue one might have.
  46272. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  46273. */
  46274. export class RayHelper {
  46275. /**
  46276. * Defines the ray we are currently tryin to visualize.
  46277. */
  46278. ray: Nullable<Ray>;
  46279. private _renderPoints;
  46280. private _renderLine;
  46281. private _renderFunction;
  46282. private _scene;
  46283. private _updateToMeshFunction;
  46284. private _attachedToMesh;
  46285. private _meshSpaceDirection;
  46286. private _meshSpaceOrigin;
  46287. /**
  46288. * Helper function to create a colored helper in a scene in one line.
  46289. * @param ray Defines the ray we are currently tryin to visualize
  46290. * @param scene Defines the scene the ray is used in
  46291. * @param color Defines the color we want to see the ray in
  46292. * @returns The newly created ray helper.
  46293. */
  46294. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  46295. /**
  46296. * Instantiate a new ray helper.
  46297. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  46298. * in order to better appreciate the issue one might have.
  46299. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  46300. * @param ray Defines the ray we are currently tryin to visualize
  46301. */
  46302. constructor(ray: Ray);
  46303. /**
  46304. * Shows the ray we are willing to debug.
  46305. * @param scene Defines the scene the ray needs to be rendered in
  46306. * @param color Defines the color the ray needs to be rendered in
  46307. */
  46308. show(scene: Scene, color?: Color3): void;
  46309. /**
  46310. * Hides the ray we are debugging.
  46311. */
  46312. hide(): void;
  46313. private _render;
  46314. /**
  46315. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  46316. * @param mesh Defines the mesh we want the helper attached to
  46317. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  46318. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  46319. * @param length Defines the length of the ray
  46320. */
  46321. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  46322. /**
  46323. * Detach the ray helper from the mesh it has previously been attached to.
  46324. */
  46325. detachFromMesh(): void;
  46326. private _updateToMesh;
  46327. /**
  46328. * Dispose the helper and release its associated resources.
  46329. */
  46330. dispose(): void;
  46331. }
  46332. }
  46333. declare module BABYLON.Debug {
  46334. /**
  46335. * Class used to render a debug view of a given skeleton
  46336. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  46337. */
  46338. export class SkeletonViewer {
  46339. /** defines the skeleton to render */
  46340. skeleton: Skeleton;
  46341. /** defines the mesh attached to the skeleton */
  46342. mesh: AbstractMesh;
  46343. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  46344. autoUpdateBonesMatrices: boolean;
  46345. /** defines the rendering group id to use with the viewer */
  46346. renderingGroupId: number;
  46347. /** Gets or sets the color used to render the skeleton */
  46348. color: Color3;
  46349. private _scene;
  46350. private _debugLines;
  46351. private _debugMesh;
  46352. private _isEnabled;
  46353. private _renderFunction;
  46354. private _utilityLayer;
  46355. /**
  46356. * Returns the mesh used to render the bones
  46357. */
  46358. get debugMesh(): Nullable<LinesMesh>;
  46359. /**
  46360. * Creates a new SkeletonViewer
  46361. * @param skeleton defines the skeleton to render
  46362. * @param mesh defines the mesh attached to the skeleton
  46363. * @param scene defines the hosting scene
  46364. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  46365. * @param renderingGroupId defines the rendering group id to use with the viewer
  46366. */
  46367. constructor(
  46368. /** defines the skeleton to render */
  46369. skeleton: Skeleton,
  46370. /** defines the mesh attached to the skeleton */
  46371. mesh: AbstractMesh, scene: Scene,
  46372. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  46373. autoUpdateBonesMatrices?: boolean,
  46374. /** defines the rendering group id to use with the viewer */
  46375. renderingGroupId?: number);
  46376. /** Gets or sets a boolean indicating if the viewer is enabled */
  46377. set isEnabled(value: boolean);
  46378. get isEnabled(): boolean;
  46379. private _getBonePosition;
  46380. private _getLinesForBonesWithLength;
  46381. private _getLinesForBonesNoLength;
  46382. /** Update the viewer to sync with current skeleton state */
  46383. update(): void;
  46384. /** Release associated resources */
  46385. dispose(): void;
  46386. }
  46387. }
  46388. declare module BABYLON {
  46389. /**
  46390. * Options to create the null engine
  46391. */
  46392. export class NullEngineOptions {
  46393. /**
  46394. * Render width (Default: 512)
  46395. */
  46396. renderWidth: number;
  46397. /**
  46398. * Render height (Default: 256)
  46399. */
  46400. renderHeight: number;
  46401. /**
  46402. * Texture size (Default: 512)
  46403. */
  46404. textureSize: number;
  46405. /**
  46406. * If delta time between frames should be constant
  46407. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46408. */
  46409. deterministicLockstep: boolean;
  46410. /**
  46411. * Maximum about of steps between frames (Default: 4)
  46412. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46413. */
  46414. lockstepMaxSteps: number;
  46415. }
  46416. /**
  46417. * The null engine class provides support for headless version of babylon.js.
  46418. * This can be used in server side scenario or for testing purposes
  46419. */
  46420. export class NullEngine extends Engine {
  46421. private _options;
  46422. /**
  46423. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  46424. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46425. * @returns true if engine is in deterministic lock step mode
  46426. */
  46427. isDeterministicLockStep(): boolean;
  46428. /**
  46429. * Gets the max steps when engine is running in deterministic lock step
  46430. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46431. * @returns the max steps
  46432. */
  46433. getLockstepMaxSteps(): number;
  46434. /**
  46435. * Gets the current hardware scaling level.
  46436. * By default the hardware scaling level is computed from the window device ratio.
  46437. * 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.
  46438. * @returns a number indicating the current hardware scaling level
  46439. */
  46440. getHardwareScalingLevel(): number;
  46441. constructor(options?: NullEngineOptions);
  46442. /**
  46443. * Creates a vertex buffer
  46444. * @param vertices the data for the vertex buffer
  46445. * @returns the new WebGL static buffer
  46446. */
  46447. createVertexBuffer(vertices: FloatArray): DataBuffer;
  46448. /**
  46449. * Creates a new index buffer
  46450. * @param indices defines the content of the index buffer
  46451. * @param updatable defines if the index buffer must be updatable
  46452. * @returns a new webGL buffer
  46453. */
  46454. createIndexBuffer(indices: IndicesArray): DataBuffer;
  46455. /**
  46456. * Clear the current render buffer or the current render target (if any is set up)
  46457. * @param color defines the color to use
  46458. * @param backBuffer defines if the back buffer must be cleared
  46459. * @param depth defines if the depth buffer must be cleared
  46460. * @param stencil defines if the stencil buffer must be cleared
  46461. */
  46462. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  46463. /**
  46464. * Gets the current render width
  46465. * @param useScreen defines if screen size must be used (or the current render target if any)
  46466. * @returns a number defining the current render width
  46467. */
  46468. getRenderWidth(useScreen?: boolean): number;
  46469. /**
  46470. * Gets the current render height
  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 height
  46473. */
  46474. getRenderHeight(useScreen?: boolean): number;
  46475. /**
  46476. * Set the WebGL's viewport
  46477. * @param viewport defines the viewport element to be used
  46478. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  46479. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  46480. */
  46481. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  46482. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  46483. /**
  46484. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  46485. * @param pipelineContext defines the pipeline context to use
  46486. * @param uniformsNames defines the list of uniform names
  46487. * @returns an array of webGL uniform locations
  46488. */
  46489. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  46490. /**
  46491. * Gets the lsit of active attributes for a given webGL program
  46492. * @param pipelineContext defines the pipeline context to use
  46493. * @param attributesNames defines the list of attribute names to get
  46494. * @returns an array of indices indicating the offset of each attribute
  46495. */
  46496. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  46497. /**
  46498. * Binds an effect to the webGL context
  46499. * @param effect defines the effect to bind
  46500. */
  46501. bindSamplers(effect: Effect): void;
  46502. /**
  46503. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  46504. * @param effect defines the effect to activate
  46505. */
  46506. enableEffect(effect: Effect): void;
  46507. /**
  46508. * Set various states to the webGL context
  46509. * @param culling defines backface culling state
  46510. * @param zOffset defines the value to apply to zOffset (0 by default)
  46511. * @param force defines if states must be applied even if cache is up to date
  46512. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  46513. */
  46514. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  46515. /**
  46516. * Set the value of an uniform to an array of int32
  46517. * @param uniform defines the webGL uniform location where to store the value
  46518. * @param array defines the array of int32 to store
  46519. */
  46520. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  46521. /**
  46522. * Set the value of an uniform to an array of int32 (stored as vec2)
  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. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  46527. /**
  46528. * Set the value of an uniform to an array of int32 (stored as vec3)
  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. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  46533. /**
  46534. * Set the value of an uniform to an array of int32 (stored as vec4)
  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. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  46539. /**
  46540. * Set the value of an uniform to an array of float32
  46541. * @param uniform defines the webGL uniform location where to store the value
  46542. * @param array defines the array of float32 to store
  46543. */
  46544. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  46545. /**
  46546. * Set the value of an uniform to an array of float32 (stored as vec2)
  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. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  46551. /**
  46552. * Set the value of an uniform to an array of float32 (stored as vec3)
  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. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  46557. /**
  46558. * Set the value of an uniform to an array of float32 (stored as vec4)
  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. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  46563. /**
  46564. * Set the value of an uniform to an array of number
  46565. * @param uniform defines the webGL uniform location where to store the value
  46566. * @param array defines the array of number to store
  46567. */
  46568. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  46569. /**
  46570. * Set the value of an uniform to an array of number (stored as vec2)
  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. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  46575. /**
  46576. * Set the value of an uniform to an array of number (stored as vec3)
  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. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  46581. /**
  46582. * Set the value of an uniform to an array of number (stored as vec4)
  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. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  46587. /**
  46588. * Set the value of an uniform to an array of float32 (stored as matrices)
  46589. * @param uniform defines the webGL uniform location where to store the value
  46590. * @param matrices defines the array of float32 to store
  46591. */
  46592. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  46593. /**
  46594. * Set the value of an uniform to a matrix (3x3)
  46595. * @param uniform defines the webGL uniform location where to store the value
  46596. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  46597. */
  46598. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  46599. /**
  46600. * Set the value of an uniform to a matrix (2x2)
  46601. * @param uniform defines the webGL uniform location where to store the value
  46602. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  46603. */
  46604. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  46605. /**
  46606. * Set the value of an uniform to a number (float)
  46607. * @param uniform defines the webGL uniform location where to store the value
  46608. * @param value defines the float number to store
  46609. */
  46610. setFloat(uniform: WebGLUniformLocation, value: number): void;
  46611. /**
  46612. * Set the value of an uniform to a vec2
  46613. * @param uniform defines the webGL uniform location where to store the value
  46614. * @param x defines the 1st component of the value
  46615. * @param y defines the 2nd component of the value
  46616. */
  46617. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  46618. /**
  46619. * Set the value of an uniform to a vec3
  46620. * @param uniform defines the webGL uniform location where to store the value
  46621. * @param x defines the 1st component of the value
  46622. * @param y defines the 2nd component of the value
  46623. * @param z defines the 3rd component of the value
  46624. */
  46625. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  46626. /**
  46627. * Set the value of an uniform to a boolean
  46628. * @param uniform defines the webGL uniform location where to store the value
  46629. * @param bool defines the boolean to store
  46630. */
  46631. setBool(uniform: WebGLUniformLocation, bool: number): void;
  46632. /**
  46633. * Set the value of an uniform to a vec4
  46634. * @param uniform defines the webGL uniform location where to store the value
  46635. * @param x defines the 1st component of the value
  46636. * @param y defines the 2nd component of the value
  46637. * @param z defines the 3rd component of the value
  46638. * @param w defines the 4th component of the value
  46639. */
  46640. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  46641. /**
  46642. * Sets the current alpha mode
  46643. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  46644. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  46645. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  46646. */
  46647. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  46648. /**
  46649. * Bind webGl buffers directly to the webGL context
  46650. * @param vertexBuffers defines the vertex buffer to bind
  46651. * @param indexBuffer defines the index buffer to bind
  46652. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  46653. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  46654. * @param effect defines the effect associated with the vertex buffer
  46655. */
  46656. bindBuffers(vertexBuffers: {
  46657. [key: string]: VertexBuffer;
  46658. }, indexBuffer: DataBuffer, effect: Effect): void;
  46659. /**
  46660. * Force the entire cache to be cleared
  46661. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  46662. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  46663. */
  46664. wipeCaches(bruteForce?: boolean): void;
  46665. /**
  46666. * Send a draw order
  46667. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  46668. * @param indexStart defines the starting index
  46669. * @param indexCount defines the number of index to draw
  46670. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  46671. */
  46672. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  46673. /**
  46674. * Draw a list of indexed primitives
  46675. * @param fillMode defines the primitive to use
  46676. * @param indexStart defines the starting index
  46677. * @param indexCount defines the number of index to draw
  46678. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  46679. */
  46680. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  46681. /**
  46682. * Draw a list of unindexed primitives
  46683. * @param fillMode defines the primitive to use
  46684. * @param verticesStart defines the index of first vertex to draw
  46685. * @param verticesCount defines the count of vertices to draw
  46686. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  46687. */
  46688. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  46689. /** @hidden */
  46690. _createTexture(): WebGLTexture;
  46691. /** @hidden */
  46692. _releaseTexture(texture: InternalTexture): void;
  46693. /**
  46694. * Usually called from Texture.ts.
  46695. * Passed information to create a WebGLTexture
  46696. * @param urlArg defines a value which contains one of the following:
  46697. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  46698. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  46699. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  46700. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  46701. * @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)
  46702. * @param scene needed for loading to the correct scene
  46703. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  46704. * @param onLoad optional callback to be called upon successful completion
  46705. * @param onError optional callback to be called upon failure
  46706. * @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
  46707. * @param fallBack an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  46708. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  46709. * @param forcedExtension defines the extension to use to pick the right loader
  46710. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  46711. * @returns a InternalTexture for assignment back into BABYLON.Texture
  46712. */
  46713. 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;
  46714. /**
  46715. * Creates a new render target texture
  46716. * @param size defines the size of the texture
  46717. * @param options defines the options used to create the texture
  46718. * @returns a new render target texture stored in an InternalTexture
  46719. */
  46720. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  46721. /**
  46722. * Update the sampling mode of a given texture
  46723. * @param samplingMode defines the required sampling mode
  46724. * @param texture defines the texture to update
  46725. */
  46726. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  46727. /**
  46728. * Binds the frame buffer to the specified texture.
  46729. * @param texture The texture to render to or null for the default canvas
  46730. * @param faceIndex The face of the texture to render to in case of cube texture
  46731. * @param requiredWidth The width of the target to render to
  46732. * @param requiredHeight The height of the target to render to
  46733. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  46734. * @param lodLevel defines le lod level to bind to the frame buffer
  46735. */
  46736. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  46737. /**
  46738. * Unbind the current render target texture from the webGL context
  46739. * @param texture defines the render target texture to unbind
  46740. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  46741. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  46742. */
  46743. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  46744. /**
  46745. * Creates a dynamic vertex buffer
  46746. * @param vertices the data for the dynamic vertex buffer
  46747. * @returns the new WebGL dynamic buffer
  46748. */
  46749. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  46750. /**
  46751. * Update the content of a dynamic texture
  46752. * @param texture defines the texture to update
  46753. * @param canvas defines the canvas containing the source
  46754. * @param invertY defines if data must be stored with Y axis inverted
  46755. * @param premulAlpha defines if alpha is stored as premultiplied
  46756. * @param format defines the format of the data
  46757. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  46758. */
  46759. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  46760. /**
  46761. * Gets a boolean indicating if all created effects are ready
  46762. * @returns true if all effects are ready
  46763. */
  46764. areAllEffectsReady(): boolean;
  46765. /**
  46766. * @hidden
  46767. * Get the current error code of the webGL context
  46768. * @returns the error code
  46769. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  46770. */
  46771. getError(): number;
  46772. /** @hidden */
  46773. _getUnpackAlignement(): number;
  46774. /** @hidden */
  46775. _unpackFlipY(value: boolean): void;
  46776. /**
  46777. * Update a dynamic index buffer
  46778. * @param indexBuffer defines the target index buffer
  46779. * @param indices defines the data to update
  46780. * @param offset defines the offset in the target index buffer where update should start
  46781. */
  46782. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  46783. /**
  46784. * Updates a dynamic vertex buffer.
  46785. * @param vertexBuffer the vertex buffer to update
  46786. * @param vertices the data used to update the vertex buffer
  46787. * @param byteOffset the byte offset of the data (optional)
  46788. * @param byteLength the byte length of the data (optional)
  46789. */
  46790. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  46791. /** @hidden */
  46792. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  46793. /** @hidden */
  46794. _bindTexture(channel: number, texture: InternalTexture): void;
  46795. protected _deleteBuffer(buffer: WebGLBuffer): void;
  46796. /**
  46797. * 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
  46798. */
  46799. releaseEffects(): void;
  46800. displayLoadingUI(): void;
  46801. hideLoadingUI(): void;
  46802. /** @hidden */
  46803. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46804. /** @hidden */
  46805. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46806. /** @hidden */
  46807. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46808. /** @hidden */
  46809. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  46810. }
  46811. }
  46812. declare module BABYLON {
  46813. /**
  46814. * @hidden
  46815. **/
  46816. export class _TimeToken {
  46817. _startTimeQuery: Nullable<WebGLQuery>;
  46818. _endTimeQuery: Nullable<WebGLQuery>;
  46819. _timeElapsedQuery: Nullable<WebGLQuery>;
  46820. _timeElapsedQueryEnded: boolean;
  46821. }
  46822. }
  46823. declare module BABYLON {
  46824. /** @hidden */
  46825. export class _OcclusionDataStorage {
  46826. /** @hidden */
  46827. occlusionInternalRetryCounter: number;
  46828. /** @hidden */
  46829. isOcclusionQueryInProgress: boolean;
  46830. /** @hidden */
  46831. isOccluded: boolean;
  46832. /** @hidden */
  46833. occlusionRetryCount: number;
  46834. /** @hidden */
  46835. occlusionType: number;
  46836. /** @hidden */
  46837. occlusionQueryAlgorithmType: number;
  46838. }
  46839. interface Engine {
  46840. /**
  46841. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  46842. * @return the new query
  46843. */
  46844. createQuery(): WebGLQuery;
  46845. /**
  46846. * Delete and release a webGL query
  46847. * @param query defines the query to delete
  46848. * @return the current engine
  46849. */
  46850. deleteQuery(query: WebGLQuery): Engine;
  46851. /**
  46852. * Check if a given query has resolved and got its value
  46853. * @param query defines the query to check
  46854. * @returns true if the query got its value
  46855. */
  46856. isQueryResultAvailable(query: WebGLQuery): boolean;
  46857. /**
  46858. * Gets the value of a given query
  46859. * @param query defines the query to check
  46860. * @returns the value of the query
  46861. */
  46862. getQueryResult(query: WebGLQuery): number;
  46863. /**
  46864. * Initiates an occlusion query
  46865. * @param algorithmType defines the algorithm to use
  46866. * @param query defines the query to use
  46867. * @returns the current engine
  46868. * @see http://doc.babylonjs.com/features/occlusionquery
  46869. */
  46870. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  46871. /**
  46872. * Ends an occlusion query
  46873. * @see http://doc.babylonjs.com/features/occlusionquery
  46874. * @param algorithmType defines the algorithm to use
  46875. * @returns the current engine
  46876. */
  46877. endOcclusionQuery(algorithmType: number): Engine;
  46878. /**
  46879. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  46880. * Please note that only one query can be issued at a time
  46881. * @returns a time token used to track the time span
  46882. */
  46883. startTimeQuery(): Nullable<_TimeToken>;
  46884. /**
  46885. * Ends a time query
  46886. * @param token defines the token used to measure the time span
  46887. * @returns the time spent (in ns)
  46888. */
  46889. endTimeQuery(token: _TimeToken): int;
  46890. /** @hidden */
  46891. _currentNonTimestampToken: Nullable<_TimeToken>;
  46892. /** @hidden */
  46893. _createTimeQuery(): WebGLQuery;
  46894. /** @hidden */
  46895. _deleteTimeQuery(query: WebGLQuery): void;
  46896. /** @hidden */
  46897. _getGlAlgorithmType(algorithmType: number): number;
  46898. /** @hidden */
  46899. _getTimeQueryResult(query: WebGLQuery): any;
  46900. /** @hidden */
  46901. _getTimeQueryAvailability(query: WebGLQuery): any;
  46902. }
  46903. interface AbstractMesh {
  46904. /**
  46905. * Backing filed
  46906. * @hidden
  46907. */
  46908. __occlusionDataStorage: _OcclusionDataStorage;
  46909. /**
  46910. * Access property
  46911. * @hidden
  46912. */
  46913. _occlusionDataStorage: _OcclusionDataStorage;
  46914. /**
  46915. * 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.
  46916. * The default value is -1 which means don't break the query and wait till the result
  46917. * @see http://doc.babylonjs.com/features/occlusionquery
  46918. */
  46919. occlusionRetryCount: number;
  46920. /**
  46921. * 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:
  46922. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  46923. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  46924. * * 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.
  46925. * @see http://doc.babylonjs.com/features/occlusionquery
  46926. */
  46927. occlusionType: number;
  46928. /**
  46929. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  46930. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  46931. * * 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.
  46932. * @see http://doc.babylonjs.com/features/occlusionquery
  46933. */
  46934. occlusionQueryAlgorithmType: number;
  46935. /**
  46936. * 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
  46937. * @see http://doc.babylonjs.com/features/occlusionquery
  46938. */
  46939. isOccluded: boolean;
  46940. /**
  46941. * Flag to check the progress status of the query
  46942. * @see http://doc.babylonjs.com/features/occlusionquery
  46943. */
  46944. isOcclusionQueryInProgress: boolean;
  46945. }
  46946. }
  46947. declare module BABYLON {
  46948. /** @hidden */
  46949. export var _forceTransformFeedbackToBundle: boolean;
  46950. interface Engine {
  46951. /**
  46952. * Creates a webGL transform feedback object
  46953. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  46954. * @returns the webGL transform feedback object
  46955. */
  46956. createTransformFeedback(): WebGLTransformFeedback;
  46957. /**
  46958. * Delete a webGL transform feedback object
  46959. * @param value defines the webGL transform feedback object to delete
  46960. */
  46961. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  46962. /**
  46963. * Bind a webGL transform feedback object to the webgl context
  46964. * @param value defines the webGL transform feedback object to bind
  46965. */
  46966. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  46967. /**
  46968. * Begins a transform feedback operation
  46969. * @param usePoints defines if points or triangles must be used
  46970. */
  46971. beginTransformFeedback(usePoints: boolean): void;
  46972. /**
  46973. * Ends a transform feedback operation
  46974. */
  46975. endTransformFeedback(): void;
  46976. /**
  46977. * Specify the varyings to use with transform feedback
  46978. * @param program defines the associated webGL program
  46979. * @param value defines the list of strings representing the varying names
  46980. */
  46981. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  46982. /**
  46983. * Bind a webGL buffer for a transform feedback operation
  46984. * @param value defines the webGL buffer to bind
  46985. */
  46986. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  46987. }
  46988. }
  46989. declare module BABYLON {
  46990. /**
  46991. * Creation options of the multi render target texture.
  46992. */
  46993. export interface IMultiRenderTargetOptions {
  46994. /**
  46995. * Define if the texture needs to create mip maps after render.
  46996. */
  46997. generateMipMaps?: boolean;
  46998. /**
  46999. * Define the types of all the draw buffers we want to create
  47000. */
  47001. types?: number[];
  47002. /**
  47003. * Define the sampling modes of all the draw buffers we want to create
  47004. */
  47005. samplingModes?: number[];
  47006. /**
  47007. * Define if a depth buffer is required
  47008. */
  47009. generateDepthBuffer?: boolean;
  47010. /**
  47011. * Define if a stencil buffer is required
  47012. */
  47013. generateStencilBuffer?: boolean;
  47014. /**
  47015. * Define if a depth texture is required instead of a depth buffer
  47016. */
  47017. generateDepthTexture?: boolean;
  47018. /**
  47019. * Define the number of desired draw buffers
  47020. */
  47021. textureCount?: number;
  47022. /**
  47023. * Define if aspect ratio should be adapted to the texture or stay the scene one
  47024. */
  47025. doNotChangeAspectRatio?: boolean;
  47026. /**
  47027. * Define the default type of the buffers we are creating
  47028. */
  47029. defaultType?: number;
  47030. }
  47031. /**
  47032. * A multi render target, like a render target provides the ability to render to a texture.
  47033. * Unlike the render target, it can render to several draw buffers in one draw.
  47034. * This is specially interesting in deferred rendering or for any effects requiring more than
  47035. * just one color from a single pass.
  47036. */
  47037. export class MultiRenderTarget extends RenderTargetTexture {
  47038. private _internalTextures;
  47039. private _textures;
  47040. private _multiRenderTargetOptions;
  47041. /**
  47042. * Get if draw buffers are currently supported by the used hardware and browser.
  47043. */
  47044. get isSupported(): boolean;
  47045. /**
  47046. * Get the list of textures generated by the multi render target.
  47047. */
  47048. get textures(): Texture[];
  47049. /**
  47050. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  47051. */
  47052. get depthTexture(): Texture;
  47053. /**
  47054. * Set the wrapping mode on U of all the textures we are rendering to.
  47055. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  47056. */
  47057. set wrapU(wrap: number);
  47058. /**
  47059. * Set the wrapping mode on V of all the textures we are rendering to.
  47060. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  47061. */
  47062. set wrapV(wrap: number);
  47063. /**
  47064. * Instantiate a new multi render target texture.
  47065. * A multi render target, like a render target provides the ability to render to a texture.
  47066. * Unlike the render target, it can render to several draw buffers in one draw.
  47067. * This is specially interesting in deferred rendering or for any effects requiring more than
  47068. * just one color from a single pass.
  47069. * @param name Define the name of the texture
  47070. * @param size Define the size of the buffers to render to
  47071. * @param count Define the number of target we are rendering into
  47072. * @param scene Define the scene the texture belongs to
  47073. * @param options Define the options used to create the multi render target
  47074. */
  47075. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  47076. /** @hidden */
  47077. _rebuild(): void;
  47078. private _createInternalTextures;
  47079. private _createTextures;
  47080. /**
  47081. * Define the number of samples used if MSAA is enabled.
  47082. */
  47083. get samples(): number;
  47084. set samples(value: number);
  47085. /**
  47086. * Resize all the textures in the multi render target.
  47087. * Be carrefull as it will recreate all the data in the new texture.
  47088. * @param size Define the new size
  47089. */
  47090. resize(size: any): void;
  47091. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  47092. /**
  47093. * Dispose the render targets and their associated resources
  47094. */
  47095. dispose(): void;
  47096. /**
  47097. * Release all the underlying texture used as draw buffers.
  47098. */
  47099. releaseInternalTextures(): void;
  47100. }
  47101. }
  47102. declare module BABYLON {
  47103. interface ThinEngine {
  47104. /**
  47105. * Unbind a list of render target textures from the webGL context
  47106. * This is used only when drawBuffer extension or webGL2 are active
  47107. * @param textures defines the render target textures to unbind
  47108. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  47109. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  47110. */
  47111. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  47112. /**
  47113. * Create a multi render target texture
  47114. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  47115. * @param size defines the size of the texture
  47116. * @param options defines the creation options
  47117. * @returns the cube texture as an InternalTexture
  47118. */
  47119. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  47120. /**
  47121. * Update the sample count for a given multiple render target texture
  47122. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  47123. * @param textures defines the textures to update
  47124. * @param samples defines the sample count to set
  47125. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  47126. */
  47127. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  47128. }
  47129. }
  47130. declare module BABYLON {
  47131. /**
  47132. * Class used to define an additional view for the engine
  47133. * @see https://doc.babylonjs.com/how_to/multi_canvases
  47134. */
  47135. export class EngineView {
  47136. /** Defines the canvas where to render the view */
  47137. target: HTMLCanvasElement;
  47138. /** Defines an optional camera used to render the view (will use active camera else) */
  47139. camera?: Camera;
  47140. }
  47141. interface Engine {
  47142. /**
  47143. * Gets or sets the HTML element to use for attaching events
  47144. */
  47145. inputElement: Nullable<HTMLElement>;
  47146. /**
  47147. * Gets the current engine view
  47148. * @see https://doc.babylonjs.com/how_to/multi_canvases
  47149. */
  47150. activeView: Nullable<EngineView>;
  47151. /** Gets or sets the list of views */
  47152. views: EngineView[];
  47153. /**
  47154. * Register a new child canvas
  47155. * @param canvas defines the canvas to register
  47156. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  47157. * @returns the associated view
  47158. */
  47159. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  47160. /**
  47161. * Remove a registered child canvas
  47162. * @param canvas defines the canvas to remove
  47163. * @returns the current engine
  47164. */
  47165. unRegisterView(canvas: HTMLCanvasElement): Engine;
  47166. }
  47167. }
  47168. declare module BABYLON {
  47169. /**
  47170. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  47171. */
  47172. export interface CubeMapInfo {
  47173. /**
  47174. * The pixel array for the front face.
  47175. * This is stored in format, left to right, up to down format.
  47176. */
  47177. front: Nullable<ArrayBufferView>;
  47178. /**
  47179. * The pixel array for the back face.
  47180. * This is stored in format, left to right, up to down format.
  47181. */
  47182. back: Nullable<ArrayBufferView>;
  47183. /**
  47184. * The pixel array for the left face.
  47185. * This is stored in format, left to right, up to down format.
  47186. */
  47187. left: Nullable<ArrayBufferView>;
  47188. /**
  47189. * The pixel array for the right face.
  47190. * This is stored in format, left to right, up to down format.
  47191. */
  47192. right: Nullable<ArrayBufferView>;
  47193. /**
  47194. * The pixel array for the up face.
  47195. * This is stored in format, left to right, up to down format.
  47196. */
  47197. up: Nullable<ArrayBufferView>;
  47198. /**
  47199. * The pixel array for the down face.
  47200. * This is stored in format, left to right, up to down format.
  47201. */
  47202. down: Nullable<ArrayBufferView>;
  47203. /**
  47204. * The size of the cubemap stored.
  47205. *
  47206. * Each faces will be size * size pixels.
  47207. */
  47208. size: number;
  47209. /**
  47210. * The format of the texture.
  47211. *
  47212. * RGBA, RGB.
  47213. */
  47214. format: number;
  47215. /**
  47216. * The type of the texture data.
  47217. *
  47218. * UNSIGNED_INT, FLOAT.
  47219. */
  47220. type: number;
  47221. /**
  47222. * Specifies whether the texture is in gamma space.
  47223. */
  47224. gammaSpace: boolean;
  47225. }
  47226. /**
  47227. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  47228. */
  47229. export class PanoramaToCubeMapTools {
  47230. private static FACE_FRONT;
  47231. private static FACE_BACK;
  47232. private static FACE_RIGHT;
  47233. private static FACE_LEFT;
  47234. private static FACE_DOWN;
  47235. private static FACE_UP;
  47236. /**
  47237. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  47238. *
  47239. * @param float32Array The source data.
  47240. * @param inputWidth The width of the input panorama.
  47241. * @param inputHeight The height of the input panorama.
  47242. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  47243. * @return The cubemap data
  47244. */
  47245. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  47246. private static CreateCubemapTexture;
  47247. private static CalcProjectionSpherical;
  47248. }
  47249. }
  47250. declare module BABYLON {
  47251. /**
  47252. * Helper class dealing with the extraction of spherical polynomial dataArray
  47253. * from a cube map.
  47254. */
  47255. export class CubeMapToSphericalPolynomialTools {
  47256. private static FileFaces;
  47257. /**
  47258. * Converts a texture to the according Spherical Polynomial data.
  47259. * This extracts the first 3 orders only as they are the only one used in the lighting.
  47260. *
  47261. * @param texture The texture to extract the information from.
  47262. * @return The Spherical Polynomial data.
  47263. */
  47264. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  47265. /**
  47266. * Converts a cubemap to the according Spherical Polynomial data.
  47267. * This extracts the first 3 orders only as they are the only one used in the lighting.
  47268. *
  47269. * @param cubeInfo The Cube map to extract the information from.
  47270. * @return The Spherical Polynomial data.
  47271. */
  47272. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  47273. }
  47274. }
  47275. declare module BABYLON {
  47276. interface BaseTexture {
  47277. /**
  47278. * Get the polynomial representation of the texture data.
  47279. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  47280. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  47281. */
  47282. sphericalPolynomial: Nullable<SphericalPolynomial>;
  47283. }
  47284. }
  47285. declare module BABYLON {
  47286. /** @hidden */
  47287. export var rgbdEncodePixelShader: {
  47288. name: string;
  47289. shader: string;
  47290. };
  47291. }
  47292. declare module BABYLON {
  47293. /** @hidden */
  47294. export var rgbdDecodePixelShader: {
  47295. name: string;
  47296. shader: string;
  47297. };
  47298. }
  47299. declare module BABYLON {
  47300. /**
  47301. * Raw texture data and descriptor sufficient for WebGL texture upload
  47302. */
  47303. export interface EnvironmentTextureInfo {
  47304. /**
  47305. * Version of the environment map
  47306. */
  47307. version: number;
  47308. /**
  47309. * Width of image
  47310. */
  47311. width: number;
  47312. /**
  47313. * Irradiance information stored in the file.
  47314. */
  47315. irradiance: any;
  47316. /**
  47317. * Specular information stored in the file.
  47318. */
  47319. specular: any;
  47320. }
  47321. /**
  47322. * Defines One Image in the file. It requires only the position in the file
  47323. * as well as the length.
  47324. */
  47325. interface BufferImageData {
  47326. /**
  47327. * Length of the image data.
  47328. */
  47329. length: number;
  47330. /**
  47331. * Position of the data from the null terminator delimiting the end of the JSON.
  47332. */
  47333. position: number;
  47334. }
  47335. /**
  47336. * Defines the specular data enclosed in the file.
  47337. * This corresponds to the version 1 of the data.
  47338. */
  47339. export interface EnvironmentTextureSpecularInfoV1 {
  47340. /**
  47341. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  47342. */
  47343. specularDataPosition?: number;
  47344. /**
  47345. * This contains all the images data needed to reconstruct the cubemap.
  47346. */
  47347. mipmaps: Array<BufferImageData>;
  47348. /**
  47349. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  47350. */
  47351. lodGenerationScale: number;
  47352. }
  47353. /**
  47354. * Sets of helpers addressing the serialization and deserialization of environment texture
  47355. * stored in a BabylonJS env file.
  47356. * Those files are usually stored as .env files.
  47357. */
  47358. export class EnvironmentTextureTools {
  47359. /**
  47360. * Magic number identifying the env file.
  47361. */
  47362. private static _MagicBytes;
  47363. /**
  47364. * Gets the environment info from an env file.
  47365. * @param data The array buffer containing the .env bytes.
  47366. * @returns the environment file info (the json header) if successfully parsed.
  47367. */
  47368. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  47369. /**
  47370. * Creates an environment texture from a loaded cube texture.
  47371. * @param texture defines the cube texture to convert in env file
  47372. * @return a promise containing the environment data if succesfull.
  47373. */
  47374. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  47375. /**
  47376. * Creates a JSON representation of the spherical data.
  47377. * @param texture defines the texture containing the polynomials
  47378. * @return the JSON representation of the spherical info
  47379. */
  47380. private static _CreateEnvTextureIrradiance;
  47381. /**
  47382. * Creates the ArrayBufferViews used for initializing environment texture image data.
  47383. * @param data the image data
  47384. * @param info parameters that determine what views will be created for accessing the underlying buffer
  47385. * @return the views described by info providing access to the underlying buffer
  47386. */
  47387. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  47388. /**
  47389. * Uploads the texture info contained in the env file to the GPU.
  47390. * @param texture defines the internal texture to upload to
  47391. * @param data defines the data to load
  47392. * @param info defines the texture info retrieved through the GetEnvInfo method
  47393. * @returns a promise
  47394. */
  47395. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  47396. private static _OnImageReadyAsync;
  47397. /**
  47398. * Uploads the levels of image data to the GPU.
  47399. * @param texture defines the internal texture to upload to
  47400. * @param imageData defines the array buffer views of image data [mipmap][face]
  47401. * @returns a promise
  47402. */
  47403. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  47404. /**
  47405. * Uploads spherical polynomials information to the texture.
  47406. * @param texture defines the texture we are trying to upload the information to
  47407. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  47408. */
  47409. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  47410. /** @hidden */
  47411. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  47412. }
  47413. }
  47414. declare module BABYLON {
  47415. /**
  47416. * Contains position and normal vectors for a vertex
  47417. */
  47418. export class PositionNormalVertex {
  47419. /** the position of the vertex (defaut: 0,0,0) */
  47420. position: Vector3;
  47421. /** the normal of the vertex (defaut: 0,1,0) */
  47422. normal: Vector3;
  47423. /**
  47424. * Creates a PositionNormalVertex
  47425. * @param position the position of the vertex (defaut: 0,0,0)
  47426. * @param normal the normal of the vertex (defaut: 0,1,0)
  47427. */
  47428. constructor(
  47429. /** the position of the vertex (defaut: 0,0,0) */
  47430. position?: Vector3,
  47431. /** the normal of the vertex (defaut: 0,1,0) */
  47432. normal?: Vector3);
  47433. /**
  47434. * Clones the PositionNormalVertex
  47435. * @returns the cloned PositionNormalVertex
  47436. */
  47437. clone(): PositionNormalVertex;
  47438. }
  47439. /**
  47440. * Contains position, normal and uv vectors for a vertex
  47441. */
  47442. export class PositionNormalTextureVertex {
  47443. /** the position of the vertex (defaut: 0,0,0) */
  47444. position: Vector3;
  47445. /** the normal of the vertex (defaut: 0,1,0) */
  47446. normal: Vector3;
  47447. /** the uv of the vertex (default: 0,0) */
  47448. uv: Vector2;
  47449. /**
  47450. * Creates a PositionNormalTextureVertex
  47451. * @param position the position of the vertex (defaut: 0,0,0)
  47452. * @param normal the normal of the vertex (defaut: 0,1,0)
  47453. * @param uv the uv of the vertex (default: 0,0)
  47454. */
  47455. constructor(
  47456. /** the position of the vertex (defaut: 0,0,0) */
  47457. position?: Vector3,
  47458. /** the normal of the vertex (defaut: 0,1,0) */
  47459. normal?: Vector3,
  47460. /** the uv of the vertex (default: 0,0) */
  47461. uv?: Vector2);
  47462. /**
  47463. * Clones the PositionNormalTextureVertex
  47464. * @returns the cloned PositionNormalTextureVertex
  47465. */
  47466. clone(): PositionNormalTextureVertex;
  47467. }
  47468. }
  47469. declare module BABYLON {
  47470. /** @hidden */
  47471. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  47472. private _genericAttributeLocation;
  47473. private _varyingLocationCount;
  47474. private _varyingLocationMap;
  47475. private _replacements;
  47476. private _textureCount;
  47477. private _uniforms;
  47478. lineProcessor(line: string): string;
  47479. attributeProcessor(attribute: string): string;
  47480. varyingProcessor(varying: string, isFragment: boolean): string;
  47481. uniformProcessor(uniform: string): string;
  47482. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  47483. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  47484. }
  47485. }
  47486. declare module BABYLON {
  47487. /**
  47488. * Container for accessors for natively-stored mesh data buffers.
  47489. */
  47490. class NativeDataBuffer extends DataBuffer {
  47491. /**
  47492. * Accessor value used to identify/retrieve a natively-stored index buffer.
  47493. */
  47494. nativeIndexBuffer?: any;
  47495. /**
  47496. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  47497. */
  47498. nativeVertexBuffer?: any;
  47499. }
  47500. /** @hidden */
  47501. class NativeTexture extends InternalTexture {
  47502. getInternalTexture(): InternalTexture;
  47503. getViewCount(): number;
  47504. }
  47505. /** @hidden */
  47506. export class NativeEngine extends Engine {
  47507. private readonly _native;
  47508. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  47509. private readonly INVALID_HANDLE;
  47510. getHardwareScalingLevel(): number;
  47511. constructor();
  47512. /**
  47513. * Can be used to override the current requestAnimationFrame requester.
  47514. * @hidden
  47515. */
  47516. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  47517. /**
  47518. * Override default engine behavior.
  47519. * @param color
  47520. * @param backBuffer
  47521. * @param depth
  47522. * @param stencil
  47523. */
  47524. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  47525. /**
  47526. * Gets host document
  47527. * @returns the host document object
  47528. */
  47529. getHostDocument(): Nullable<Document>;
  47530. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  47531. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  47532. createVertexBuffer(data: DataArray): NativeDataBuffer;
  47533. recordVertexArrayObject(vertexBuffers: {
  47534. [key: string]: VertexBuffer;
  47535. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  47536. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  47537. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  47538. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  47539. /**
  47540. * Draw a list of indexed primitives
  47541. * @param fillMode defines the primitive to use
  47542. * @param indexStart defines the starting index
  47543. * @param indexCount defines the number of index to draw
  47544. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  47545. */
  47546. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  47547. /**
  47548. * Draw a list of unindexed primitives
  47549. * @param fillMode defines the primitive to use
  47550. * @param verticesStart defines the index of first vertex to draw
  47551. * @param verticesCount defines the count of vertices to draw
  47552. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  47553. */
  47554. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  47555. createPipelineContext(): IPipelineContext;
  47556. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  47557. /** @hidden */
  47558. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  47559. /** @hidden */
  47560. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  47561. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  47562. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  47563. protected _setProgram(program: WebGLProgram): void;
  47564. _releaseEffect(effect: Effect): void;
  47565. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  47566. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  47567. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  47568. bindSamplers(effect: Effect): void;
  47569. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  47570. getRenderWidth(useScreen?: boolean): number;
  47571. getRenderHeight(useScreen?: boolean): number;
  47572. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  47573. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  47574. /**
  47575. * Set the z offset to apply to current rendering
  47576. * @param value defines the offset to apply
  47577. */
  47578. setZOffset(value: number): void;
  47579. /**
  47580. * Gets the current value of the zOffset
  47581. * @returns the current zOffset state
  47582. */
  47583. getZOffset(): number;
  47584. /**
  47585. * Enable or disable depth buffering
  47586. * @param enable defines the state to set
  47587. */
  47588. setDepthBuffer(enable: boolean): void;
  47589. /**
  47590. * Gets a boolean indicating if depth writing is enabled
  47591. * @returns the current depth writing state
  47592. */
  47593. getDepthWrite(): boolean;
  47594. /**
  47595. * Enable or disable depth writing
  47596. * @param enable defines the state to set
  47597. */
  47598. setDepthWrite(enable: boolean): void;
  47599. /**
  47600. * Enable or disable color writing
  47601. * @param enable defines the state to set
  47602. */
  47603. setColorWrite(enable: boolean): void;
  47604. /**
  47605. * Gets a boolean indicating if color writing is enabled
  47606. * @returns the current color writing state
  47607. */
  47608. getColorWrite(): boolean;
  47609. /**
  47610. * Sets alpha constants used by some alpha blending modes
  47611. * @param r defines the red component
  47612. * @param g defines the green component
  47613. * @param b defines the blue component
  47614. * @param a defines the alpha component
  47615. */
  47616. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  47617. /**
  47618. * Sets the current alpha mode
  47619. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  47620. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  47621. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  47622. */
  47623. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  47624. /**
  47625. * Gets the current alpha mode
  47626. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  47627. * @returns the current alpha mode
  47628. */
  47629. getAlphaMode(): number;
  47630. setInt(uniform: WebGLUniformLocation, int: number): void;
  47631. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  47632. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  47633. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  47634. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  47635. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  47636. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  47637. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  47638. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  47639. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  47640. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  47641. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  47642. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  47643. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  47644. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  47645. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  47646. setFloat(uniform: WebGLUniformLocation, value: number): void;
  47647. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  47648. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  47649. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  47650. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  47651. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  47652. wipeCaches(bruteForce?: boolean): void;
  47653. _createTexture(): WebGLTexture;
  47654. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  47655. /**
  47656. * Usually called from BABYLON.Texture.ts.
  47657. * Passed information to create a WebGLTexture
  47658. * @param urlArg defines a value which contains one of the following:
  47659. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  47660. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  47661. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  47662. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  47663. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  47664. * @param scene needed for loading to the correct scene
  47665. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  47666. * @param onLoad optional callback to be called upon successful completion
  47667. * @param onError optional callback to be called upon failure
  47668. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  47669. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  47670. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  47671. * @param forcedExtension defines the extension to use to pick the right loader
  47672. * @returns a InternalTexture for assignment back into BABYLON.Texture
  47673. */
  47674. 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;
  47675. /**
  47676. * Creates a cube texture
  47677. * @param rootUrl defines the url where the files to load is located
  47678. * @param scene defines the current scene
  47679. * @param files defines the list of files to load (1 per face)
  47680. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  47681. * @param onLoad defines an optional callback raised when the texture is loaded
  47682. * @param onError defines an optional callback raised if there is an issue to load the texture
  47683. * @param format defines the format of the data
  47684. * @param forcedExtension defines the extension to use to pick the right loader
  47685. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  47686. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  47687. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  47688. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  47689. * @returns the cube texture as an InternalTexture
  47690. */
  47691. 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;
  47692. private _getSamplingFilter;
  47693. private static _GetNativeTextureFormat;
  47694. createRenderTargetTexture(size: number | {
  47695. width: number;
  47696. height: number;
  47697. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  47698. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  47699. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  47700. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  47701. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  47702. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  47703. /**
  47704. * Updates a dynamic vertex buffer.
  47705. * @param vertexBuffer the vertex buffer to update
  47706. * @param data the data used to update the vertex buffer
  47707. * @param byteOffset the byte offset of the data (optional)
  47708. * @param byteLength the byte length of the data (optional)
  47709. */
  47710. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  47711. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  47712. private _updateAnisotropicLevel;
  47713. private _getAddressMode;
  47714. /** @hidden */
  47715. _bindTexture(channel: number, texture: InternalTexture): void;
  47716. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  47717. releaseEffects(): void;
  47718. /** @hidden */
  47719. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47720. /** @hidden */
  47721. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47722. /** @hidden */
  47723. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47724. /** @hidden */
  47725. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  47726. }
  47727. }
  47728. declare module BABYLON {
  47729. /**
  47730. * Gather the list of clipboard event types as constants.
  47731. */
  47732. export class ClipboardEventTypes {
  47733. /**
  47734. * The clipboard event is fired when a copy command is active (pressed).
  47735. */
  47736. static readonly COPY: number;
  47737. /**
  47738. * The clipboard event is fired when a cut command is active (pressed).
  47739. */
  47740. static readonly CUT: number;
  47741. /**
  47742. * The clipboard event is fired when a paste command is active (pressed).
  47743. */
  47744. static readonly PASTE: number;
  47745. }
  47746. /**
  47747. * This class is used to store clipboard related info for the onClipboardObservable event.
  47748. */
  47749. export class ClipboardInfo {
  47750. /**
  47751. * Defines the type of event (BABYLON.ClipboardEventTypes)
  47752. */
  47753. type: number;
  47754. /**
  47755. * Defines the related dom event
  47756. */
  47757. event: ClipboardEvent;
  47758. /**
  47759. *Creates an instance of ClipboardInfo.
  47760. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  47761. * @param event Defines the related dom event
  47762. */
  47763. constructor(
  47764. /**
  47765. * Defines the type of event (BABYLON.ClipboardEventTypes)
  47766. */
  47767. type: number,
  47768. /**
  47769. * Defines the related dom event
  47770. */
  47771. event: ClipboardEvent);
  47772. /**
  47773. * Get the clipboard event's type from the keycode.
  47774. * @param keyCode Defines the keyCode for the current keyboard event.
  47775. * @return {number}
  47776. */
  47777. static GetTypeFromCharacter(keyCode: number): number;
  47778. }
  47779. }
  47780. declare module BABYLON {
  47781. /**
  47782. * Google Daydream controller
  47783. */
  47784. export class DaydreamController extends WebVRController {
  47785. /**
  47786. * Base Url for the controller model.
  47787. */
  47788. static MODEL_BASE_URL: string;
  47789. /**
  47790. * File name for the controller model.
  47791. */
  47792. static MODEL_FILENAME: string;
  47793. /**
  47794. * Gamepad Id prefix used to identify Daydream Controller.
  47795. */
  47796. static readonly GAMEPAD_ID_PREFIX: string;
  47797. /**
  47798. * Creates a new DaydreamController from a gamepad
  47799. * @param vrGamepad the gamepad that the controller should be created from
  47800. */
  47801. constructor(vrGamepad: any);
  47802. /**
  47803. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  47804. * @param scene scene in which to add meshes
  47805. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  47806. */
  47807. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  47808. /**
  47809. * Called once for each button that changed state since the last frame
  47810. * @param buttonIdx Which button index changed
  47811. * @param state New state of the button
  47812. * @param changes Which properties on the state changed since last frame
  47813. */
  47814. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  47815. }
  47816. }
  47817. declare module BABYLON {
  47818. /**
  47819. * Gear VR Controller
  47820. */
  47821. export class GearVRController extends WebVRController {
  47822. /**
  47823. * Base Url for the controller model.
  47824. */
  47825. static MODEL_BASE_URL: string;
  47826. /**
  47827. * File name for the controller model.
  47828. */
  47829. static MODEL_FILENAME: string;
  47830. /**
  47831. * Gamepad Id prefix used to identify this controller.
  47832. */
  47833. static readonly GAMEPAD_ID_PREFIX: string;
  47834. private readonly _buttonIndexToObservableNameMap;
  47835. /**
  47836. * Creates a new GearVRController from a gamepad
  47837. * @param vrGamepad the gamepad that the controller should be created from
  47838. */
  47839. constructor(vrGamepad: any);
  47840. /**
  47841. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  47842. * @param scene scene in which to add meshes
  47843. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  47844. */
  47845. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  47846. /**
  47847. * Called once for each button that changed state since the last frame
  47848. * @param buttonIdx Which button index changed
  47849. * @param state New state of the button
  47850. * @param changes Which properties on the state changed since last frame
  47851. */
  47852. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  47853. }
  47854. }
  47855. declare module BABYLON {
  47856. /**
  47857. * Generic Controller
  47858. */
  47859. export class GenericController extends WebVRController {
  47860. /**
  47861. * Base Url for the controller model.
  47862. */
  47863. static readonly MODEL_BASE_URL: string;
  47864. /**
  47865. * File name for the controller model.
  47866. */
  47867. static readonly MODEL_FILENAME: string;
  47868. /**
  47869. * Creates a new GenericController from a gamepad
  47870. * @param vrGamepad the gamepad that the controller should be created from
  47871. */
  47872. constructor(vrGamepad: any);
  47873. /**
  47874. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  47875. * @param scene scene in which to add meshes
  47876. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  47877. */
  47878. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  47879. /**
  47880. * Called once for each button that changed state since the last frame
  47881. * @param buttonIdx Which button index changed
  47882. * @param state New state of the button
  47883. * @param changes Which properties on the state changed since last frame
  47884. */
  47885. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  47886. }
  47887. }
  47888. declare module BABYLON {
  47889. /**
  47890. * Oculus Touch Controller
  47891. */
  47892. export class OculusTouchController extends WebVRController {
  47893. /**
  47894. * Base Url for the controller model.
  47895. */
  47896. static MODEL_BASE_URL: string;
  47897. /**
  47898. * File name for the left controller model.
  47899. */
  47900. static MODEL_LEFT_FILENAME: string;
  47901. /**
  47902. * File name for the right controller model.
  47903. */
  47904. static MODEL_RIGHT_FILENAME: string;
  47905. /**
  47906. * Base Url for the Quest controller model.
  47907. */
  47908. static QUEST_MODEL_BASE_URL: string;
  47909. /**
  47910. * @hidden
  47911. * If the controllers are running on a device that needs the updated Quest controller models
  47912. */
  47913. static _IsQuest: boolean;
  47914. /**
  47915. * Fired when the secondary trigger on this controller is modified
  47916. */
  47917. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  47918. /**
  47919. * Fired when the thumb rest on this controller is modified
  47920. */
  47921. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  47922. /**
  47923. * Creates a new OculusTouchController from a gamepad
  47924. * @param vrGamepad the gamepad that the controller should be created from
  47925. */
  47926. constructor(vrGamepad: any);
  47927. /**
  47928. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  47929. * @param scene scene in which to add meshes
  47930. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  47931. */
  47932. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  47933. /**
  47934. * Fired when the A button on this controller is modified
  47935. */
  47936. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  47937. /**
  47938. * Fired when the B button on this controller is modified
  47939. */
  47940. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  47941. /**
  47942. * Fired when the X button on this controller is modified
  47943. */
  47944. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  47945. /**
  47946. * Fired when the Y button on this controller is modified
  47947. */
  47948. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  47949. /**
  47950. * Called once for each button that changed state since the last frame
  47951. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  47952. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  47953. * 2) secondary trigger (same)
  47954. * 3) A (right) X (left), touch, pressed = value
  47955. * 4) B / Y
  47956. * 5) thumb rest
  47957. * @param buttonIdx Which button index changed
  47958. * @param state New state of the button
  47959. * @param changes Which properties on the state changed since last frame
  47960. */
  47961. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  47962. }
  47963. }
  47964. declare module BABYLON {
  47965. /**
  47966. * Vive Controller
  47967. */
  47968. export class ViveController extends WebVRController {
  47969. /**
  47970. * Base Url for the controller model.
  47971. */
  47972. static MODEL_BASE_URL: string;
  47973. /**
  47974. * File name for the controller model.
  47975. */
  47976. static MODEL_FILENAME: string;
  47977. /**
  47978. * Creates a new ViveController from a gamepad
  47979. * @param vrGamepad the gamepad that the controller should be created from
  47980. */
  47981. constructor(vrGamepad: any);
  47982. /**
  47983. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  47984. * @param scene scene in which to add meshes
  47985. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  47986. */
  47987. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  47988. /**
  47989. * Fired when the left button on this controller is modified
  47990. */
  47991. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  47992. /**
  47993. * Fired when the right button on this controller is modified
  47994. */
  47995. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  47996. /**
  47997. * Fired when the menu button on this controller is modified
  47998. */
  47999. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48000. /**
  48001. * Called once for each button that changed state since the last frame
  48002. * Vive mapping:
  48003. * 0: touchpad
  48004. * 1: trigger
  48005. * 2: left AND right buttons
  48006. * 3: menu button
  48007. * @param buttonIdx Which button index changed
  48008. * @param state New state of the button
  48009. * @param changes Which properties on the state changed since last frame
  48010. */
  48011. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48012. }
  48013. }
  48014. declare module BABYLON {
  48015. /**
  48016. * Defines the WindowsMotionController object that the state of the windows motion controller
  48017. */
  48018. export class WindowsMotionController extends WebVRController {
  48019. /**
  48020. * The base url used to load the left and right controller models
  48021. */
  48022. static MODEL_BASE_URL: string;
  48023. /**
  48024. * The name of the left controller model file
  48025. */
  48026. static MODEL_LEFT_FILENAME: string;
  48027. /**
  48028. * The name of the right controller model file
  48029. */
  48030. static MODEL_RIGHT_FILENAME: string;
  48031. /**
  48032. * The controller name prefix for this controller type
  48033. */
  48034. static readonly GAMEPAD_ID_PREFIX: string;
  48035. /**
  48036. * The controller id pattern for this controller type
  48037. */
  48038. private static readonly GAMEPAD_ID_PATTERN;
  48039. private _loadedMeshInfo;
  48040. protected readonly _mapping: {
  48041. buttons: string[];
  48042. buttonMeshNames: {
  48043. 'trigger': string;
  48044. 'menu': string;
  48045. 'grip': string;
  48046. 'thumbstick': string;
  48047. 'trackpad': string;
  48048. };
  48049. buttonObservableNames: {
  48050. 'trigger': string;
  48051. 'menu': string;
  48052. 'grip': string;
  48053. 'thumbstick': string;
  48054. 'trackpad': string;
  48055. };
  48056. axisMeshNames: string[];
  48057. pointingPoseMeshName: string;
  48058. };
  48059. /**
  48060. * Fired when the trackpad on this controller is clicked
  48061. */
  48062. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  48063. /**
  48064. * Fired when the trackpad on this controller is modified
  48065. */
  48066. onTrackpadValuesChangedObservable: Observable<StickValues>;
  48067. /**
  48068. * The current x and y values of this controller's trackpad
  48069. */
  48070. trackpad: StickValues;
  48071. /**
  48072. * Creates a new WindowsMotionController from a gamepad
  48073. * @param vrGamepad the gamepad that the controller should be created from
  48074. */
  48075. constructor(vrGamepad: any);
  48076. /**
  48077. * Fired when the trigger on this controller is modified
  48078. */
  48079. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48080. /**
  48081. * Fired when the menu button on this controller is modified
  48082. */
  48083. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48084. /**
  48085. * Fired when the grip button on this controller is modified
  48086. */
  48087. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48088. /**
  48089. * Fired when the thumbstick button on this controller is modified
  48090. */
  48091. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48092. /**
  48093. * Fired when the touchpad button on this controller is modified
  48094. */
  48095. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48096. /**
  48097. * Fired when the touchpad values on this controller are modified
  48098. */
  48099. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  48100. protected _updateTrackpad(): void;
  48101. /**
  48102. * Called once per frame by the engine.
  48103. */
  48104. update(): void;
  48105. /**
  48106. * Called once for each button that changed state since the last frame
  48107. * @param buttonIdx Which button index changed
  48108. * @param state New state of the button
  48109. * @param changes Which properties on the state changed since last frame
  48110. */
  48111. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48112. /**
  48113. * Moves the buttons on the controller mesh based on their current state
  48114. * @param buttonName the name of the button to move
  48115. * @param buttonValue the value of the button which determines the buttons new position
  48116. */
  48117. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  48118. /**
  48119. * Moves the axis on the controller mesh based on its current state
  48120. * @param axis the index of the axis
  48121. * @param axisValue the value of the axis which determines the meshes new position
  48122. * @hidden
  48123. */
  48124. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  48125. /**
  48126. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48127. * @param scene scene in which to add meshes
  48128. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48129. */
  48130. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  48131. /**
  48132. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  48133. * can be transformed by button presses and axes values, based on this._mapping.
  48134. *
  48135. * @param scene scene in which the meshes exist
  48136. * @param meshes list of meshes that make up the controller model to process
  48137. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  48138. */
  48139. private processModel;
  48140. private createMeshInfo;
  48141. /**
  48142. * Gets the ray of the controller in the direction the controller is pointing
  48143. * @param length the length the resulting ray should be
  48144. * @returns a ray in the direction the controller is pointing
  48145. */
  48146. getForwardRay(length?: number): Ray;
  48147. /**
  48148. * Disposes of the controller
  48149. */
  48150. dispose(): void;
  48151. }
  48152. /**
  48153. * This class represents a new windows motion controller in XR.
  48154. */
  48155. export class XRWindowsMotionController extends WindowsMotionController {
  48156. /**
  48157. * Changing the original WIndowsMotionController mapping to fir the new mapping
  48158. */
  48159. protected readonly _mapping: {
  48160. buttons: string[];
  48161. buttonMeshNames: {
  48162. 'trigger': string;
  48163. 'menu': string;
  48164. 'grip': string;
  48165. 'thumbstick': string;
  48166. 'trackpad': string;
  48167. };
  48168. buttonObservableNames: {
  48169. 'trigger': string;
  48170. 'menu': string;
  48171. 'grip': string;
  48172. 'thumbstick': string;
  48173. 'trackpad': string;
  48174. };
  48175. axisMeshNames: string[];
  48176. pointingPoseMeshName: string;
  48177. };
  48178. /**
  48179. * Construct a new XR-Based windows motion controller
  48180. *
  48181. * @param gamepadInfo the gamepad object from the browser
  48182. */
  48183. constructor(gamepadInfo: any);
  48184. /**
  48185. * holds the thumbstick values (X,Y)
  48186. */
  48187. thumbstickValues: StickValues;
  48188. /**
  48189. * Fired when the thumbstick on this controller is clicked
  48190. */
  48191. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  48192. /**
  48193. * Fired when the thumbstick on this controller is modified
  48194. */
  48195. onThumbstickValuesChangedObservable: Observable<StickValues>;
  48196. /**
  48197. * Fired when the touchpad button on this controller is modified
  48198. */
  48199. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  48200. /**
  48201. * Fired when the touchpad values on this controller are modified
  48202. */
  48203. onTrackpadValuesChangedObservable: Observable<StickValues>;
  48204. /**
  48205. * Fired when the thumbstick button on this controller is modified
  48206. * here to prevent breaking changes
  48207. */
  48208. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48209. /**
  48210. * updating the thumbstick(!) and not the trackpad.
  48211. * This is named this way due to the difference between WebVR and XR and to avoid
  48212. * changing the parent class.
  48213. */
  48214. protected _updateTrackpad(): void;
  48215. /**
  48216. * Disposes the class with joy
  48217. */
  48218. dispose(): void;
  48219. }
  48220. }
  48221. declare module BABYLON {
  48222. /**
  48223. * Class containing static functions to help procedurally build meshes
  48224. */
  48225. export class PolyhedronBuilder {
  48226. /**
  48227. * Creates a polyhedron mesh
  48228. * * 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
  48229. * * The parameter `size` (positive float, default 1) sets the polygon size
  48230. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  48231. * * 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`
  48232. * * 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
  48233. * * 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)`)
  48234. * * 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
  48235. * * 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
  48236. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48237. * * 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
  48238. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48239. * @param name defines the name of the mesh
  48240. * @param options defines the options used to create the mesh
  48241. * @param scene defines the hosting scene
  48242. * @returns the polyhedron mesh
  48243. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  48244. */
  48245. static CreatePolyhedron(name: string, options: {
  48246. type?: number;
  48247. size?: number;
  48248. sizeX?: number;
  48249. sizeY?: number;
  48250. sizeZ?: number;
  48251. custom?: any;
  48252. faceUV?: Vector4[];
  48253. faceColors?: Color4[];
  48254. flat?: boolean;
  48255. updatable?: boolean;
  48256. sideOrientation?: number;
  48257. frontUVs?: Vector4;
  48258. backUVs?: Vector4;
  48259. }, scene?: Nullable<Scene>): Mesh;
  48260. }
  48261. }
  48262. declare module BABYLON {
  48263. /**
  48264. * Gizmo that enables scaling a mesh along 3 axis
  48265. */
  48266. export class ScaleGizmo extends Gizmo {
  48267. /**
  48268. * Internal gizmo used for interactions on the x axis
  48269. */
  48270. xGizmo: AxisScaleGizmo;
  48271. /**
  48272. * Internal gizmo used for interactions on the y axis
  48273. */
  48274. yGizmo: AxisScaleGizmo;
  48275. /**
  48276. * Internal gizmo used for interactions on the z axis
  48277. */
  48278. zGizmo: AxisScaleGizmo;
  48279. /**
  48280. * Internal gizmo used to scale all axis equally
  48281. */
  48282. uniformScaleGizmo: AxisScaleGizmo;
  48283. private _meshAttached;
  48284. private _updateGizmoRotationToMatchAttachedMesh;
  48285. private _snapDistance;
  48286. private _scaleRatio;
  48287. private _uniformScalingMesh;
  48288. private _octahedron;
  48289. private _sensitivity;
  48290. /** Fires an event when any of it's sub gizmos are dragged */
  48291. onDragStartObservable: Observable<unknown>;
  48292. /** Fires an event when any of it's sub gizmos are released from dragging */
  48293. onDragEndObservable: Observable<unknown>;
  48294. get attachedMesh(): Nullable<AbstractMesh>;
  48295. set attachedMesh(mesh: Nullable<AbstractMesh>);
  48296. /**
  48297. * Creates a ScaleGizmo
  48298. * @param gizmoLayer The utility layer the gizmo will be added to
  48299. */
  48300. constructor(gizmoLayer?: UtilityLayerRenderer);
  48301. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  48302. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  48303. /**
  48304. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  48305. */
  48306. set snapDistance(value: number);
  48307. get snapDistance(): number;
  48308. /**
  48309. * Ratio for the scale of the gizmo (Default: 1)
  48310. */
  48311. set scaleRatio(value: number);
  48312. get scaleRatio(): number;
  48313. /**
  48314. * Sensitivity factor for dragging (Default: 1)
  48315. */
  48316. set sensitivity(value: number);
  48317. get sensitivity(): number;
  48318. /**
  48319. * Disposes of the gizmo
  48320. */
  48321. dispose(): void;
  48322. }
  48323. }
  48324. declare module BABYLON {
  48325. /**
  48326. * Single axis scale gizmo
  48327. */
  48328. export class AxisScaleGizmo extends Gizmo {
  48329. /**
  48330. * Drag behavior responsible for the gizmos dragging interactions
  48331. */
  48332. dragBehavior: PointerDragBehavior;
  48333. private _pointerObserver;
  48334. /**
  48335. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  48336. */
  48337. snapDistance: number;
  48338. /**
  48339. * Event that fires each time the gizmo snaps to a new location.
  48340. * * snapDistance is the the change in distance
  48341. */
  48342. onSnapObservable: Observable<{
  48343. snapDistance: number;
  48344. }>;
  48345. /**
  48346. * If the scaling operation should be done on all axis (default: false)
  48347. */
  48348. uniformScaling: boolean;
  48349. /**
  48350. * Custom sensitivity value for the drag strength
  48351. */
  48352. sensitivity: number;
  48353. private _isEnabled;
  48354. private _parent;
  48355. private _arrow;
  48356. private _coloredMaterial;
  48357. private _hoverMaterial;
  48358. /**
  48359. * Creates an AxisScaleGizmo
  48360. * @param gizmoLayer The utility layer the gizmo will be added to
  48361. * @param dragAxis The axis which the gizmo will be able to scale on
  48362. * @param color The color of the gizmo
  48363. */
  48364. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  48365. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  48366. /**
  48367. * If the gizmo is enabled
  48368. */
  48369. set isEnabled(value: boolean);
  48370. get isEnabled(): boolean;
  48371. /**
  48372. * Disposes of the gizmo
  48373. */
  48374. dispose(): void;
  48375. /**
  48376. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  48377. * @param mesh The mesh to replace the default mesh of the gizmo
  48378. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  48379. */
  48380. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  48381. }
  48382. }
  48383. declare module BABYLON {
  48384. /**
  48385. * Bounding box gizmo
  48386. */
  48387. export class BoundingBoxGizmo extends Gizmo {
  48388. private _lineBoundingBox;
  48389. private _rotateSpheresParent;
  48390. private _scaleBoxesParent;
  48391. private _boundingDimensions;
  48392. private _renderObserver;
  48393. private _pointerObserver;
  48394. private _scaleDragSpeed;
  48395. private _tmpQuaternion;
  48396. private _tmpVector;
  48397. private _tmpRotationMatrix;
  48398. /**
  48399. * 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)
  48400. */
  48401. ignoreChildren: boolean;
  48402. /**
  48403. * 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)
  48404. */
  48405. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  48406. /**
  48407. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  48408. */
  48409. rotationSphereSize: number;
  48410. /**
  48411. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  48412. */
  48413. scaleBoxSize: number;
  48414. /**
  48415. * 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)
  48416. */
  48417. fixedDragMeshScreenSize: boolean;
  48418. /**
  48419. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  48420. */
  48421. fixedDragMeshScreenSizeDistanceFactor: number;
  48422. /**
  48423. * Fired when a rotation sphere or scale box is dragged
  48424. */
  48425. onDragStartObservable: Observable<{}>;
  48426. /**
  48427. * Fired when a scale box is dragged
  48428. */
  48429. onScaleBoxDragObservable: Observable<{}>;
  48430. /**
  48431. * Fired when a scale box drag is ended
  48432. */
  48433. onScaleBoxDragEndObservable: Observable<{}>;
  48434. /**
  48435. * Fired when a rotation sphere is dragged
  48436. */
  48437. onRotationSphereDragObservable: Observable<{}>;
  48438. /**
  48439. * Fired when a rotation sphere drag is ended
  48440. */
  48441. onRotationSphereDragEndObservable: Observable<{}>;
  48442. /**
  48443. * 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)
  48444. */
  48445. scalePivot: Nullable<Vector3>;
  48446. /**
  48447. * Mesh used as a pivot to rotate the attached mesh
  48448. */
  48449. private _anchorMesh;
  48450. private _existingMeshScale;
  48451. private _dragMesh;
  48452. private pointerDragBehavior;
  48453. private coloredMaterial;
  48454. private hoverColoredMaterial;
  48455. /**
  48456. * Sets the color of the bounding box gizmo
  48457. * @param color the color to set
  48458. */
  48459. setColor(color: Color3): void;
  48460. /**
  48461. * Creates an BoundingBoxGizmo
  48462. * @param gizmoLayer The utility layer the gizmo will be added to
  48463. * @param color The color of the gizmo
  48464. */
  48465. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  48466. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  48467. private _selectNode;
  48468. /**
  48469. * Updates the bounding box information for the Gizmo
  48470. */
  48471. updateBoundingBox(): void;
  48472. private _updateRotationSpheres;
  48473. private _updateScaleBoxes;
  48474. /**
  48475. * Enables rotation on the specified axis and disables rotation on the others
  48476. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  48477. */
  48478. setEnabledRotationAxis(axis: string): void;
  48479. /**
  48480. * Enables/disables scaling
  48481. * @param enable if scaling should be enabled
  48482. */
  48483. setEnabledScaling(enable: boolean): void;
  48484. private _updateDummy;
  48485. /**
  48486. * Enables a pointer drag behavior on the bounding box of the gizmo
  48487. */
  48488. enableDragBehavior(): void;
  48489. /**
  48490. * Disposes of the gizmo
  48491. */
  48492. dispose(): void;
  48493. /**
  48494. * 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)
  48495. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  48496. * @returns the bounding box mesh with the passed in mesh as a child
  48497. */
  48498. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  48499. /**
  48500. * CustomMeshes are not supported by this gizmo
  48501. * @param mesh The mesh to replace the default mesh of the gizmo
  48502. */
  48503. setCustomMesh(mesh: Mesh): void;
  48504. }
  48505. }
  48506. declare module BABYLON {
  48507. /**
  48508. * Single plane rotation gizmo
  48509. */
  48510. export class PlaneRotationGizmo extends Gizmo {
  48511. /**
  48512. * Drag behavior responsible for the gizmos dragging interactions
  48513. */
  48514. dragBehavior: PointerDragBehavior;
  48515. private _pointerObserver;
  48516. /**
  48517. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  48518. */
  48519. snapDistance: number;
  48520. /**
  48521. * Event that fires each time the gizmo snaps to a new location.
  48522. * * snapDistance is the the change in distance
  48523. */
  48524. onSnapObservable: Observable<{
  48525. snapDistance: number;
  48526. }>;
  48527. private _isEnabled;
  48528. private _parent;
  48529. /**
  48530. * Creates a PlaneRotationGizmo
  48531. * @param gizmoLayer The utility layer the gizmo will be added to
  48532. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  48533. * @param color The color of the gizmo
  48534. * @param tessellation Amount of tessellation to be used when creating rotation circles
  48535. * @param useEulerRotation Use and update Euler angle instead of quaternion
  48536. */
  48537. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  48538. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  48539. /**
  48540. * If the gizmo is enabled
  48541. */
  48542. set isEnabled(value: boolean);
  48543. get isEnabled(): boolean;
  48544. /**
  48545. * Disposes of the gizmo
  48546. */
  48547. dispose(): void;
  48548. }
  48549. }
  48550. declare module BABYLON {
  48551. /**
  48552. * Gizmo that enables rotating a mesh along 3 axis
  48553. */
  48554. export class RotationGizmo extends Gizmo {
  48555. /**
  48556. * Internal gizmo used for interactions on the x axis
  48557. */
  48558. xGizmo: PlaneRotationGizmo;
  48559. /**
  48560. * Internal gizmo used for interactions on the y axis
  48561. */
  48562. yGizmo: PlaneRotationGizmo;
  48563. /**
  48564. * Internal gizmo used for interactions on the z axis
  48565. */
  48566. zGizmo: PlaneRotationGizmo;
  48567. /** Fires an event when any of it's sub gizmos are dragged */
  48568. onDragStartObservable: Observable<unknown>;
  48569. /** Fires an event when any of it's sub gizmos are released from dragging */
  48570. onDragEndObservable: Observable<unknown>;
  48571. private _meshAttached;
  48572. get attachedMesh(): Nullable<AbstractMesh>;
  48573. set attachedMesh(mesh: Nullable<AbstractMesh>);
  48574. /**
  48575. * Creates a RotationGizmo
  48576. * @param gizmoLayer The utility layer the gizmo will be added to
  48577. * @param tessellation Amount of tessellation to be used when creating rotation circles
  48578. * @param useEulerRotation Use and update Euler angle instead of quaternion
  48579. */
  48580. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  48581. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  48582. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  48583. /**
  48584. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  48585. */
  48586. set snapDistance(value: number);
  48587. get snapDistance(): number;
  48588. /**
  48589. * Ratio for the scale of the gizmo (Default: 1)
  48590. */
  48591. set scaleRatio(value: number);
  48592. get scaleRatio(): number;
  48593. /**
  48594. * Disposes of the gizmo
  48595. */
  48596. dispose(): void;
  48597. /**
  48598. * CustomMeshes are not supported by this gizmo
  48599. * @param mesh The mesh to replace the default mesh of the gizmo
  48600. */
  48601. setCustomMesh(mesh: Mesh): void;
  48602. }
  48603. }
  48604. declare module BABYLON {
  48605. /**
  48606. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  48607. */
  48608. export class GizmoManager implements IDisposable {
  48609. private scene;
  48610. /**
  48611. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  48612. */
  48613. gizmos: {
  48614. positionGizmo: Nullable<PositionGizmo>;
  48615. rotationGizmo: Nullable<RotationGizmo>;
  48616. scaleGizmo: Nullable<ScaleGizmo>;
  48617. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  48618. };
  48619. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  48620. clearGizmoOnEmptyPointerEvent: boolean;
  48621. /** Fires an event when the manager is attached to a mesh */
  48622. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  48623. private _gizmosEnabled;
  48624. private _pointerObserver;
  48625. private _attachedMesh;
  48626. private _boundingBoxColor;
  48627. private _defaultUtilityLayer;
  48628. private _defaultKeepDepthUtilityLayer;
  48629. /**
  48630. * When bounding box gizmo is enabled, this can be used to track drag/end events
  48631. */
  48632. boundingBoxDragBehavior: SixDofDragBehavior;
  48633. /**
  48634. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  48635. */
  48636. attachableMeshes: Nullable<Array<AbstractMesh>>;
  48637. /**
  48638. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  48639. */
  48640. usePointerToAttachGizmos: boolean;
  48641. /**
  48642. * Utility layer that the bounding box gizmo belongs to
  48643. */
  48644. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  48645. /**
  48646. * Utility layer that all gizmos besides bounding box belong to
  48647. */
  48648. get utilityLayer(): UtilityLayerRenderer;
  48649. /**
  48650. * Instatiates a gizmo manager
  48651. * @param scene the scene to overlay the gizmos on top of
  48652. */
  48653. constructor(scene: Scene);
  48654. /**
  48655. * Attaches a set of gizmos to the specified mesh
  48656. * @param mesh The mesh the gizmo's should be attached to
  48657. */
  48658. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  48659. /**
  48660. * If the position gizmo is enabled
  48661. */
  48662. set positionGizmoEnabled(value: boolean);
  48663. get positionGizmoEnabled(): boolean;
  48664. /**
  48665. * If the rotation gizmo is enabled
  48666. */
  48667. set rotationGizmoEnabled(value: boolean);
  48668. get rotationGizmoEnabled(): boolean;
  48669. /**
  48670. * If the scale gizmo is enabled
  48671. */
  48672. set scaleGizmoEnabled(value: boolean);
  48673. get scaleGizmoEnabled(): boolean;
  48674. /**
  48675. * If the boundingBox gizmo is enabled
  48676. */
  48677. set boundingBoxGizmoEnabled(value: boolean);
  48678. get boundingBoxGizmoEnabled(): boolean;
  48679. /**
  48680. * Disposes of the gizmo manager
  48681. */
  48682. dispose(): void;
  48683. }
  48684. }
  48685. declare module BABYLON {
  48686. /**
  48687. * A directional light is defined by a direction (what a surprise!).
  48688. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  48689. * 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.
  48690. * Documentation: https://doc.babylonjs.com/babylon101/lights
  48691. */
  48692. export class DirectionalLight extends ShadowLight {
  48693. private _shadowFrustumSize;
  48694. /**
  48695. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  48696. */
  48697. get shadowFrustumSize(): number;
  48698. /**
  48699. * Specifies a fix frustum size for the shadow generation.
  48700. */
  48701. set shadowFrustumSize(value: number);
  48702. private _shadowOrthoScale;
  48703. /**
  48704. * Gets the shadow projection scale against the optimal computed one.
  48705. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  48706. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  48707. */
  48708. get shadowOrthoScale(): number;
  48709. /**
  48710. * Sets 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. set shadowOrthoScale(value: number);
  48715. /**
  48716. * Automatically compute the projection matrix to best fit (including all the casters)
  48717. * on each frame.
  48718. */
  48719. autoUpdateExtends: boolean;
  48720. /**
  48721. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  48722. * on each frame. autoUpdateExtends must be set to true for this to work
  48723. */
  48724. autoCalcShadowZBounds: boolean;
  48725. private _orthoLeft;
  48726. private _orthoRight;
  48727. private _orthoTop;
  48728. private _orthoBottom;
  48729. /**
  48730. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  48731. * The directional light is emitted from everywhere in the given direction.
  48732. * It can cast shadows.
  48733. * Documentation : https://doc.babylonjs.com/babylon101/lights
  48734. * @param name The friendly name of the light
  48735. * @param direction The direction of the light
  48736. * @param scene The scene the light belongs to
  48737. */
  48738. constructor(name: string, direction: Vector3, scene: Scene);
  48739. /**
  48740. * Returns the string "DirectionalLight".
  48741. * @return The class name
  48742. */
  48743. getClassName(): string;
  48744. /**
  48745. * Returns the integer 1.
  48746. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  48747. */
  48748. getTypeID(): number;
  48749. /**
  48750. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  48751. * Returns the DirectionalLight Shadow projection matrix.
  48752. */
  48753. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  48754. /**
  48755. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  48756. * Returns the DirectionalLight Shadow projection matrix.
  48757. */
  48758. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  48759. /**
  48760. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  48761. * Returns the DirectionalLight Shadow projection matrix.
  48762. */
  48763. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  48764. protected _buildUniformLayout(): void;
  48765. /**
  48766. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  48767. * @param effect The effect to update
  48768. * @param lightIndex The index of the light in the effect to update
  48769. * @returns The directional light
  48770. */
  48771. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  48772. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  48773. /**
  48774. * Gets the minZ used for shadow according to both the scene and the light.
  48775. *
  48776. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  48777. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  48778. * @param activeCamera The camera we are returning the min for
  48779. * @returns the depth min z
  48780. */
  48781. getDepthMinZ(activeCamera: Camera): number;
  48782. /**
  48783. * Gets the maxZ used for shadow according to both the scene and the light.
  48784. *
  48785. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  48786. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  48787. * @param activeCamera The camera we are returning the max for
  48788. * @returns the depth max z
  48789. */
  48790. getDepthMaxZ(activeCamera: Camera): number;
  48791. /**
  48792. * Prepares the list of defines specific to the light type.
  48793. * @param defines the list of defines
  48794. * @param lightIndex defines the index of the light for the effect
  48795. */
  48796. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  48797. }
  48798. }
  48799. declare module BABYLON {
  48800. /**
  48801. * Class containing static functions to help procedurally build meshes
  48802. */
  48803. export class HemisphereBuilder {
  48804. /**
  48805. * Creates a hemisphere mesh
  48806. * @param name defines the name of the mesh
  48807. * @param options defines the options used to create the mesh
  48808. * @param scene defines the hosting scene
  48809. * @returns the hemisphere mesh
  48810. */
  48811. static CreateHemisphere(name: string, options: {
  48812. segments?: number;
  48813. diameter?: number;
  48814. sideOrientation?: number;
  48815. }, scene: any): Mesh;
  48816. }
  48817. }
  48818. declare module BABYLON {
  48819. /**
  48820. * A spot light is defined by a position, a direction, an angle, and an exponent.
  48821. * These values define a cone of light starting from the position, emitting toward the direction.
  48822. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  48823. * and the exponent defines the speed of the decay of the light with distance (reach).
  48824. * Documentation: https://doc.babylonjs.com/babylon101/lights
  48825. */
  48826. export class SpotLight extends ShadowLight {
  48827. private _angle;
  48828. private _innerAngle;
  48829. private _cosHalfAngle;
  48830. private _lightAngleScale;
  48831. private _lightAngleOffset;
  48832. /**
  48833. * Gets the cone angle of the spot light in Radians.
  48834. */
  48835. get angle(): number;
  48836. /**
  48837. * Sets the cone angle of the spot light in Radians.
  48838. */
  48839. set angle(value: number);
  48840. /**
  48841. * Only used in gltf falloff mode, this defines the angle where
  48842. * the directional falloff will start before cutting at angle which could be seen
  48843. * as outer angle.
  48844. */
  48845. get innerAngle(): 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. set innerAngle(value: number);
  48852. private _shadowAngleScale;
  48853. /**
  48854. * Allows scaling the angle of the light for shadow generation only.
  48855. */
  48856. get shadowAngleScale(): number;
  48857. /**
  48858. * Allows scaling the angle of the light for shadow generation only.
  48859. */
  48860. set shadowAngleScale(value: number);
  48861. /**
  48862. * The light decay speed with the distance from the emission spot.
  48863. */
  48864. exponent: number;
  48865. private _projectionTextureMatrix;
  48866. /**
  48867. * Allows reading the projecton texture
  48868. */
  48869. get projectionTextureMatrix(): Matrix;
  48870. protected _projectionTextureLightNear: number;
  48871. /**
  48872. * Gets the near clip of the Spotlight for texture projection.
  48873. */
  48874. get projectionTextureLightNear(): number;
  48875. /**
  48876. * Sets the near clip of the Spotlight for texture projection.
  48877. */
  48878. set projectionTextureLightNear(value: number);
  48879. protected _projectionTextureLightFar: number;
  48880. /**
  48881. * Gets the far clip of the Spotlight for texture projection.
  48882. */
  48883. get projectionTextureLightFar(): number;
  48884. /**
  48885. * Sets the far clip of the Spotlight for texture projection.
  48886. */
  48887. set projectionTextureLightFar(value: number);
  48888. protected _projectionTextureUpDirection: Vector3;
  48889. /**
  48890. * Gets the Up vector of the Spotlight for texture projection.
  48891. */
  48892. get projectionTextureUpDirection(): Vector3;
  48893. /**
  48894. * Sets the Up vector of the Spotlight for texture projection.
  48895. */
  48896. set projectionTextureUpDirection(value: Vector3);
  48897. private _projectionTexture;
  48898. /**
  48899. * Gets the projection texture of the light.
  48900. */
  48901. get projectionTexture(): Nullable<BaseTexture>;
  48902. /**
  48903. * Sets the projection texture of the light.
  48904. */
  48905. set projectionTexture(value: Nullable<BaseTexture>);
  48906. private _projectionTextureViewLightDirty;
  48907. private _projectionTextureProjectionLightDirty;
  48908. private _projectionTextureDirty;
  48909. private _projectionTextureViewTargetVector;
  48910. private _projectionTextureViewLightMatrix;
  48911. private _projectionTextureProjectionLightMatrix;
  48912. private _projectionTextureScalingMatrix;
  48913. /**
  48914. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  48915. * It can cast shadows.
  48916. * Documentation : https://doc.babylonjs.com/babylon101/lights
  48917. * @param name The light friendly name
  48918. * @param position The position of the spot light in the scene
  48919. * @param direction The direction of the light in the scene
  48920. * @param angle The cone angle of the light in Radians
  48921. * @param exponent The light decay speed with the distance from the emission spot
  48922. * @param scene The scene the lights belongs to
  48923. */
  48924. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  48925. /**
  48926. * Returns the string "SpotLight".
  48927. * @returns the class name
  48928. */
  48929. getClassName(): string;
  48930. /**
  48931. * Returns the integer 2.
  48932. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  48933. */
  48934. getTypeID(): number;
  48935. /**
  48936. * Overrides the direction setter to recompute the projection texture view light Matrix.
  48937. */
  48938. protected _setDirection(value: Vector3): void;
  48939. /**
  48940. * Overrides the position setter to recompute the projection texture view light Matrix.
  48941. */
  48942. protected _setPosition(value: Vector3): void;
  48943. /**
  48944. * 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.
  48945. * Returns the SpotLight.
  48946. */
  48947. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  48948. protected _computeProjectionTextureViewLightMatrix(): void;
  48949. protected _computeProjectionTextureProjectionLightMatrix(): void;
  48950. /**
  48951. * Main function for light texture projection matrix computing.
  48952. */
  48953. protected _computeProjectionTextureMatrix(): void;
  48954. protected _buildUniformLayout(): void;
  48955. private _computeAngleValues;
  48956. /**
  48957. * Sets the passed Effect "effect" with the Light textures.
  48958. * @param effect The effect to update
  48959. * @param lightIndex The index of the light in the effect to update
  48960. * @returns The light
  48961. */
  48962. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  48963. /**
  48964. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  48965. * @param effect The effect to update
  48966. * @param lightIndex The index of the light in the effect to update
  48967. * @returns The spot light
  48968. */
  48969. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  48970. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  48971. /**
  48972. * Disposes the light and the associated resources.
  48973. */
  48974. dispose(): void;
  48975. /**
  48976. * Prepares the list of defines specific to the light type.
  48977. * @param defines the list of defines
  48978. * @param lightIndex defines the index of the light for the effect
  48979. */
  48980. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  48981. }
  48982. }
  48983. declare module BABYLON {
  48984. /**
  48985. * Gizmo that enables viewing a light
  48986. */
  48987. export class LightGizmo extends Gizmo {
  48988. private _lightMesh;
  48989. private _material;
  48990. private _cachedPosition;
  48991. private _cachedForward;
  48992. private _attachedMeshParent;
  48993. /**
  48994. * Creates a LightGizmo
  48995. * @param gizmoLayer The utility layer the gizmo will be added to
  48996. */
  48997. constructor(gizmoLayer?: UtilityLayerRenderer);
  48998. private _light;
  48999. /**
  49000. * The light that the gizmo is attached to
  49001. */
  49002. set light(light: Nullable<Light>);
  49003. get light(): Nullable<Light>;
  49004. /**
  49005. * Gets the material used to render the light gizmo
  49006. */
  49007. get material(): StandardMaterial;
  49008. /**
  49009. * @hidden
  49010. * Updates the gizmo to match the attached mesh's position/rotation
  49011. */
  49012. protected _update(): void;
  49013. private static _Scale;
  49014. /**
  49015. * Creates the lines for a light mesh
  49016. */
  49017. private static _CreateLightLines;
  49018. /**
  49019. * Disposes of the light gizmo
  49020. */
  49021. dispose(): void;
  49022. private static _CreateHemisphericLightMesh;
  49023. private static _CreatePointLightMesh;
  49024. private static _CreateSpotLightMesh;
  49025. private static _CreateDirectionalLightMesh;
  49026. }
  49027. }
  49028. declare module BABYLON {
  49029. /** @hidden */
  49030. export var backgroundFragmentDeclaration: {
  49031. name: string;
  49032. shader: string;
  49033. };
  49034. }
  49035. declare module BABYLON {
  49036. /** @hidden */
  49037. export var backgroundUboDeclaration: {
  49038. name: string;
  49039. shader: string;
  49040. };
  49041. }
  49042. declare module BABYLON {
  49043. /** @hidden */
  49044. export var backgroundPixelShader: {
  49045. name: string;
  49046. shader: string;
  49047. };
  49048. }
  49049. declare module BABYLON {
  49050. /** @hidden */
  49051. export var backgroundVertexDeclaration: {
  49052. name: string;
  49053. shader: string;
  49054. };
  49055. }
  49056. declare module BABYLON {
  49057. /** @hidden */
  49058. export var backgroundVertexShader: {
  49059. name: string;
  49060. shader: string;
  49061. };
  49062. }
  49063. declare module BABYLON {
  49064. /**
  49065. * Background material used to create an efficient environement around your scene.
  49066. */
  49067. export class BackgroundMaterial extends PushMaterial {
  49068. /**
  49069. * Standard reflectance value at parallel view angle.
  49070. */
  49071. static StandardReflectance0: number;
  49072. /**
  49073. * Standard reflectance value at grazing angle.
  49074. */
  49075. static StandardReflectance90: number;
  49076. protected _primaryColor: Color3;
  49077. /**
  49078. * Key light Color (multiply against the environement texture)
  49079. */
  49080. primaryColor: Color3;
  49081. protected __perceptualColor: Nullable<Color3>;
  49082. /**
  49083. * Experimental Internal Use Only.
  49084. *
  49085. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  49086. * This acts as a helper to set the primary color to a more "human friendly" value.
  49087. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  49088. * output color as close as possible from the chosen value.
  49089. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  49090. * part of lighting setup.)
  49091. */
  49092. get _perceptualColor(): Nullable<Color3>;
  49093. set _perceptualColor(value: Nullable<Color3>);
  49094. protected _primaryColorShadowLevel: float;
  49095. /**
  49096. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  49097. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  49098. */
  49099. get primaryColorShadowLevel(): float;
  49100. set primaryColorShadowLevel(value: float);
  49101. protected _primaryColorHighlightLevel: float;
  49102. /**
  49103. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  49104. * The primary color is used at the level chosen to define what the white area would look.
  49105. */
  49106. get primaryColorHighlightLevel(): float;
  49107. set primaryColorHighlightLevel(value: float);
  49108. protected _reflectionTexture: Nullable<BaseTexture>;
  49109. /**
  49110. * Reflection Texture used in the material.
  49111. * Should be author in a specific way for the best result (refer to the documentation).
  49112. */
  49113. reflectionTexture: Nullable<BaseTexture>;
  49114. protected _reflectionBlur: float;
  49115. /**
  49116. * Reflection Texture level of blur.
  49117. *
  49118. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  49119. * texture twice.
  49120. */
  49121. reflectionBlur: float;
  49122. protected _diffuseTexture: Nullable<BaseTexture>;
  49123. /**
  49124. * Diffuse Texture used in the material.
  49125. * Should be author in a specific way for the best result (refer to the documentation).
  49126. */
  49127. diffuseTexture: Nullable<BaseTexture>;
  49128. protected _shadowLights: Nullable<IShadowLight[]>;
  49129. /**
  49130. * Specify the list of lights casting shadow on the material.
  49131. * All scene shadow lights will be included if null.
  49132. */
  49133. shadowLights: Nullable<IShadowLight[]>;
  49134. protected _shadowLevel: float;
  49135. /**
  49136. * Helps adjusting the shadow to a softer level if required.
  49137. * 0 means black shadows and 1 means no shadows.
  49138. */
  49139. shadowLevel: float;
  49140. protected _sceneCenter: Vector3;
  49141. /**
  49142. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  49143. * It is usually zero but might be interesting to modify according to your setup.
  49144. */
  49145. sceneCenter: Vector3;
  49146. protected _opacityFresnel: boolean;
  49147. /**
  49148. * This helps specifying that the material is falling off to the sky box at grazing angle.
  49149. * This helps ensuring a nice transition when the camera goes under the ground.
  49150. */
  49151. opacityFresnel: boolean;
  49152. protected _reflectionFresnel: boolean;
  49153. /**
  49154. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  49155. * This helps adding a mirror texture on the ground.
  49156. */
  49157. reflectionFresnel: boolean;
  49158. protected _reflectionFalloffDistance: number;
  49159. /**
  49160. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  49161. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  49162. */
  49163. reflectionFalloffDistance: number;
  49164. protected _reflectionAmount: number;
  49165. /**
  49166. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  49167. */
  49168. reflectionAmount: number;
  49169. protected _reflectionReflectance0: number;
  49170. /**
  49171. * This specifies the weight of the reflection at grazing angle.
  49172. */
  49173. reflectionReflectance0: number;
  49174. protected _reflectionReflectance90: number;
  49175. /**
  49176. * This specifies the weight of the reflection at a perpendicular point of view.
  49177. */
  49178. reflectionReflectance90: number;
  49179. /**
  49180. * Sets the reflection reflectance fresnel values according to the default standard
  49181. * empirically know to work well :-)
  49182. */
  49183. set reflectionStandardFresnelWeight(value: number);
  49184. protected _useRGBColor: boolean;
  49185. /**
  49186. * Helps to directly use the maps channels instead of their level.
  49187. */
  49188. useRGBColor: boolean;
  49189. protected _enableNoise: boolean;
  49190. /**
  49191. * This helps reducing the banding effect that could occur on the background.
  49192. */
  49193. enableNoise: boolean;
  49194. /**
  49195. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  49196. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  49197. * Recommended to be keep at 1.0 except for special cases.
  49198. */
  49199. get fovMultiplier(): number;
  49200. set fovMultiplier(value: number);
  49201. private _fovMultiplier;
  49202. /**
  49203. * Enable the FOV adjustment feature controlled by fovMultiplier.
  49204. */
  49205. useEquirectangularFOV: boolean;
  49206. private _maxSimultaneousLights;
  49207. /**
  49208. * Number of Simultaneous lights allowed on the material.
  49209. */
  49210. maxSimultaneousLights: int;
  49211. /**
  49212. * Default configuration related to image processing available in the Background Material.
  49213. */
  49214. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  49215. /**
  49216. * Keep track of the image processing observer to allow dispose and replace.
  49217. */
  49218. private _imageProcessingObserver;
  49219. /**
  49220. * Attaches a new image processing configuration to the PBR Material.
  49221. * @param configuration (if null the scene configuration will be use)
  49222. */
  49223. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  49224. /**
  49225. * Gets the image processing configuration used either in this material.
  49226. */
  49227. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  49228. /**
  49229. * Sets the Default image processing configuration used either in the this material.
  49230. *
  49231. * If sets to null, the scene one is in use.
  49232. */
  49233. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  49234. /**
  49235. * Gets wether the color curves effect is enabled.
  49236. */
  49237. get cameraColorCurvesEnabled(): boolean;
  49238. /**
  49239. * Sets wether the color curves effect is enabled.
  49240. */
  49241. set cameraColorCurvesEnabled(value: boolean);
  49242. /**
  49243. * Gets wether the color grading effect is enabled.
  49244. */
  49245. get cameraColorGradingEnabled(): boolean;
  49246. /**
  49247. * Gets wether the color grading effect is enabled.
  49248. */
  49249. set cameraColorGradingEnabled(value: boolean);
  49250. /**
  49251. * Gets wether tonemapping is enabled or not.
  49252. */
  49253. get cameraToneMappingEnabled(): boolean;
  49254. /**
  49255. * Sets wether tonemapping is enabled or not
  49256. */
  49257. set cameraToneMappingEnabled(value: boolean);
  49258. /**
  49259. * The camera exposure used on this material.
  49260. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  49261. * This corresponds to a photographic exposure.
  49262. */
  49263. get cameraExposure(): float;
  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. set cameraExposure(value: float);
  49270. /**
  49271. * Gets The camera contrast used on this material.
  49272. */
  49273. get cameraContrast(): float;
  49274. /**
  49275. * Sets The camera contrast used on this material.
  49276. */
  49277. set cameraContrast(value: float);
  49278. /**
  49279. * Gets the Color Grading 2D Lookup Texture.
  49280. */
  49281. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  49282. /**
  49283. * Sets the Color Grading 2D Lookup Texture.
  49284. */
  49285. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  49286. /**
  49287. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  49288. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  49289. * 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;
  49290. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  49291. */
  49292. get cameraColorCurves(): Nullable<ColorCurves>;
  49293. /**
  49294. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  49295. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  49296. * 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;
  49297. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  49298. */
  49299. set cameraColorCurves(value: Nullable<ColorCurves>);
  49300. /**
  49301. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  49302. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  49303. */
  49304. switchToBGR: boolean;
  49305. private _renderTargets;
  49306. private _reflectionControls;
  49307. private _white;
  49308. private _primaryShadowColor;
  49309. private _primaryHighlightColor;
  49310. /**
  49311. * Instantiates a Background Material in the given scene
  49312. * @param name The friendly name of the material
  49313. * @param scene The scene to add the material to
  49314. */
  49315. constructor(name: string, scene: Scene);
  49316. /**
  49317. * Gets a boolean indicating that current material needs to register RTT
  49318. */
  49319. get hasRenderTargetTextures(): boolean;
  49320. /**
  49321. * The entire material has been created in order to prevent overdraw.
  49322. * @returns false
  49323. */
  49324. needAlphaTesting(): boolean;
  49325. /**
  49326. * The entire material has been created in order to prevent overdraw.
  49327. * @returns true if blending is enable
  49328. */
  49329. needAlphaBlending(): boolean;
  49330. /**
  49331. * Checks wether the material is ready to be rendered for a given mesh.
  49332. * @param mesh The mesh to render
  49333. * @param subMesh The submesh to check against
  49334. * @param useInstances Specify wether or not the material is used with instances
  49335. * @returns true if all the dependencies are ready (Textures, Effects...)
  49336. */
  49337. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  49338. /**
  49339. * Compute the primary color according to the chosen perceptual color.
  49340. */
  49341. private _computePrimaryColorFromPerceptualColor;
  49342. /**
  49343. * Compute the highlights and shadow colors according to their chosen levels.
  49344. */
  49345. private _computePrimaryColors;
  49346. /**
  49347. * Build the uniform buffer used in the material.
  49348. */
  49349. buildUniformLayout(): void;
  49350. /**
  49351. * Unbind the material.
  49352. */
  49353. unbind(): void;
  49354. /**
  49355. * Bind only the world matrix to the material.
  49356. * @param world The world matrix to bind.
  49357. */
  49358. bindOnlyWorldMatrix(world: Matrix): void;
  49359. /**
  49360. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  49361. * @param world The world matrix to bind.
  49362. * @param subMesh The submesh to bind for.
  49363. */
  49364. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  49365. /**
  49366. * Checks to see if a texture is used in the material.
  49367. * @param texture - Base texture to use.
  49368. * @returns - Boolean specifying if a texture is used in the material.
  49369. */
  49370. hasTexture(texture: BaseTexture): boolean;
  49371. /**
  49372. * Dispose the material.
  49373. * @param forceDisposeEffect Force disposal of the associated effect.
  49374. * @param forceDisposeTextures Force disposal of the associated textures.
  49375. */
  49376. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  49377. /**
  49378. * Clones the material.
  49379. * @param name The cloned name.
  49380. * @returns The cloned material.
  49381. */
  49382. clone(name: string): BackgroundMaterial;
  49383. /**
  49384. * Serializes the current material to its JSON representation.
  49385. * @returns The JSON representation.
  49386. */
  49387. serialize(): any;
  49388. /**
  49389. * Gets the class name of the material
  49390. * @returns "BackgroundMaterial"
  49391. */
  49392. getClassName(): string;
  49393. /**
  49394. * Parse a JSON input to create back a background material.
  49395. * @param source The JSON data to parse
  49396. * @param scene The scene to create the parsed material in
  49397. * @param rootUrl The root url of the assets the material depends upon
  49398. * @returns the instantiated BackgroundMaterial.
  49399. */
  49400. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  49401. }
  49402. }
  49403. declare module BABYLON {
  49404. /**
  49405. * Represents the different options available during the creation of
  49406. * a Environment helper.
  49407. *
  49408. * This can control the default ground, skybox and image processing setup of your scene.
  49409. */
  49410. export interface IEnvironmentHelperOptions {
  49411. /**
  49412. * Specifies whether or not to create a ground.
  49413. * True by default.
  49414. */
  49415. createGround: boolean;
  49416. /**
  49417. * Specifies the ground size.
  49418. * 15 by default.
  49419. */
  49420. groundSize: number;
  49421. /**
  49422. * The texture used on the ground for the main color.
  49423. * Comes from the BabylonJS CDN by default.
  49424. *
  49425. * Remarks: Can be either a texture or a url.
  49426. */
  49427. groundTexture: string | BaseTexture;
  49428. /**
  49429. * The color mixed in the ground texture by default.
  49430. * BabylonJS clearColor by default.
  49431. */
  49432. groundColor: Color3;
  49433. /**
  49434. * Specifies the ground opacity.
  49435. * 1 by default.
  49436. */
  49437. groundOpacity: number;
  49438. /**
  49439. * Enables the ground to receive shadows.
  49440. * True by default.
  49441. */
  49442. enableGroundShadow: boolean;
  49443. /**
  49444. * Helps preventing the shadow to be fully black on the ground.
  49445. * 0.5 by default.
  49446. */
  49447. groundShadowLevel: number;
  49448. /**
  49449. * Creates a mirror texture attach to the ground.
  49450. * false by default.
  49451. */
  49452. enableGroundMirror: boolean;
  49453. /**
  49454. * Specifies the ground mirror size ratio.
  49455. * 0.3 by default as the default kernel is 64.
  49456. */
  49457. groundMirrorSizeRatio: number;
  49458. /**
  49459. * Specifies the ground mirror blur kernel size.
  49460. * 64 by default.
  49461. */
  49462. groundMirrorBlurKernel: number;
  49463. /**
  49464. * Specifies the ground mirror visibility amount.
  49465. * 1 by default
  49466. */
  49467. groundMirrorAmount: number;
  49468. /**
  49469. * Specifies the ground mirror reflectance weight.
  49470. * This uses the standard weight of the background material to setup the fresnel effect
  49471. * of the mirror.
  49472. * 1 by default.
  49473. */
  49474. groundMirrorFresnelWeight: number;
  49475. /**
  49476. * Specifies the ground mirror Falloff distance.
  49477. * This can helps reducing the size of the reflection.
  49478. * 0 by Default.
  49479. */
  49480. groundMirrorFallOffDistance: number;
  49481. /**
  49482. * Specifies the ground mirror texture type.
  49483. * Unsigned Int by Default.
  49484. */
  49485. groundMirrorTextureType: number;
  49486. /**
  49487. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  49488. * the shown objects.
  49489. */
  49490. groundYBias: number;
  49491. /**
  49492. * Specifies whether or not to create a skybox.
  49493. * True by default.
  49494. */
  49495. createSkybox: boolean;
  49496. /**
  49497. * Specifies the skybox size.
  49498. * 20 by default.
  49499. */
  49500. skyboxSize: number;
  49501. /**
  49502. * The texture used on the skybox for the main color.
  49503. * Comes from the BabylonJS CDN by default.
  49504. *
  49505. * Remarks: Can be either a texture or a url.
  49506. */
  49507. skyboxTexture: string | BaseTexture;
  49508. /**
  49509. * The color mixed in the skybox texture by default.
  49510. * BabylonJS clearColor by default.
  49511. */
  49512. skyboxColor: Color3;
  49513. /**
  49514. * The background rotation around the Y axis of the scene.
  49515. * This helps aligning the key lights of your scene with the background.
  49516. * 0 by default.
  49517. */
  49518. backgroundYRotation: number;
  49519. /**
  49520. * Compute automatically the size of the elements to best fit with the scene.
  49521. */
  49522. sizeAuto: boolean;
  49523. /**
  49524. * Default position of the rootMesh if autoSize is not true.
  49525. */
  49526. rootPosition: Vector3;
  49527. /**
  49528. * Sets up the image processing in the scene.
  49529. * true by default.
  49530. */
  49531. setupImageProcessing: boolean;
  49532. /**
  49533. * The texture used as your environment texture in the scene.
  49534. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  49535. *
  49536. * Remarks: Can be either a texture or a url.
  49537. */
  49538. environmentTexture: string | BaseTexture;
  49539. /**
  49540. * The value of the exposure to apply to the scene.
  49541. * 0.6 by default if setupImageProcessing is true.
  49542. */
  49543. cameraExposure: number;
  49544. /**
  49545. * The value of the contrast to apply to the scene.
  49546. * 1.6 by default if setupImageProcessing is true.
  49547. */
  49548. cameraContrast: number;
  49549. /**
  49550. * Specifies whether or not tonemapping should be enabled in the scene.
  49551. * true by default if setupImageProcessing is true.
  49552. */
  49553. toneMappingEnabled: boolean;
  49554. }
  49555. /**
  49556. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  49557. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  49558. * It also helps with the default setup of your imageProcessing configuration.
  49559. */
  49560. export class EnvironmentHelper {
  49561. /**
  49562. * Default ground texture URL.
  49563. */
  49564. private static _groundTextureCDNUrl;
  49565. /**
  49566. * Default skybox texture URL.
  49567. */
  49568. private static _skyboxTextureCDNUrl;
  49569. /**
  49570. * Default environment texture URL.
  49571. */
  49572. private static _environmentTextureCDNUrl;
  49573. /**
  49574. * Creates the default options for the helper.
  49575. */
  49576. private static _getDefaultOptions;
  49577. private _rootMesh;
  49578. /**
  49579. * Gets the root mesh created by the helper.
  49580. */
  49581. get rootMesh(): Mesh;
  49582. private _skybox;
  49583. /**
  49584. * Gets the skybox created by the helper.
  49585. */
  49586. get skybox(): Nullable<Mesh>;
  49587. private _skyboxTexture;
  49588. /**
  49589. * Gets the skybox texture created by the helper.
  49590. */
  49591. get skyboxTexture(): Nullable<BaseTexture>;
  49592. private _skyboxMaterial;
  49593. /**
  49594. * Gets the skybox material created by the helper.
  49595. */
  49596. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  49597. private _ground;
  49598. /**
  49599. * Gets the ground mesh created by the helper.
  49600. */
  49601. get ground(): Nullable<Mesh>;
  49602. private _groundTexture;
  49603. /**
  49604. * Gets the ground texture created by the helper.
  49605. */
  49606. get groundTexture(): Nullable<BaseTexture>;
  49607. private _groundMirror;
  49608. /**
  49609. * Gets the ground mirror created by the helper.
  49610. */
  49611. get groundMirror(): Nullable<MirrorTexture>;
  49612. /**
  49613. * Gets the ground mirror render list to helps pushing the meshes
  49614. * you wish in the ground reflection.
  49615. */
  49616. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  49617. private _groundMaterial;
  49618. /**
  49619. * Gets the ground material created by the helper.
  49620. */
  49621. get groundMaterial(): Nullable<BackgroundMaterial>;
  49622. /**
  49623. * Stores the creation options.
  49624. */
  49625. private readonly _scene;
  49626. private _options;
  49627. /**
  49628. * This observable will be notified with any error during the creation of the environment,
  49629. * mainly texture creation errors.
  49630. */
  49631. onErrorObservable: Observable<{
  49632. message?: string;
  49633. exception?: any;
  49634. }>;
  49635. /**
  49636. * constructor
  49637. * @param options Defines the options we want to customize the helper
  49638. * @param scene The scene to add the material to
  49639. */
  49640. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  49641. /**
  49642. * Updates the background according to the new options
  49643. * @param options
  49644. */
  49645. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  49646. /**
  49647. * Sets the primary color of all the available elements.
  49648. * @param color the main color to affect to the ground and the background
  49649. */
  49650. setMainColor(color: Color3): void;
  49651. /**
  49652. * Setup the image processing according to the specified options.
  49653. */
  49654. private _setupImageProcessing;
  49655. /**
  49656. * Setup the environment texture according to the specified options.
  49657. */
  49658. private _setupEnvironmentTexture;
  49659. /**
  49660. * Setup the background according to the specified options.
  49661. */
  49662. private _setupBackground;
  49663. /**
  49664. * Get the scene sizes according to the setup.
  49665. */
  49666. private _getSceneSize;
  49667. /**
  49668. * Setup the ground according to the specified options.
  49669. */
  49670. private _setupGround;
  49671. /**
  49672. * Setup the ground material according to the specified options.
  49673. */
  49674. private _setupGroundMaterial;
  49675. /**
  49676. * Setup the ground diffuse texture according to the specified options.
  49677. */
  49678. private _setupGroundDiffuseTexture;
  49679. /**
  49680. * Setup the ground mirror texture according to the specified options.
  49681. */
  49682. private _setupGroundMirrorTexture;
  49683. /**
  49684. * Setup the ground to receive the mirror texture.
  49685. */
  49686. private _setupMirrorInGroundMaterial;
  49687. /**
  49688. * Setup the skybox according to the specified options.
  49689. */
  49690. private _setupSkybox;
  49691. /**
  49692. * Setup the skybox material according to the specified options.
  49693. */
  49694. private _setupSkyboxMaterial;
  49695. /**
  49696. * Setup the skybox reflection texture according to the specified options.
  49697. */
  49698. private _setupSkyboxReflectionTexture;
  49699. private _errorHandler;
  49700. /**
  49701. * Dispose all the elements created by the Helper.
  49702. */
  49703. dispose(): void;
  49704. }
  49705. }
  49706. declare module BABYLON {
  49707. /**
  49708. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  49709. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  49710. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  49711. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  49712. */
  49713. export class PhotoDome extends TransformNode {
  49714. /**
  49715. * Define the image as a Monoscopic panoramic 360 image.
  49716. */
  49717. static readonly MODE_MONOSCOPIC: number;
  49718. /**
  49719. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  49720. */
  49721. static readonly MODE_TOPBOTTOM: number;
  49722. /**
  49723. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  49724. */
  49725. static readonly MODE_SIDEBYSIDE: number;
  49726. private _useDirectMapping;
  49727. /**
  49728. * The texture being displayed on the sphere
  49729. */
  49730. protected _photoTexture: Texture;
  49731. /**
  49732. * Gets or sets the texture being displayed on the sphere
  49733. */
  49734. get photoTexture(): Texture;
  49735. set photoTexture(value: Texture);
  49736. /**
  49737. * Observable raised when an error occured while loading the 360 image
  49738. */
  49739. onLoadErrorObservable: Observable<string>;
  49740. /**
  49741. * The skybox material
  49742. */
  49743. protected _material: BackgroundMaterial;
  49744. /**
  49745. * The surface used for the skybox
  49746. */
  49747. protected _mesh: Mesh;
  49748. /**
  49749. * Gets the mesh used for the skybox.
  49750. */
  49751. get mesh(): Mesh;
  49752. /**
  49753. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  49754. * Also see the options.resolution property.
  49755. */
  49756. get fovMultiplier(): number;
  49757. set fovMultiplier(value: number);
  49758. private _imageMode;
  49759. /**
  49760. * Gets or set the current video mode for the video. It can be:
  49761. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  49762. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  49763. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  49764. */
  49765. get imageMode(): number;
  49766. set imageMode(value: number);
  49767. /**
  49768. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  49769. * @param name Element's name, child elements will append suffixes for their own names.
  49770. * @param urlsOfPhoto defines the url of the photo to display
  49771. * @param options defines an object containing optional or exposed sub element properties
  49772. * @param onError defines a callback called when an error occured while loading the texture
  49773. */
  49774. constructor(name: string, urlOfPhoto: string, options: {
  49775. resolution?: number;
  49776. size?: number;
  49777. useDirectMapping?: boolean;
  49778. faceForward?: boolean;
  49779. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  49780. private _onBeforeCameraRenderObserver;
  49781. private _changeImageMode;
  49782. /**
  49783. * Releases resources associated with this node.
  49784. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  49785. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  49786. */
  49787. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  49788. }
  49789. }
  49790. declare module BABYLON {
  49791. /**
  49792. * Class used to host RGBD texture specific utilities
  49793. */
  49794. export class RGBDTextureTools {
  49795. /**
  49796. * Expand the RGBD Texture from RGBD to Half Float if possible.
  49797. * @param texture the texture to expand.
  49798. */
  49799. static ExpandRGBDTexture(texture: Texture): void;
  49800. }
  49801. }
  49802. declare module BABYLON {
  49803. /**
  49804. * Class used to host texture specific utilities
  49805. */
  49806. export class BRDFTextureTools {
  49807. /**
  49808. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  49809. * @param scene defines the hosting scene
  49810. * @returns the environment BRDF texture
  49811. */
  49812. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  49813. private static _environmentBRDFBase64Texture;
  49814. }
  49815. }
  49816. declare module BABYLON {
  49817. /**
  49818. * @hidden
  49819. */
  49820. export interface IMaterialClearCoatDefines {
  49821. CLEARCOAT: boolean;
  49822. CLEARCOAT_DEFAULTIOR: boolean;
  49823. CLEARCOAT_TEXTURE: boolean;
  49824. CLEARCOAT_TEXTUREDIRECTUV: number;
  49825. CLEARCOAT_BUMP: boolean;
  49826. CLEARCOAT_BUMPDIRECTUV: number;
  49827. CLEARCOAT_TINT: boolean;
  49828. CLEARCOAT_TINT_TEXTURE: boolean;
  49829. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  49830. /** @hidden */
  49831. _areTexturesDirty: boolean;
  49832. }
  49833. /**
  49834. * Define the code related to the clear coat parameters of the pbr material.
  49835. */
  49836. export class PBRClearCoatConfiguration {
  49837. /**
  49838. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  49839. * The default fits with a polyurethane material.
  49840. */
  49841. private static readonly _DefaultIndexOfRefraction;
  49842. private _isEnabled;
  49843. /**
  49844. * Defines if the clear coat is enabled in the material.
  49845. */
  49846. isEnabled: boolean;
  49847. /**
  49848. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  49849. */
  49850. intensity: number;
  49851. /**
  49852. * Defines the clear coat layer roughness.
  49853. */
  49854. roughness: number;
  49855. private _indexOfRefraction;
  49856. /**
  49857. * Defines the index of refraction of the clear coat.
  49858. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  49859. * The default fits with a polyurethane material.
  49860. * Changing the default value is more performance intensive.
  49861. */
  49862. indexOfRefraction: number;
  49863. private _texture;
  49864. /**
  49865. * Stores the clear coat values in a texture.
  49866. */
  49867. texture: Nullable<BaseTexture>;
  49868. private _bumpTexture;
  49869. /**
  49870. * Define the clear coat specific bump texture.
  49871. */
  49872. bumpTexture: Nullable<BaseTexture>;
  49873. private _isTintEnabled;
  49874. /**
  49875. * Defines if the clear coat tint is enabled in the material.
  49876. */
  49877. isTintEnabled: boolean;
  49878. /**
  49879. * Defines the clear coat tint of the material.
  49880. * This is only use if tint is enabled
  49881. */
  49882. tintColor: Color3;
  49883. /**
  49884. * Defines the distance at which the tint color should be found in the
  49885. * clear coat media.
  49886. * This is only use if tint is enabled
  49887. */
  49888. tintColorAtDistance: number;
  49889. /**
  49890. * Defines the clear coat layer thickness.
  49891. * This is only use if tint is enabled
  49892. */
  49893. tintThickness: number;
  49894. private _tintTexture;
  49895. /**
  49896. * Stores the clear tint values in a texture.
  49897. * rgb is tint
  49898. * a is a thickness factor
  49899. */
  49900. tintTexture: Nullable<BaseTexture>;
  49901. /** @hidden */
  49902. private _internalMarkAllSubMeshesAsTexturesDirty;
  49903. /** @hidden */
  49904. _markAllSubMeshesAsTexturesDirty(): void;
  49905. /**
  49906. * Instantiate a new istance of clear coat configuration.
  49907. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  49908. */
  49909. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  49910. /**
  49911. * Gets wehter the submesh is ready to be used or not.
  49912. * @param defines the list of "defines" to update.
  49913. * @param scene defines the scene the material belongs to.
  49914. * @param engine defines the engine the material belongs to.
  49915. * @param disableBumpMap defines wether the material disables bump or not.
  49916. * @returns - boolean indicating that the submesh is ready or not.
  49917. */
  49918. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  49919. /**
  49920. * Checks to see if a texture is used in the material.
  49921. * @param defines the list of "defines" to update.
  49922. * @param scene defines the scene to the material belongs to.
  49923. */
  49924. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  49925. /**
  49926. * Binds the material data.
  49927. * @param uniformBuffer defines the Uniform buffer to fill in.
  49928. * @param scene defines the scene the material belongs to.
  49929. * @param engine defines the engine the material belongs to.
  49930. * @param disableBumpMap defines wether the material disables bump or not.
  49931. * @param isFrozen defines wether the material is frozen or not.
  49932. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  49933. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  49934. */
  49935. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  49936. /**
  49937. * Checks to see if a texture is used in the material.
  49938. * @param texture - Base texture to use.
  49939. * @returns - Boolean specifying if a texture is used in the material.
  49940. */
  49941. hasTexture(texture: BaseTexture): boolean;
  49942. /**
  49943. * Returns an array of the actively used textures.
  49944. * @param activeTextures Array of BaseTextures
  49945. */
  49946. getActiveTextures(activeTextures: BaseTexture[]): void;
  49947. /**
  49948. * Returns the animatable textures.
  49949. * @param animatables Array of animatable textures.
  49950. */
  49951. getAnimatables(animatables: IAnimatable[]): void;
  49952. /**
  49953. * Disposes the resources of the material.
  49954. * @param forceDisposeTextures - Forces the disposal of all textures.
  49955. */
  49956. dispose(forceDisposeTextures?: boolean): void;
  49957. /**
  49958. * Get the current class name of the texture useful for serialization or dynamic coding.
  49959. * @returns "PBRClearCoatConfiguration"
  49960. */
  49961. getClassName(): string;
  49962. /**
  49963. * Add fallbacks to the effect fallbacks list.
  49964. * @param defines defines the Base texture to use.
  49965. * @param fallbacks defines the current fallback list.
  49966. * @param currentRank defines the current fallback rank.
  49967. * @returns the new fallback rank.
  49968. */
  49969. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  49970. /**
  49971. * Add the required uniforms to the current list.
  49972. * @param uniforms defines the current uniform list.
  49973. */
  49974. static AddUniforms(uniforms: string[]): void;
  49975. /**
  49976. * Add the required samplers to the current list.
  49977. * @param samplers defines the current sampler list.
  49978. */
  49979. static AddSamplers(samplers: string[]): void;
  49980. /**
  49981. * Add the required uniforms to the current buffer.
  49982. * @param uniformBuffer defines the current uniform buffer.
  49983. */
  49984. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  49985. /**
  49986. * Makes a duplicate of the current configuration into another one.
  49987. * @param clearCoatConfiguration define the config where to copy the info
  49988. */
  49989. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  49990. /**
  49991. * Serializes this clear coat configuration.
  49992. * @returns - An object with the serialized config.
  49993. */
  49994. serialize(): any;
  49995. /**
  49996. * Parses a anisotropy Configuration from a serialized object.
  49997. * @param source - Serialized object.
  49998. * @param scene Defines the scene we are parsing for
  49999. * @param rootUrl Defines the rootUrl to load from
  50000. */
  50001. parse(source: any, scene: Scene, rootUrl: string): void;
  50002. }
  50003. }
  50004. declare module BABYLON {
  50005. /**
  50006. * @hidden
  50007. */
  50008. export interface IMaterialAnisotropicDefines {
  50009. ANISOTROPIC: boolean;
  50010. ANISOTROPIC_TEXTURE: boolean;
  50011. ANISOTROPIC_TEXTUREDIRECTUV: number;
  50012. MAINUV1: boolean;
  50013. _areTexturesDirty: boolean;
  50014. _needUVs: boolean;
  50015. }
  50016. /**
  50017. * Define the code related to the anisotropic parameters of the pbr material.
  50018. */
  50019. export class PBRAnisotropicConfiguration {
  50020. private _isEnabled;
  50021. /**
  50022. * Defines if the anisotropy is enabled in the material.
  50023. */
  50024. isEnabled: boolean;
  50025. /**
  50026. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  50027. */
  50028. intensity: number;
  50029. /**
  50030. * Defines if the effect is along the tangents, bitangents or in between.
  50031. * By default, the effect is "strectching" the highlights along the tangents.
  50032. */
  50033. direction: Vector2;
  50034. private _texture;
  50035. /**
  50036. * Stores the anisotropy values in a texture.
  50037. * rg is direction (like normal from -1 to 1)
  50038. * b is a intensity
  50039. */
  50040. texture: Nullable<BaseTexture>;
  50041. /** @hidden */
  50042. private _internalMarkAllSubMeshesAsTexturesDirty;
  50043. /** @hidden */
  50044. _markAllSubMeshesAsTexturesDirty(): void;
  50045. /**
  50046. * Instantiate a new istance of anisotropy configuration.
  50047. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  50048. */
  50049. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  50050. /**
  50051. * Specifies that the submesh is ready to be used.
  50052. * @param defines the list of "defines" to update.
  50053. * @param scene defines the scene the material belongs to.
  50054. * @returns - boolean indicating that the submesh is ready or not.
  50055. */
  50056. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  50057. /**
  50058. * Checks to see if a texture is used in the material.
  50059. * @param defines the list of "defines" to update.
  50060. * @param mesh the mesh we are preparing the defines for.
  50061. * @param scene defines the scene the material belongs to.
  50062. */
  50063. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  50064. /**
  50065. * Binds the material data.
  50066. * @param uniformBuffer defines the Uniform buffer to fill in.
  50067. * @param scene defines the scene the material belongs to.
  50068. * @param isFrozen defines wether the material is frozen or not.
  50069. */
  50070. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  50071. /**
  50072. * Checks to see if a texture is used in the material.
  50073. * @param texture - Base texture to use.
  50074. * @returns - Boolean specifying if a texture is used in the material.
  50075. */
  50076. hasTexture(texture: BaseTexture): boolean;
  50077. /**
  50078. * Returns an array of the actively used textures.
  50079. * @param activeTextures Array of BaseTextures
  50080. */
  50081. getActiveTextures(activeTextures: BaseTexture[]): void;
  50082. /**
  50083. * Returns the animatable textures.
  50084. * @param animatables Array of animatable textures.
  50085. */
  50086. getAnimatables(animatables: IAnimatable[]): void;
  50087. /**
  50088. * Disposes the resources of the material.
  50089. * @param forceDisposeTextures - Forces the disposal of all textures.
  50090. */
  50091. dispose(forceDisposeTextures?: boolean): void;
  50092. /**
  50093. * Get the current class name of the texture useful for serialization or dynamic coding.
  50094. * @returns "PBRAnisotropicConfiguration"
  50095. */
  50096. getClassName(): string;
  50097. /**
  50098. * Add fallbacks to the effect fallbacks list.
  50099. * @param defines defines the Base texture to use.
  50100. * @param fallbacks defines the current fallback list.
  50101. * @param currentRank defines the current fallback rank.
  50102. * @returns the new fallback rank.
  50103. */
  50104. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  50105. /**
  50106. * Add the required uniforms to the current list.
  50107. * @param uniforms defines the current uniform list.
  50108. */
  50109. static AddUniforms(uniforms: string[]): void;
  50110. /**
  50111. * Add the required uniforms to the current buffer.
  50112. * @param uniformBuffer defines the current uniform buffer.
  50113. */
  50114. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  50115. /**
  50116. * Add the required samplers to the current list.
  50117. * @param samplers defines the current sampler list.
  50118. */
  50119. static AddSamplers(samplers: string[]): void;
  50120. /**
  50121. * Makes a duplicate of the current configuration into another one.
  50122. * @param anisotropicConfiguration define the config where to copy the info
  50123. */
  50124. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  50125. /**
  50126. * Serializes this anisotropy configuration.
  50127. * @returns - An object with the serialized config.
  50128. */
  50129. serialize(): any;
  50130. /**
  50131. * Parses a anisotropy Configuration from a serialized object.
  50132. * @param source - Serialized object.
  50133. * @param scene Defines the scene we are parsing for
  50134. * @param rootUrl Defines the rootUrl to load from
  50135. */
  50136. parse(source: any, scene: Scene, rootUrl: string): void;
  50137. }
  50138. }
  50139. declare module BABYLON {
  50140. /**
  50141. * @hidden
  50142. */
  50143. export interface IMaterialBRDFDefines {
  50144. BRDF_V_HEIGHT_CORRELATED: boolean;
  50145. MS_BRDF_ENERGY_CONSERVATION: boolean;
  50146. SPHERICAL_HARMONICS: boolean;
  50147. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  50148. /** @hidden */
  50149. _areMiscDirty: boolean;
  50150. }
  50151. /**
  50152. * Define the code related to the BRDF parameters of the pbr material.
  50153. */
  50154. export class PBRBRDFConfiguration {
  50155. /**
  50156. * Default value used for the energy conservation.
  50157. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  50158. */
  50159. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  50160. /**
  50161. * Default value used for the Smith Visibility Height Correlated mode.
  50162. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  50163. */
  50164. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  50165. /**
  50166. * Default value used for the IBL diffuse part.
  50167. * This can help switching back to the polynomials mode globally which is a tiny bit
  50168. * less GPU intensive at the drawback of a lower quality.
  50169. */
  50170. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  50171. /**
  50172. * Default value used for activating energy conservation for the specular workflow.
  50173. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  50174. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  50175. */
  50176. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  50177. private _useEnergyConservation;
  50178. /**
  50179. * Defines if the material uses energy conservation.
  50180. */
  50181. useEnergyConservation: boolean;
  50182. private _useSmithVisibilityHeightCorrelated;
  50183. /**
  50184. * LEGACY Mode set to false
  50185. * Defines if the material uses height smith correlated visibility term.
  50186. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  50187. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  50188. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  50189. * Not relying on height correlated will also disable energy conservation.
  50190. */
  50191. useSmithVisibilityHeightCorrelated: boolean;
  50192. private _useSphericalHarmonics;
  50193. /**
  50194. * LEGACY Mode set to false
  50195. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  50196. * diffuse part of the IBL.
  50197. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  50198. * to the ground truth.
  50199. */
  50200. useSphericalHarmonics: boolean;
  50201. private _useSpecularGlossinessInputEnergyConservation;
  50202. /**
  50203. * Defines if the material uses energy conservation, when the specular workflow is active.
  50204. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  50205. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  50206. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  50207. */
  50208. useSpecularGlossinessInputEnergyConservation: boolean;
  50209. /** @hidden */
  50210. private _internalMarkAllSubMeshesAsMiscDirty;
  50211. /** @hidden */
  50212. _markAllSubMeshesAsMiscDirty(): void;
  50213. /**
  50214. * Instantiate a new istance of clear coat configuration.
  50215. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  50216. */
  50217. constructor(markAllSubMeshesAsMiscDirty: () => void);
  50218. /**
  50219. * Checks to see if a texture is used in the material.
  50220. * @param defines the list of "defines" to update.
  50221. */
  50222. prepareDefines(defines: IMaterialBRDFDefines): void;
  50223. /**
  50224. * Get the current class name of the texture useful for serialization or dynamic coding.
  50225. * @returns "PBRClearCoatConfiguration"
  50226. */
  50227. getClassName(): string;
  50228. /**
  50229. * Makes a duplicate of the current configuration into another one.
  50230. * @param brdfConfiguration define the config where to copy the info
  50231. */
  50232. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  50233. /**
  50234. * Serializes this BRDF configuration.
  50235. * @returns - An object with the serialized config.
  50236. */
  50237. serialize(): any;
  50238. /**
  50239. * Parses a anisotropy Configuration from a serialized object.
  50240. * @param source - Serialized object.
  50241. * @param scene Defines the scene we are parsing for
  50242. * @param rootUrl Defines the rootUrl to load from
  50243. */
  50244. parse(source: any, scene: Scene, rootUrl: string): void;
  50245. }
  50246. }
  50247. declare module BABYLON {
  50248. /**
  50249. * @hidden
  50250. */
  50251. export interface IMaterialSheenDefines {
  50252. SHEEN: boolean;
  50253. SHEEN_TEXTURE: boolean;
  50254. SHEEN_TEXTUREDIRECTUV: number;
  50255. SHEEN_LINKWITHALBEDO: boolean;
  50256. /** @hidden */
  50257. _areTexturesDirty: boolean;
  50258. }
  50259. /**
  50260. * Define the code related to the Sheen parameters of the pbr material.
  50261. */
  50262. export class PBRSheenConfiguration {
  50263. private _isEnabled;
  50264. /**
  50265. * Defines if the material uses sheen.
  50266. */
  50267. isEnabled: boolean;
  50268. private _linkSheenWithAlbedo;
  50269. /**
  50270. * Defines if the sheen is linked to the sheen color.
  50271. */
  50272. linkSheenWithAlbedo: boolean;
  50273. /**
  50274. * Defines the sheen intensity.
  50275. */
  50276. intensity: number;
  50277. /**
  50278. * Defines the sheen color.
  50279. */
  50280. color: Color3;
  50281. private _texture;
  50282. /**
  50283. * Stores the sheen tint values in a texture.
  50284. * rgb is tint
  50285. * a is a intensity
  50286. */
  50287. texture: Nullable<BaseTexture>;
  50288. /** @hidden */
  50289. private _internalMarkAllSubMeshesAsTexturesDirty;
  50290. /** @hidden */
  50291. _markAllSubMeshesAsTexturesDirty(): void;
  50292. /**
  50293. * Instantiate a new istance of clear coat configuration.
  50294. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  50295. */
  50296. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  50297. /**
  50298. * Specifies that the submesh is ready to be used.
  50299. * @param defines the list of "defines" to update.
  50300. * @param scene defines the scene the material belongs to.
  50301. * @returns - boolean indicating that the submesh is ready or not.
  50302. */
  50303. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  50304. /**
  50305. * Checks to see if a texture is used in the material.
  50306. * @param defines the list of "defines" to update.
  50307. * @param scene defines the scene the material belongs to.
  50308. */
  50309. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  50310. /**
  50311. * Binds the material data.
  50312. * @param uniformBuffer defines the Uniform buffer to fill in.
  50313. * @param scene defines the scene the material belongs to.
  50314. * @param isFrozen defines wether the material is frozen or not.
  50315. */
  50316. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  50317. /**
  50318. * Checks to see if a texture is used in the material.
  50319. * @param texture - Base texture to use.
  50320. * @returns - Boolean specifying if a texture is used in the material.
  50321. */
  50322. hasTexture(texture: BaseTexture): boolean;
  50323. /**
  50324. * Returns an array of the actively used textures.
  50325. * @param activeTextures Array of BaseTextures
  50326. */
  50327. getActiveTextures(activeTextures: BaseTexture[]): void;
  50328. /**
  50329. * Returns the animatable textures.
  50330. * @param animatables Array of animatable textures.
  50331. */
  50332. getAnimatables(animatables: IAnimatable[]): void;
  50333. /**
  50334. * Disposes the resources of the material.
  50335. * @param forceDisposeTextures - Forces the disposal of all textures.
  50336. */
  50337. dispose(forceDisposeTextures?: boolean): void;
  50338. /**
  50339. * Get the current class name of the texture useful for serialization or dynamic coding.
  50340. * @returns "PBRSheenConfiguration"
  50341. */
  50342. getClassName(): string;
  50343. /**
  50344. * Add fallbacks to the effect fallbacks list.
  50345. * @param defines defines the Base texture to use.
  50346. * @param fallbacks defines the current fallback list.
  50347. * @param currentRank defines the current fallback rank.
  50348. * @returns the new fallback rank.
  50349. */
  50350. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  50351. /**
  50352. * Add the required uniforms to the current list.
  50353. * @param uniforms defines the current uniform list.
  50354. */
  50355. static AddUniforms(uniforms: string[]): void;
  50356. /**
  50357. * Add the required uniforms to the current buffer.
  50358. * @param uniformBuffer defines the current uniform buffer.
  50359. */
  50360. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  50361. /**
  50362. * Add the required samplers to the current list.
  50363. * @param samplers defines the current sampler list.
  50364. */
  50365. static AddSamplers(samplers: string[]): void;
  50366. /**
  50367. * Makes a duplicate of the current configuration into another one.
  50368. * @param sheenConfiguration define the config where to copy the info
  50369. */
  50370. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  50371. /**
  50372. * Serializes this BRDF configuration.
  50373. * @returns - An object with the serialized config.
  50374. */
  50375. serialize(): any;
  50376. /**
  50377. * Parses a anisotropy Configuration from a serialized object.
  50378. * @param source - Serialized object.
  50379. * @param scene Defines the scene we are parsing for
  50380. * @param rootUrl Defines the rootUrl to load from
  50381. */
  50382. parse(source: any, scene: Scene, rootUrl: string): void;
  50383. }
  50384. }
  50385. declare module BABYLON {
  50386. /**
  50387. * @hidden
  50388. */
  50389. export interface IMaterialSubSurfaceDefines {
  50390. SUBSURFACE: boolean;
  50391. SS_REFRACTION: boolean;
  50392. SS_TRANSLUCENCY: boolean;
  50393. SS_SCATERRING: boolean;
  50394. SS_THICKNESSANDMASK_TEXTURE: boolean;
  50395. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  50396. SS_REFRACTIONMAP_3D: boolean;
  50397. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  50398. SS_LODINREFRACTIONALPHA: boolean;
  50399. SS_GAMMAREFRACTION: boolean;
  50400. SS_RGBDREFRACTION: boolean;
  50401. SS_LINEARSPECULARREFRACTION: boolean;
  50402. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  50403. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  50404. /** @hidden */
  50405. _areTexturesDirty: boolean;
  50406. }
  50407. /**
  50408. * Define the code related to the sub surface parameters of the pbr material.
  50409. */
  50410. export class PBRSubSurfaceConfiguration {
  50411. private _isRefractionEnabled;
  50412. /**
  50413. * Defines if the refraction is enabled in the material.
  50414. */
  50415. isRefractionEnabled: boolean;
  50416. private _isTranslucencyEnabled;
  50417. /**
  50418. * Defines if the translucency is enabled in the material.
  50419. */
  50420. isTranslucencyEnabled: boolean;
  50421. private _isScatteringEnabled;
  50422. /**
  50423. * Defines the refraction intensity of the material.
  50424. * The refraction when enabled replaces the Diffuse part of the material.
  50425. * The intensity helps transitionning between diffuse and refraction.
  50426. */
  50427. refractionIntensity: number;
  50428. /**
  50429. * Defines the translucency intensity of the material.
  50430. * When translucency has been enabled, this defines how much of the "translucency"
  50431. * is addded to the diffuse part of the material.
  50432. */
  50433. translucencyIntensity: number;
  50434. /**
  50435. * Defines the scattering intensity of the material.
  50436. * When scattering has been enabled, this defines how much of the "scattered light"
  50437. * is addded to the diffuse part of the material.
  50438. */
  50439. scatteringIntensity: number;
  50440. private _thicknessTexture;
  50441. /**
  50442. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  50443. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  50444. * 0 would mean minimumThickness
  50445. * 1 would mean maximumThickness
  50446. * The other channels might be use as a mask to vary the different effects intensity.
  50447. */
  50448. thicknessTexture: Nullable<BaseTexture>;
  50449. private _refractionTexture;
  50450. /**
  50451. * Defines the texture to use for refraction.
  50452. */
  50453. refractionTexture: Nullable<BaseTexture>;
  50454. private _indexOfRefraction;
  50455. /**
  50456. * Defines the index of refraction used in the material.
  50457. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  50458. */
  50459. indexOfRefraction: number;
  50460. private _invertRefractionY;
  50461. /**
  50462. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  50463. */
  50464. invertRefractionY: boolean;
  50465. private _linkRefractionWithTransparency;
  50466. /**
  50467. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  50468. * Materials half opaque for instance using refraction could benefit from this control.
  50469. */
  50470. linkRefractionWithTransparency: boolean;
  50471. /**
  50472. * Defines the minimum thickness stored in the thickness map.
  50473. * If no thickness map is defined, this value will be used to simulate thickness.
  50474. */
  50475. minimumThickness: number;
  50476. /**
  50477. * Defines the maximum thickness stored in the thickness map.
  50478. */
  50479. maximumThickness: number;
  50480. /**
  50481. * Defines the volume tint of the material.
  50482. * This is used for both translucency and scattering.
  50483. */
  50484. tintColor: Color3;
  50485. /**
  50486. * Defines the distance at which the tint color should be found in the media.
  50487. * This is used for refraction only.
  50488. */
  50489. tintColorAtDistance: number;
  50490. /**
  50491. * Defines how far each channel transmit through the media.
  50492. * It is defined as a color to simplify it selection.
  50493. */
  50494. diffusionDistance: Color3;
  50495. private _useMaskFromThicknessTexture;
  50496. /**
  50497. * Stores the intensity of the different subsurface effects in the thickness texture.
  50498. * * the green channel is the translucency intensity.
  50499. * * the blue channel is the scattering intensity.
  50500. * * the alpha channel is the refraction intensity.
  50501. */
  50502. useMaskFromThicknessTexture: boolean;
  50503. /** @hidden */
  50504. private _internalMarkAllSubMeshesAsTexturesDirty;
  50505. /** @hidden */
  50506. _markAllSubMeshesAsTexturesDirty(): void;
  50507. /**
  50508. * Instantiate a new istance of sub surface configuration.
  50509. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  50510. */
  50511. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  50512. /**
  50513. * Gets wehter the submesh is ready to be used or not.
  50514. * @param defines the list of "defines" to update.
  50515. * @param scene defines the scene the material belongs to.
  50516. * @returns - boolean indicating that the submesh is ready or not.
  50517. */
  50518. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  50519. /**
  50520. * Checks to see if a texture is used in the material.
  50521. * @param defines the list of "defines" to update.
  50522. * @param scene defines the scene to the material belongs to.
  50523. */
  50524. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  50525. /**
  50526. * Binds the material data.
  50527. * @param uniformBuffer defines the Uniform buffer to fill in.
  50528. * @param scene defines the scene the material belongs to.
  50529. * @param engine defines the engine the material belongs to.
  50530. * @param isFrozen defines wether the material is frozen or not.
  50531. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  50532. */
  50533. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  50534. /**
  50535. * Unbinds the material from the mesh.
  50536. * @param activeEffect defines the effect that should be unbound from.
  50537. * @returns true if unbound, otherwise false
  50538. */
  50539. unbind(activeEffect: Effect): boolean;
  50540. /**
  50541. * Returns the texture used for refraction or null if none is used.
  50542. * @param scene defines the scene the material belongs to.
  50543. * @returns - Refraction texture if present. If no refraction texture and refraction
  50544. * is linked with transparency, returns environment texture. Otherwise, returns null.
  50545. */
  50546. private _getRefractionTexture;
  50547. /**
  50548. * Returns true if alpha blending should be disabled.
  50549. */
  50550. get disableAlphaBlending(): boolean;
  50551. /**
  50552. * Fills the list of render target textures.
  50553. * @param renderTargets the list of render targets to update
  50554. */
  50555. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  50556. /**
  50557. * Checks to see if a texture is used in the material.
  50558. * @param texture - Base texture to use.
  50559. * @returns - Boolean specifying if a texture is used in the material.
  50560. */
  50561. hasTexture(texture: BaseTexture): boolean;
  50562. /**
  50563. * Gets a boolean indicating that current material needs to register RTT
  50564. * @returns true if this uses a render target otherwise false.
  50565. */
  50566. hasRenderTargetTextures(): boolean;
  50567. /**
  50568. * Returns an array of the actively used textures.
  50569. * @param activeTextures Array of BaseTextures
  50570. */
  50571. getActiveTextures(activeTextures: BaseTexture[]): void;
  50572. /**
  50573. * Returns the animatable textures.
  50574. * @param animatables Array of animatable textures.
  50575. */
  50576. getAnimatables(animatables: IAnimatable[]): void;
  50577. /**
  50578. * Disposes the resources of the material.
  50579. * @param forceDisposeTextures - Forces the disposal of all textures.
  50580. */
  50581. dispose(forceDisposeTextures?: boolean): void;
  50582. /**
  50583. * Get the current class name of the texture useful for serialization or dynamic coding.
  50584. * @returns "PBRSubSurfaceConfiguration"
  50585. */
  50586. getClassName(): string;
  50587. /**
  50588. * Add fallbacks to the effect fallbacks list.
  50589. * @param defines defines the Base texture to use.
  50590. * @param fallbacks defines the current fallback list.
  50591. * @param currentRank defines the current fallback rank.
  50592. * @returns the new fallback rank.
  50593. */
  50594. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  50595. /**
  50596. * Add the required uniforms to the current list.
  50597. * @param uniforms defines the current uniform list.
  50598. */
  50599. static AddUniforms(uniforms: string[]): void;
  50600. /**
  50601. * Add the required samplers to the current list.
  50602. * @param samplers defines the current sampler list.
  50603. */
  50604. static AddSamplers(samplers: string[]): void;
  50605. /**
  50606. * Add the required uniforms to the current buffer.
  50607. * @param uniformBuffer defines the current uniform buffer.
  50608. */
  50609. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  50610. /**
  50611. * Makes a duplicate of the current configuration into another one.
  50612. * @param configuration define the config where to copy the info
  50613. */
  50614. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  50615. /**
  50616. * Serializes this Sub Surface configuration.
  50617. * @returns - An object with the serialized config.
  50618. */
  50619. serialize(): any;
  50620. /**
  50621. * Parses a anisotropy Configuration from a serialized object.
  50622. * @param source - Serialized object.
  50623. * @param scene Defines the scene we are parsing for
  50624. * @param rootUrl Defines the rootUrl to load from
  50625. */
  50626. parse(source: any, scene: Scene, rootUrl: string): void;
  50627. }
  50628. }
  50629. declare module BABYLON {
  50630. /** @hidden */
  50631. export var pbrFragmentDeclaration: {
  50632. name: string;
  50633. shader: string;
  50634. };
  50635. }
  50636. declare module BABYLON {
  50637. /** @hidden */
  50638. export var pbrUboDeclaration: {
  50639. name: string;
  50640. shader: string;
  50641. };
  50642. }
  50643. declare module BABYLON {
  50644. /** @hidden */
  50645. export var pbrFragmentExtraDeclaration: {
  50646. name: string;
  50647. shader: string;
  50648. };
  50649. }
  50650. declare module BABYLON {
  50651. /** @hidden */
  50652. export var pbrFragmentSamplersDeclaration: {
  50653. name: string;
  50654. shader: string;
  50655. };
  50656. }
  50657. declare module BABYLON {
  50658. /** @hidden */
  50659. export var pbrHelperFunctions: {
  50660. name: string;
  50661. shader: string;
  50662. };
  50663. }
  50664. declare module BABYLON {
  50665. /** @hidden */
  50666. export var harmonicsFunctions: {
  50667. name: string;
  50668. shader: string;
  50669. };
  50670. }
  50671. declare module BABYLON {
  50672. /** @hidden */
  50673. export var pbrDirectLightingSetupFunctions: {
  50674. name: string;
  50675. shader: string;
  50676. };
  50677. }
  50678. declare module BABYLON {
  50679. /** @hidden */
  50680. export var pbrDirectLightingFalloffFunctions: {
  50681. name: string;
  50682. shader: string;
  50683. };
  50684. }
  50685. declare module BABYLON {
  50686. /** @hidden */
  50687. export var pbrBRDFFunctions: {
  50688. name: string;
  50689. shader: string;
  50690. };
  50691. }
  50692. declare module BABYLON {
  50693. /** @hidden */
  50694. export var pbrDirectLightingFunctions: {
  50695. name: string;
  50696. shader: string;
  50697. };
  50698. }
  50699. declare module BABYLON {
  50700. /** @hidden */
  50701. export var pbrIBLFunctions: {
  50702. name: string;
  50703. shader: string;
  50704. };
  50705. }
  50706. declare module BABYLON {
  50707. /** @hidden */
  50708. export var pbrDebug: {
  50709. name: string;
  50710. shader: string;
  50711. };
  50712. }
  50713. declare module BABYLON {
  50714. /** @hidden */
  50715. export var pbrPixelShader: {
  50716. name: string;
  50717. shader: string;
  50718. };
  50719. }
  50720. declare module BABYLON {
  50721. /** @hidden */
  50722. export var pbrVertexDeclaration: {
  50723. name: string;
  50724. shader: string;
  50725. };
  50726. }
  50727. declare module BABYLON {
  50728. /** @hidden */
  50729. export var pbrVertexShader: {
  50730. name: string;
  50731. shader: string;
  50732. };
  50733. }
  50734. declare module BABYLON {
  50735. /**
  50736. * Manages the defines for the PBR Material.
  50737. * @hidden
  50738. */
  50739. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  50740. PBR: boolean;
  50741. MAINUV1: boolean;
  50742. MAINUV2: boolean;
  50743. UV1: boolean;
  50744. UV2: boolean;
  50745. ALBEDO: boolean;
  50746. ALBEDODIRECTUV: number;
  50747. VERTEXCOLOR: boolean;
  50748. AMBIENT: boolean;
  50749. AMBIENTDIRECTUV: number;
  50750. AMBIENTINGRAYSCALE: boolean;
  50751. OPACITY: boolean;
  50752. VERTEXALPHA: boolean;
  50753. OPACITYDIRECTUV: number;
  50754. OPACITYRGB: boolean;
  50755. ALPHATEST: boolean;
  50756. DEPTHPREPASS: boolean;
  50757. ALPHABLEND: boolean;
  50758. ALPHAFROMALBEDO: boolean;
  50759. ALPHATESTVALUE: string;
  50760. SPECULAROVERALPHA: boolean;
  50761. RADIANCEOVERALPHA: boolean;
  50762. ALPHAFRESNEL: boolean;
  50763. LINEARALPHAFRESNEL: boolean;
  50764. PREMULTIPLYALPHA: boolean;
  50765. EMISSIVE: boolean;
  50766. EMISSIVEDIRECTUV: number;
  50767. REFLECTIVITY: boolean;
  50768. REFLECTIVITYDIRECTUV: number;
  50769. SPECULARTERM: boolean;
  50770. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  50771. MICROSURFACEAUTOMATIC: boolean;
  50772. LODBASEDMICROSFURACE: boolean;
  50773. MICROSURFACEMAP: boolean;
  50774. MICROSURFACEMAPDIRECTUV: number;
  50775. METALLICWORKFLOW: boolean;
  50776. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  50777. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  50778. METALLNESSSTOREINMETALMAPBLUE: boolean;
  50779. AOSTOREINMETALMAPRED: boolean;
  50780. METALLICF0FACTORFROMMETALLICMAP: boolean;
  50781. ENVIRONMENTBRDF: boolean;
  50782. ENVIRONMENTBRDF_RGBD: boolean;
  50783. NORMAL: boolean;
  50784. TANGENT: boolean;
  50785. BUMP: boolean;
  50786. BUMPDIRECTUV: number;
  50787. OBJECTSPACE_NORMALMAP: boolean;
  50788. PARALLAX: boolean;
  50789. PARALLAXOCCLUSION: boolean;
  50790. NORMALXYSCALE: boolean;
  50791. LIGHTMAP: boolean;
  50792. LIGHTMAPDIRECTUV: number;
  50793. USELIGHTMAPASSHADOWMAP: boolean;
  50794. GAMMALIGHTMAP: boolean;
  50795. RGBDLIGHTMAP: boolean;
  50796. REFLECTION: boolean;
  50797. REFLECTIONMAP_3D: boolean;
  50798. REFLECTIONMAP_SPHERICAL: boolean;
  50799. REFLECTIONMAP_PLANAR: boolean;
  50800. REFLECTIONMAP_CUBIC: boolean;
  50801. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  50802. REFLECTIONMAP_PROJECTION: boolean;
  50803. REFLECTIONMAP_SKYBOX: boolean;
  50804. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  50805. REFLECTIONMAP_EXPLICIT: boolean;
  50806. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  50807. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  50808. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  50809. INVERTCUBICMAP: boolean;
  50810. USESPHERICALFROMREFLECTIONMAP: boolean;
  50811. USEIRRADIANCEMAP: boolean;
  50812. SPHERICAL_HARMONICS: boolean;
  50813. USESPHERICALINVERTEX: boolean;
  50814. REFLECTIONMAP_OPPOSITEZ: boolean;
  50815. LODINREFLECTIONALPHA: boolean;
  50816. GAMMAREFLECTION: boolean;
  50817. RGBDREFLECTION: boolean;
  50818. LINEARSPECULARREFLECTION: boolean;
  50819. RADIANCEOCCLUSION: boolean;
  50820. HORIZONOCCLUSION: boolean;
  50821. INSTANCES: boolean;
  50822. NUM_BONE_INFLUENCERS: number;
  50823. BonesPerMesh: number;
  50824. BONETEXTURE: boolean;
  50825. NONUNIFORMSCALING: boolean;
  50826. MORPHTARGETS: boolean;
  50827. MORPHTARGETS_NORMAL: boolean;
  50828. MORPHTARGETS_TANGENT: boolean;
  50829. MORPHTARGETS_UV: boolean;
  50830. NUM_MORPH_INFLUENCERS: number;
  50831. IMAGEPROCESSING: boolean;
  50832. VIGNETTE: boolean;
  50833. VIGNETTEBLENDMODEMULTIPLY: boolean;
  50834. VIGNETTEBLENDMODEOPAQUE: boolean;
  50835. TONEMAPPING: boolean;
  50836. TONEMAPPING_ACES: boolean;
  50837. CONTRAST: boolean;
  50838. COLORCURVES: boolean;
  50839. COLORGRADING: boolean;
  50840. COLORGRADING3D: boolean;
  50841. SAMPLER3DGREENDEPTH: boolean;
  50842. SAMPLER3DBGRMAP: boolean;
  50843. IMAGEPROCESSINGPOSTPROCESS: boolean;
  50844. EXPOSURE: boolean;
  50845. MULTIVIEW: boolean;
  50846. USEPHYSICALLIGHTFALLOFF: boolean;
  50847. USEGLTFLIGHTFALLOFF: boolean;
  50848. TWOSIDEDLIGHTING: boolean;
  50849. SHADOWFLOAT: boolean;
  50850. CLIPPLANE: boolean;
  50851. CLIPPLANE2: boolean;
  50852. CLIPPLANE3: boolean;
  50853. CLIPPLANE4: boolean;
  50854. CLIPPLANE5: boolean;
  50855. CLIPPLANE6: boolean;
  50856. POINTSIZE: boolean;
  50857. FOG: boolean;
  50858. LOGARITHMICDEPTH: boolean;
  50859. FORCENORMALFORWARD: boolean;
  50860. SPECULARAA: boolean;
  50861. CLEARCOAT: boolean;
  50862. CLEARCOAT_DEFAULTIOR: boolean;
  50863. CLEARCOAT_TEXTURE: boolean;
  50864. CLEARCOAT_TEXTUREDIRECTUV: number;
  50865. CLEARCOAT_BUMP: boolean;
  50866. CLEARCOAT_BUMPDIRECTUV: number;
  50867. CLEARCOAT_TINT: boolean;
  50868. CLEARCOAT_TINT_TEXTURE: boolean;
  50869. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  50870. ANISOTROPIC: boolean;
  50871. ANISOTROPIC_TEXTURE: boolean;
  50872. ANISOTROPIC_TEXTUREDIRECTUV: number;
  50873. BRDF_V_HEIGHT_CORRELATED: boolean;
  50874. MS_BRDF_ENERGY_CONSERVATION: boolean;
  50875. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  50876. SHEEN: boolean;
  50877. SHEEN_TEXTURE: boolean;
  50878. SHEEN_TEXTUREDIRECTUV: number;
  50879. SHEEN_LINKWITHALBEDO: boolean;
  50880. SUBSURFACE: boolean;
  50881. SS_REFRACTION: boolean;
  50882. SS_TRANSLUCENCY: boolean;
  50883. SS_SCATERRING: boolean;
  50884. SS_THICKNESSANDMASK_TEXTURE: boolean;
  50885. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  50886. SS_REFRACTIONMAP_3D: boolean;
  50887. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  50888. SS_LODINREFRACTIONALPHA: boolean;
  50889. SS_GAMMAREFRACTION: boolean;
  50890. SS_RGBDREFRACTION: boolean;
  50891. SS_LINEARSPECULARREFRACTION: boolean;
  50892. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  50893. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  50894. UNLIT: boolean;
  50895. DEBUGMODE: number;
  50896. /**
  50897. * Initializes the PBR Material defines.
  50898. */
  50899. constructor();
  50900. /**
  50901. * Resets the PBR Material defines.
  50902. */
  50903. reset(): void;
  50904. }
  50905. /**
  50906. * The Physically based material base class of BJS.
  50907. *
  50908. * This offers the main features of a standard PBR material.
  50909. * For more information, please refer to the documentation :
  50910. * https://doc.babylonjs.com/how_to/physically_based_rendering
  50911. */
  50912. export abstract class PBRBaseMaterial extends PushMaterial {
  50913. /**
  50914. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  50915. */
  50916. static readonly PBRMATERIAL_OPAQUE: number;
  50917. /**
  50918. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  50919. */
  50920. static readonly PBRMATERIAL_ALPHATEST: number;
  50921. /**
  50922. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  50923. */
  50924. static readonly PBRMATERIAL_ALPHABLEND: number;
  50925. /**
  50926. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  50927. * They are also discarded below the alpha cutoff threshold to improve performances.
  50928. */
  50929. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  50930. /**
  50931. * Defines the default value of how much AO map is occluding the analytical lights
  50932. * (point spot...).
  50933. */
  50934. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  50935. /**
  50936. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  50937. */
  50938. static readonly LIGHTFALLOFF_PHYSICAL: number;
  50939. /**
  50940. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  50941. * to enhance interoperability with other engines.
  50942. */
  50943. static readonly LIGHTFALLOFF_GLTF: number;
  50944. /**
  50945. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  50946. * to enhance interoperability with other materials.
  50947. */
  50948. static readonly LIGHTFALLOFF_STANDARD: number;
  50949. /**
  50950. * Intensity of the direct lights e.g. the four lights available in your scene.
  50951. * This impacts both the direct diffuse and specular highlights.
  50952. */
  50953. protected _directIntensity: number;
  50954. /**
  50955. * Intensity of the emissive part of the material.
  50956. * This helps controlling the emissive effect without modifying the emissive color.
  50957. */
  50958. protected _emissiveIntensity: number;
  50959. /**
  50960. * Intensity of the environment e.g. how much the environment will light the object
  50961. * either through harmonics for rough material or through the refelction for shiny ones.
  50962. */
  50963. protected _environmentIntensity: number;
  50964. /**
  50965. * This is a special control allowing the reduction of the specular highlights coming from the
  50966. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  50967. */
  50968. protected _specularIntensity: number;
  50969. /**
  50970. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  50971. */
  50972. private _lightingInfos;
  50973. /**
  50974. * Debug Control allowing disabling the bump map on this material.
  50975. */
  50976. protected _disableBumpMap: boolean;
  50977. /**
  50978. * AKA Diffuse Texture in standard nomenclature.
  50979. */
  50980. protected _albedoTexture: Nullable<BaseTexture>;
  50981. /**
  50982. * AKA Occlusion Texture in other nomenclature.
  50983. */
  50984. protected _ambientTexture: Nullable<BaseTexture>;
  50985. /**
  50986. * AKA Occlusion Texture Intensity in other nomenclature.
  50987. */
  50988. protected _ambientTextureStrength: number;
  50989. /**
  50990. * Defines how much the AO map is occluding the analytical lights (point spot...).
  50991. * 1 means it completely occludes it
  50992. * 0 mean it has no impact
  50993. */
  50994. protected _ambientTextureImpactOnAnalyticalLights: number;
  50995. /**
  50996. * Stores the alpha values in a texture.
  50997. */
  50998. protected _opacityTexture: Nullable<BaseTexture>;
  50999. /**
  51000. * Stores the reflection values in a texture.
  51001. */
  51002. protected _reflectionTexture: Nullable<BaseTexture>;
  51003. /**
  51004. * Stores the emissive values in a texture.
  51005. */
  51006. protected _emissiveTexture: Nullable<BaseTexture>;
  51007. /**
  51008. * AKA Specular texture in other nomenclature.
  51009. */
  51010. protected _reflectivityTexture: Nullable<BaseTexture>;
  51011. /**
  51012. * Used to switch from specular/glossiness to metallic/roughness workflow.
  51013. */
  51014. protected _metallicTexture: Nullable<BaseTexture>;
  51015. /**
  51016. * Specifies the metallic scalar of the metallic/roughness workflow.
  51017. * Can also be used to scale the metalness values of the metallic texture.
  51018. */
  51019. protected _metallic: Nullable<number>;
  51020. /**
  51021. * Specifies the roughness scalar of the metallic/roughness workflow.
  51022. * Can also be used to scale the roughness values of the metallic texture.
  51023. */
  51024. protected _roughness: Nullable<number>;
  51025. /**
  51026. * Specifies the an F0 factor to help configuring the material F0.
  51027. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  51028. * to 0.5 the previously hard coded value stays the same.
  51029. * Can also be used to scale the F0 values of the metallic texture.
  51030. */
  51031. protected _metallicF0Factor: number;
  51032. /**
  51033. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  51034. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  51035. * your expectation as it multiplies with the texture data.
  51036. */
  51037. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  51038. /**
  51039. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  51040. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  51041. */
  51042. protected _microSurfaceTexture: Nullable<BaseTexture>;
  51043. /**
  51044. * Stores surface normal data used to displace a mesh in a texture.
  51045. */
  51046. protected _bumpTexture: Nullable<BaseTexture>;
  51047. /**
  51048. * Stores the pre-calculated light information of a mesh in a texture.
  51049. */
  51050. protected _lightmapTexture: Nullable<BaseTexture>;
  51051. /**
  51052. * The color of a material in ambient lighting.
  51053. */
  51054. protected _ambientColor: Color3;
  51055. /**
  51056. * AKA Diffuse Color in other nomenclature.
  51057. */
  51058. protected _albedoColor: Color3;
  51059. /**
  51060. * AKA Specular Color in other nomenclature.
  51061. */
  51062. protected _reflectivityColor: Color3;
  51063. /**
  51064. * The color applied when light is reflected from a material.
  51065. */
  51066. protected _reflectionColor: Color3;
  51067. /**
  51068. * The color applied when light is emitted from a material.
  51069. */
  51070. protected _emissiveColor: Color3;
  51071. /**
  51072. * AKA Glossiness in other nomenclature.
  51073. */
  51074. protected _microSurface: number;
  51075. /**
  51076. * Specifies that the material will use the light map as a show map.
  51077. */
  51078. protected _useLightmapAsShadowmap: boolean;
  51079. /**
  51080. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  51081. * makes the reflect vector face the model (under horizon).
  51082. */
  51083. protected _useHorizonOcclusion: boolean;
  51084. /**
  51085. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  51086. * too much the area relying on ambient texture to define their ambient occlusion.
  51087. */
  51088. protected _useRadianceOcclusion: boolean;
  51089. /**
  51090. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  51091. */
  51092. protected _useAlphaFromAlbedoTexture: boolean;
  51093. /**
  51094. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  51095. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  51096. */
  51097. protected _useSpecularOverAlpha: boolean;
  51098. /**
  51099. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  51100. */
  51101. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  51102. /**
  51103. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  51104. */
  51105. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  51106. /**
  51107. * Specifies if the metallic texture contains the roughness information in its green channel.
  51108. */
  51109. protected _useRoughnessFromMetallicTextureGreen: boolean;
  51110. /**
  51111. * Specifies if the metallic texture contains the metallness information in its blue channel.
  51112. */
  51113. protected _useMetallnessFromMetallicTextureBlue: boolean;
  51114. /**
  51115. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  51116. */
  51117. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  51118. /**
  51119. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  51120. */
  51121. protected _useAmbientInGrayScale: boolean;
  51122. /**
  51123. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  51124. * The material will try to infer what glossiness each pixel should be.
  51125. */
  51126. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  51127. /**
  51128. * Defines the falloff type used in this material.
  51129. * It by default is Physical.
  51130. */
  51131. protected _lightFalloff: number;
  51132. /**
  51133. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  51134. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  51135. */
  51136. protected _useRadianceOverAlpha: boolean;
  51137. /**
  51138. * Allows using an object space normal map (instead of tangent space).
  51139. */
  51140. protected _useObjectSpaceNormalMap: boolean;
  51141. /**
  51142. * Allows using the bump map in parallax mode.
  51143. */
  51144. protected _useParallax: boolean;
  51145. /**
  51146. * Allows using the bump map in parallax occlusion mode.
  51147. */
  51148. protected _useParallaxOcclusion: boolean;
  51149. /**
  51150. * Controls the scale bias of the parallax mode.
  51151. */
  51152. protected _parallaxScaleBias: number;
  51153. /**
  51154. * If sets to true, disables all the lights affecting the material.
  51155. */
  51156. protected _disableLighting: boolean;
  51157. /**
  51158. * Number of Simultaneous lights allowed on the material.
  51159. */
  51160. protected _maxSimultaneousLights: number;
  51161. /**
  51162. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  51163. */
  51164. protected _invertNormalMapX: boolean;
  51165. /**
  51166. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  51167. */
  51168. protected _invertNormalMapY: boolean;
  51169. /**
  51170. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  51171. */
  51172. protected _twoSidedLighting: boolean;
  51173. /**
  51174. * Defines the alpha limits in alpha test mode.
  51175. */
  51176. protected _alphaCutOff: number;
  51177. /**
  51178. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  51179. */
  51180. protected _forceAlphaTest: boolean;
  51181. /**
  51182. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  51183. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  51184. */
  51185. protected _useAlphaFresnel: boolean;
  51186. /**
  51187. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  51188. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  51189. */
  51190. protected _useLinearAlphaFresnel: boolean;
  51191. /**
  51192. * The transparency mode of the material.
  51193. */
  51194. protected _transparencyMode: Nullable<number>;
  51195. /**
  51196. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  51197. * from cos thetav and roughness:
  51198. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  51199. */
  51200. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  51201. /**
  51202. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  51203. */
  51204. protected _forceIrradianceInFragment: boolean;
  51205. /**
  51206. * Force normal to face away from face.
  51207. */
  51208. protected _forceNormalForward: boolean;
  51209. /**
  51210. * Enables specular anti aliasing in the PBR shader.
  51211. * It will both interacts on the Geometry for analytical and IBL lighting.
  51212. * It also prefilter the roughness map based on the bump values.
  51213. */
  51214. protected _enableSpecularAntiAliasing: boolean;
  51215. /**
  51216. * Default configuration related to image processing available in the PBR Material.
  51217. */
  51218. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  51219. /**
  51220. * Keep track of the image processing observer to allow dispose and replace.
  51221. */
  51222. private _imageProcessingObserver;
  51223. /**
  51224. * Attaches a new image processing configuration to the PBR Material.
  51225. * @param configuration
  51226. */
  51227. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  51228. /**
  51229. * Stores the available render targets.
  51230. */
  51231. private _renderTargets;
  51232. /**
  51233. * Sets the global ambient color for the material used in lighting calculations.
  51234. */
  51235. private _globalAmbientColor;
  51236. /**
  51237. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  51238. */
  51239. private _useLogarithmicDepth;
  51240. /**
  51241. * If set to true, no lighting calculations will be applied.
  51242. */
  51243. private _unlit;
  51244. private _debugMode;
  51245. /**
  51246. * @hidden
  51247. * This is reserved for the inspector.
  51248. * Defines the material debug mode.
  51249. * It helps seeing only some components of the material while troubleshooting.
  51250. */
  51251. debugMode: number;
  51252. /**
  51253. * @hidden
  51254. * This is reserved for the inspector.
  51255. * Specify from where on screen the debug mode should start.
  51256. * The value goes from -1 (full screen) to 1 (not visible)
  51257. * It helps with side by side comparison against the final render
  51258. * This defaults to -1
  51259. */
  51260. private debugLimit;
  51261. /**
  51262. * @hidden
  51263. * This is reserved for the inspector.
  51264. * As the default viewing range might not be enough (if the ambient is really small for instance)
  51265. * You can use the factor to better multiply the final value.
  51266. */
  51267. private debugFactor;
  51268. /**
  51269. * Defines the clear coat layer parameters for the material.
  51270. */
  51271. readonly clearCoat: PBRClearCoatConfiguration;
  51272. /**
  51273. * Defines the anisotropic parameters for the material.
  51274. */
  51275. readonly anisotropy: PBRAnisotropicConfiguration;
  51276. /**
  51277. * Defines the BRDF parameters for the material.
  51278. */
  51279. readonly brdf: PBRBRDFConfiguration;
  51280. /**
  51281. * Defines the Sheen parameters for the material.
  51282. */
  51283. readonly sheen: PBRSheenConfiguration;
  51284. /**
  51285. * Defines the SubSurface parameters for the material.
  51286. */
  51287. readonly subSurface: PBRSubSurfaceConfiguration;
  51288. /**
  51289. * Custom callback helping to override the default shader used in the material.
  51290. */
  51291. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  51292. protected _rebuildInParallel: boolean;
  51293. /**
  51294. * Instantiates a new PBRMaterial instance.
  51295. *
  51296. * @param name The material name
  51297. * @param scene The scene the material will be use in.
  51298. */
  51299. constructor(name: string, scene: Scene);
  51300. /**
  51301. * Gets a boolean indicating that current material needs to register RTT
  51302. */
  51303. get hasRenderTargetTextures(): boolean;
  51304. /**
  51305. * Gets the name of the material class.
  51306. */
  51307. getClassName(): string;
  51308. /**
  51309. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  51310. */
  51311. get useLogarithmicDepth(): boolean;
  51312. /**
  51313. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  51314. */
  51315. set useLogarithmicDepth(value: boolean);
  51316. /**
  51317. * Gets the current transparency mode.
  51318. */
  51319. get transparencyMode(): Nullable<number>;
  51320. /**
  51321. * Sets the transparency mode of the material.
  51322. *
  51323. * | Value | Type | Description |
  51324. * | ----- | ----------------------------------- | ----------- |
  51325. * | 0 | OPAQUE | |
  51326. * | 1 | ALPHATEST | |
  51327. * | 2 | ALPHABLEND | |
  51328. * | 3 | ALPHATESTANDBLEND | |
  51329. *
  51330. */
  51331. set transparencyMode(value: Nullable<number>);
  51332. /**
  51333. * Returns true if alpha blending should be disabled.
  51334. */
  51335. private get _disableAlphaBlending();
  51336. /**
  51337. * Specifies whether or not this material should be rendered in alpha blend mode.
  51338. */
  51339. needAlphaBlending(): boolean;
  51340. /**
  51341. * Specifies if the mesh will require alpha blending.
  51342. * @param mesh - BJS mesh.
  51343. */
  51344. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  51345. /**
  51346. * Specifies whether or not this material should be rendered in alpha test mode.
  51347. */
  51348. needAlphaTesting(): boolean;
  51349. /**
  51350. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  51351. */
  51352. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  51353. /**
  51354. * Gets the texture used for the alpha test.
  51355. */
  51356. getAlphaTestTexture(): Nullable<BaseTexture>;
  51357. /**
  51358. * Specifies that the submesh is ready to be used.
  51359. * @param mesh - BJS mesh.
  51360. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  51361. * @param useInstances - Specifies that instances should be used.
  51362. * @returns - boolean indicating that the submesh is ready or not.
  51363. */
  51364. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  51365. /**
  51366. * Specifies if the material uses metallic roughness workflow.
  51367. * @returns boolean specifiying if the material uses metallic roughness workflow.
  51368. */
  51369. isMetallicWorkflow(): boolean;
  51370. private _prepareEffect;
  51371. private _prepareDefines;
  51372. /**
  51373. * Force shader compilation
  51374. */
  51375. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  51376. /**
  51377. * Initializes the uniform buffer layout for the shader.
  51378. */
  51379. buildUniformLayout(): void;
  51380. /**
  51381. * Unbinds the material from the mesh
  51382. */
  51383. unbind(): void;
  51384. /**
  51385. * Binds the submesh data.
  51386. * @param world - The world matrix.
  51387. * @param mesh - The BJS mesh.
  51388. * @param subMesh - A submesh of the BJS mesh.
  51389. */
  51390. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  51391. /**
  51392. * Returns the animatable textures.
  51393. * @returns - Array of animatable textures.
  51394. */
  51395. getAnimatables(): IAnimatable[];
  51396. /**
  51397. * Returns the texture used for reflections.
  51398. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  51399. */
  51400. private _getReflectionTexture;
  51401. /**
  51402. * Returns an array of the actively used textures.
  51403. * @returns - Array of BaseTextures
  51404. */
  51405. getActiveTextures(): BaseTexture[];
  51406. /**
  51407. * Checks to see if a texture is used in the material.
  51408. * @param texture - Base texture to use.
  51409. * @returns - Boolean specifying if a texture is used in the material.
  51410. */
  51411. hasTexture(texture: BaseTexture): boolean;
  51412. /**
  51413. * Disposes the resources of the material.
  51414. * @param forceDisposeEffect - Forces the disposal of effects.
  51415. * @param forceDisposeTextures - Forces the disposal of all textures.
  51416. */
  51417. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  51418. }
  51419. }
  51420. declare module BABYLON {
  51421. /**
  51422. * The Physically based material of BJS.
  51423. *
  51424. * This offers the main features of a standard PBR material.
  51425. * For more information, please refer to the documentation :
  51426. * https://doc.babylonjs.com/how_to/physically_based_rendering
  51427. */
  51428. export class PBRMaterial extends PBRBaseMaterial {
  51429. /**
  51430. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  51431. */
  51432. static readonly PBRMATERIAL_OPAQUE: number;
  51433. /**
  51434. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  51435. */
  51436. static readonly PBRMATERIAL_ALPHATEST: number;
  51437. /**
  51438. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  51439. */
  51440. static readonly PBRMATERIAL_ALPHABLEND: number;
  51441. /**
  51442. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  51443. * They are also discarded below the alpha cutoff threshold to improve performances.
  51444. */
  51445. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  51446. /**
  51447. * Defines the default value of how much AO map is occluding the analytical lights
  51448. * (point spot...).
  51449. */
  51450. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  51451. /**
  51452. * Intensity of the direct lights e.g. the four lights available in your scene.
  51453. * This impacts both the direct diffuse and specular highlights.
  51454. */
  51455. directIntensity: number;
  51456. /**
  51457. * Intensity of the emissive part of the material.
  51458. * This helps controlling the emissive effect without modifying the emissive color.
  51459. */
  51460. emissiveIntensity: number;
  51461. /**
  51462. * Intensity of the environment e.g. how much the environment will light the object
  51463. * either through harmonics for rough material or through the refelction for shiny ones.
  51464. */
  51465. environmentIntensity: number;
  51466. /**
  51467. * This is a special control allowing the reduction of the specular highlights coming from the
  51468. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  51469. */
  51470. specularIntensity: number;
  51471. /**
  51472. * Debug Control allowing disabling the bump map on this material.
  51473. */
  51474. disableBumpMap: boolean;
  51475. /**
  51476. * AKA Diffuse Texture in standard nomenclature.
  51477. */
  51478. albedoTexture: BaseTexture;
  51479. /**
  51480. * AKA Occlusion Texture in other nomenclature.
  51481. */
  51482. ambientTexture: BaseTexture;
  51483. /**
  51484. * AKA Occlusion Texture Intensity in other nomenclature.
  51485. */
  51486. ambientTextureStrength: number;
  51487. /**
  51488. * Defines how much the AO map is occluding the analytical lights (point spot...).
  51489. * 1 means it completely occludes it
  51490. * 0 mean it has no impact
  51491. */
  51492. ambientTextureImpactOnAnalyticalLights: number;
  51493. /**
  51494. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  51495. */
  51496. opacityTexture: BaseTexture;
  51497. /**
  51498. * Stores the reflection values in a texture.
  51499. */
  51500. reflectionTexture: Nullable<BaseTexture>;
  51501. /**
  51502. * Stores the emissive values in a texture.
  51503. */
  51504. emissiveTexture: BaseTexture;
  51505. /**
  51506. * AKA Specular texture in other nomenclature.
  51507. */
  51508. reflectivityTexture: BaseTexture;
  51509. /**
  51510. * Used to switch from specular/glossiness to metallic/roughness workflow.
  51511. */
  51512. metallicTexture: BaseTexture;
  51513. /**
  51514. * Specifies the metallic scalar of the metallic/roughness workflow.
  51515. * Can also be used to scale the metalness values of the metallic texture.
  51516. */
  51517. metallic: Nullable<number>;
  51518. /**
  51519. * Specifies the roughness scalar of the metallic/roughness workflow.
  51520. * Can also be used to scale the roughness values of the metallic texture.
  51521. */
  51522. roughness: Nullable<number>;
  51523. /**
  51524. * Specifies the an F0 factor to help configuring the material F0.
  51525. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  51526. * to 0.5 the previously hard coded value stays the same.
  51527. * Can also be used to scale the F0 values of the metallic texture.
  51528. */
  51529. metallicF0Factor: number;
  51530. /**
  51531. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  51532. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  51533. * your expectation as it multiplies with the texture data.
  51534. */
  51535. useMetallicF0FactorFromMetallicTexture: boolean;
  51536. /**
  51537. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  51538. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  51539. */
  51540. microSurfaceTexture: BaseTexture;
  51541. /**
  51542. * Stores surface normal data used to displace a mesh in a texture.
  51543. */
  51544. bumpTexture: BaseTexture;
  51545. /**
  51546. * Stores the pre-calculated light information of a mesh in a texture.
  51547. */
  51548. lightmapTexture: BaseTexture;
  51549. /**
  51550. * Stores the refracted light information in a texture.
  51551. */
  51552. get refractionTexture(): Nullable<BaseTexture>;
  51553. set refractionTexture(value: Nullable<BaseTexture>);
  51554. /**
  51555. * The color of a material in ambient lighting.
  51556. */
  51557. ambientColor: Color3;
  51558. /**
  51559. * AKA Diffuse Color in other nomenclature.
  51560. */
  51561. albedoColor: Color3;
  51562. /**
  51563. * AKA Specular Color in other nomenclature.
  51564. */
  51565. reflectivityColor: Color3;
  51566. /**
  51567. * The color reflected from the material.
  51568. */
  51569. reflectionColor: Color3;
  51570. /**
  51571. * The color emitted from the material.
  51572. */
  51573. emissiveColor: Color3;
  51574. /**
  51575. * AKA Glossiness in other nomenclature.
  51576. */
  51577. microSurface: number;
  51578. /**
  51579. * source material index of refraction (IOR)' / 'destination material IOR.
  51580. */
  51581. get indexOfRefraction(): number;
  51582. set indexOfRefraction(value: number);
  51583. /**
  51584. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  51585. */
  51586. get invertRefractionY(): boolean;
  51587. set invertRefractionY(value: boolean);
  51588. /**
  51589. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  51590. * Materials half opaque for instance using refraction could benefit from this control.
  51591. */
  51592. get linkRefractionWithTransparency(): boolean;
  51593. set linkRefractionWithTransparency(value: boolean);
  51594. /**
  51595. * If true, the light map contains occlusion information instead of lighting info.
  51596. */
  51597. useLightmapAsShadowmap: boolean;
  51598. /**
  51599. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  51600. */
  51601. useAlphaFromAlbedoTexture: boolean;
  51602. /**
  51603. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  51604. */
  51605. forceAlphaTest: boolean;
  51606. /**
  51607. * Defines the alpha limits in alpha test mode.
  51608. */
  51609. alphaCutOff: number;
  51610. /**
  51611. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  51612. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  51613. */
  51614. useSpecularOverAlpha: boolean;
  51615. /**
  51616. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  51617. */
  51618. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  51619. /**
  51620. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  51621. */
  51622. useRoughnessFromMetallicTextureAlpha: boolean;
  51623. /**
  51624. * Specifies if the metallic texture contains the roughness information in its green channel.
  51625. */
  51626. useRoughnessFromMetallicTextureGreen: boolean;
  51627. /**
  51628. * Specifies if the metallic texture contains the metallness information in its blue channel.
  51629. */
  51630. useMetallnessFromMetallicTextureBlue: boolean;
  51631. /**
  51632. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  51633. */
  51634. useAmbientOcclusionFromMetallicTextureRed: boolean;
  51635. /**
  51636. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  51637. */
  51638. useAmbientInGrayScale: boolean;
  51639. /**
  51640. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  51641. * The material will try to infer what glossiness each pixel should be.
  51642. */
  51643. useAutoMicroSurfaceFromReflectivityMap: boolean;
  51644. /**
  51645. * BJS is using an harcoded light falloff based on a manually sets up range.
  51646. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  51647. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  51648. */
  51649. get usePhysicalLightFalloff(): 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. set usePhysicalLightFalloff(value: boolean);
  51656. /**
  51657. * In order to support the falloff compatibility with gltf, a special mode has been added
  51658. * to reproduce the gltf light falloff.
  51659. */
  51660. get useGLTFLightFalloff(): boolean;
  51661. /**
  51662. * In order to support the falloff compatibility with gltf, a special mode has been added
  51663. * to reproduce the gltf light falloff.
  51664. */
  51665. set useGLTFLightFalloff(value: boolean);
  51666. /**
  51667. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  51668. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  51669. */
  51670. useRadianceOverAlpha: boolean;
  51671. /**
  51672. * Allows using an object space normal map (instead of tangent space).
  51673. */
  51674. useObjectSpaceNormalMap: boolean;
  51675. /**
  51676. * Allows using the bump map in parallax mode.
  51677. */
  51678. useParallax: boolean;
  51679. /**
  51680. * Allows using the bump map in parallax occlusion mode.
  51681. */
  51682. useParallaxOcclusion: boolean;
  51683. /**
  51684. * Controls the scale bias of the parallax mode.
  51685. */
  51686. parallaxScaleBias: number;
  51687. /**
  51688. * If sets to true, disables all the lights affecting the material.
  51689. */
  51690. disableLighting: boolean;
  51691. /**
  51692. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  51693. */
  51694. forceIrradianceInFragment: boolean;
  51695. /**
  51696. * Number of Simultaneous lights allowed on the material.
  51697. */
  51698. maxSimultaneousLights: number;
  51699. /**
  51700. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  51701. */
  51702. invertNormalMapX: boolean;
  51703. /**
  51704. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  51705. */
  51706. invertNormalMapY: boolean;
  51707. /**
  51708. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  51709. */
  51710. twoSidedLighting: boolean;
  51711. /**
  51712. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  51713. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  51714. */
  51715. useAlphaFresnel: boolean;
  51716. /**
  51717. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  51718. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  51719. */
  51720. useLinearAlphaFresnel: boolean;
  51721. /**
  51722. * Let user defines the brdf lookup texture used for IBL.
  51723. * A default 8bit version is embedded but you could point at :
  51724. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  51725. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  51726. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  51727. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  51728. */
  51729. environmentBRDFTexture: Nullable<BaseTexture>;
  51730. /**
  51731. * Force normal to face away from face.
  51732. */
  51733. forceNormalForward: boolean;
  51734. /**
  51735. * Enables specular anti aliasing in the PBR shader.
  51736. * It will both interacts on the Geometry for analytical and IBL lighting.
  51737. * It also prefilter the roughness map based on the bump values.
  51738. */
  51739. enableSpecularAntiAliasing: boolean;
  51740. /**
  51741. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  51742. * makes the reflect vector face the model (under horizon).
  51743. */
  51744. useHorizonOcclusion: boolean;
  51745. /**
  51746. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  51747. * too much the area relying on ambient texture to define their ambient occlusion.
  51748. */
  51749. useRadianceOcclusion: boolean;
  51750. /**
  51751. * If set to true, no lighting calculations will be applied.
  51752. */
  51753. unlit: boolean;
  51754. /**
  51755. * Gets the image processing configuration used either in this material.
  51756. */
  51757. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  51758. /**
  51759. * Sets the Default image processing configuration used either in the this material.
  51760. *
  51761. * If sets to null, the scene one is in use.
  51762. */
  51763. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  51764. /**
  51765. * Gets wether the color curves effect is enabled.
  51766. */
  51767. get cameraColorCurvesEnabled(): boolean;
  51768. /**
  51769. * Sets wether the color curves effect is enabled.
  51770. */
  51771. set cameraColorCurvesEnabled(value: boolean);
  51772. /**
  51773. * Gets wether the color grading effect is enabled.
  51774. */
  51775. get cameraColorGradingEnabled(): boolean;
  51776. /**
  51777. * Gets wether the color grading effect is enabled.
  51778. */
  51779. set cameraColorGradingEnabled(value: boolean);
  51780. /**
  51781. * Gets wether tonemapping is enabled or not.
  51782. */
  51783. get cameraToneMappingEnabled(): boolean;
  51784. /**
  51785. * Sets wether tonemapping is enabled or not
  51786. */
  51787. set cameraToneMappingEnabled(value: boolean);
  51788. /**
  51789. * The camera exposure used on this material.
  51790. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  51791. * This corresponds to a photographic exposure.
  51792. */
  51793. get cameraExposure(): number;
  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. set cameraExposure(value: number);
  51800. /**
  51801. * Gets The camera contrast used on this material.
  51802. */
  51803. get cameraContrast(): number;
  51804. /**
  51805. * Sets The camera contrast used on this material.
  51806. */
  51807. set cameraContrast(value: number);
  51808. /**
  51809. * Gets the Color Grading 2D Lookup Texture.
  51810. */
  51811. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  51812. /**
  51813. * Sets the Color Grading 2D Lookup Texture.
  51814. */
  51815. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  51816. /**
  51817. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  51818. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  51819. * 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;
  51820. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  51821. */
  51822. get cameraColorCurves(): Nullable<ColorCurves>;
  51823. /**
  51824. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  51825. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  51826. * 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;
  51827. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  51828. */
  51829. set cameraColorCurves(value: Nullable<ColorCurves>);
  51830. /**
  51831. * Instantiates a new PBRMaterial instance.
  51832. *
  51833. * @param name The material name
  51834. * @param scene The scene the material will be use in.
  51835. */
  51836. constructor(name: string, scene: Scene);
  51837. /**
  51838. * Returns the name of this material class.
  51839. */
  51840. getClassName(): string;
  51841. /**
  51842. * Makes a duplicate of the current material.
  51843. * @param name - name to use for the new material.
  51844. */
  51845. clone(name: string): PBRMaterial;
  51846. /**
  51847. * Serializes this PBR Material.
  51848. * @returns - An object with the serialized material.
  51849. */
  51850. serialize(): any;
  51851. /**
  51852. * Parses a PBR Material from a serialized object.
  51853. * @param source - Serialized object.
  51854. * @param scene - BJS scene instance.
  51855. * @param rootUrl - url for the scene object
  51856. * @returns - PBRMaterial
  51857. */
  51858. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  51859. }
  51860. }
  51861. declare module BABYLON {
  51862. /**
  51863. * Direct draw surface info
  51864. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  51865. */
  51866. export interface DDSInfo {
  51867. /**
  51868. * Width of the texture
  51869. */
  51870. width: number;
  51871. /**
  51872. * Width of the texture
  51873. */
  51874. height: number;
  51875. /**
  51876. * Number of Mipmaps for the texture
  51877. * @see https://en.wikipedia.org/wiki/Mipmap
  51878. */
  51879. mipmapCount: number;
  51880. /**
  51881. * If the textures format is a known fourCC format
  51882. * @see https://www.fourcc.org/
  51883. */
  51884. isFourCC: boolean;
  51885. /**
  51886. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  51887. */
  51888. isRGB: boolean;
  51889. /**
  51890. * If the texture is a lumincance format
  51891. */
  51892. isLuminance: boolean;
  51893. /**
  51894. * If this is a cube texture
  51895. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  51896. */
  51897. isCube: boolean;
  51898. /**
  51899. * If the texture is a compressed format eg. FOURCC_DXT1
  51900. */
  51901. isCompressed: boolean;
  51902. /**
  51903. * The dxgiFormat of the texture
  51904. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  51905. */
  51906. dxgiFormat: number;
  51907. /**
  51908. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  51909. */
  51910. textureType: number;
  51911. /**
  51912. * Sphericle polynomial created for the dds texture
  51913. */
  51914. sphericalPolynomial?: SphericalPolynomial;
  51915. }
  51916. /**
  51917. * Class used to provide DDS decompression tools
  51918. */
  51919. export class DDSTools {
  51920. /**
  51921. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  51922. */
  51923. static StoreLODInAlphaChannel: boolean;
  51924. /**
  51925. * Gets DDS information from an array buffer
  51926. * @param data defines the array buffer view to read data from
  51927. * @returns the DDS information
  51928. */
  51929. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  51930. private static _FloatView;
  51931. private static _Int32View;
  51932. private static _ToHalfFloat;
  51933. private static _FromHalfFloat;
  51934. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  51935. private static _GetHalfFloatRGBAArrayBuffer;
  51936. private static _GetFloatRGBAArrayBuffer;
  51937. private static _GetFloatAsUIntRGBAArrayBuffer;
  51938. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  51939. private static _GetRGBAArrayBuffer;
  51940. private static _ExtractLongWordOrder;
  51941. private static _GetRGBArrayBuffer;
  51942. private static _GetLuminanceArrayBuffer;
  51943. /**
  51944. * Uploads DDS Levels to a Babylon Texture
  51945. * @hidden
  51946. */
  51947. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  51948. }
  51949. interface ThinEngine {
  51950. /**
  51951. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  51952. * @param rootUrl defines the url where the file to load is located
  51953. * @param scene defines the current scene
  51954. * @param lodScale defines scale to apply to the mip map selection
  51955. * @param lodOffset defines offset to apply to the mip map selection
  51956. * @param onLoad defines an optional callback raised when the texture is loaded
  51957. * @param onError defines an optional callback raised if there is an issue to load the texture
  51958. * @param format defines the format of the data
  51959. * @param forcedExtension defines the extension to use to pick the right loader
  51960. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  51961. * @returns the cube texture as an InternalTexture
  51962. */
  51963. 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;
  51964. }
  51965. }
  51966. declare module BABYLON {
  51967. /**
  51968. * Implementation of the DDS Texture Loader.
  51969. * @hidden
  51970. */
  51971. export class _DDSTextureLoader implements IInternalTextureLoader {
  51972. /**
  51973. * Defines wether the loader supports cascade loading the different faces.
  51974. */
  51975. readonly supportCascades: boolean;
  51976. /**
  51977. * This returns if the loader support the current file information.
  51978. * @param extension defines the file extension of the file being loaded
  51979. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51980. * @param fallback defines the fallback internal texture if any
  51981. * @param isBase64 defines whether the texture is encoded as a base64
  51982. * @param isBuffer defines whether the texture data are stored as a buffer
  51983. * @returns true if the loader can load the specified file
  51984. */
  51985. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  51986. /**
  51987. * Transform the url before loading if required.
  51988. * @param rootUrl the url of the texture
  51989. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51990. * @returns the transformed texture
  51991. */
  51992. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  51993. /**
  51994. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  51995. * @param rootUrl the url of the texture
  51996. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51997. * @returns the fallback texture
  51998. */
  51999. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  52000. /**
  52001. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  52002. * @param data contains the texture data
  52003. * @param texture defines the BabylonJS internal texture
  52004. * @param createPolynomials will be true if polynomials have been requested
  52005. * @param onLoad defines the callback to trigger once the texture is ready
  52006. * @param onError defines the callback to trigger in case of error
  52007. */
  52008. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  52009. /**
  52010. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  52011. * @param data contains the texture data
  52012. * @param texture defines the BabylonJS internal texture
  52013. * @param callback defines the method to call once ready to upload
  52014. */
  52015. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  52016. }
  52017. }
  52018. declare module BABYLON {
  52019. /**
  52020. * Implementation of the ENV Texture Loader.
  52021. * @hidden
  52022. */
  52023. export class _ENVTextureLoader implements IInternalTextureLoader {
  52024. /**
  52025. * Defines wether the loader supports cascade loading the different faces.
  52026. */
  52027. readonly supportCascades: boolean;
  52028. /**
  52029. * This returns if the loader support the current file information.
  52030. * @param extension defines the file extension of the file being loaded
  52031. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52032. * @param fallback defines the fallback internal texture if any
  52033. * @param isBase64 defines whether the texture is encoded as a base64
  52034. * @param isBuffer defines whether the texture data are stored as a buffer
  52035. * @returns true if the loader can load the specified file
  52036. */
  52037. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  52038. /**
  52039. * Transform the url before loading if required.
  52040. * @param rootUrl the url of the texture
  52041. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52042. * @returns the transformed texture
  52043. */
  52044. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  52045. /**
  52046. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  52047. * @param rootUrl the url of the texture
  52048. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52049. * @returns the fallback texture
  52050. */
  52051. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  52052. /**
  52053. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  52054. * @param data contains the texture data
  52055. * @param texture defines the BabylonJS internal texture
  52056. * @param createPolynomials will be true if polynomials have been requested
  52057. * @param onLoad defines the callback to trigger once the texture is ready
  52058. * @param onError defines the callback to trigger in case of error
  52059. */
  52060. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  52061. /**
  52062. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  52063. * @param data contains the texture data
  52064. * @param texture defines the BabylonJS internal texture
  52065. * @param callback defines the method to call once ready to upload
  52066. */
  52067. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  52068. }
  52069. }
  52070. declare module BABYLON {
  52071. /**
  52072. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  52073. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  52074. */
  52075. export class KhronosTextureContainer {
  52076. /** contents of the KTX container file */
  52077. data: ArrayBufferView;
  52078. private static HEADER_LEN;
  52079. private static COMPRESSED_2D;
  52080. private static COMPRESSED_3D;
  52081. private static TEX_2D;
  52082. private static TEX_3D;
  52083. /**
  52084. * Gets the openGL type
  52085. */
  52086. glType: number;
  52087. /**
  52088. * Gets the openGL type size
  52089. */
  52090. glTypeSize: number;
  52091. /**
  52092. * Gets the openGL format
  52093. */
  52094. glFormat: number;
  52095. /**
  52096. * Gets the openGL internal format
  52097. */
  52098. glInternalFormat: number;
  52099. /**
  52100. * Gets the base internal format
  52101. */
  52102. glBaseInternalFormat: number;
  52103. /**
  52104. * Gets image width in pixel
  52105. */
  52106. pixelWidth: number;
  52107. /**
  52108. * Gets image height in pixel
  52109. */
  52110. pixelHeight: number;
  52111. /**
  52112. * Gets image depth in pixels
  52113. */
  52114. pixelDepth: number;
  52115. /**
  52116. * Gets the number of array elements
  52117. */
  52118. numberOfArrayElements: number;
  52119. /**
  52120. * Gets the number of faces
  52121. */
  52122. numberOfFaces: number;
  52123. /**
  52124. * Gets the number of mipmap levels
  52125. */
  52126. numberOfMipmapLevels: number;
  52127. /**
  52128. * Gets the bytes of key value data
  52129. */
  52130. bytesOfKeyValueData: number;
  52131. /**
  52132. * Gets the load type
  52133. */
  52134. loadType: number;
  52135. /**
  52136. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  52137. */
  52138. isInvalid: boolean;
  52139. /**
  52140. * Creates a new KhronosTextureContainer
  52141. * @param data contents of the KTX container file
  52142. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  52143. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  52144. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  52145. */
  52146. constructor(
  52147. /** contents of the KTX container file */
  52148. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  52149. /**
  52150. * Uploads KTX content to a Babylon Texture.
  52151. * It is assumed that the texture has already been created & is currently bound
  52152. * @hidden
  52153. */
  52154. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  52155. private _upload2DCompressedLevels;
  52156. }
  52157. }
  52158. declare module BABYLON {
  52159. /**
  52160. * Implementation of the KTX Texture Loader.
  52161. * @hidden
  52162. */
  52163. export class _KTXTextureLoader implements IInternalTextureLoader {
  52164. /**
  52165. * Defines wether the loader supports cascade loading the different faces.
  52166. */
  52167. readonly supportCascades: boolean;
  52168. /**
  52169. * This returns if the loader support the current file information.
  52170. * @param extension defines the file extension of the file being loaded
  52171. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52172. * @param fallback defines the fallback internal texture if any
  52173. * @param isBase64 defines whether the texture is encoded as a base64
  52174. * @param isBuffer defines whether the texture data are stored as a buffer
  52175. * @returns true if the loader can load the specified file
  52176. */
  52177. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  52178. /**
  52179. * Transform the url before loading if required.
  52180. * @param rootUrl the url of the texture
  52181. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52182. * @returns the transformed texture
  52183. */
  52184. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  52185. /**
  52186. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  52187. * @param rootUrl the url of the texture
  52188. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52189. * @returns the fallback texture
  52190. */
  52191. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  52192. /**
  52193. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  52194. * @param data contains the texture data
  52195. * @param texture defines the BabylonJS internal texture
  52196. * @param createPolynomials will be true if polynomials have been requested
  52197. * @param onLoad defines the callback to trigger once the texture is ready
  52198. * @param onError defines the callback to trigger in case of error
  52199. */
  52200. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  52201. /**
  52202. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  52203. * @param data contains the texture data
  52204. * @param texture defines the BabylonJS internal texture
  52205. * @param callback defines the method to call once ready to upload
  52206. */
  52207. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  52208. }
  52209. }
  52210. declare module BABYLON {
  52211. /** @hidden */
  52212. export var _forceSceneHelpersToBundle: boolean;
  52213. interface Scene {
  52214. /**
  52215. * Creates a default light for the scene.
  52216. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  52217. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  52218. */
  52219. createDefaultLight(replace?: boolean): void;
  52220. /**
  52221. * Creates a default camera for the scene.
  52222. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  52223. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  52224. * @param replace has default false, when true replaces the active camera in the scene
  52225. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  52226. */
  52227. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  52228. /**
  52229. * Creates a default camera and a default light.
  52230. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  52231. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  52232. * @param replace has the default false, when true replaces the active camera/light in the scene
  52233. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  52234. */
  52235. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  52236. /**
  52237. * Creates a new sky box
  52238. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  52239. * @param environmentTexture defines the texture to use as environment texture
  52240. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  52241. * @param scale defines the overall scale of the skybox
  52242. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  52243. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  52244. * @returns a new mesh holding the sky box
  52245. */
  52246. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  52247. /**
  52248. * Creates a new environment
  52249. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  52250. * @param options defines the options you can use to configure the environment
  52251. * @returns the new EnvironmentHelper
  52252. */
  52253. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  52254. /**
  52255. * Creates a new VREXperienceHelper
  52256. * @see http://doc.babylonjs.com/how_to/webvr_helper
  52257. * @param webVROptions defines the options used to create the new VREXperienceHelper
  52258. * @returns a new VREXperienceHelper
  52259. */
  52260. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  52261. /**
  52262. * Creates a new WebXRDefaultExperience
  52263. * @see http://doc.babylonjs.com/how_to/webxr
  52264. * @param options experience options
  52265. * @returns a promise for a new WebXRDefaultExperience
  52266. */
  52267. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  52268. }
  52269. }
  52270. declare module BABYLON {
  52271. /**
  52272. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  52273. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  52274. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  52275. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  52276. */
  52277. export class VideoDome extends TransformNode {
  52278. /**
  52279. * Define the video source as a Monoscopic panoramic 360 video.
  52280. */
  52281. static readonly MODE_MONOSCOPIC: number;
  52282. /**
  52283. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  52284. */
  52285. static readonly MODE_TOPBOTTOM: number;
  52286. /**
  52287. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  52288. */
  52289. static readonly MODE_SIDEBYSIDE: number;
  52290. private _halfDome;
  52291. private _useDirectMapping;
  52292. /**
  52293. * The video texture being displayed on the sphere
  52294. */
  52295. protected _videoTexture: VideoTexture;
  52296. /**
  52297. * Gets the video texture being displayed on the sphere
  52298. */
  52299. get videoTexture(): VideoTexture;
  52300. /**
  52301. * The skybox material
  52302. */
  52303. protected _material: BackgroundMaterial;
  52304. /**
  52305. * The surface used for the skybox
  52306. */
  52307. protected _mesh: Mesh;
  52308. /**
  52309. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  52310. */
  52311. private _halfDomeMask;
  52312. /**
  52313. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  52314. * Also see the options.resolution property.
  52315. */
  52316. get fovMultiplier(): number;
  52317. set fovMultiplier(value: number);
  52318. private _videoMode;
  52319. /**
  52320. * Gets or set the current video mode for the video. It can be:
  52321. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  52322. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  52323. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  52324. */
  52325. get videoMode(): number;
  52326. set videoMode(value: number);
  52327. /**
  52328. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  52329. *
  52330. */
  52331. get halfDome(): boolean;
  52332. /**
  52333. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  52334. */
  52335. set halfDome(enabled: boolean);
  52336. /**
  52337. * Oberserver used in Stereoscopic VR Mode.
  52338. */
  52339. private _onBeforeCameraRenderObserver;
  52340. /**
  52341. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  52342. * @param name Element's name, child elements will append suffixes for their own names.
  52343. * @param urlsOrVideo defines the url(s) or the video element to use
  52344. * @param options An object containing optional or exposed sub element properties
  52345. */
  52346. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  52347. resolution?: number;
  52348. clickToPlay?: boolean;
  52349. autoPlay?: boolean;
  52350. loop?: boolean;
  52351. size?: number;
  52352. poster?: string;
  52353. faceForward?: boolean;
  52354. useDirectMapping?: boolean;
  52355. halfDomeMode?: boolean;
  52356. }, scene: Scene);
  52357. private _changeVideoMode;
  52358. /**
  52359. * Releases resources associated with this node.
  52360. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  52361. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  52362. */
  52363. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  52364. }
  52365. }
  52366. declare module BABYLON {
  52367. /**
  52368. * This class can be used to get instrumentation data from a Babylon engine
  52369. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  52370. */
  52371. export class EngineInstrumentation implements IDisposable {
  52372. /**
  52373. * Define the instrumented engine.
  52374. */
  52375. engine: Engine;
  52376. private _captureGPUFrameTime;
  52377. private _gpuFrameTimeToken;
  52378. private _gpuFrameTime;
  52379. private _captureShaderCompilationTime;
  52380. private _shaderCompilationTime;
  52381. private _onBeginFrameObserver;
  52382. private _onEndFrameObserver;
  52383. private _onBeforeShaderCompilationObserver;
  52384. private _onAfterShaderCompilationObserver;
  52385. /**
  52386. * Gets the perf counter used for GPU frame time
  52387. */
  52388. get gpuFrameTimeCounter(): PerfCounter;
  52389. /**
  52390. * Gets the GPU frame time capture status
  52391. */
  52392. get captureGPUFrameTime(): boolean;
  52393. /**
  52394. * Enable or disable the GPU frame time capture
  52395. */
  52396. set captureGPUFrameTime(value: boolean);
  52397. /**
  52398. * Gets the perf counter used for shader compilation time
  52399. */
  52400. get shaderCompilationTimeCounter(): PerfCounter;
  52401. /**
  52402. * Gets the shader compilation time capture status
  52403. */
  52404. get captureShaderCompilationTime(): boolean;
  52405. /**
  52406. * Enable or disable the shader compilation time capture
  52407. */
  52408. set captureShaderCompilationTime(value: boolean);
  52409. /**
  52410. * Instantiates a new engine instrumentation.
  52411. * This class can be used to get instrumentation data from a Babylon engine
  52412. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  52413. * @param engine Defines the engine to instrument
  52414. */
  52415. constructor(
  52416. /**
  52417. * Define the instrumented engine.
  52418. */
  52419. engine: Engine);
  52420. /**
  52421. * Dispose and release associated resources.
  52422. */
  52423. dispose(): void;
  52424. }
  52425. }
  52426. declare module BABYLON {
  52427. /**
  52428. * This class can be used to get instrumentation data from a Babylon engine
  52429. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  52430. */
  52431. export class SceneInstrumentation implements IDisposable {
  52432. /**
  52433. * Defines the scene to instrument
  52434. */
  52435. scene: Scene;
  52436. private _captureActiveMeshesEvaluationTime;
  52437. private _activeMeshesEvaluationTime;
  52438. private _captureRenderTargetsRenderTime;
  52439. private _renderTargetsRenderTime;
  52440. private _captureFrameTime;
  52441. private _frameTime;
  52442. private _captureRenderTime;
  52443. private _renderTime;
  52444. private _captureInterFrameTime;
  52445. private _interFrameTime;
  52446. private _captureParticlesRenderTime;
  52447. private _particlesRenderTime;
  52448. private _captureSpritesRenderTime;
  52449. private _spritesRenderTime;
  52450. private _capturePhysicsTime;
  52451. private _physicsTime;
  52452. private _captureAnimationsTime;
  52453. private _animationsTime;
  52454. private _captureCameraRenderTime;
  52455. private _cameraRenderTime;
  52456. private _onBeforeActiveMeshesEvaluationObserver;
  52457. private _onAfterActiveMeshesEvaluationObserver;
  52458. private _onBeforeRenderTargetsRenderObserver;
  52459. private _onAfterRenderTargetsRenderObserver;
  52460. private _onAfterRenderObserver;
  52461. private _onBeforeDrawPhaseObserver;
  52462. private _onAfterDrawPhaseObserver;
  52463. private _onBeforeAnimationsObserver;
  52464. private _onBeforeParticlesRenderingObserver;
  52465. private _onAfterParticlesRenderingObserver;
  52466. private _onBeforeSpritesRenderingObserver;
  52467. private _onAfterSpritesRenderingObserver;
  52468. private _onBeforePhysicsObserver;
  52469. private _onAfterPhysicsObserver;
  52470. private _onAfterAnimationsObserver;
  52471. private _onBeforeCameraRenderObserver;
  52472. private _onAfterCameraRenderObserver;
  52473. /**
  52474. * Gets the perf counter used for active meshes evaluation time
  52475. */
  52476. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  52477. /**
  52478. * Gets the active meshes evaluation time capture status
  52479. */
  52480. get captureActiveMeshesEvaluationTime(): boolean;
  52481. /**
  52482. * Enable or disable the active meshes evaluation time capture
  52483. */
  52484. set captureActiveMeshesEvaluationTime(value: boolean);
  52485. /**
  52486. * Gets the perf counter used for render targets render time
  52487. */
  52488. get renderTargetsRenderTimeCounter(): PerfCounter;
  52489. /**
  52490. * Gets the render targets render time capture status
  52491. */
  52492. get captureRenderTargetsRenderTime(): boolean;
  52493. /**
  52494. * Enable or disable the render targets render time capture
  52495. */
  52496. set captureRenderTargetsRenderTime(value: boolean);
  52497. /**
  52498. * Gets the perf counter used for particles render time
  52499. */
  52500. get particlesRenderTimeCounter(): PerfCounter;
  52501. /**
  52502. * Gets the particles render time capture status
  52503. */
  52504. get captureParticlesRenderTime(): boolean;
  52505. /**
  52506. * Enable or disable the particles render time capture
  52507. */
  52508. set captureParticlesRenderTime(value: boolean);
  52509. /**
  52510. * Gets the perf counter used for sprites render time
  52511. */
  52512. get spritesRenderTimeCounter(): PerfCounter;
  52513. /**
  52514. * Gets the sprites render time capture status
  52515. */
  52516. get captureSpritesRenderTime(): boolean;
  52517. /**
  52518. * Enable or disable the sprites render time capture
  52519. */
  52520. set captureSpritesRenderTime(value: boolean);
  52521. /**
  52522. * Gets the perf counter used for physics time
  52523. */
  52524. get physicsTimeCounter(): PerfCounter;
  52525. /**
  52526. * Gets the physics time capture status
  52527. */
  52528. get capturePhysicsTime(): boolean;
  52529. /**
  52530. * Enable or disable the physics time capture
  52531. */
  52532. set capturePhysicsTime(value: boolean);
  52533. /**
  52534. * Gets the perf counter used for animations time
  52535. */
  52536. get animationsTimeCounter(): PerfCounter;
  52537. /**
  52538. * Gets the animations time capture status
  52539. */
  52540. get captureAnimationsTime(): boolean;
  52541. /**
  52542. * Enable or disable the animations time capture
  52543. */
  52544. set captureAnimationsTime(value: boolean);
  52545. /**
  52546. * Gets the perf counter used for frame time capture
  52547. */
  52548. get frameTimeCounter(): PerfCounter;
  52549. /**
  52550. * Gets the frame time capture status
  52551. */
  52552. get captureFrameTime(): boolean;
  52553. /**
  52554. * Enable or disable the frame time capture
  52555. */
  52556. set captureFrameTime(value: boolean);
  52557. /**
  52558. * Gets the perf counter used for inter-frames time capture
  52559. */
  52560. get interFrameTimeCounter(): PerfCounter;
  52561. /**
  52562. * Gets the inter-frames time capture status
  52563. */
  52564. get captureInterFrameTime(): boolean;
  52565. /**
  52566. * Enable or disable the inter-frames time capture
  52567. */
  52568. set captureInterFrameTime(value: boolean);
  52569. /**
  52570. * Gets the perf counter used for render time capture
  52571. */
  52572. get renderTimeCounter(): PerfCounter;
  52573. /**
  52574. * Gets the render time capture status
  52575. */
  52576. get captureRenderTime(): boolean;
  52577. /**
  52578. * Enable or disable the render time capture
  52579. */
  52580. set captureRenderTime(value: boolean);
  52581. /**
  52582. * Gets the perf counter used for camera render time capture
  52583. */
  52584. get cameraRenderTimeCounter(): PerfCounter;
  52585. /**
  52586. * Gets the camera render time capture status
  52587. */
  52588. get captureCameraRenderTime(): boolean;
  52589. /**
  52590. * Enable or disable the camera render time capture
  52591. */
  52592. set captureCameraRenderTime(value: boolean);
  52593. /**
  52594. * Gets the perf counter used for draw calls
  52595. */
  52596. get drawCallsCounter(): PerfCounter;
  52597. /**
  52598. * Instantiates a new scene instrumentation.
  52599. * This class can be used to get instrumentation data from a Babylon engine
  52600. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  52601. * @param scene Defines the scene to instrument
  52602. */
  52603. constructor(
  52604. /**
  52605. * Defines the scene to instrument
  52606. */
  52607. scene: Scene);
  52608. /**
  52609. * Dispose and release associated resources.
  52610. */
  52611. dispose(): void;
  52612. }
  52613. }
  52614. declare module BABYLON {
  52615. /** @hidden */
  52616. export var glowMapGenerationPixelShader: {
  52617. name: string;
  52618. shader: string;
  52619. };
  52620. }
  52621. declare module BABYLON {
  52622. /** @hidden */
  52623. export var glowMapGenerationVertexShader: {
  52624. name: string;
  52625. shader: string;
  52626. };
  52627. }
  52628. declare module BABYLON {
  52629. /**
  52630. * Effect layer options. This helps customizing the behaviour
  52631. * of the effect layer.
  52632. */
  52633. export interface IEffectLayerOptions {
  52634. /**
  52635. * Multiplication factor apply to the canvas size to compute the render target size
  52636. * used to generated the objects (the smaller the faster).
  52637. */
  52638. mainTextureRatio: number;
  52639. /**
  52640. * Enforces a fixed size texture to ensure effect stability across devices.
  52641. */
  52642. mainTextureFixedSize?: number;
  52643. /**
  52644. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  52645. */
  52646. alphaBlendingMode: number;
  52647. /**
  52648. * The camera attached to the layer.
  52649. */
  52650. camera: Nullable<Camera>;
  52651. /**
  52652. * The rendering group to draw the layer in.
  52653. */
  52654. renderingGroupId: number;
  52655. }
  52656. /**
  52657. * The effect layer Helps adding post process effect blended with the main pass.
  52658. *
  52659. * This can be for instance use to generate glow or higlight effects on the scene.
  52660. *
  52661. * The effect layer class can not be used directly and is intented to inherited from to be
  52662. * customized per effects.
  52663. */
  52664. export abstract class EffectLayer {
  52665. private _vertexBuffers;
  52666. private _indexBuffer;
  52667. private _cachedDefines;
  52668. private _effectLayerMapGenerationEffect;
  52669. private _effectLayerOptions;
  52670. private _mergeEffect;
  52671. protected _scene: Scene;
  52672. protected _engine: Engine;
  52673. protected _maxSize: number;
  52674. protected _mainTextureDesiredSize: ISize;
  52675. protected _mainTexture: RenderTargetTexture;
  52676. protected _shouldRender: boolean;
  52677. protected _postProcesses: PostProcess[];
  52678. protected _textures: BaseTexture[];
  52679. protected _emissiveTextureAndColor: {
  52680. texture: Nullable<BaseTexture>;
  52681. color: Color4;
  52682. };
  52683. /**
  52684. * The name of the layer
  52685. */
  52686. name: string;
  52687. /**
  52688. * The clear color of the texture used to generate the glow map.
  52689. */
  52690. neutralColor: Color4;
  52691. /**
  52692. * Specifies whether the highlight layer is enabled or not.
  52693. */
  52694. isEnabled: boolean;
  52695. /**
  52696. * Gets the camera attached to the layer.
  52697. */
  52698. get camera(): Nullable<Camera>;
  52699. /**
  52700. * Gets the rendering group id the layer should render in.
  52701. */
  52702. get renderingGroupId(): number;
  52703. set renderingGroupId(renderingGroupId: number);
  52704. /**
  52705. * An event triggered when the effect layer has been disposed.
  52706. */
  52707. onDisposeObservable: Observable<EffectLayer>;
  52708. /**
  52709. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  52710. */
  52711. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  52712. /**
  52713. * An event triggered when the generated texture is being merged in the scene.
  52714. */
  52715. onBeforeComposeObservable: Observable<EffectLayer>;
  52716. /**
  52717. * An event triggered when the mesh is rendered into the effect render target.
  52718. */
  52719. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  52720. /**
  52721. * An event triggered after the mesh has been rendered into the effect render target.
  52722. */
  52723. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  52724. /**
  52725. * An event triggered when the generated texture has been merged in the scene.
  52726. */
  52727. onAfterComposeObservable: Observable<EffectLayer>;
  52728. /**
  52729. * An event triggered when the efffect layer changes its size.
  52730. */
  52731. onSizeChangedObservable: Observable<EffectLayer>;
  52732. /** @hidden */
  52733. static _SceneComponentInitialization: (scene: Scene) => void;
  52734. /**
  52735. * Instantiates a new effect Layer and references it in the scene.
  52736. * @param name The name of the layer
  52737. * @param scene The scene to use the layer in
  52738. */
  52739. constructor(
  52740. /** The Friendly of the effect in the scene */
  52741. name: string, scene: Scene);
  52742. /**
  52743. * Get the effect name of the layer.
  52744. * @return The effect name
  52745. */
  52746. abstract getEffectName(): string;
  52747. /**
  52748. * Checks for the readiness of the element composing the layer.
  52749. * @param subMesh the mesh to check for
  52750. * @param useInstances specify whether or not to use instances to render the mesh
  52751. * @return true if ready otherwise, false
  52752. */
  52753. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  52754. /**
  52755. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  52756. * @returns true if the effect requires stencil during the main canvas render pass.
  52757. */
  52758. abstract needStencil(): boolean;
  52759. /**
  52760. * Create the merge effect. This is the shader use to blit the information back
  52761. * to the main canvas at the end of the scene rendering.
  52762. * @returns The effect containing the shader used to merge the effect on the main canvas
  52763. */
  52764. protected abstract _createMergeEffect(): Effect;
  52765. /**
  52766. * Creates the render target textures and post processes used in the effect layer.
  52767. */
  52768. protected abstract _createTextureAndPostProcesses(): void;
  52769. /**
  52770. * Implementation specific of rendering the generating effect on the main canvas.
  52771. * @param effect The effect used to render through
  52772. */
  52773. protected abstract _internalRender(effect: Effect): void;
  52774. /**
  52775. * Sets the required values for both the emissive texture and and the main color.
  52776. */
  52777. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  52778. /**
  52779. * Free any resources and references associated to a mesh.
  52780. * Internal use
  52781. * @param mesh The mesh to free.
  52782. */
  52783. abstract _disposeMesh(mesh: Mesh): void;
  52784. /**
  52785. * Serializes this layer (Glow or Highlight for example)
  52786. * @returns a serialized layer object
  52787. */
  52788. abstract serialize?(): any;
  52789. /**
  52790. * Initializes the effect layer with the required options.
  52791. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  52792. */
  52793. protected _init(options: Partial<IEffectLayerOptions>): void;
  52794. /**
  52795. * Generates the index buffer of the full screen quad blending to the main canvas.
  52796. */
  52797. private _generateIndexBuffer;
  52798. /**
  52799. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  52800. */
  52801. private _generateVertexBuffer;
  52802. /**
  52803. * Sets the main texture desired size which is the closest power of two
  52804. * of the engine canvas size.
  52805. */
  52806. private _setMainTextureSize;
  52807. /**
  52808. * Creates the main texture for the effect layer.
  52809. */
  52810. protected _createMainTexture(): void;
  52811. /**
  52812. * Adds specific effects defines.
  52813. * @param defines The defines to add specifics to.
  52814. */
  52815. protected _addCustomEffectDefines(defines: string[]): void;
  52816. /**
  52817. * Checks for the readiness of the element composing the layer.
  52818. * @param subMesh the mesh to check for
  52819. * @param useInstances specify whether or not to use instances to render the mesh
  52820. * @param emissiveTexture the associated emissive texture used to generate the glow
  52821. * @return true if ready otherwise, false
  52822. */
  52823. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  52824. /**
  52825. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  52826. */
  52827. render(): void;
  52828. /**
  52829. * Determine if a given mesh will be used in the current effect.
  52830. * @param mesh mesh to test
  52831. * @returns true if the mesh will be used
  52832. */
  52833. hasMesh(mesh: AbstractMesh): boolean;
  52834. /**
  52835. * Returns true if the layer contains information to display, otherwise false.
  52836. * @returns true if the glow layer should be rendered
  52837. */
  52838. shouldRender(): boolean;
  52839. /**
  52840. * Returns true if the mesh should render, otherwise false.
  52841. * @param mesh The mesh to render
  52842. * @returns true if it should render otherwise false
  52843. */
  52844. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  52845. /**
  52846. * Returns true if the mesh can be rendered, otherwise false.
  52847. * @param mesh The mesh to render
  52848. * @param material The material used on the mesh
  52849. * @returns true if it can be rendered otherwise false
  52850. */
  52851. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  52852. /**
  52853. * Returns true if the mesh should render, otherwise false.
  52854. * @param mesh The mesh to render
  52855. * @returns true if it should render otherwise false
  52856. */
  52857. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  52858. /**
  52859. * Renders the submesh passed in parameter to the generation map.
  52860. */
  52861. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  52862. /**
  52863. * Defines whether the current material of the mesh should be use to render the effect.
  52864. * @param mesh defines the current mesh to render
  52865. */
  52866. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  52867. /**
  52868. * Rebuild the required buffers.
  52869. * @hidden Internal use only.
  52870. */
  52871. _rebuild(): void;
  52872. /**
  52873. * Dispose only the render target textures and post process.
  52874. */
  52875. private _disposeTextureAndPostProcesses;
  52876. /**
  52877. * Dispose the highlight layer and free resources.
  52878. */
  52879. dispose(): void;
  52880. /**
  52881. * Gets the class name of the effect layer
  52882. * @returns the string with the class name of the effect layer
  52883. */
  52884. getClassName(): string;
  52885. /**
  52886. * Creates an effect layer from parsed effect layer data
  52887. * @param parsedEffectLayer defines effect layer data
  52888. * @param scene defines the current scene
  52889. * @param rootUrl defines the root URL containing the effect layer information
  52890. * @returns a parsed effect Layer
  52891. */
  52892. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  52893. }
  52894. }
  52895. declare module BABYLON {
  52896. interface AbstractScene {
  52897. /**
  52898. * The list of effect layers (highlights/glow) added to the scene
  52899. * @see http://doc.babylonjs.com/how_to/highlight_layer
  52900. * @see http://doc.babylonjs.com/how_to/glow_layer
  52901. */
  52902. effectLayers: Array<EffectLayer>;
  52903. /**
  52904. * Removes the given effect layer from this scene.
  52905. * @param toRemove defines the effect layer to remove
  52906. * @returns the index of the removed effect layer
  52907. */
  52908. removeEffectLayer(toRemove: EffectLayer): number;
  52909. /**
  52910. * Adds the given effect layer to this scene
  52911. * @param newEffectLayer defines the effect layer to add
  52912. */
  52913. addEffectLayer(newEffectLayer: EffectLayer): void;
  52914. }
  52915. /**
  52916. * Defines the layer scene component responsible to manage any effect layers
  52917. * in a given scene.
  52918. */
  52919. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  52920. /**
  52921. * The component name helpfull to identify the component in the list of scene components.
  52922. */
  52923. readonly name: string;
  52924. /**
  52925. * The scene the component belongs to.
  52926. */
  52927. scene: Scene;
  52928. private _engine;
  52929. private _renderEffects;
  52930. private _needStencil;
  52931. private _previousStencilState;
  52932. /**
  52933. * Creates a new instance of the component for the given scene
  52934. * @param scene Defines the scene to register the component in
  52935. */
  52936. constructor(scene: Scene);
  52937. /**
  52938. * Registers the component in a given scene
  52939. */
  52940. register(): void;
  52941. /**
  52942. * Rebuilds the elements related to this component in case of
  52943. * context lost for instance.
  52944. */
  52945. rebuild(): void;
  52946. /**
  52947. * Serializes the component data to the specified json object
  52948. * @param serializationObject The object to serialize to
  52949. */
  52950. serialize(serializationObject: any): void;
  52951. /**
  52952. * Adds all the elements from the container to the scene
  52953. * @param container the container holding the elements
  52954. */
  52955. addFromContainer(container: AbstractScene): void;
  52956. /**
  52957. * Removes all the elements in the container from the scene
  52958. * @param container contains the elements to remove
  52959. * @param dispose if the removed element should be disposed (default: false)
  52960. */
  52961. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  52962. /**
  52963. * Disposes the component and the associated ressources.
  52964. */
  52965. dispose(): void;
  52966. private _isReadyForMesh;
  52967. private _renderMainTexture;
  52968. private _setStencil;
  52969. private _setStencilBack;
  52970. private _draw;
  52971. private _drawCamera;
  52972. private _drawRenderingGroup;
  52973. }
  52974. }
  52975. declare module BABYLON {
  52976. /** @hidden */
  52977. export var glowMapMergePixelShader: {
  52978. name: string;
  52979. shader: string;
  52980. };
  52981. }
  52982. declare module BABYLON {
  52983. /** @hidden */
  52984. export var glowMapMergeVertexShader: {
  52985. name: string;
  52986. shader: string;
  52987. };
  52988. }
  52989. declare module BABYLON {
  52990. interface AbstractScene {
  52991. /**
  52992. * Return a the first highlight layer of the scene with a given name.
  52993. * @param name The name of the highlight layer to look for.
  52994. * @return The highlight layer if found otherwise null.
  52995. */
  52996. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  52997. }
  52998. /**
  52999. * Glow layer options. This helps customizing the behaviour
  53000. * of the glow layer.
  53001. */
  53002. export interface IGlowLayerOptions {
  53003. /**
  53004. * Multiplication factor apply to the canvas size to compute the render target size
  53005. * used to generated the glowing objects (the smaller the faster).
  53006. */
  53007. mainTextureRatio: number;
  53008. /**
  53009. * Enforces a fixed size texture to ensure resize independant blur.
  53010. */
  53011. mainTextureFixedSize?: number;
  53012. /**
  53013. * How big is the kernel of the blur texture.
  53014. */
  53015. blurKernelSize: number;
  53016. /**
  53017. * The camera attached to the layer.
  53018. */
  53019. camera: Nullable<Camera>;
  53020. /**
  53021. * Enable MSAA by chosing the number of samples.
  53022. */
  53023. mainTextureSamples?: number;
  53024. /**
  53025. * The rendering group to draw the layer in.
  53026. */
  53027. renderingGroupId: number;
  53028. }
  53029. /**
  53030. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  53031. *
  53032. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  53033. *
  53034. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  53035. */
  53036. export class GlowLayer extends EffectLayer {
  53037. /**
  53038. * Effect Name of the layer.
  53039. */
  53040. static readonly EffectName: string;
  53041. /**
  53042. * The default blur kernel size used for the glow.
  53043. */
  53044. static DefaultBlurKernelSize: number;
  53045. /**
  53046. * The default texture size ratio used for the glow.
  53047. */
  53048. static DefaultTextureRatio: number;
  53049. /**
  53050. * Sets the kernel size of the blur.
  53051. */
  53052. set blurKernelSize(value: number);
  53053. /**
  53054. * Gets the kernel size of the blur.
  53055. */
  53056. get blurKernelSize(): number;
  53057. /**
  53058. * Sets the glow intensity.
  53059. */
  53060. set intensity(value: number);
  53061. /**
  53062. * Gets the glow intensity.
  53063. */
  53064. get intensity(): number;
  53065. private _options;
  53066. private _intensity;
  53067. private _horizontalBlurPostprocess1;
  53068. private _verticalBlurPostprocess1;
  53069. private _horizontalBlurPostprocess2;
  53070. private _verticalBlurPostprocess2;
  53071. private _blurTexture1;
  53072. private _blurTexture2;
  53073. private _postProcesses1;
  53074. private _postProcesses2;
  53075. private _includedOnlyMeshes;
  53076. private _excludedMeshes;
  53077. private _meshesUsingTheirOwnMaterials;
  53078. /**
  53079. * Callback used to let the user override the color selection on a per mesh basis
  53080. */
  53081. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  53082. /**
  53083. * Callback used to let the user override the texture selection on a per mesh basis
  53084. */
  53085. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  53086. /**
  53087. * Instantiates a new glow Layer and references it to the scene.
  53088. * @param name The name of the layer
  53089. * @param scene The scene to use the layer in
  53090. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  53091. */
  53092. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  53093. /**
  53094. * Get the effect name of the layer.
  53095. * @return The effect name
  53096. */
  53097. getEffectName(): string;
  53098. /**
  53099. * Create the merge effect. This is the shader use to blit the information back
  53100. * to the main canvas at the end of the scene rendering.
  53101. */
  53102. protected _createMergeEffect(): Effect;
  53103. /**
  53104. * Creates the render target textures and post processes used in the glow layer.
  53105. */
  53106. protected _createTextureAndPostProcesses(): void;
  53107. /**
  53108. * Checks for the readiness of the element composing the layer.
  53109. * @param subMesh the mesh to check for
  53110. * @param useInstances specify wether or not to use instances to render the mesh
  53111. * @param emissiveTexture the associated emissive texture used to generate the glow
  53112. * @return true if ready otherwise, false
  53113. */
  53114. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  53115. /**
  53116. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  53117. */
  53118. needStencil(): boolean;
  53119. /**
  53120. * Returns true if the mesh can be rendered, otherwise false.
  53121. * @param mesh The mesh to render
  53122. * @param material The material used on the mesh
  53123. * @returns true if it can be rendered otherwise false
  53124. */
  53125. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  53126. /**
  53127. * Implementation specific of rendering the generating effect on the main canvas.
  53128. * @param effect The effect used to render through
  53129. */
  53130. protected _internalRender(effect: Effect): void;
  53131. /**
  53132. * Sets the required values for both the emissive texture and and the main color.
  53133. */
  53134. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  53135. /**
  53136. * Returns true if the mesh should render, otherwise false.
  53137. * @param mesh The mesh to render
  53138. * @returns true if it should render otherwise false
  53139. */
  53140. protected _shouldRenderMesh(mesh: Mesh): boolean;
  53141. /**
  53142. * Adds specific effects defines.
  53143. * @param defines The defines to add specifics to.
  53144. */
  53145. protected _addCustomEffectDefines(defines: string[]): void;
  53146. /**
  53147. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  53148. * @param mesh The mesh to exclude from the glow layer
  53149. */
  53150. addExcludedMesh(mesh: Mesh): void;
  53151. /**
  53152. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  53153. * @param mesh The mesh to remove
  53154. */
  53155. removeExcludedMesh(mesh: Mesh): void;
  53156. /**
  53157. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  53158. * @param mesh The mesh to include in the glow layer
  53159. */
  53160. addIncludedOnlyMesh(mesh: Mesh): void;
  53161. /**
  53162. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  53163. * @param mesh The mesh to remove
  53164. */
  53165. removeIncludedOnlyMesh(mesh: Mesh): void;
  53166. /**
  53167. * Determine if a given mesh will be used in the glow layer
  53168. * @param mesh The mesh to test
  53169. * @returns true if the mesh will be highlighted by the current glow layer
  53170. */
  53171. hasMesh(mesh: AbstractMesh): boolean;
  53172. /**
  53173. * Defines whether the current material of the mesh should be use to render the effect.
  53174. * @param mesh defines the current mesh to render
  53175. */
  53176. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  53177. /**
  53178. * Add a mesh to be rendered through its own material and not with emissive only.
  53179. * @param mesh The mesh for which we need to use its material
  53180. */
  53181. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  53182. /**
  53183. * Remove a mesh from being rendered through its own material and not with emissive only.
  53184. * @param mesh The mesh for which we need to not use its material
  53185. */
  53186. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  53187. /**
  53188. * Free any resources and references associated to a mesh.
  53189. * Internal use
  53190. * @param mesh The mesh to free.
  53191. * @hidden
  53192. */
  53193. _disposeMesh(mesh: Mesh): void;
  53194. /**
  53195. * Gets the class name of the effect layer
  53196. * @returns the string with the class name of the effect layer
  53197. */
  53198. getClassName(): string;
  53199. /**
  53200. * Serializes this glow layer
  53201. * @returns a serialized glow layer object
  53202. */
  53203. serialize(): any;
  53204. /**
  53205. * Creates a Glow Layer from parsed glow layer data
  53206. * @param parsedGlowLayer defines glow layer data
  53207. * @param scene defines the current scene
  53208. * @param rootUrl defines the root URL containing the glow layer information
  53209. * @returns a parsed Glow Layer
  53210. */
  53211. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  53212. }
  53213. }
  53214. declare module BABYLON {
  53215. /** @hidden */
  53216. export var glowBlurPostProcessPixelShader: {
  53217. name: string;
  53218. shader: string;
  53219. };
  53220. }
  53221. declare module BABYLON {
  53222. interface AbstractScene {
  53223. /**
  53224. * Return a the first highlight layer of the scene with a given name.
  53225. * @param name The name of the highlight layer to look for.
  53226. * @return The highlight layer if found otherwise null.
  53227. */
  53228. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  53229. }
  53230. /**
  53231. * Highlight layer options. This helps customizing the behaviour
  53232. * of the highlight layer.
  53233. */
  53234. export interface IHighlightLayerOptions {
  53235. /**
  53236. * Multiplication factor apply to the canvas size to compute the render target size
  53237. * used to generated the glowing objects (the smaller the faster).
  53238. */
  53239. mainTextureRatio: number;
  53240. /**
  53241. * Enforces a fixed size texture to ensure resize independant blur.
  53242. */
  53243. mainTextureFixedSize?: number;
  53244. /**
  53245. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  53246. * of the picture to blur (the smaller the faster).
  53247. */
  53248. blurTextureSizeRatio: number;
  53249. /**
  53250. * How big in texel of the blur texture is the vertical blur.
  53251. */
  53252. blurVerticalSize: number;
  53253. /**
  53254. * How big in texel of the blur texture is the horizontal blur.
  53255. */
  53256. blurHorizontalSize: number;
  53257. /**
  53258. * Alpha blending mode used to apply the blur. Default is combine.
  53259. */
  53260. alphaBlendingMode: number;
  53261. /**
  53262. * The camera attached to the layer.
  53263. */
  53264. camera: Nullable<Camera>;
  53265. /**
  53266. * Should we display highlight as a solid stroke?
  53267. */
  53268. isStroke?: boolean;
  53269. /**
  53270. * The rendering group to draw the layer in.
  53271. */
  53272. renderingGroupId: number;
  53273. }
  53274. /**
  53275. * The highlight layer Helps adding a glow effect around a mesh.
  53276. *
  53277. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  53278. * glowy meshes to your scene.
  53279. *
  53280. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  53281. */
  53282. export class HighlightLayer extends EffectLayer {
  53283. name: string;
  53284. /**
  53285. * Effect Name of the highlight layer.
  53286. */
  53287. static readonly EffectName: string;
  53288. /**
  53289. * The neutral color used during the preparation of the glow effect.
  53290. * This is black by default as the blend operation is a blend operation.
  53291. */
  53292. static NeutralColor: Color4;
  53293. /**
  53294. * Stencil value used for glowing meshes.
  53295. */
  53296. static GlowingMeshStencilReference: number;
  53297. /**
  53298. * Stencil value used for the other meshes in the scene.
  53299. */
  53300. static NormalMeshStencilReference: number;
  53301. /**
  53302. * Specifies whether or not the inner glow is ACTIVE in the layer.
  53303. */
  53304. innerGlow: boolean;
  53305. /**
  53306. * Specifies whether or not the outer glow is ACTIVE in the layer.
  53307. */
  53308. outerGlow: boolean;
  53309. /**
  53310. * Specifies the horizontal size of the blur.
  53311. */
  53312. set blurHorizontalSize(value: number);
  53313. /**
  53314. * Specifies the vertical size of the blur.
  53315. */
  53316. set blurVerticalSize(value: number);
  53317. /**
  53318. * Gets the horizontal size of the blur.
  53319. */
  53320. get blurHorizontalSize(): number;
  53321. /**
  53322. * Gets the vertical size of the blur.
  53323. */
  53324. get blurVerticalSize(): number;
  53325. /**
  53326. * An event triggered when the highlight layer is being blurred.
  53327. */
  53328. onBeforeBlurObservable: Observable<HighlightLayer>;
  53329. /**
  53330. * An event triggered when the highlight layer has been blurred.
  53331. */
  53332. onAfterBlurObservable: Observable<HighlightLayer>;
  53333. private _instanceGlowingMeshStencilReference;
  53334. private _options;
  53335. private _downSamplePostprocess;
  53336. private _horizontalBlurPostprocess;
  53337. private _verticalBlurPostprocess;
  53338. private _blurTexture;
  53339. private _meshes;
  53340. private _excludedMeshes;
  53341. /**
  53342. * Instantiates a new highlight Layer and references it to the scene..
  53343. * @param name The name of the layer
  53344. * @param scene The scene to use the layer in
  53345. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  53346. */
  53347. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  53348. /**
  53349. * Get the effect name of the layer.
  53350. * @return The effect name
  53351. */
  53352. getEffectName(): string;
  53353. /**
  53354. * Create the merge effect. This is the shader use to blit the information back
  53355. * to the main canvas at the end of the scene rendering.
  53356. */
  53357. protected _createMergeEffect(): Effect;
  53358. /**
  53359. * Creates the render target textures and post processes used in the highlight layer.
  53360. */
  53361. protected _createTextureAndPostProcesses(): void;
  53362. /**
  53363. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  53364. */
  53365. needStencil(): boolean;
  53366. /**
  53367. * Checks for the readiness of the element composing the layer.
  53368. * @param subMesh the mesh to check for
  53369. * @param useInstances specify wether or not to use instances to render the mesh
  53370. * @param emissiveTexture the associated emissive texture used to generate the glow
  53371. * @return true if ready otherwise, false
  53372. */
  53373. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  53374. /**
  53375. * Implementation specific of rendering the generating effect on the main canvas.
  53376. * @param effect The effect used to render through
  53377. */
  53378. protected _internalRender(effect: Effect): void;
  53379. /**
  53380. * Returns true if the layer contains information to display, otherwise false.
  53381. */
  53382. shouldRender(): boolean;
  53383. /**
  53384. * Returns true if the mesh should render, otherwise false.
  53385. * @param mesh The mesh to render
  53386. * @returns true if it should render otherwise false
  53387. */
  53388. protected _shouldRenderMesh(mesh: Mesh): boolean;
  53389. /**
  53390. * Sets the required values for both the emissive texture and and the main color.
  53391. */
  53392. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  53393. /**
  53394. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  53395. * @param mesh The mesh to exclude from the highlight layer
  53396. */
  53397. addExcludedMesh(mesh: Mesh): void;
  53398. /**
  53399. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  53400. * @param mesh The mesh to highlight
  53401. */
  53402. removeExcludedMesh(mesh: Mesh): void;
  53403. /**
  53404. * Determine if a given mesh will be highlighted by the current HighlightLayer
  53405. * @param mesh mesh to test
  53406. * @returns true if the mesh will be highlighted by the current HighlightLayer
  53407. */
  53408. hasMesh(mesh: AbstractMesh): boolean;
  53409. /**
  53410. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  53411. * @param mesh The mesh to highlight
  53412. * @param color The color of the highlight
  53413. * @param glowEmissiveOnly Extract the glow from the emissive texture
  53414. */
  53415. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  53416. /**
  53417. * Remove a mesh from the highlight layer in order to make it stop glowing.
  53418. * @param mesh The mesh to highlight
  53419. */
  53420. removeMesh(mesh: Mesh): void;
  53421. /**
  53422. * Force the stencil to the normal expected value for none glowing parts
  53423. */
  53424. private _defaultStencilReference;
  53425. /**
  53426. * Free any resources and references associated to a mesh.
  53427. * Internal use
  53428. * @param mesh The mesh to free.
  53429. * @hidden
  53430. */
  53431. _disposeMesh(mesh: Mesh): void;
  53432. /**
  53433. * Dispose the highlight layer and free resources.
  53434. */
  53435. dispose(): void;
  53436. /**
  53437. * Gets the class name of the effect layer
  53438. * @returns the string with the class name of the effect layer
  53439. */
  53440. getClassName(): string;
  53441. /**
  53442. * Serializes this Highlight layer
  53443. * @returns a serialized Highlight layer object
  53444. */
  53445. serialize(): any;
  53446. /**
  53447. * Creates a Highlight layer from parsed Highlight layer data
  53448. * @param parsedHightlightLayer defines the Highlight layer data
  53449. * @param scene defines the current scene
  53450. * @param rootUrl defines the root URL containing the Highlight layer information
  53451. * @returns a parsed Highlight layer
  53452. */
  53453. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  53454. }
  53455. }
  53456. declare module BABYLON {
  53457. interface AbstractScene {
  53458. /**
  53459. * The list of layers (background and foreground) of the scene
  53460. */
  53461. layers: Array<Layer>;
  53462. }
  53463. /**
  53464. * Defines the layer scene component responsible to manage any layers
  53465. * in a given scene.
  53466. */
  53467. export class LayerSceneComponent implements ISceneComponent {
  53468. /**
  53469. * The component name helpfull to identify the component in the list of scene components.
  53470. */
  53471. readonly name: string;
  53472. /**
  53473. * The scene the component belongs to.
  53474. */
  53475. scene: Scene;
  53476. private _engine;
  53477. /**
  53478. * Creates a new instance of the component for the given scene
  53479. * @param scene Defines the scene to register the component in
  53480. */
  53481. constructor(scene: Scene);
  53482. /**
  53483. * Registers the component in a given scene
  53484. */
  53485. register(): void;
  53486. /**
  53487. * Rebuilds the elements related to this component in case of
  53488. * context lost for instance.
  53489. */
  53490. rebuild(): void;
  53491. /**
  53492. * Disposes the component and the associated ressources.
  53493. */
  53494. dispose(): void;
  53495. private _draw;
  53496. private _drawCameraPredicate;
  53497. private _drawCameraBackground;
  53498. private _drawCameraForeground;
  53499. private _drawRenderTargetPredicate;
  53500. private _drawRenderTargetBackground;
  53501. private _drawRenderTargetForeground;
  53502. /**
  53503. * Adds all the elements from the container to the scene
  53504. * @param container the container holding the elements
  53505. */
  53506. addFromContainer(container: AbstractScene): void;
  53507. /**
  53508. * Removes all the elements in the container from the scene
  53509. * @param container contains the elements to remove
  53510. * @param dispose if the removed element should be disposed (default: false)
  53511. */
  53512. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  53513. }
  53514. }
  53515. declare module BABYLON {
  53516. /** @hidden */
  53517. export var layerPixelShader: {
  53518. name: string;
  53519. shader: string;
  53520. };
  53521. }
  53522. declare module BABYLON {
  53523. /** @hidden */
  53524. export var layerVertexShader: {
  53525. name: string;
  53526. shader: string;
  53527. };
  53528. }
  53529. declare module BABYLON {
  53530. /**
  53531. * This represents a full screen 2d layer.
  53532. * This can be useful to display a picture in the background of your scene for instance.
  53533. * @see https://www.babylonjs-playground.com/#08A2BS#1
  53534. */
  53535. export class Layer {
  53536. /**
  53537. * Define the name of the layer.
  53538. */
  53539. name: string;
  53540. /**
  53541. * Define the texture the layer should display.
  53542. */
  53543. texture: Nullable<Texture>;
  53544. /**
  53545. * Is the layer in background or foreground.
  53546. */
  53547. isBackground: boolean;
  53548. /**
  53549. * Define the color of the layer (instead of texture).
  53550. */
  53551. color: Color4;
  53552. /**
  53553. * Define the scale of the layer in order to zoom in out of the texture.
  53554. */
  53555. scale: Vector2;
  53556. /**
  53557. * Define an offset for the layer in order to shift the texture.
  53558. */
  53559. offset: Vector2;
  53560. /**
  53561. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  53562. */
  53563. alphaBlendingMode: number;
  53564. /**
  53565. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  53566. * Alpha test will not mix with the background color in case of transparency.
  53567. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  53568. */
  53569. alphaTest: boolean;
  53570. /**
  53571. * Define a mask to restrict the layer to only some of the scene cameras.
  53572. */
  53573. layerMask: number;
  53574. /**
  53575. * Define the list of render target the layer is visible into.
  53576. */
  53577. renderTargetTextures: RenderTargetTexture[];
  53578. /**
  53579. * Define if the layer is only used in renderTarget or if it also
  53580. * renders in the main frame buffer of the canvas.
  53581. */
  53582. renderOnlyInRenderTargetTextures: boolean;
  53583. private _scene;
  53584. private _vertexBuffers;
  53585. private _indexBuffer;
  53586. private _effect;
  53587. private _previousDefines;
  53588. /**
  53589. * An event triggered when the layer is disposed.
  53590. */
  53591. onDisposeObservable: Observable<Layer>;
  53592. private _onDisposeObserver;
  53593. /**
  53594. * Back compatibility with callback before the onDisposeObservable existed.
  53595. * The set callback will be triggered when the layer has been disposed.
  53596. */
  53597. set onDispose(callback: () => void);
  53598. /**
  53599. * An event triggered before rendering the scene
  53600. */
  53601. onBeforeRenderObservable: Observable<Layer>;
  53602. private _onBeforeRenderObserver;
  53603. /**
  53604. * Back compatibility with callback before the onBeforeRenderObservable existed.
  53605. * The set callback will be triggered just before rendering the layer.
  53606. */
  53607. set onBeforeRender(callback: () => void);
  53608. /**
  53609. * An event triggered after rendering the scene
  53610. */
  53611. onAfterRenderObservable: Observable<Layer>;
  53612. private _onAfterRenderObserver;
  53613. /**
  53614. * Back compatibility with callback before the onAfterRenderObservable existed.
  53615. * The set callback will be triggered just after rendering the layer.
  53616. */
  53617. set onAfterRender(callback: () => void);
  53618. /**
  53619. * Instantiates a new layer.
  53620. * This represents a full screen 2d layer.
  53621. * This can be useful to display a picture in the background of your scene for instance.
  53622. * @see https://www.babylonjs-playground.com/#08A2BS#1
  53623. * @param name Define the name of the layer in the scene
  53624. * @param imgUrl Define the url of the texture to display in the layer
  53625. * @param scene Define the scene the layer belongs to
  53626. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  53627. * @param color Defines a color for the layer
  53628. */
  53629. constructor(
  53630. /**
  53631. * Define the name of the layer.
  53632. */
  53633. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  53634. private _createIndexBuffer;
  53635. /** @hidden */
  53636. _rebuild(): void;
  53637. /**
  53638. * Renders the layer in the scene.
  53639. */
  53640. render(): void;
  53641. /**
  53642. * Disposes and releases the associated ressources.
  53643. */
  53644. dispose(): void;
  53645. }
  53646. }
  53647. declare module BABYLON {
  53648. /** @hidden */
  53649. export var lensFlarePixelShader: {
  53650. name: string;
  53651. shader: string;
  53652. };
  53653. }
  53654. declare module BABYLON {
  53655. /** @hidden */
  53656. export var lensFlareVertexShader: {
  53657. name: string;
  53658. shader: string;
  53659. };
  53660. }
  53661. declare module BABYLON {
  53662. /**
  53663. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  53664. * It is usually composed of several `lensFlare`.
  53665. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53666. */
  53667. export class LensFlareSystem {
  53668. /**
  53669. * Define the name of the lens flare system
  53670. */
  53671. name: string;
  53672. /**
  53673. * List of lens flares used in this system.
  53674. */
  53675. lensFlares: LensFlare[];
  53676. /**
  53677. * Define a limit from the border the lens flare can be visible.
  53678. */
  53679. borderLimit: number;
  53680. /**
  53681. * Define a viewport border we do not want to see the lens flare in.
  53682. */
  53683. viewportBorder: number;
  53684. /**
  53685. * Define a predicate which could limit the list of meshes able to occlude the effect.
  53686. */
  53687. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  53688. /**
  53689. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  53690. */
  53691. layerMask: number;
  53692. /**
  53693. * Define the id of the lens flare system in the scene.
  53694. * (equal to name by default)
  53695. */
  53696. id: string;
  53697. private _scene;
  53698. private _emitter;
  53699. private _vertexBuffers;
  53700. private _indexBuffer;
  53701. private _effect;
  53702. private _positionX;
  53703. private _positionY;
  53704. private _isEnabled;
  53705. /** @hidden */
  53706. static _SceneComponentInitialization: (scene: Scene) => void;
  53707. /**
  53708. * Instantiates a lens flare system.
  53709. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  53710. * It is usually composed of several `lensFlare`.
  53711. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53712. * @param name Define the name of the lens flare system in the scene
  53713. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  53714. * @param scene Define the scene the lens flare system belongs to
  53715. */
  53716. constructor(
  53717. /**
  53718. * Define the name of the lens flare system
  53719. */
  53720. name: string, emitter: any, scene: Scene);
  53721. /**
  53722. * Define if the lens flare system is enabled.
  53723. */
  53724. get isEnabled(): boolean;
  53725. set isEnabled(value: boolean);
  53726. /**
  53727. * Get the scene the effects belongs to.
  53728. * @returns the scene holding the lens flare system
  53729. */
  53730. getScene(): Scene;
  53731. /**
  53732. * Get the emitter of the lens flare system.
  53733. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  53734. * @returns the emitter of the lens flare system
  53735. */
  53736. getEmitter(): any;
  53737. /**
  53738. * Set 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. * @param newEmitter Define the new emitter of the system
  53741. */
  53742. setEmitter(newEmitter: any): void;
  53743. /**
  53744. * Get the lens flare system emitter position.
  53745. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  53746. * @returns the position
  53747. */
  53748. getEmitterPosition(): Vector3;
  53749. /**
  53750. * @hidden
  53751. */
  53752. computeEffectivePosition(globalViewport: Viewport): boolean;
  53753. /** @hidden */
  53754. _isVisible(): boolean;
  53755. /**
  53756. * @hidden
  53757. */
  53758. render(): boolean;
  53759. /**
  53760. * Dispose and release the lens flare with its associated resources.
  53761. */
  53762. dispose(): void;
  53763. /**
  53764. * Parse a lens flare system from a JSON repressentation
  53765. * @param parsedLensFlareSystem Define the JSON to parse
  53766. * @param scene Define the scene the parsed system should be instantiated in
  53767. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  53768. * @returns the parsed system
  53769. */
  53770. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  53771. /**
  53772. * Serialize the current Lens Flare System into a JSON representation.
  53773. * @returns the serialized JSON
  53774. */
  53775. serialize(): any;
  53776. }
  53777. }
  53778. declare module BABYLON {
  53779. /**
  53780. * This represents one of the lens effect in a `lensFlareSystem`.
  53781. * It controls one of the indiviual texture used in the effect.
  53782. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53783. */
  53784. export class LensFlare {
  53785. /**
  53786. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  53787. */
  53788. size: number;
  53789. /**
  53790. * 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.
  53791. */
  53792. position: number;
  53793. /**
  53794. * Define the lens color.
  53795. */
  53796. color: Color3;
  53797. /**
  53798. * Define the lens texture.
  53799. */
  53800. texture: Nullable<Texture>;
  53801. /**
  53802. * Define the alpha mode to render this particular lens.
  53803. */
  53804. alphaMode: number;
  53805. private _system;
  53806. /**
  53807. * Creates a new Lens Flare.
  53808. * This represents one of the lens effect in a `lensFlareSystem`.
  53809. * It controls one of the indiviual texture used in the effect.
  53810. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53811. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  53812. * @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.
  53813. * @param color Define the lens color
  53814. * @param imgUrl Define the lens texture url
  53815. * @param system Define the `lensFlareSystem` this flare is part of
  53816. * @returns The newly created Lens Flare
  53817. */
  53818. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  53819. /**
  53820. * Instantiates a new Lens Flare.
  53821. * This represents one of the lens effect in a `lensFlareSystem`.
  53822. * It controls one of the indiviual texture used in the effect.
  53823. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53824. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  53825. * @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.
  53826. * @param color Define the lens color
  53827. * @param imgUrl Define the lens texture url
  53828. * @param system Define the `lensFlareSystem` this flare is part of
  53829. */
  53830. constructor(
  53831. /**
  53832. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  53833. */
  53834. size: number,
  53835. /**
  53836. * 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.
  53837. */
  53838. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  53839. /**
  53840. * Dispose and release the lens flare with its associated resources.
  53841. */
  53842. dispose(): void;
  53843. }
  53844. }
  53845. declare module BABYLON {
  53846. interface AbstractScene {
  53847. /**
  53848. * The list of lens flare system added to the scene
  53849. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53850. */
  53851. lensFlareSystems: Array<LensFlareSystem>;
  53852. /**
  53853. * Removes the given lens flare system from this scene.
  53854. * @param toRemove The lens flare system to remove
  53855. * @returns The index of the removed lens flare system
  53856. */
  53857. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  53858. /**
  53859. * Adds the given lens flare system to this scene
  53860. * @param newLensFlareSystem The lens flare system to add
  53861. */
  53862. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  53863. /**
  53864. * Gets a lens flare system using its name
  53865. * @param name defines the name to look for
  53866. * @returns the lens flare system or null if not found
  53867. */
  53868. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  53869. /**
  53870. * Gets a lens flare system using its id
  53871. * @param id defines the id to look for
  53872. * @returns the lens flare system or null if not found
  53873. */
  53874. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  53875. }
  53876. /**
  53877. * Defines the lens flare scene component responsible to manage any lens flares
  53878. * in a given scene.
  53879. */
  53880. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  53881. /**
  53882. * The component name helpfull to identify the component in the list of scene components.
  53883. */
  53884. readonly name: string;
  53885. /**
  53886. * The scene the component belongs to.
  53887. */
  53888. scene: Scene;
  53889. /**
  53890. * Creates a new instance of the component for the given scene
  53891. * @param scene Defines the scene to register the component in
  53892. */
  53893. constructor(scene: Scene);
  53894. /**
  53895. * Registers the component in a given scene
  53896. */
  53897. register(): void;
  53898. /**
  53899. * Rebuilds the elements related to this component in case of
  53900. * context lost for instance.
  53901. */
  53902. rebuild(): void;
  53903. /**
  53904. * Adds all the elements from the container to the scene
  53905. * @param container the container holding the elements
  53906. */
  53907. addFromContainer(container: AbstractScene): void;
  53908. /**
  53909. * Removes all the elements in the container from the scene
  53910. * @param container contains the elements to remove
  53911. * @param dispose if the removed element should be disposed (default: false)
  53912. */
  53913. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  53914. /**
  53915. * Serializes the component data to the specified json object
  53916. * @param serializationObject The object to serialize to
  53917. */
  53918. serialize(serializationObject: any): void;
  53919. /**
  53920. * Disposes the component and the associated ressources.
  53921. */
  53922. dispose(): void;
  53923. private _draw;
  53924. }
  53925. }
  53926. declare module BABYLON {
  53927. /** @hidden */
  53928. export var depthPixelShader: {
  53929. name: string;
  53930. shader: string;
  53931. };
  53932. }
  53933. declare module BABYLON {
  53934. /** @hidden */
  53935. export var depthVertexShader: {
  53936. name: string;
  53937. shader: string;
  53938. };
  53939. }
  53940. declare module BABYLON {
  53941. /**
  53942. * This represents a depth renderer in Babylon.
  53943. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  53944. */
  53945. export class DepthRenderer {
  53946. private _scene;
  53947. private _depthMap;
  53948. private _effect;
  53949. private readonly _storeNonLinearDepth;
  53950. private readonly _clearColor;
  53951. /** Get if the depth renderer is using packed depth or not */
  53952. readonly isPacked: boolean;
  53953. private _cachedDefines;
  53954. private _camera;
  53955. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  53956. enabled: boolean;
  53957. /**
  53958. * Specifiess that the depth renderer will only be used within
  53959. * the camera it is created for.
  53960. * This can help forcing its rendering during the camera processing.
  53961. */
  53962. useOnlyInActiveCamera: boolean;
  53963. /** @hidden */
  53964. static _SceneComponentInitialization: (scene: Scene) => void;
  53965. /**
  53966. * Instantiates a depth renderer
  53967. * @param scene The scene the renderer belongs to
  53968. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  53969. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  53970. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  53971. */
  53972. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  53973. /**
  53974. * Creates the depth rendering effect and checks if the effect is ready.
  53975. * @param subMesh The submesh to be used to render the depth map of
  53976. * @param useInstances If multiple world instances should be used
  53977. * @returns if the depth renderer is ready to render the depth map
  53978. */
  53979. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  53980. /**
  53981. * Gets the texture which the depth map will be written to.
  53982. * @returns The depth map texture
  53983. */
  53984. getDepthMap(): RenderTargetTexture;
  53985. /**
  53986. * Disposes of the depth renderer.
  53987. */
  53988. dispose(): void;
  53989. }
  53990. }
  53991. declare module BABYLON {
  53992. /** @hidden */
  53993. export var minmaxReduxPixelShader: {
  53994. name: string;
  53995. shader: string;
  53996. };
  53997. }
  53998. declare module BABYLON {
  53999. /**
  54000. * This class computes a min/max reduction from a texture: it means it computes the minimum
  54001. * and maximum values from all values of the texture.
  54002. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  54003. * The source values are read from the red channel of the texture.
  54004. */
  54005. export class MinMaxReducer {
  54006. /**
  54007. * Observable triggered when the computation has been performed
  54008. */
  54009. onAfterReductionPerformed: Observable<{
  54010. min: number;
  54011. max: number;
  54012. }>;
  54013. protected _camera: Camera;
  54014. protected _sourceTexture: Nullable<RenderTargetTexture>;
  54015. protected _reductionSteps: Nullable<Array<PostProcess>>;
  54016. protected _postProcessManager: PostProcessManager;
  54017. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  54018. protected _forceFullscreenViewport: boolean;
  54019. /**
  54020. * Creates a min/max reducer
  54021. * @param camera The camera to use for the post processes
  54022. */
  54023. constructor(camera: Camera);
  54024. /**
  54025. * Gets the texture used to read the values from.
  54026. */
  54027. get sourceTexture(): Nullable<RenderTargetTexture>;
  54028. /**
  54029. * Sets the source texture to read the values from.
  54030. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  54031. * because in such textures '1' value must not be taken into account to compute the maximum
  54032. * as this value is used to clear the texture.
  54033. * Note that the computation is not activated by calling this function, you must call activate() for that!
  54034. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  54035. * @param depthRedux Indicates if the texture is a depth texture or not
  54036. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  54037. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  54038. */
  54039. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  54040. /**
  54041. * Defines the refresh rate of the computation.
  54042. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  54043. */
  54044. get refreshRate(): number;
  54045. set refreshRate(value: number);
  54046. protected _activated: boolean;
  54047. /**
  54048. * Gets the activation status of the reducer
  54049. */
  54050. get activated(): boolean;
  54051. /**
  54052. * Activates the reduction computation.
  54053. * When activated, the observers registered in onAfterReductionPerformed are
  54054. * called after the compuation is performed
  54055. */
  54056. activate(): void;
  54057. /**
  54058. * Deactivates the reduction computation.
  54059. */
  54060. deactivate(): void;
  54061. /**
  54062. * Disposes the min/max reducer
  54063. * @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.
  54064. */
  54065. dispose(disposeAll?: boolean): void;
  54066. }
  54067. }
  54068. declare module BABYLON {
  54069. /**
  54070. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  54071. */
  54072. export class DepthReducer extends MinMaxReducer {
  54073. private _depthRenderer;
  54074. private _depthRendererId;
  54075. /**
  54076. * Gets the depth renderer used for the computation.
  54077. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  54078. */
  54079. get depthRenderer(): Nullable<DepthRenderer>;
  54080. /**
  54081. * Creates a depth reducer
  54082. * @param camera The camera used to render the depth texture
  54083. */
  54084. constructor(camera: Camera);
  54085. /**
  54086. * Sets the depth renderer to use to generate the depth map
  54087. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  54088. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  54089. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  54090. */
  54091. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  54092. /** @hidden */
  54093. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  54094. /**
  54095. * Activates the reduction computation.
  54096. * When activated, the observers registered in onAfterReductionPerformed are
  54097. * called after the compuation is performed
  54098. */
  54099. activate(): void;
  54100. /**
  54101. * Deactivates the reduction computation.
  54102. */
  54103. deactivate(): void;
  54104. /**
  54105. * Disposes the depth reducer
  54106. * @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.
  54107. */
  54108. dispose(disposeAll?: boolean): void;
  54109. }
  54110. }
  54111. declare module BABYLON {
  54112. /**
  54113. * A CSM implementation allowing casting shadows on large scenes.
  54114. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  54115. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  54116. */
  54117. export class CascadedShadowGenerator extends ShadowGenerator {
  54118. private static readonly frustumCornersNDCSpace;
  54119. /**
  54120. * Name of the CSM class
  54121. */
  54122. static CLASSNAME: string;
  54123. /**
  54124. * Defines the default number of cascades used by the CSM.
  54125. */
  54126. static readonly DEFAULT_CASCADES_COUNT: number;
  54127. /**
  54128. * Defines the minimum number of cascades used by the CSM.
  54129. */
  54130. static readonly MIN_CASCADES_COUNT: number;
  54131. /**
  54132. * Defines the maximum number of cascades used by the CSM.
  54133. */
  54134. static readonly MAX_CASCADES_COUNT: number;
  54135. protected _validateFilter(filter: number): number;
  54136. /**
  54137. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  54138. */
  54139. penumbraDarkness: number;
  54140. private _numCascades;
  54141. /**
  54142. * Gets or set the number of cascades used by the CSM.
  54143. */
  54144. get numCascades(): number;
  54145. set numCascades(value: number);
  54146. /**
  54147. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  54148. * The trade off is that you loose some precision in the shadow rendering when enabling this setting.
  54149. */
  54150. stabilizeCascades: boolean;
  54151. private _freezeShadowCastersBoundingInfo;
  54152. private _freezeShadowCastersBoundingInfoObservable;
  54153. /**
  54154. * Enables or disables the shadow casters bounding info computation.
  54155. * If your shadow casters don't move, you can disable this feature.
  54156. * If it is enabled, the bounding box computation is done every frame.
  54157. */
  54158. get freezeShadowCastersBoundingInfo(): boolean;
  54159. set freezeShadowCastersBoundingInfo(freeze: boolean);
  54160. private _scbiMin;
  54161. private _scbiMax;
  54162. protected _computeShadowCastersBoundingInfo(): void;
  54163. protected _shadowCastersBoundingInfo: BoundingInfo;
  54164. /**
  54165. * Gets or sets the shadow casters bounding info.
  54166. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  54167. * so that the system won't overwrite the bounds you provide
  54168. */
  54169. get shadowCastersBoundingInfo(): BoundingInfo;
  54170. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  54171. protected _breaksAreDirty: boolean;
  54172. protected _minDistance: number;
  54173. protected _maxDistance: number;
  54174. /**
  54175. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  54176. *
  54177. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  54178. * If you don't know these values, simply leave them to their defaults and don't call this function.
  54179. * @param min minimal distance for the breaks (default to 0.)
  54180. * @param max maximal distance for the breaks (default to 1.)
  54181. */
  54182. setMinMaxDistance(min: number, max: number): void;
  54183. /** Gets the minimal distance used in the cascade break computation */
  54184. get minDistance(): number;
  54185. /** Gets the maximal distance used in the cascade break computation */
  54186. get maxDistance(): number;
  54187. /**
  54188. * Gets the class name of that object
  54189. * @returns "CascadedShadowGenerator"
  54190. */
  54191. getClassName(): string;
  54192. private _cascadeMinExtents;
  54193. private _cascadeMaxExtents;
  54194. /**
  54195. * Gets a cascade minimum extents
  54196. * @param cascadeIndex index of the cascade
  54197. * @returns the minimum cascade extents
  54198. */
  54199. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  54200. /**
  54201. * Gets a cascade maximum extents
  54202. * @param cascadeIndex index of the cascade
  54203. * @returns the maximum cascade extents
  54204. */
  54205. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  54206. private _cascades;
  54207. private _currentLayer;
  54208. private _viewSpaceFrustumsZ;
  54209. private _viewMatrices;
  54210. private _projectionMatrices;
  54211. private _transformMatrices;
  54212. private _transformMatricesAsArray;
  54213. private _frustumLengths;
  54214. private _lightSizeUVCorrection;
  54215. private _depthCorrection;
  54216. private _frustumCornersWorldSpace;
  54217. private _frustumCenter;
  54218. private _shadowCameraPos;
  54219. private _shadowMaxZ;
  54220. /**
  54221. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  54222. * It defaults to camera.maxZ
  54223. */
  54224. get shadowMaxZ(): number;
  54225. /**
  54226. * Sets the shadow max z distance.
  54227. */
  54228. set shadowMaxZ(value: number);
  54229. protected _debug: boolean;
  54230. /**
  54231. * Gets or sets the debug flag.
  54232. * When enabled, the cascades are materialized by different colors on the screen.
  54233. */
  54234. get debug(): boolean;
  54235. set debug(dbg: boolean);
  54236. private _depthClamp;
  54237. /**
  54238. * Gets or sets the depth clamping value.
  54239. *
  54240. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  54241. * to account for the shadow casters far away.
  54242. *
  54243. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  54244. */
  54245. get depthClamp(): boolean;
  54246. set depthClamp(value: boolean);
  54247. private _cascadeBlendPercentage;
  54248. /**
  54249. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  54250. * It defaults to 0.1 (10% blending).
  54251. */
  54252. get cascadeBlendPercentage(): number;
  54253. set cascadeBlendPercentage(value: number);
  54254. private _lambda;
  54255. /**
  54256. * Gets or set the lambda parameter.
  54257. * This parameter is used to split the camera frustum and create the cascades.
  54258. * 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.
  54259. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  54260. */
  54261. get lambda(): number;
  54262. set lambda(value: number);
  54263. /**
  54264. * Gets the view matrix corresponding to a given cascade
  54265. * @param cascadeNum cascade to retrieve the view matrix from
  54266. * @returns the cascade view matrix
  54267. */
  54268. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  54269. /**
  54270. * Gets the projection matrix corresponding to a given cascade
  54271. * @param cascadeNum cascade to retrieve the projection matrix from
  54272. * @returns the cascade projection matrix
  54273. */
  54274. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  54275. /**
  54276. * Gets the transformation matrix corresponding to a given cascade
  54277. * @param cascadeNum cascade to retrieve the transformation matrix from
  54278. * @returns the cascade transformation matrix
  54279. */
  54280. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  54281. private _depthRenderer;
  54282. /**
  54283. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  54284. *
  54285. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  54286. *
  54287. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  54288. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  54289. * @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
  54290. */
  54291. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  54292. private _depthReducer;
  54293. private _autoCalcDepthBounds;
  54294. /**
  54295. * Gets or sets the autoCalcDepthBounds property.
  54296. *
  54297. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  54298. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  54299. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  54300. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  54301. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  54302. */
  54303. get autoCalcDepthBounds(): boolean;
  54304. set autoCalcDepthBounds(value: boolean);
  54305. /**
  54306. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  54307. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  54308. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  54309. * for setting the refresh rate on the renderer yourself!
  54310. */
  54311. get autoCalcDepthBoundsRefreshRate(): number;
  54312. set autoCalcDepthBoundsRefreshRate(value: number);
  54313. /**
  54314. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  54315. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  54316. * you change the camera near/far planes!
  54317. */
  54318. splitFrustum(): void;
  54319. private _splitFrustum;
  54320. private _computeMatrices;
  54321. private _computeFrustumInWorldSpace;
  54322. private _computeCascadeFrustum;
  54323. /** @hidden */
  54324. static _SceneComponentInitialization: (scene: Scene) => void;
  54325. /**
  54326. * Creates a Cascaded Shadow Generator object.
  54327. * A ShadowGenerator is the required tool to use the shadows.
  54328. * Each directional light casting shadows needs to use its own ShadowGenerator.
  54329. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  54330. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  54331. * @param light The directional light object generating the shadows.
  54332. * @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.
  54333. */
  54334. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  54335. protected _initializeGenerator(): void;
  54336. protected _createTargetRenderTexture(): void;
  54337. protected _initializeShadowMap(): void;
  54338. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect): void;
  54339. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  54340. /**
  54341. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  54342. * @param defines Defines of the material we want to update
  54343. * @param lightIndex Index of the light in the enabled light list of the material
  54344. */
  54345. prepareDefines(defines: any, lightIndex: number): void;
  54346. /**
  54347. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  54348. * defined in the generator but impacting the effect).
  54349. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  54350. * @param effect The effect we are binfing the information for
  54351. */
  54352. bindShadowLight(lightIndex: string, effect: Effect): void;
  54353. /**
  54354. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  54355. * (eq to view projection * shadow projection matrices)
  54356. * @returns The transform matrix used to create the shadow map
  54357. */
  54358. getTransformMatrix(): Matrix;
  54359. /**
  54360. * Disposes the ShadowGenerator.
  54361. * Returns nothing.
  54362. */
  54363. dispose(): void;
  54364. /**
  54365. * Serializes the shadow generator setup to a json object.
  54366. * @returns The serialized JSON object
  54367. */
  54368. serialize(): any;
  54369. /**
  54370. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  54371. * @param parsedShadowGenerator The JSON object to parse
  54372. * @param scene The scene to create the shadow map for
  54373. * @returns The parsed shadow generator
  54374. */
  54375. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  54376. }
  54377. }
  54378. declare module BABYLON {
  54379. /**
  54380. * Defines the shadow generator component responsible to manage any shadow generators
  54381. * in a given scene.
  54382. */
  54383. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  54384. /**
  54385. * The component name helpfull to identify the component in the list of scene components.
  54386. */
  54387. readonly name: string;
  54388. /**
  54389. * The scene the component belongs to.
  54390. */
  54391. scene: Scene;
  54392. /**
  54393. * Creates a new instance of the component for the given scene
  54394. * @param scene Defines the scene to register the component in
  54395. */
  54396. constructor(scene: Scene);
  54397. /**
  54398. * Registers the component in a given scene
  54399. */
  54400. register(): void;
  54401. /**
  54402. * Rebuilds the elements related to this component in case of
  54403. * context lost for instance.
  54404. */
  54405. rebuild(): void;
  54406. /**
  54407. * Serializes the component data to the specified json object
  54408. * @param serializationObject The object to serialize to
  54409. */
  54410. serialize(serializationObject: any): void;
  54411. /**
  54412. * Adds all the elements from the container to the scene
  54413. * @param container the container holding the elements
  54414. */
  54415. addFromContainer(container: AbstractScene): void;
  54416. /**
  54417. * Removes all the elements in the container from the scene
  54418. * @param container contains the elements to remove
  54419. * @param dispose if the removed element should be disposed (default: false)
  54420. */
  54421. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  54422. /**
  54423. * Rebuilds the elements related to this component in case of
  54424. * context lost for instance.
  54425. */
  54426. dispose(): void;
  54427. private _gatherRenderTargets;
  54428. }
  54429. }
  54430. declare module BABYLON {
  54431. /**
  54432. * A point light is a light defined by an unique point in world space.
  54433. * The light is emitted in every direction from this point.
  54434. * A good example of a point light is a standard light bulb.
  54435. * Documentation: https://doc.babylonjs.com/babylon101/lights
  54436. */
  54437. export class PointLight extends ShadowLight {
  54438. private _shadowAngle;
  54439. /**
  54440. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  54441. * This specifies what angle the shadow will use to be created.
  54442. *
  54443. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  54444. */
  54445. get shadowAngle(): number;
  54446. /**
  54447. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  54448. * This specifies what angle the shadow will use to be created.
  54449. *
  54450. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  54451. */
  54452. set shadowAngle(value: number);
  54453. /**
  54454. * Gets the direction if it has been set.
  54455. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  54456. */
  54457. get direction(): Vector3;
  54458. /**
  54459. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  54460. */
  54461. set direction(value: Vector3);
  54462. /**
  54463. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  54464. * A PointLight emits the light in every direction.
  54465. * It can cast shadows.
  54466. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  54467. * ```javascript
  54468. * var pointLight = new PointLight("pl", camera.position, scene);
  54469. * ```
  54470. * Documentation : https://doc.babylonjs.com/babylon101/lights
  54471. * @param name The light friendly name
  54472. * @param position The position of the point light in the scene
  54473. * @param scene The scene the lights belongs to
  54474. */
  54475. constructor(name: string, position: Vector3, scene: Scene);
  54476. /**
  54477. * Returns the string "PointLight"
  54478. * @returns the class name
  54479. */
  54480. getClassName(): string;
  54481. /**
  54482. * Returns the integer 0.
  54483. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  54484. */
  54485. getTypeID(): number;
  54486. /**
  54487. * Specifies wether or not the shadowmap should be a cube texture.
  54488. * @returns true if the shadowmap needs to be a cube texture.
  54489. */
  54490. needCube(): boolean;
  54491. /**
  54492. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  54493. * @param faceIndex The index of the face we are computed the direction to generate shadow
  54494. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  54495. */
  54496. getShadowDirection(faceIndex?: number): Vector3;
  54497. /**
  54498. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  54499. * - fov = PI / 2
  54500. * - aspect ratio : 1.0
  54501. * - z-near and far equal to the active camera minZ and maxZ.
  54502. * Returns the PointLight.
  54503. */
  54504. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  54505. protected _buildUniformLayout(): void;
  54506. /**
  54507. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  54508. * @param effect The effect to update
  54509. * @param lightIndex The index of the light in the effect to update
  54510. * @returns The point light
  54511. */
  54512. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  54513. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  54514. /**
  54515. * Prepares the list of defines specific to the light type.
  54516. * @param defines the list of defines
  54517. * @param lightIndex defines the index of the light for the effect
  54518. */
  54519. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  54520. }
  54521. }
  54522. declare module BABYLON {
  54523. /**
  54524. * Header information of HDR texture files.
  54525. */
  54526. export interface HDRInfo {
  54527. /**
  54528. * The height of the texture in pixels.
  54529. */
  54530. height: number;
  54531. /**
  54532. * The width of the texture in pixels.
  54533. */
  54534. width: number;
  54535. /**
  54536. * The index of the beginning of the data in the binary file.
  54537. */
  54538. dataPosition: number;
  54539. }
  54540. /**
  54541. * This groups tools to convert HDR texture to native colors array.
  54542. */
  54543. export class HDRTools {
  54544. private static Ldexp;
  54545. private static Rgbe2float;
  54546. private static readStringLine;
  54547. /**
  54548. * Reads header information from an RGBE texture stored in a native array.
  54549. * More information on this format are available here:
  54550. * https://en.wikipedia.org/wiki/RGBE_image_format
  54551. *
  54552. * @param uint8array The binary file stored in native array.
  54553. * @return The header information.
  54554. */
  54555. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  54556. /**
  54557. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  54558. * This RGBE texture needs to store the information as a panorama.
  54559. *
  54560. * More information on this format are available here:
  54561. * https://en.wikipedia.org/wiki/RGBE_image_format
  54562. *
  54563. * @param buffer The binary file stored in an array buffer.
  54564. * @param size The expected size of the extracted cubemap.
  54565. * @return The Cube Map information.
  54566. */
  54567. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  54568. /**
  54569. * Returns the pixels data extracted from an RGBE texture.
  54570. * This pixels will be stored left to right up to down in the R G B order in one array.
  54571. *
  54572. * More information on this format are available here:
  54573. * https://en.wikipedia.org/wiki/RGBE_image_format
  54574. *
  54575. * @param uint8array The binary file stored in an array buffer.
  54576. * @param hdrInfo The header information of the file.
  54577. * @return The pixels data in RGB right to left up to down order.
  54578. */
  54579. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  54580. private static RGBE_ReadPixels_RLE;
  54581. }
  54582. }
  54583. declare module BABYLON {
  54584. /**
  54585. * This represents a texture coming from an HDR input.
  54586. *
  54587. * The only supported format is currently panorama picture stored in RGBE format.
  54588. * Example of such files can be found on HDRLib: http://hdrlib.com/
  54589. */
  54590. export class HDRCubeTexture extends BaseTexture {
  54591. private static _facesMapping;
  54592. private _generateHarmonics;
  54593. private _noMipmap;
  54594. private _textureMatrix;
  54595. private _size;
  54596. private _onLoad;
  54597. private _onError;
  54598. /**
  54599. * The texture URL.
  54600. */
  54601. url: string;
  54602. /**
  54603. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  54604. */
  54605. coordinatesMode: number;
  54606. protected _isBlocking: boolean;
  54607. /**
  54608. * Sets wether or not the texture is blocking during loading.
  54609. */
  54610. set isBlocking(value: boolean);
  54611. /**
  54612. * Gets wether or not the texture is blocking during loading.
  54613. */
  54614. get isBlocking(): boolean;
  54615. protected _rotationY: number;
  54616. /**
  54617. * Sets texture matrix rotation angle around Y axis in radians.
  54618. */
  54619. set rotationY(value: number);
  54620. /**
  54621. * Gets texture matrix rotation angle around Y axis radians.
  54622. */
  54623. get rotationY(): number;
  54624. /**
  54625. * Gets or sets the center of the bounding box associated with the cube texture
  54626. * It must define where the camera used to render the texture was set
  54627. */
  54628. boundingBoxPosition: Vector3;
  54629. private _boundingBoxSize;
  54630. /**
  54631. * Gets or sets the size of the bounding box associated with the cube texture
  54632. * When defined, the cubemap will switch to local mode
  54633. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  54634. * @example https://www.babylonjs-playground.com/#RNASML
  54635. */
  54636. set boundingBoxSize(value: Vector3);
  54637. get boundingBoxSize(): Vector3;
  54638. /**
  54639. * Instantiates an HDRTexture from the following parameters.
  54640. *
  54641. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  54642. * @param scene The scene the texture will be used in
  54643. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  54644. * @param noMipmap Forces to not generate the mipmap if true
  54645. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  54646. * @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)
  54647. * @param reserved Reserved flag for internal use.
  54648. */
  54649. 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>);
  54650. /**
  54651. * Get the current class name of the texture useful for serialization or dynamic coding.
  54652. * @returns "HDRCubeTexture"
  54653. */
  54654. getClassName(): string;
  54655. /**
  54656. * Occurs when the file is raw .hdr file.
  54657. */
  54658. private loadTexture;
  54659. clone(): HDRCubeTexture;
  54660. delayLoad(): void;
  54661. /**
  54662. * Get the texture reflection matrix used to rotate/transform the reflection.
  54663. * @returns the reflection matrix
  54664. */
  54665. getReflectionTextureMatrix(): Matrix;
  54666. /**
  54667. * Set the texture reflection matrix used to rotate/transform the reflection.
  54668. * @param value Define the reflection matrix to set
  54669. */
  54670. setReflectionTextureMatrix(value: Matrix): void;
  54671. /**
  54672. * Parses a JSON representation of an HDR Texture in order to create the texture
  54673. * @param parsedTexture Define the JSON representation
  54674. * @param scene Define the scene the texture should be created in
  54675. * @param rootUrl Define the root url in case we need to load relative dependencies
  54676. * @returns the newly created texture after parsing
  54677. */
  54678. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  54679. serialize(): any;
  54680. }
  54681. }
  54682. declare module BABYLON {
  54683. /**
  54684. * Class used to control physics engine
  54685. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  54686. */
  54687. export class PhysicsEngine implements IPhysicsEngine {
  54688. private _physicsPlugin;
  54689. /**
  54690. * Global value used to control the smallest number supported by the simulation
  54691. */
  54692. static Epsilon: number;
  54693. private _impostors;
  54694. private _joints;
  54695. private _subTimeStep;
  54696. /**
  54697. * Gets the gravity vector used by the simulation
  54698. */
  54699. gravity: Vector3;
  54700. /**
  54701. * Factory used to create the default physics plugin.
  54702. * @returns The default physics plugin
  54703. */
  54704. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  54705. /**
  54706. * Creates a new Physics Engine
  54707. * @param gravity defines the gravity vector used by the simulation
  54708. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  54709. */
  54710. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  54711. /**
  54712. * Sets the gravity vector used by the simulation
  54713. * @param gravity defines the gravity vector to use
  54714. */
  54715. setGravity(gravity: Vector3): void;
  54716. /**
  54717. * Set the time step of the physics engine.
  54718. * Default is 1/60.
  54719. * To slow it down, enter 1/600 for example.
  54720. * To speed it up, 1/30
  54721. * @param newTimeStep defines the new timestep to apply to this world.
  54722. */
  54723. setTimeStep(newTimeStep?: number): void;
  54724. /**
  54725. * Get the time step of the physics engine.
  54726. * @returns the current time step
  54727. */
  54728. getTimeStep(): number;
  54729. /**
  54730. * Set the sub time step of the physics engine.
  54731. * Default is 0 meaning there is no sub steps
  54732. * To increase physics resolution precision, set a small value (like 1 ms)
  54733. * @param subTimeStep defines the new sub timestep used for physics resolution.
  54734. */
  54735. setSubTimeStep(subTimeStep?: number): void;
  54736. /**
  54737. * Get the sub time step of the physics engine.
  54738. * @returns the current sub time step
  54739. */
  54740. getSubTimeStep(): number;
  54741. /**
  54742. * Release all resources
  54743. */
  54744. dispose(): void;
  54745. /**
  54746. * Gets the name of the current physics plugin
  54747. * @returns the name of the plugin
  54748. */
  54749. getPhysicsPluginName(): string;
  54750. /**
  54751. * Adding a new impostor for the impostor tracking.
  54752. * This will be done by the impostor itself.
  54753. * @param impostor the impostor to add
  54754. */
  54755. addImpostor(impostor: PhysicsImpostor): void;
  54756. /**
  54757. * Remove an impostor from the engine.
  54758. * This impostor and its mesh will not longer be updated by the physics engine.
  54759. * @param impostor the impostor to remove
  54760. */
  54761. removeImpostor(impostor: PhysicsImpostor): void;
  54762. /**
  54763. * Add a joint to the physics engine
  54764. * @param mainImpostor defines the main impostor to which the joint is added.
  54765. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  54766. * @param joint defines the joint that will connect both impostors.
  54767. */
  54768. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  54769. /**
  54770. * Removes a joint from the simulation
  54771. * @param mainImpostor defines the impostor used with the joint
  54772. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  54773. * @param joint defines the joint to remove
  54774. */
  54775. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  54776. /**
  54777. * Called by the scene. No need to call it.
  54778. * @param delta defines the timespam between frames
  54779. */
  54780. _step(delta: number): void;
  54781. /**
  54782. * Gets the current plugin used to run the simulation
  54783. * @returns current plugin
  54784. */
  54785. getPhysicsPlugin(): IPhysicsEnginePlugin;
  54786. /**
  54787. * Gets the list of physic impostors
  54788. * @returns an array of PhysicsImpostor
  54789. */
  54790. getImpostors(): Array<PhysicsImpostor>;
  54791. /**
  54792. * Gets the impostor for a physics enabled object
  54793. * @param object defines the object impersonated by the impostor
  54794. * @returns the PhysicsImpostor or null if not found
  54795. */
  54796. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  54797. /**
  54798. * Gets the impostor for a physics body object
  54799. * @param body defines physics body used by the impostor
  54800. * @returns the PhysicsImpostor or null if not found
  54801. */
  54802. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  54803. /**
  54804. * Does a raycast in the physics world
  54805. * @param from when should the ray start?
  54806. * @param to when should the ray end?
  54807. * @returns PhysicsRaycastResult
  54808. */
  54809. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  54810. }
  54811. }
  54812. declare module BABYLON {
  54813. /** @hidden */
  54814. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  54815. private _useDeltaForWorldStep;
  54816. world: any;
  54817. name: string;
  54818. private _physicsMaterials;
  54819. private _fixedTimeStep;
  54820. private _cannonRaycastResult;
  54821. private _raycastResult;
  54822. private _physicsBodysToRemoveAfterStep;
  54823. BJSCANNON: any;
  54824. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  54825. setGravity(gravity: Vector3): void;
  54826. setTimeStep(timeStep: number): void;
  54827. getTimeStep(): number;
  54828. executeStep(delta: number): void;
  54829. private _removeMarkedPhysicsBodiesFromWorld;
  54830. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  54831. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  54832. generatePhysicsBody(impostor: PhysicsImpostor): void;
  54833. private _processChildMeshes;
  54834. removePhysicsBody(impostor: PhysicsImpostor): void;
  54835. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  54836. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  54837. private _addMaterial;
  54838. private _checkWithEpsilon;
  54839. private _createShape;
  54840. private _createHeightmap;
  54841. private _minus90X;
  54842. private _plus90X;
  54843. private _tmpPosition;
  54844. private _tmpDeltaPosition;
  54845. private _tmpUnityRotation;
  54846. private _updatePhysicsBodyTransformation;
  54847. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  54848. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  54849. isSupported(): boolean;
  54850. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  54851. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  54852. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  54853. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  54854. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  54855. getBodyMass(impostor: PhysicsImpostor): number;
  54856. getBodyFriction(impostor: PhysicsImpostor): number;
  54857. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  54858. getBodyRestitution(impostor: PhysicsImpostor): number;
  54859. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  54860. sleepBody(impostor: PhysicsImpostor): void;
  54861. wakeUpBody(impostor: PhysicsImpostor): void;
  54862. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  54863. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  54864. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  54865. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  54866. getRadius(impostor: PhysicsImpostor): number;
  54867. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  54868. dispose(): void;
  54869. private _extendNamespace;
  54870. /**
  54871. * Does a raycast in the physics world
  54872. * @param from when should the ray start?
  54873. * @param to when should the ray end?
  54874. * @returns PhysicsRaycastResult
  54875. */
  54876. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  54877. }
  54878. }
  54879. declare module BABYLON {
  54880. /** @hidden */
  54881. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  54882. world: any;
  54883. name: string;
  54884. BJSOIMO: any;
  54885. private _raycastResult;
  54886. constructor(iterations?: number, oimoInjection?: any);
  54887. setGravity(gravity: Vector3): void;
  54888. setTimeStep(timeStep: number): void;
  54889. getTimeStep(): number;
  54890. private _tmpImpostorsArray;
  54891. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  54892. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  54893. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  54894. generatePhysicsBody(impostor: PhysicsImpostor): void;
  54895. private _tmpPositionVector;
  54896. removePhysicsBody(impostor: PhysicsImpostor): void;
  54897. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  54898. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  54899. isSupported(): boolean;
  54900. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  54901. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  54902. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  54903. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  54904. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  54905. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  54906. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  54907. getBodyMass(impostor: PhysicsImpostor): number;
  54908. getBodyFriction(impostor: PhysicsImpostor): number;
  54909. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  54910. getBodyRestitution(impostor: PhysicsImpostor): number;
  54911. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  54912. sleepBody(impostor: PhysicsImpostor): void;
  54913. wakeUpBody(impostor: PhysicsImpostor): void;
  54914. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  54915. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  54916. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  54917. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  54918. getRadius(impostor: PhysicsImpostor): number;
  54919. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  54920. dispose(): void;
  54921. /**
  54922. * Does a raycast in the physics world
  54923. * @param from when should the ray start?
  54924. * @param to when should the ray end?
  54925. * @returns PhysicsRaycastResult
  54926. */
  54927. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  54928. }
  54929. }
  54930. declare module BABYLON {
  54931. /**
  54932. * Class containing static functions to help procedurally build meshes
  54933. */
  54934. export class RibbonBuilder {
  54935. /**
  54936. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  54937. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  54938. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  54939. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  54940. * * 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
  54941. * * 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
  54942. * * 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
  54943. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54944. * * 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
  54945. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  54946. * * 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
  54947. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  54948. * * 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
  54949. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  54950. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54951. * @param name defines the name of the mesh
  54952. * @param options defines the options used to create the mesh
  54953. * @param scene defines the hosting scene
  54954. * @returns the ribbon mesh
  54955. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  54956. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  54957. */
  54958. static CreateRibbon(name: string, options: {
  54959. pathArray: Vector3[][];
  54960. closeArray?: boolean;
  54961. closePath?: boolean;
  54962. offset?: number;
  54963. updatable?: boolean;
  54964. sideOrientation?: number;
  54965. frontUVs?: Vector4;
  54966. backUVs?: Vector4;
  54967. instance?: Mesh;
  54968. invertUV?: boolean;
  54969. uvs?: Vector2[];
  54970. colors?: Color4[];
  54971. }, scene?: Nullable<Scene>): Mesh;
  54972. }
  54973. }
  54974. declare module BABYLON {
  54975. /**
  54976. * Class containing static functions to help procedurally build meshes
  54977. */
  54978. export class ShapeBuilder {
  54979. /**
  54980. * 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.
  54981. * * 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.
  54982. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  54983. * * 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.
  54984. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  54985. * * 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
  54986. * * 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
  54987. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  54988. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54989. * * 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
  54990. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  54991. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  54992. * @param name defines the name of the mesh
  54993. * @param options defines the options used to create the mesh
  54994. * @param scene defines the hosting scene
  54995. * @returns the extruded shape mesh
  54996. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  54997. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  54998. */
  54999. static ExtrudeShape(name: string, options: {
  55000. shape: Vector3[];
  55001. path: Vector3[];
  55002. scale?: number;
  55003. rotation?: number;
  55004. cap?: number;
  55005. updatable?: boolean;
  55006. sideOrientation?: number;
  55007. frontUVs?: Vector4;
  55008. backUVs?: Vector4;
  55009. instance?: Mesh;
  55010. invertUV?: boolean;
  55011. }, scene?: Nullable<Scene>): Mesh;
  55012. /**
  55013. * Creates an custom extruded shape mesh.
  55014. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  55015. * * 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.
  55016. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  55017. * * 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
  55018. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  55019. * * 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
  55020. * * It must returns a float value that will be the scale value applied to the shape on each path point
  55021. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  55022. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  55023. * * 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
  55024. * * 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
  55025. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  55026. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55027. * * 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
  55028. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55029. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55030. * @param name defines the name of the mesh
  55031. * @param options defines the options used to create the mesh
  55032. * @param scene defines the hosting scene
  55033. * @returns the custom extruded shape mesh
  55034. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  55035. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55036. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  55037. */
  55038. static ExtrudeShapeCustom(name: string, options: {
  55039. shape: Vector3[];
  55040. path: Vector3[];
  55041. scaleFunction?: any;
  55042. rotationFunction?: any;
  55043. ribbonCloseArray?: boolean;
  55044. ribbonClosePath?: boolean;
  55045. cap?: number;
  55046. updatable?: boolean;
  55047. sideOrientation?: number;
  55048. frontUVs?: Vector4;
  55049. backUVs?: Vector4;
  55050. instance?: Mesh;
  55051. invertUV?: boolean;
  55052. }, scene?: Nullable<Scene>): Mesh;
  55053. private static _ExtrudeShapeGeneric;
  55054. }
  55055. }
  55056. declare module BABYLON {
  55057. /**
  55058. * AmmoJS Physics plugin
  55059. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  55060. * @see https://github.com/kripken/ammo.js/
  55061. */
  55062. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  55063. private _useDeltaForWorldStep;
  55064. /**
  55065. * Reference to the Ammo library
  55066. */
  55067. bjsAMMO: any;
  55068. /**
  55069. * Created ammoJS world which physics bodies are added to
  55070. */
  55071. world: any;
  55072. /**
  55073. * Name of the plugin
  55074. */
  55075. name: string;
  55076. private _timeStep;
  55077. private _fixedTimeStep;
  55078. private _maxSteps;
  55079. private _tmpQuaternion;
  55080. private _tmpAmmoTransform;
  55081. private _tmpAmmoQuaternion;
  55082. private _tmpAmmoConcreteContactResultCallback;
  55083. private _collisionConfiguration;
  55084. private _dispatcher;
  55085. private _overlappingPairCache;
  55086. private _solver;
  55087. private _softBodySolver;
  55088. private _tmpAmmoVectorA;
  55089. private _tmpAmmoVectorB;
  55090. private _tmpAmmoVectorC;
  55091. private _tmpAmmoVectorD;
  55092. private _tmpContactCallbackResult;
  55093. private _tmpAmmoVectorRCA;
  55094. private _tmpAmmoVectorRCB;
  55095. private _raycastResult;
  55096. private static readonly DISABLE_COLLISION_FLAG;
  55097. private static readonly KINEMATIC_FLAG;
  55098. private static readonly DISABLE_DEACTIVATION_FLAG;
  55099. /**
  55100. * Initializes the ammoJS plugin
  55101. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  55102. * @param ammoInjection can be used to inject your own ammo reference
  55103. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  55104. */
  55105. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  55106. /**
  55107. * Sets the gravity of the physics world (m/(s^2))
  55108. * @param gravity Gravity to set
  55109. */
  55110. setGravity(gravity: Vector3): void;
  55111. /**
  55112. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  55113. * @param timeStep timestep to use in seconds
  55114. */
  55115. setTimeStep(timeStep: number): void;
  55116. /**
  55117. * 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)
  55118. * @param fixedTimeStep fixedTimeStep to use in seconds
  55119. */
  55120. setFixedTimeStep(fixedTimeStep: number): void;
  55121. /**
  55122. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  55123. * @param maxSteps the maximum number of steps by the physics engine per frame
  55124. */
  55125. setMaxSteps(maxSteps: number): void;
  55126. /**
  55127. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  55128. * @returns the current timestep in seconds
  55129. */
  55130. getTimeStep(): number;
  55131. /**
  55132. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  55133. */
  55134. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  55135. private _isImpostorInContact;
  55136. private _isImpostorPairInContact;
  55137. private _stepSimulation;
  55138. /**
  55139. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  55140. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  55141. * After the step the babylon meshes are set to the position of the physics imposters
  55142. * @param delta amount of time to step forward
  55143. * @param impostors array of imposters to update before/after the step
  55144. */
  55145. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  55146. /**
  55147. * Update babylon mesh to match physics world object
  55148. * @param impostor imposter to match
  55149. */
  55150. private _afterSoftStep;
  55151. /**
  55152. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  55153. * @param impostor imposter to match
  55154. */
  55155. private _ropeStep;
  55156. /**
  55157. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  55158. * @param impostor imposter to match
  55159. */
  55160. private _softbodyOrClothStep;
  55161. private _tmpVector;
  55162. private _tmpMatrix;
  55163. /**
  55164. * Applies an impulse on the imposter
  55165. * @param impostor imposter to apply impulse to
  55166. * @param force amount of force to be applied to the imposter
  55167. * @param contactPoint the location to apply the impulse on the imposter
  55168. */
  55169. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55170. /**
  55171. * Applies a force on the imposter
  55172. * @param impostor imposter to apply force
  55173. * @param force amount of force to be applied to the imposter
  55174. * @param contactPoint the location to apply the force on the imposter
  55175. */
  55176. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55177. /**
  55178. * Creates a physics body using the plugin
  55179. * @param impostor the imposter to create the physics body on
  55180. */
  55181. generatePhysicsBody(impostor: PhysicsImpostor): void;
  55182. /**
  55183. * Removes the physics body from the imposter and disposes of the body's memory
  55184. * @param impostor imposter to remove the physics body from
  55185. */
  55186. removePhysicsBody(impostor: PhysicsImpostor): void;
  55187. /**
  55188. * Generates a joint
  55189. * @param impostorJoint the imposter joint to create the joint with
  55190. */
  55191. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  55192. /**
  55193. * Removes a joint
  55194. * @param impostorJoint the imposter joint to remove the joint from
  55195. */
  55196. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  55197. private _addMeshVerts;
  55198. /**
  55199. * Initialise the soft body vertices to match its object's (mesh) vertices
  55200. * Softbody vertices (nodes) are in world space and to match this
  55201. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  55202. * @param impostor to create the softbody for
  55203. */
  55204. private _softVertexData;
  55205. /**
  55206. * Create an impostor's soft body
  55207. * @param impostor to create the softbody for
  55208. */
  55209. private _createSoftbody;
  55210. /**
  55211. * Create cloth for an impostor
  55212. * @param impostor to create the softbody for
  55213. */
  55214. private _createCloth;
  55215. /**
  55216. * Create rope for an impostor
  55217. * @param impostor to create the softbody for
  55218. */
  55219. private _createRope;
  55220. /**
  55221. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  55222. * @param impostor to create the custom physics shape for
  55223. */
  55224. private _createCustom;
  55225. private _addHullVerts;
  55226. private _createShape;
  55227. /**
  55228. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  55229. * @param impostor imposter containing the physics body and babylon object
  55230. */
  55231. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  55232. /**
  55233. * Sets the babylon object's position/rotation from the physics body's position/rotation
  55234. * @param impostor imposter containing the physics body and babylon object
  55235. * @param newPosition new position
  55236. * @param newRotation new rotation
  55237. */
  55238. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  55239. /**
  55240. * If this plugin is supported
  55241. * @returns true if its supported
  55242. */
  55243. isSupported(): boolean;
  55244. /**
  55245. * Sets the linear velocity of the physics body
  55246. * @param impostor imposter to set the velocity on
  55247. * @param velocity velocity to set
  55248. */
  55249. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55250. /**
  55251. * Sets the angular velocity of the physics body
  55252. * @param impostor imposter to set the velocity on
  55253. * @param velocity velocity to set
  55254. */
  55255. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55256. /**
  55257. * gets the linear velocity
  55258. * @param impostor imposter to get linear velocity from
  55259. * @returns linear velocity
  55260. */
  55261. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55262. /**
  55263. * gets the angular velocity
  55264. * @param impostor imposter to get angular velocity from
  55265. * @returns angular velocity
  55266. */
  55267. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55268. /**
  55269. * Sets the mass of physics body
  55270. * @param impostor imposter to set the mass on
  55271. * @param mass mass to set
  55272. */
  55273. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  55274. /**
  55275. * Gets the mass of the physics body
  55276. * @param impostor imposter to get the mass from
  55277. * @returns mass
  55278. */
  55279. getBodyMass(impostor: PhysicsImpostor): number;
  55280. /**
  55281. * Gets friction of the impostor
  55282. * @param impostor impostor to get friction from
  55283. * @returns friction value
  55284. */
  55285. getBodyFriction(impostor: PhysicsImpostor): number;
  55286. /**
  55287. * Sets friction of the impostor
  55288. * @param impostor impostor to set friction on
  55289. * @param friction friction value
  55290. */
  55291. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  55292. /**
  55293. * Gets restitution of the impostor
  55294. * @param impostor impostor to get restitution from
  55295. * @returns restitution value
  55296. */
  55297. getBodyRestitution(impostor: PhysicsImpostor): number;
  55298. /**
  55299. * Sets resitution of the impostor
  55300. * @param impostor impostor to set resitution on
  55301. * @param restitution resitution value
  55302. */
  55303. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  55304. /**
  55305. * Gets pressure inside the impostor
  55306. * @param impostor impostor to get pressure from
  55307. * @returns pressure value
  55308. */
  55309. getBodyPressure(impostor: PhysicsImpostor): number;
  55310. /**
  55311. * Sets pressure inside a soft body impostor
  55312. * Cloth and rope must remain 0 pressure
  55313. * @param impostor impostor to set pressure on
  55314. * @param pressure pressure value
  55315. */
  55316. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  55317. /**
  55318. * Gets stiffness of the impostor
  55319. * @param impostor impostor to get stiffness from
  55320. * @returns pressure value
  55321. */
  55322. getBodyStiffness(impostor: PhysicsImpostor): number;
  55323. /**
  55324. * Sets stiffness of the impostor
  55325. * @param impostor impostor to set stiffness on
  55326. * @param stiffness stiffness value from 0 to 1
  55327. */
  55328. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  55329. /**
  55330. * Gets velocityIterations of the impostor
  55331. * @param impostor impostor to get velocity iterations from
  55332. * @returns velocityIterations value
  55333. */
  55334. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  55335. /**
  55336. * Sets velocityIterations of the impostor
  55337. * @param impostor impostor to set velocity iterations on
  55338. * @param velocityIterations velocityIterations value
  55339. */
  55340. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  55341. /**
  55342. * Gets positionIterations of the impostor
  55343. * @param impostor impostor to get position iterations from
  55344. * @returns positionIterations value
  55345. */
  55346. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  55347. /**
  55348. * Sets positionIterations of the impostor
  55349. * @param impostor impostor to set position on
  55350. * @param positionIterations positionIterations value
  55351. */
  55352. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  55353. /**
  55354. * Append an anchor to a cloth object
  55355. * @param impostor is the cloth impostor to add anchor to
  55356. * @param otherImpostor is the rigid impostor to anchor to
  55357. * @param width ratio across width from 0 to 1
  55358. * @param height ratio up height from 0 to 1
  55359. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  55360. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  55361. */
  55362. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  55363. /**
  55364. * Append an hook to a rope object
  55365. * @param impostor is the rope impostor to add hook to
  55366. * @param otherImpostor is the rigid impostor to hook to
  55367. * @param length ratio along the rope from 0 to 1
  55368. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  55369. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  55370. */
  55371. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  55372. /**
  55373. * Sleeps the physics body and stops it from being active
  55374. * @param impostor impostor to sleep
  55375. */
  55376. sleepBody(impostor: PhysicsImpostor): void;
  55377. /**
  55378. * Activates the physics body
  55379. * @param impostor impostor to activate
  55380. */
  55381. wakeUpBody(impostor: PhysicsImpostor): void;
  55382. /**
  55383. * Updates the distance parameters of the joint
  55384. * @param joint joint to update
  55385. * @param maxDistance maximum distance of the joint
  55386. * @param minDistance minimum distance of the joint
  55387. */
  55388. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  55389. /**
  55390. * Sets a motor on the joint
  55391. * @param joint joint to set motor on
  55392. * @param speed speed of the motor
  55393. * @param maxForce maximum force of the motor
  55394. * @param motorIndex index of the motor
  55395. */
  55396. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  55397. /**
  55398. * Sets the motors limit
  55399. * @param joint joint to set limit on
  55400. * @param upperLimit upper limit
  55401. * @param lowerLimit lower limit
  55402. */
  55403. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  55404. /**
  55405. * Syncs the position and rotation of a mesh with the impostor
  55406. * @param mesh mesh to sync
  55407. * @param impostor impostor to update the mesh with
  55408. */
  55409. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  55410. /**
  55411. * Gets the radius of the impostor
  55412. * @param impostor impostor to get radius from
  55413. * @returns the radius
  55414. */
  55415. getRadius(impostor: PhysicsImpostor): number;
  55416. /**
  55417. * Gets the box size of the impostor
  55418. * @param impostor impostor to get box size from
  55419. * @param result the resulting box size
  55420. */
  55421. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  55422. /**
  55423. * Disposes of the impostor
  55424. */
  55425. dispose(): void;
  55426. /**
  55427. * Does a raycast in the physics world
  55428. * @param from when should the ray start?
  55429. * @param to when should the ray end?
  55430. * @returns PhysicsRaycastResult
  55431. */
  55432. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  55433. }
  55434. }
  55435. declare module BABYLON {
  55436. interface AbstractScene {
  55437. /**
  55438. * The list of reflection probes added to the scene
  55439. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  55440. */
  55441. reflectionProbes: Array<ReflectionProbe>;
  55442. /**
  55443. * Removes the given reflection probe from this scene.
  55444. * @param toRemove The reflection probe to remove
  55445. * @returns The index of the removed reflection probe
  55446. */
  55447. removeReflectionProbe(toRemove: ReflectionProbe): number;
  55448. /**
  55449. * Adds the given reflection probe to this scene.
  55450. * @param newReflectionProbe The reflection probe to add
  55451. */
  55452. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  55453. }
  55454. /**
  55455. * Class used to generate realtime reflection / refraction cube textures
  55456. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  55457. */
  55458. export class ReflectionProbe {
  55459. /** defines the name of the probe */
  55460. name: string;
  55461. private _scene;
  55462. private _renderTargetTexture;
  55463. private _projectionMatrix;
  55464. private _viewMatrix;
  55465. private _target;
  55466. private _add;
  55467. private _attachedMesh;
  55468. private _invertYAxis;
  55469. /** Gets or sets probe position (center of the cube map) */
  55470. position: Vector3;
  55471. /**
  55472. * Creates a new reflection probe
  55473. * @param name defines the name of the probe
  55474. * @param size defines the texture resolution (for each face)
  55475. * @param scene defines the hosting scene
  55476. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  55477. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  55478. */
  55479. constructor(
  55480. /** defines the name of the probe */
  55481. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  55482. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  55483. get samples(): number;
  55484. set samples(value: number);
  55485. /** Gets or sets the refresh rate to use (on every frame by default) */
  55486. get refreshRate(): number;
  55487. set refreshRate(value: number);
  55488. /**
  55489. * Gets the hosting scene
  55490. * @returns a Scene
  55491. */
  55492. getScene(): Scene;
  55493. /** Gets the internal CubeTexture used to render to */
  55494. get cubeTexture(): RenderTargetTexture;
  55495. /** Gets the list of meshes to render */
  55496. get renderList(): Nullable<AbstractMesh[]>;
  55497. /**
  55498. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  55499. * @param mesh defines the mesh to attach to
  55500. */
  55501. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  55502. /**
  55503. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  55504. * @param renderingGroupId The rendering group id corresponding to its index
  55505. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  55506. */
  55507. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  55508. /**
  55509. * Clean all associated resources
  55510. */
  55511. dispose(): void;
  55512. /**
  55513. * Converts the reflection probe information to a readable string for debug purpose.
  55514. * @param fullDetails Supports for multiple levels of logging within scene loading
  55515. * @returns the human readable reflection probe info
  55516. */
  55517. toString(fullDetails?: boolean): string;
  55518. /**
  55519. * Get the class name of the relfection probe.
  55520. * @returns "ReflectionProbe"
  55521. */
  55522. getClassName(): string;
  55523. /**
  55524. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  55525. * @returns The JSON representation of the texture
  55526. */
  55527. serialize(): any;
  55528. /**
  55529. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  55530. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  55531. * @param scene Define the scene the parsed reflection probe should be instantiated in
  55532. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  55533. * @returns The parsed reflection probe if successful
  55534. */
  55535. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  55536. }
  55537. }
  55538. declare module BABYLON {
  55539. /** @hidden */
  55540. export var _BabylonLoaderRegistered: boolean;
  55541. /**
  55542. * Helps setting up some configuration for the babylon file loader.
  55543. */
  55544. export class BabylonFileLoaderConfiguration {
  55545. /**
  55546. * The loader does not allow injecting custom physix engine into the plugins.
  55547. * Unfortunately in ES6, we need to manually inject them into the plugin.
  55548. * So you could set this variable to your engine import to make it work.
  55549. */
  55550. static LoaderInjectedPhysicsEngine: any;
  55551. }
  55552. }
  55553. declare module BABYLON {
  55554. /**
  55555. * The Physically based simple base material of BJS.
  55556. *
  55557. * This enables better naming and convention enforcements on top of the pbrMaterial.
  55558. * It is used as the base class for both the specGloss and metalRough conventions.
  55559. */
  55560. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  55561. /**
  55562. * Number of Simultaneous lights allowed on the material.
  55563. */
  55564. maxSimultaneousLights: number;
  55565. /**
  55566. * If sets to true, disables all the lights affecting the material.
  55567. */
  55568. disableLighting: boolean;
  55569. /**
  55570. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  55571. */
  55572. environmentTexture: BaseTexture;
  55573. /**
  55574. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  55575. */
  55576. invertNormalMapX: boolean;
  55577. /**
  55578. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  55579. */
  55580. invertNormalMapY: boolean;
  55581. /**
  55582. * Normal map used in the model.
  55583. */
  55584. normalTexture: BaseTexture;
  55585. /**
  55586. * Emissivie color used to self-illuminate the model.
  55587. */
  55588. emissiveColor: Color3;
  55589. /**
  55590. * Emissivie texture used to self-illuminate the model.
  55591. */
  55592. emissiveTexture: BaseTexture;
  55593. /**
  55594. * Occlusion Channel Strenght.
  55595. */
  55596. occlusionStrength: number;
  55597. /**
  55598. * Occlusion Texture of the material (adding extra occlusion effects).
  55599. */
  55600. occlusionTexture: BaseTexture;
  55601. /**
  55602. * Defines the alpha limits in alpha test mode.
  55603. */
  55604. alphaCutOff: number;
  55605. /**
  55606. * Gets the current double sided mode.
  55607. */
  55608. get doubleSided(): boolean;
  55609. /**
  55610. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  55611. */
  55612. set doubleSided(value: boolean);
  55613. /**
  55614. * Stores the pre-calculated light information of a mesh in a texture.
  55615. */
  55616. lightmapTexture: BaseTexture;
  55617. /**
  55618. * If true, the light map contains occlusion information instead of lighting info.
  55619. */
  55620. useLightmapAsShadowmap: boolean;
  55621. /**
  55622. * Instantiates a new PBRMaterial instance.
  55623. *
  55624. * @param name The material name
  55625. * @param scene The scene the material will be use in.
  55626. */
  55627. constructor(name: string, scene: Scene);
  55628. getClassName(): string;
  55629. }
  55630. }
  55631. declare module BABYLON {
  55632. /**
  55633. * The PBR material of BJS following the metal roughness convention.
  55634. *
  55635. * This fits to the PBR convention in the GLTF definition:
  55636. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  55637. */
  55638. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  55639. /**
  55640. * The base color has two different interpretations depending on the value of metalness.
  55641. * When the material is a metal, the base color is the specific measured reflectance value
  55642. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  55643. * of the material.
  55644. */
  55645. baseColor: Color3;
  55646. /**
  55647. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  55648. * well as opacity information in the alpha channel.
  55649. */
  55650. baseTexture: BaseTexture;
  55651. /**
  55652. * Specifies the metallic scalar value of the material.
  55653. * Can also be used to scale the metalness values of the metallic texture.
  55654. */
  55655. metallic: number;
  55656. /**
  55657. * Specifies the roughness scalar value of the material.
  55658. * Can also be used to scale the roughness values of the metallic texture.
  55659. */
  55660. roughness: number;
  55661. /**
  55662. * Texture containing both the metallic value in the B channel and the
  55663. * roughness value in the G channel to keep better precision.
  55664. */
  55665. metallicRoughnessTexture: BaseTexture;
  55666. /**
  55667. * Instantiates a new PBRMetalRoughnessMaterial instance.
  55668. *
  55669. * @param name The material name
  55670. * @param scene The scene the material will be use in.
  55671. */
  55672. constructor(name: string, scene: Scene);
  55673. /**
  55674. * Return the currrent class name of the material.
  55675. */
  55676. getClassName(): string;
  55677. /**
  55678. * Makes a duplicate of the current material.
  55679. * @param name - name to use for the new material.
  55680. */
  55681. clone(name: string): PBRMetallicRoughnessMaterial;
  55682. /**
  55683. * Serialize the material to a parsable JSON object.
  55684. */
  55685. serialize(): any;
  55686. /**
  55687. * Parses a JSON object correponding to the serialize function.
  55688. */
  55689. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  55690. }
  55691. }
  55692. declare module BABYLON {
  55693. /**
  55694. * The PBR material of BJS following the specular glossiness convention.
  55695. *
  55696. * This fits to the PBR convention in the GLTF definition:
  55697. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  55698. */
  55699. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  55700. /**
  55701. * Specifies the diffuse color of the material.
  55702. */
  55703. diffuseColor: Color3;
  55704. /**
  55705. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  55706. * channel.
  55707. */
  55708. diffuseTexture: BaseTexture;
  55709. /**
  55710. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  55711. */
  55712. specularColor: Color3;
  55713. /**
  55714. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  55715. */
  55716. glossiness: number;
  55717. /**
  55718. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  55719. */
  55720. specularGlossinessTexture: BaseTexture;
  55721. /**
  55722. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  55723. *
  55724. * @param name The material name
  55725. * @param scene The scene the material will be use in.
  55726. */
  55727. constructor(name: string, scene: Scene);
  55728. /**
  55729. * Return the currrent class name of the material.
  55730. */
  55731. getClassName(): string;
  55732. /**
  55733. * Makes a duplicate of the current material.
  55734. * @param name - name to use for the new material.
  55735. */
  55736. clone(name: string): PBRSpecularGlossinessMaterial;
  55737. /**
  55738. * Serialize the material to a parsable JSON object.
  55739. */
  55740. serialize(): any;
  55741. /**
  55742. * Parses a JSON object correponding to the serialize function.
  55743. */
  55744. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  55745. }
  55746. }
  55747. declare module BABYLON {
  55748. /**
  55749. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  55750. * It can help converting any input color in a desired output one. This can then be used to create effects
  55751. * from sepia, black and white to sixties or futuristic rendering...
  55752. *
  55753. * The only supported format is currently 3dl.
  55754. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  55755. */
  55756. export class ColorGradingTexture extends BaseTexture {
  55757. /**
  55758. * The current texture matrix. (will always be identity in color grading texture)
  55759. */
  55760. private _textureMatrix;
  55761. /**
  55762. * The texture URL.
  55763. */
  55764. url: string;
  55765. /**
  55766. * Empty line regex stored for GC.
  55767. */
  55768. private static _noneEmptyLineRegex;
  55769. private _engine;
  55770. /**
  55771. * Instantiates a ColorGradingTexture from the following parameters.
  55772. *
  55773. * @param url The location of the color gradind data (currently only supporting 3dl)
  55774. * @param scene The scene the texture will be used in
  55775. */
  55776. constructor(url: string, scene: Scene);
  55777. /**
  55778. * Returns the texture matrix used in most of the material.
  55779. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  55780. */
  55781. getTextureMatrix(): Matrix;
  55782. /**
  55783. * Occurs when the file being loaded is a .3dl LUT file.
  55784. */
  55785. private load3dlTexture;
  55786. /**
  55787. * Starts the loading process of the texture.
  55788. */
  55789. private loadTexture;
  55790. /**
  55791. * Clones the color gradind texture.
  55792. */
  55793. clone(): ColorGradingTexture;
  55794. /**
  55795. * Called during delayed load for textures.
  55796. */
  55797. delayLoad(): void;
  55798. /**
  55799. * Parses a color grading texture serialized by Babylon.
  55800. * @param parsedTexture The texture information being parsedTexture
  55801. * @param scene The scene to load the texture in
  55802. * @param rootUrl The root url of the data assets to load
  55803. * @return A color gradind texture
  55804. */
  55805. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  55806. /**
  55807. * Serializes the LUT texture to json format.
  55808. */
  55809. serialize(): any;
  55810. }
  55811. }
  55812. declare module BABYLON {
  55813. /**
  55814. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  55815. */
  55816. export class EquiRectangularCubeTexture extends BaseTexture {
  55817. /** The six faces of the cube. */
  55818. private static _FacesMapping;
  55819. private _noMipmap;
  55820. private _onLoad;
  55821. private _onError;
  55822. /** The size of the cubemap. */
  55823. private _size;
  55824. /** The buffer of the image. */
  55825. private _buffer;
  55826. /** The width of the input image. */
  55827. private _width;
  55828. /** The height of the input image. */
  55829. private _height;
  55830. /** The URL to the image. */
  55831. url: string;
  55832. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  55833. coordinatesMode: number;
  55834. /**
  55835. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  55836. * @param url The location of the image
  55837. * @param scene The scene the texture will be used in
  55838. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  55839. * @param noMipmap Forces to not generate the mipmap if true
  55840. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  55841. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  55842. * @param onLoad — defines a callback called when texture is loaded
  55843. * @param onError — defines a callback called if there is an error
  55844. */
  55845. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  55846. /**
  55847. * Load the image data, by putting the image on a canvas and extracting its buffer.
  55848. */
  55849. private loadImage;
  55850. /**
  55851. * Convert the image buffer into a cubemap and create a CubeTexture.
  55852. */
  55853. private loadTexture;
  55854. /**
  55855. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  55856. * @param buffer The ArrayBuffer that should be converted.
  55857. * @returns The buffer as Float32Array.
  55858. */
  55859. private getFloat32ArrayFromArrayBuffer;
  55860. /**
  55861. * Get the current class name of the texture useful for serialization or dynamic coding.
  55862. * @returns "EquiRectangularCubeTexture"
  55863. */
  55864. getClassName(): string;
  55865. /**
  55866. * Create a clone of the current EquiRectangularCubeTexture and return it.
  55867. * @returns A clone of the current EquiRectangularCubeTexture.
  55868. */
  55869. clone(): EquiRectangularCubeTexture;
  55870. }
  55871. }
  55872. declare module BABYLON {
  55873. /**
  55874. * Based on jsTGALoader - Javascript loader for TGA file
  55875. * By Vincent Thibault
  55876. * @see http://blog.robrowser.com/javascript-tga-loader.html
  55877. */
  55878. export class TGATools {
  55879. private static _TYPE_INDEXED;
  55880. private static _TYPE_RGB;
  55881. private static _TYPE_GREY;
  55882. private static _TYPE_RLE_INDEXED;
  55883. private static _TYPE_RLE_RGB;
  55884. private static _TYPE_RLE_GREY;
  55885. private static _ORIGIN_MASK;
  55886. private static _ORIGIN_SHIFT;
  55887. private static _ORIGIN_BL;
  55888. private static _ORIGIN_BR;
  55889. private static _ORIGIN_UL;
  55890. private static _ORIGIN_UR;
  55891. /**
  55892. * Gets the header of a TGA file
  55893. * @param data defines the TGA data
  55894. * @returns the header
  55895. */
  55896. static GetTGAHeader(data: Uint8Array): any;
  55897. /**
  55898. * Uploads TGA content to a Babylon Texture
  55899. * @hidden
  55900. */
  55901. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  55902. /** @hidden */
  55903. 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;
  55904. /** @hidden */
  55905. 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;
  55906. /** @hidden */
  55907. 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;
  55908. /** @hidden */
  55909. 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;
  55910. /** @hidden */
  55911. 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;
  55912. /** @hidden */
  55913. 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;
  55914. }
  55915. }
  55916. declare module BABYLON {
  55917. /**
  55918. * Implementation of the TGA Texture Loader.
  55919. * @hidden
  55920. */
  55921. export class _TGATextureLoader implements IInternalTextureLoader {
  55922. /**
  55923. * Defines wether the loader supports cascade loading the different faces.
  55924. */
  55925. readonly supportCascades: boolean;
  55926. /**
  55927. * This returns if the loader support the current file information.
  55928. * @param extension defines the file extension of the file being loaded
  55929. * @param textureFormatInUse defines the current compressed format in use iun the engine
  55930. * @param fallback defines the fallback internal texture if any
  55931. * @param isBase64 defines whether the texture is encoded as a base64
  55932. * @param isBuffer defines whether the texture data are stored as a buffer
  55933. * @returns true if the loader can load the specified file
  55934. */
  55935. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  55936. /**
  55937. * Transform the url before loading if required.
  55938. * @param rootUrl the url of the texture
  55939. * @param textureFormatInUse defines the current compressed format in use iun the engine
  55940. * @returns the transformed texture
  55941. */
  55942. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  55943. /**
  55944. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  55945. * @param rootUrl the url of the texture
  55946. * @param textureFormatInUse defines the current compressed format in use iun the engine
  55947. * @returns the fallback texture
  55948. */
  55949. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  55950. /**
  55951. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  55952. * @param data contains the texture data
  55953. * @param texture defines the BabylonJS internal texture
  55954. * @param createPolynomials will be true if polynomials have been requested
  55955. * @param onLoad defines the callback to trigger once the texture is ready
  55956. * @param onError defines the callback to trigger in case of error
  55957. */
  55958. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  55959. /**
  55960. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  55961. * @param data contains the texture data
  55962. * @param texture defines the BabylonJS internal texture
  55963. * @param callback defines the method to call once ready to upload
  55964. */
  55965. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  55966. }
  55967. }
  55968. declare module BABYLON {
  55969. /**
  55970. * Info about the .basis files
  55971. */
  55972. class BasisFileInfo {
  55973. /**
  55974. * If the file has alpha
  55975. */
  55976. hasAlpha: boolean;
  55977. /**
  55978. * Info about each image of the basis file
  55979. */
  55980. images: Array<{
  55981. levels: Array<{
  55982. width: number;
  55983. height: number;
  55984. transcodedPixels: ArrayBufferView;
  55985. }>;
  55986. }>;
  55987. }
  55988. /**
  55989. * Result of transcoding a basis file
  55990. */
  55991. class TranscodeResult {
  55992. /**
  55993. * Info about the .basis file
  55994. */
  55995. fileInfo: BasisFileInfo;
  55996. /**
  55997. * Format to use when loading the file
  55998. */
  55999. format: number;
  56000. }
  56001. /**
  56002. * Configuration options for the Basis transcoder
  56003. */
  56004. export class BasisTranscodeConfiguration {
  56005. /**
  56006. * Supported compression formats used to determine the supported output format of the transcoder
  56007. */
  56008. supportedCompressionFormats?: {
  56009. /**
  56010. * etc1 compression format
  56011. */
  56012. etc1?: boolean;
  56013. /**
  56014. * s3tc compression format
  56015. */
  56016. s3tc?: boolean;
  56017. /**
  56018. * pvrtc compression format
  56019. */
  56020. pvrtc?: boolean;
  56021. /**
  56022. * etc2 compression format
  56023. */
  56024. etc2?: boolean;
  56025. };
  56026. /**
  56027. * If mipmap levels should be loaded for transcoded images (Default: true)
  56028. */
  56029. loadMipmapLevels?: boolean;
  56030. /**
  56031. * Index of a single image to load (Default: all images)
  56032. */
  56033. loadSingleImage?: number;
  56034. }
  56035. /**
  56036. * Used to load .Basis files
  56037. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  56038. */
  56039. export class BasisTools {
  56040. private static _IgnoreSupportedFormats;
  56041. /**
  56042. * URL to use when loading the basis transcoder
  56043. */
  56044. static JSModuleURL: string;
  56045. /**
  56046. * URL to use when loading the wasm module for the transcoder
  56047. */
  56048. static WasmModuleURL: string;
  56049. /**
  56050. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  56051. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  56052. * @returns internal format corresponding to the Basis format
  56053. */
  56054. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  56055. private static _WorkerPromise;
  56056. private static _Worker;
  56057. private static _actionId;
  56058. private static _CreateWorkerAsync;
  56059. /**
  56060. * Transcodes a loaded image file to compressed pixel data
  56061. * @param data image data to transcode
  56062. * @param config configuration options for the transcoding
  56063. * @returns a promise resulting in the transcoded image
  56064. */
  56065. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  56066. /**
  56067. * Loads a texture from the transcode result
  56068. * @param texture texture load to
  56069. * @param transcodeResult the result of transcoding the basis file to load from
  56070. */
  56071. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  56072. }
  56073. }
  56074. declare module BABYLON {
  56075. /**
  56076. * Loader for .basis file format
  56077. */
  56078. export class _BasisTextureLoader implements IInternalTextureLoader {
  56079. /**
  56080. * Defines whether the loader supports cascade loading the different faces.
  56081. */
  56082. readonly supportCascades: boolean;
  56083. /**
  56084. * This returns if the loader support the current file information.
  56085. * @param extension defines the file extension of the file being loaded
  56086. * @param textureFormatInUse defines the current compressed format in use iun the engine
  56087. * @param fallback defines the fallback internal texture if any
  56088. * @param isBase64 defines whether the texture is encoded as a base64
  56089. * @param isBuffer defines whether the texture data are stored as a buffer
  56090. * @returns true if the loader can load the specified file
  56091. */
  56092. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  56093. /**
  56094. * Transform the url before loading if required.
  56095. * @param rootUrl the url of the texture
  56096. * @param textureFormatInUse defines the current compressed format in use iun the engine
  56097. * @returns the transformed texture
  56098. */
  56099. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  56100. /**
  56101. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  56102. * @param rootUrl the url of the texture
  56103. * @param textureFormatInUse defines the current compressed format in use iun the engine
  56104. * @returns the fallback texture
  56105. */
  56106. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  56107. /**
  56108. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  56109. * @param data contains the texture data
  56110. * @param texture defines the BabylonJS internal texture
  56111. * @param createPolynomials will be true if polynomials have been requested
  56112. * @param onLoad defines the callback to trigger once the texture is ready
  56113. * @param onError defines the callback to trigger in case of error
  56114. */
  56115. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  56116. /**
  56117. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  56118. * @param data contains the texture data
  56119. * @param texture defines the BabylonJS internal texture
  56120. * @param callback defines the method to call once ready to upload
  56121. */
  56122. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  56123. }
  56124. }
  56125. declare module BABYLON {
  56126. /**
  56127. * 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.
  56128. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  56129. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  56130. */
  56131. export class CustomProceduralTexture extends ProceduralTexture {
  56132. private _animate;
  56133. private _time;
  56134. private _config;
  56135. private _texturePath;
  56136. /**
  56137. * Instantiates a new Custom Procedural Texture.
  56138. * 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.
  56139. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  56140. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  56141. * @param name Define the name of the texture
  56142. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  56143. * @param size Define the size of the texture to create
  56144. * @param scene Define the scene the texture belongs to
  56145. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  56146. * @param generateMipMaps Define if the texture should creates mip maps or not
  56147. */
  56148. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  56149. private _loadJson;
  56150. /**
  56151. * Is the texture ready to be used ? (rendered at least once)
  56152. * @returns true if ready, otherwise, false.
  56153. */
  56154. isReady(): boolean;
  56155. /**
  56156. * Render the texture to its associated render target.
  56157. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  56158. */
  56159. render(useCameraPostProcess?: boolean): void;
  56160. /**
  56161. * Update the list of dependant textures samplers in the shader.
  56162. */
  56163. updateTextures(): void;
  56164. /**
  56165. * Update the uniform values of the procedural texture in the shader.
  56166. */
  56167. updateShaderUniforms(): void;
  56168. /**
  56169. * Define if the texture animates or not.
  56170. */
  56171. get animate(): boolean;
  56172. set animate(value: boolean);
  56173. }
  56174. }
  56175. declare module BABYLON {
  56176. /** @hidden */
  56177. export var noisePixelShader: {
  56178. name: string;
  56179. shader: string;
  56180. };
  56181. }
  56182. declare module BABYLON {
  56183. /**
  56184. * Class used to generate noise procedural textures
  56185. */
  56186. export class NoiseProceduralTexture extends ProceduralTexture {
  56187. private _time;
  56188. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  56189. brightness: number;
  56190. /** Defines the number of octaves to process */
  56191. octaves: number;
  56192. /** Defines the level of persistence (0.8 by default) */
  56193. persistence: number;
  56194. /** Gets or sets animation speed factor (default is 1) */
  56195. animationSpeedFactor: number;
  56196. /**
  56197. * Creates a new NoiseProceduralTexture
  56198. * @param name defines the name fo the texture
  56199. * @param size defines the size of the texture (default is 256)
  56200. * @param scene defines the hosting scene
  56201. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  56202. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  56203. */
  56204. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  56205. private _updateShaderUniforms;
  56206. protected _getDefines(): string;
  56207. /** Generate the current state of the procedural texture */
  56208. render(useCameraPostProcess?: boolean): void;
  56209. /**
  56210. * Serializes this noise procedural texture
  56211. * @returns a serialized noise procedural texture object
  56212. */
  56213. serialize(): any;
  56214. /**
  56215. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  56216. * @param parsedTexture defines parsed texture data
  56217. * @param scene defines the current scene
  56218. * @param rootUrl defines the root URL containing noise procedural texture information
  56219. * @returns a parsed NoiseProceduralTexture
  56220. */
  56221. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  56222. }
  56223. }
  56224. declare module BABYLON {
  56225. /**
  56226. * Raw cube texture where the raw buffers are passed in
  56227. */
  56228. export class RawCubeTexture extends CubeTexture {
  56229. /**
  56230. * Creates a cube texture where the raw buffers are passed in.
  56231. * @param scene defines the scene the texture is attached to
  56232. * @param data defines the array of data to use to create each face
  56233. * @param size defines the size of the textures
  56234. * @param format defines the format of the data
  56235. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  56236. * @param generateMipMaps defines if the engine should generate the mip levels
  56237. * @param invertY defines if data must be stored with Y axis inverted
  56238. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  56239. * @param compression defines the compression used (null by default)
  56240. */
  56241. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  56242. /**
  56243. * Updates the raw cube texture.
  56244. * @param data defines the data to store
  56245. * @param format defines the data format
  56246. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  56247. * @param invertY defines if data must be stored with Y axis inverted
  56248. * @param compression defines the compression used (null by default)
  56249. * @param level defines which level of the texture to update
  56250. */
  56251. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  56252. /**
  56253. * Updates a raw cube texture with RGBD encoded data.
  56254. * @param data defines the array of data [mipmap][face] to use to create each face
  56255. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  56256. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  56257. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  56258. * @returns a promsie that resolves when the operation is complete
  56259. */
  56260. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  56261. /**
  56262. * Clones the raw cube texture.
  56263. * @return a new cube texture
  56264. */
  56265. clone(): CubeTexture;
  56266. /** @hidden */
  56267. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  56268. }
  56269. }
  56270. declare module BABYLON {
  56271. /**
  56272. * Class used to store 3D textures containing user data
  56273. */
  56274. export class RawTexture3D extends Texture {
  56275. /** Gets or sets the texture format to use */
  56276. format: number;
  56277. private _engine;
  56278. /**
  56279. * Create a new RawTexture3D
  56280. * @param data defines the data of the texture
  56281. * @param width defines the width of the texture
  56282. * @param height defines the height of the texture
  56283. * @param depth defines the depth of the texture
  56284. * @param format defines the texture format to use
  56285. * @param scene defines the hosting scene
  56286. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  56287. * @param invertY defines if texture must be stored with Y axis inverted
  56288. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  56289. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  56290. */
  56291. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  56292. /** Gets or sets the texture format to use */
  56293. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  56294. /**
  56295. * Update the texture with new data
  56296. * @param data defines the data to store in the texture
  56297. */
  56298. update(data: ArrayBufferView): void;
  56299. }
  56300. }
  56301. declare module BABYLON {
  56302. /**
  56303. * Class used to store 2D array textures containing user data
  56304. */
  56305. export class RawTexture2DArray extends Texture {
  56306. /** Gets or sets the texture format to use */
  56307. format: number;
  56308. private _engine;
  56309. /**
  56310. * Create a new RawTexture2DArray
  56311. * @param data defines the data of the texture
  56312. * @param width defines the width of the texture
  56313. * @param height defines the height of the texture
  56314. * @param depth defines the number of layers of the texture
  56315. * @param format defines the texture format to use
  56316. * @param scene defines the hosting scene
  56317. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  56318. * @param invertY defines if texture must be stored with Y axis inverted
  56319. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  56320. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  56321. */
  56322. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  56323. /** Gets or sets the texture format to use */
  56324. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  56325. /**
  56326. * Update the texture with new data
  56327. * @param data defines the data to store in the texture
  56328. */
  56329. update(data: ArrayBufferView): void;
  56330. }
  56331. }
  56332. declare module BABYLON {
  56333. /**
  56334. * Creates a refraction texture used by refraction channel of the standard material.
  56335. * It is like a mirror but to see through a material.
  56336. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  56337. */
  56338. export class RefractionTexture extends RenderTargetTexture {
  56339. /**
  56340. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  56341. * 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.
  56342. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  56343. */
  56344. refractionPlane: Plane;
  56345. /**
  56346. * Define how deep under the surface we should see.
  56347. */
  56348. depth: number;
  56349. /**
  56350. * Creates a refraction texture used by refraction channel of the standard material.
  56351. * It is like a mirror but to see through a material.
  56352. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  56353. * @param name Define the texture name
  56354. * @param size Define the size of the underlying texture
  56355. * @param scene Define the scene the refraction belongs to
  56356. * @param generateMipMaps Define if we need to generate mips level for the refraction
  56357. */
  56358. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  56359. /**
  56360. * Clone the refraction texture.
  56361. * @returns the cloned texture
  56362. */
  56363. clone(): RefractionTexture;
  56364. /**
  56365. * Serialize the texture to a JSON representation you could use in Parse later on
  56366. * @returns the serialized JSON representation
  56367. */
  56368. serialize(): any;
  56369. }
  56370. }
  56371. declare module BABYLON {
  56372. /**
  56373. * Defines the options related to the creation of an HtmlElementTexture
  56374. */
  56375. export interface IHtmlElementTextureOptions {
  56376. /**
  56377. * Defines wether mip maps should be created or not.
  56378. */
  56379. generateMipMaps?: boolean;
  56380. /**
  56381. * Defines the sampling mode of the texture.
  56382. */
  56383. samplingMode?: number;
  56384. /**
  56385. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  56386. */
  56387. engine: Nullable<ThinEngine>;
  56388. /**
  56389. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  56390. */
  56391. scene: Nullable<Scene>;
  56392. }
  56393. /**
  56394. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  56395. * To be as efficient as possible depending on your constraints nothing aside the first upload
  56396. * is automatically managed.
  56397. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  56398. * in your application.
  56399. *
  56400. * As the update is not automatic, you need to call them manually.
  56401. */
  56402. export class HtmlElementTexture extends BaseTexture {
  56403. /**
  56404. * The texture URL.
  56405. */
  56406. element: HTMLVideoElement | HTMLCanvasElement;
  56407. private static readonly DefaultOptions;
  56408. private _textureMatrix;
  56409. private _engine;
  56410. private _isVideo;
  56411. private _generateMipMaps;
  56412. private _samplingMode;
  56413. /**
  56414. * Instantiates a HtmlElementTexture from the following parameters.
  56415. *
  56416. * @param name Defines the name of the texture
  56417. * @param element Defines the video or canvas the texture is filled with
  56418. * @param options Defines the other none mandatory texture creation options
  56419. */
  56420. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  56421. private _createInternalTexture;
  56422. /**
  56423. * Returns the texture matrix used in most of the material.
  56424. */
  56425. getTextureMatrix(): Matrix;
  56426. /**
  56427. * Updates the content of the texture.
  56428. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  56429. */
  56430. update(invertY?: Nullable<boolean>): void;
  56431. }
  56432. }
  56433. declare module BABYLON {
  56434. /**
  56435. * Defines the basic options interface of a TexturePacker Frame
  56436. */
  56437. export interface ITexturePackerFrame {
  56438. /**
  56439. * The frame ID
  56440. */
  56441. id: number;
  56442. /**
  56443. * The frames Scale
  56444. */
  56445. scale: Vector2;
  56446. /**
  56447. * The Frames offset
  56448. */
  56449. offset: Vector2;
  56450. }
  56451. /**
  56452. * This is a support class for frame Data on texture packer sets.
  56453. */
  56454. export class TexturePackerFrame implements ITexturePackerFrame {
  56455. /**
  56456. * The frame ID
  56457. */
  56458. id: number;
  56459. /**
  56460. * The frames Scale
  56461. */
  56462. scale: Vector2;
  56463. /**
  56464. * The Frames offset
  56465. */
  56466. offset: Vector2;
  56467. /**
  56468. * Initializes a texture package frame.
  56469. * @param id The numerical frame identifier
  56470. * @param scale Scalar Vector2 for UV frame
  56471. * @param offset Vector2 for the frame position in UV units.
  56472. * @returns TexturePackerFrame
  56473. */
  56474. constructor(id: number, scale: Vector2, offset: Vector2);
  56475. }
  56476. }
  56477. declare module BABYLON {
  56478. /**
  56479. * Defines the basic options interface of a TexturePacker
  56480. */
  56481. export interface ITexturePackerOptions {
  56482. /**
  56483. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  56484. */
  56485. map?: string[];
  56486. /**
  56487. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  56488. */
  56489. uvsIn?: string;
  56490. /**
  56491. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  56492. */
  56493. uvsOut?: string;
  56494. /**
  56495. * number representing the layout style. Defaults to LAYOUT_STRIP
  56496. */
  56497. layout?: number;
  56498. /**
  56499. * number of columns if using custom column count layout(2). This defaults to 4.
  56500. */
  56501. colnum?: number;
  56502. /**
  56503. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  56504. */
  56505. updateInputMeshes?: boolean;
  56506. /**
  56507. * boolean flag to dispose all the source textures. Defaults to true.
  56508. */
  56509. disposeSources?: boolean;
  56510. /**
  56511. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  56512. */
  56513. fillBlanks?: boolean;
  56514. /**
  56515. * string value representing the context fill style color. Defaults to 'black'.
  56516. */
  56517. customFillColor?: string;
  56518. /**
  56519. * Width and Height Value of each Frame in the TexturePacker Sets
  56520. */
  56521. frameSize?: number;
  56522. /**
  56523. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  56524. */
  56525. paddingRatio?: number;
  56526. /**
  56527. * Number that declares the fill method for the padding gutter.
  56528. */
  56529. paddingMode?: number;
  56530. /**
  56531. * If in SUBUV_COLOR padding mode what color to use.
  56532. */
  56533. paddingColor?: Color3 | Color4;
  56534. }
  56535. /**
  56536. * Defines the basic interface of a TexturePacker JSON File
  56537. */
  56538. export interface ITexturePackerJSON {
  56539. /**
  56540. * The frame ID
  56541. */
  56542. name: string;
  56543. /**
  56544. * The base64 channel data
  56545. */
  56546. sets: any;
  56547. /**
  56548. * The options of the Packer
  56549. */
  56550. options: ITexturePackerOptions;
  56551. /**
  56552. * The frame data of the Packer
  56553. */
  56554. frames: Array<number>;
  56555. }
  56556. /**
  56557. * This is a support class that generates a series of packed texture sets.
  56558. * @see https://doc.babylonjs.com/babylon101/materials
  56559. */
  56560. export class TexturePacker {
  56561. /** Packer Layout Constant 0 */
  56562. static readonly LAYOUT_STRIP: number;
  56563. /** Packer Layout Constant 1 */
  56564. static readonly LAYOUT_POWER2: number;
  56565. /** Packer Layout Constant 2 */
  56566. static readonly LAYOUT_COLNUM: number;
  56567. /** Packer Layout Constant 0 */
  56568. static readonly SUBUV_WRAP: number;
  56569. /** Packer Layout Constant 1 */
  56570. static readonly SUBUV_EXTEND: number;
  56571. /** Packer Layout Constant 2 */
  56572. static readonly SUBUV_COLOR: number;
  56573. /** The Name of the Texture Package */
  56574. name: string;
  56575. /** The scene scope of the TexturePacker */
  56576. scene: Scene;
  56577. /** The Meshes to target */
  56578. meshes: AbstractMesh[];
  56579. /** Arguments passed with the Constructor */
  56580. options: ITexturePackerOptions;
  56581. /** The promise that is started upon initialization */
  56582. promise: Nullable<Promise<TexturePacker | string>>;
  56583. /** The Container object for the channel sets that are generated */
  56584. sets: object;
  56585. /** The Container array for the frames that are generated */
  56586. frames: TexturePackerFrame[];
  56587. /** The expected number of textures the system is parsing. */
  56588. private _expecting;
  56589. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  56590. private _paddingValue;
  56591. /**
  56592. * Initializes a texture package series from an array of meshes or a single mesh.
  56593. * @param name The name of the package
  56594. * @param meshes The target meshes to compose the package from
  56595. * @param options The arguments that texture packer should follow while building.
  56596. * @param scene The scene which the textures are scoped to.
  56597. * @returns TexturePacker
  56598. */
  56599. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  56600. /**
  56601. * Starts the package process
  56602. * @param resolve The promises resolution function
  56603. * @returns TexturePacker
  56604. */
  56605. private _createFrames;
  56606. /**
  56607. * Calculates the Size of the Channel Sets
  56608. * @returns Vector2
  56609. */
  56610. private _calculateSize;
  56611. /**
  56612. * Calculates the UV data for the frames.
  56613. * @param baseSize the base frameSize
  56614. * @param padding the base frame padding
  56615. * @param dtSize size of the Dynamic Texture for that channel
  56616. * @param dtUnits is 1/dtSize
  56617. * @param update flag to update the input meshes
  56618. */
  56619. private _calculateMeshUVFrames;
  56620. /**
  56621. * Calculates the frames Offset.
  56622. * @param index of the frame
  56623. * @returns Vector2
  56624. */
  56625. private _getFrameOffset;
  56626. /**
  56627. * Updates a Mesh to the frame data
  56628. * @param mesh that is the target
  56629. * @param frameID or the frame index
  56630. */
  56631. private _updateMeshUV;
  56632. /**
  56633. * Updates a Meshes materials to use the texture packer channels
  56634. * @param m is the mesh to target
  56635. * @param force all channels on the packer to be set.
  56636. */
  56637. private _updateTextureReferences;
  56638. /**
  56639. * Public method to set a Mesh to a frame
  56640. * @param m that is the target
  56641. * @param frameID or the frame index
  56642. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  56643. */
  56644. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  56645. /**
  56646. * Starts the async promise to compile the texture packer.
  56647. * @returns Promise<void>
  56648. */
  56649. processAsync(): Promise<void>;
  56650. /**
  56651. * Disposes all textures associated with this packer
  56652. */
  56653. dispose(): void;
  56654. /**
  56655. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  56656. * @param imageType is the image type to use.
  56657. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  56658. */
  56659. download(imageType?: string, quality?: number): void;
  56660. /**
  56661. * Public method to load a texturePacker JSON file.
  56662. * @param data of the JSON file in string format.
  56663. */
  56664. updateFromJSON(data: string): void;
  56665. }
  56666. }
  56667. declare module BABYLON {
  56668. /**
  56669. * Enum used to define the target of a block
  56670. */
  56671. export enum NodeMaterialBlockTargets {
  56672. /** Vertex shader */
  56673. Vertex = 1,
  56674. /** Fragment shader */
  56675. Fragment = 2,
  56676. /** Neutral */
  56677. Neutral = 4,
  56678. /** Vertex and Fragment */
  56679. VertexAndFragment = 3
  56680. }
  56681. }
  56682. declare module BABYLON {
  56683. /**
  56684. * Defines the kind of connection point for node based material
  56685. */
  56686. export enum NodeMaterialBlockConnectionPointTypes {
  56687. /** Float */
  56688. Float = 1,
  56689. /** Int */
  56690. Int = 2,
  56691. /** Vector2 */
  56692. Vector2 = 4,
  56693. /** Vector3 */
  56694. Vector3 = 8,
  56695. /** Vector4 */
  56696. Vector4 = 16,
  56697. /** Color3 */
  56698. Color3 = 32,
  56699. /** Color4 */
  56700. Color4 = 64,
  56701. /** Matrix */
  56702. Matrix = 128,
  56703. /** Detect type based on connection */
  56704. AutoDetect = 1024,
  56705. /** Output type that will be defined by input type */
  56706. BasedOnInput = 2048
  56707. }
  56708. }
  56709. declare module BABYLON {
  56710. /**
  56711. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  56712. */
  56713. export enum NodeMaterialBlockConnectionPointMode {
  56714. /** Value is an uniform */
  56715. Uniform = 0,
  56716. /** Value is a mesh attribute */
  56717. Attribute = 1,
  56718. /** Value is a varying between vertex and fragment shaders */
  56719. Varying = 2,
  56720. /** Mode is undefined */
  56721. Undefined = 3
  56722. }
  56723. }
  56724. declare module BABYLON {
  56725. /**
  56726. * Enum used to define system values e.g. values automatically provided by the system
  56727. */
  56728. export enum NodeMaterialSystemValues {
  56729. /** World */
  56730. World = 1,
  56731. /** View */
  56732. View = 2,
  56733. /** Projection */
  56734. Projection = 3,
  56735. /** ViewProjection */
  56736. ViewProjection = 4,
  56737. /** WorldView */
  56738. WorldView = 5,
  56739. /** WorldViewProjection */
  56740. WorldViewProjection = 6,
  56741. /** CameraPosition */
  56742. CameraPosition = 7,
  56743. /** Fog Color */
  56744. FogColor = 8,
  56745. /** Delta time */
  56746. DeltaTime = 9
  56747. }
  56748. }
  56749. declare module BABYLON {
  56750. /**
  56751. * Root class for all node material optimizers
  56752. */
  56753. export class NodeMaterialOptimizer {
  56754. /**
  56755. * Function used to optimize a NodeMaterial graph
  56756. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  56757. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  56758. */
  56759. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  56760. }
  56761. }
  56762. declare module BABYLON {
  56763. /**
  56764. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  56765. */
  56766. export class TransformBlock extends NodeMaterialBlock {
  56767. /**
  56768. * Defines the value to use to complement W value to transform it to a Vector4
  56769. */
  56770. complementW: number;
  56771. /**
  56772. * Defines the value to use to complement z value to transform it to a Vector4
  56773. */
  56774. complementZ: number;
  56775. /**
  56776. * Creates a new TransformBlock
  56777. * @param name defines the block name
  56778. */
  56779. constructor(name: string);
  56780. /**
  56781. * Gets the current class name
  56782. * @returns the class name
  56783. */
  56784. getClassName(): string;
  56785. /**
  56786. * Gets the vector input
  56787. */
  56788. get vector(): NodeMaterialConnectionPoint;
  56789. /**
  56790. * Gets the output component
  56791. */
  56792. get output(): NodeMaterialConnectionPoint;
  56793. /**
  56794. * Gets the matrix transform input
  56795. */
  56796. get transform(): NodeMaterialConnectionPoint;
  56797. protected _buildBlock(state: NodeMaterialBuildState): this;
  56798. serialize(): any;
  56799. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56800. protected _dumpPropertiesCode(): string;
  56801. }
  56802. }
  56803. declare module BABYLON {
  56804. /**
  56805. * Block used to output the vertex position
  56806. */
  56807. export class VertexOutputBlock extends NodeMaterialBlock {
  56808. /**
  56809. * Creates a new VertexOutputBlock
  56810. * @param name defines the block name
  56811. */
  56812. constructor(name: string);
  56813. /**
  56814. * Gets the current class name
  56815. * @returns the class name
  56816. */
  56817. getClassName(): string;
  56818. /**
  56819. * Gets the vector input component
  56820. */
  56821. get vector(): NodeMaterialConnectionPoint;
  56822. protected _buildBlock(state: NodeMaterialBuildState): this;
  56823. }
  56824. }
  56825. declare module BABYLON {
  56826. /**
  56827. * Block used to output the final color
  56828. */
  56829. export class FragmentOutputBlock extends NodeMaterialBlock {
  56830. /**
  56831. * Create a new FragmentOutputBlock
  56832. * @param name defines the block name
  56833. */
  56834. constructor(name: string);
  56835. /**
  56836. * Gets the current class name
  56837. * @returns the class name
  56838. */
  56839. getClassName(): string;
  56840. /**
  56841. * Gets the rgba input component
  56842. */
  56843. get rgba(): NodeMaterialConnectionPoint;
  56844. /**
  56845. * Gets the rgb input component
  56846. */
  56847. get rgb(): NodeMaterialConnectionPoint;
  56848. /**
  56849. * Gets the a input component
  56850. */
  56851. get a(): NodeMaterialConnectionPoint;
  56852. protected _buildBlock(state: NodeMaterialBuildState): this;
  56853. }
  56854. }
  56855. declare module BABYLON {
  56856. /**
  56857. * Block used to read a reflection texture from a sampler
  56858. */
  56859. export class ReflectionTextureBlock extends NodeMaterialBlock {
  56860. private _define3DName;
  56861. private _defineCubicName;
  56862. private _defineExplicitName;
  56863. private _defineProjectionName;
  56864. private _defineLocalCubicName;
  56865. private _defineSphericalName;
  56866. private _definePlanarName;
  56867. private _defineEquirectangularName;
  56868. private _defineMirroredEquirectangularFixedName;
  56869. private _defineEquirectangularFixedName;
  56870. private _defineSkyboxName;
  56871. private _cubeSamplerName;
  56872. private _2DSamplerName;
  56873. private _positionUVWName;
  56874. private _directionWName;
  56875. private _reflectionCoordsName;
  56876. private _reflection2DCoordsName;
  56877. private _reflectionColorName;
  56878. private _reflectionMatrixName;
  56879. /**
  56880. * Gets or sets the texture associated with the node
  56881. */
  56882. texture: Nullable<BaseTexture>;
  56883. /**
  56884. * Create a new TextureBlock
  56885. * @param name defines the block name
  56886. */
  56887. constructor(name: string);
  56888. /**
  56889. * Gets the current class name
  56890. * @returns the class name
  56891. */
  56892. getClassName(): string;
  56893. /**
  56894. * Gets the world position input component
  56895. */
  56896. get position(): NodeMaterialConnectionPoint;
  56897. /**
  56898. * Gets the world position input component
  56899. */
  56900. get worldPosition(): NodeMaterialConnectionPoint;
  56901. /**
  56902. * Gets the world normal input component
  56903. */
  56904. get worldNormal(): NodeMaterialConnectionPoint;
  56905. /**
  56906. * Gets the world input component
  56907. */
  56908. get world(): NodeMaterialConnectionPoint;
  56909. /**
  56910. * Gets the camera (or eye) position component
  56911. */
  56912. get cameraPosition(): NodeMaterialConnectionPoint;
  56913. /**
  56914. * Gets the view input component
  56915. */
  56916. get view(): NodeMaterialConnectionPoint;
  56917. /**
  56918. * Gets the rgb output component
  56919. */
  56920. get rgb(): NodeMaterialConnectionPoint;
  56921. /**
  56922. * Gets the r output component
  56923. */
  56924. get r(): NodeMaterialConnectionPoint;
  56925. /**
  56926. * Gets the g output component
  56927. */
  56928. get g(): NodeMaterialConnectionPoint;
  56929. /**
  56930. * Gets the b output component
  56931. */
  56932. get b(): NodeMaterialConnectionPoint;
  56933. autoConfigure(material: NodeMaterial): void;
  56934. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56935. isReady(): boolean;
  56936. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56937. private _injectVertexCode;
  56938. private _writeOutput;
  56939. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  56940. protected _dumpPropertiesCode(): string;
  56941. serialize(): any;
  56942. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56943. }
  56944. }
  56945. declare module BABYLON {
  56946. /**
  56947. * Interface used to configure the node material editor
  56948. */
  56949. export interface INodeMaterialEditorOptions {
  56950. /** Define the URl to load node editor script */
  56951. editorURL?: string;
  56952. }
  56953. /** @hidden */
  56954. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  56955. NORMAL: boolean;
  56956. TANGENT: boolean;
  56957. UV1: boolean;
  56958. /** BONES */
  56959. NUM_BONE_INFLUENCERS: number;
  56960. BonesPerMesh: number;
  56961. BONETEXTURE: boolean;
  56962. /** MORPH TARGETS */
  56963. MORPHTARGETS: boolean;
  56964. MORPHTARGETS_NORMAL: boolean;
  56965. MORPHTARGETS_TANGENT: boolean;
  56966. MORPHTARGETS_UV: boolean;
  56967. NUM_MORPH_INFLUENCERS: number;
  56968. /** IMAGE PROCESSING */
  56969. IMAGEPROCESSING: boolean;
  56970. VIGNETTE: boolean;
  56971. VIGNETTEBLENDMODEMULTIPLY: boolean;
  56972. VIGNETTEBLENDMODEOPAQUE: boolean;
  56973. TONEMAPPING: boolean;
  56974. TONEMAPPING_ACES: boolean;
  56975. CONTRAST: boolean;
  56976. EXPOSURE: boolean;
  56977. COLORCURVES: boolean;
  56978. COLORGRADING: boolean;
  56979. COLORGRADING3D: boolean;
  56980. SAMPLER3DGREENDEPTH: boolean;
  56981. SAMPLER3DBGRMAP: boolean;
  56982. IMAGEPROCESSINGPOSTPROCESS: boolean;
  56983. /** MISC. */
  56984. BUMPDIRECTUV: number;
  56985. constructor();
  56986. setValue(name: string, value: boolean): void;
  56987. }
  56988. /**
  56989. * Class used to configure NodeMaterial
  56990. */
  56991. export interface INodeMaterialOptions {
  56992. /**
  56993. * Defines if blocks should emit comments
  56994. */
  56995. emitComments: boolean;
  56996. }
  56997. /**
  56998. * Class used to create a node based material built by assembling shader blocks
  56999. */
  57000. export class NodeMaterial extends PushMaterial {
  57001. private static _BuildIdGenerator;
  57002. private _options;
  57003. private _vertexCompilationState;
  57004. private _fragmentCompilationState;
  57005. private _sharedData;
  57006. private _buildId;
  57007. private _buildWasSuccessful;
  57008. private _cachedWorldViewMatrix;
  57009. private _cachedWorldViewProjectionMatrix;
  57010. private _optimizers;
  57011. private _animationFrame;
  57012. /** Define the Url to load node editor script */
  57013. static EditorURL: string;
  57014. /** Define the Url to load snippets */
  57015. static SnippetUrl: string;
  57016. private BJSNODEMATERIALEDITOR;
  57017. /** Get the inspector from bundle or global */
  57018. private _getGlobalNodeMaterialEditor;
  57019. /**
  57020. * Gets or sets data used by visual editor
  57021. * @see https://nme.babylonjs.com
  57022. */
  57023. editorData: any;
  57024. /**
  57025. * 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)
  57026. */
  57027. ignoreAlpha: boolean;
  57028. /**
  57029. * Defines the maximum number of lights that can be used in the material
  57030. */
  57031. maxSimultaneousLights: number;
  57032. /**
  57033. * Observable raised when the material is built
  57034. */
  57035. onBuildObservable: Observable<NodeMaterial>;
  57036. /**
  57037. * Gets or sets the root nodes of the material vertex shader
  57038. */
  57039. _vertexOutputNodes: NodeMaterialBlock[];
  57040. /**
  57041. * Gets or sets the root nodes of the material fragment (pixel) shader
  57042. */
  57043. _fragmentOutputNodes: NodeMaterialBlock[];
  57044. /** Gets or sets options to control the node material overall behavior */
  57045. get options(): INodeMaterialOptions;
  57046. set options(options: INodeMaterialOptions);
  57047. /**
  57048. * Default configuration related to image processing available in the standard Material.
  57049. */
  57050. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  57051. /**
  57052. * Gets the image processing configuration used either in this material.
  57053. */
  57054. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  57055. /**
  57056. * Sets the Default image processing configuration used either in the this material.
  57057. *
  57058. * If sets to null, the scene one is in use.
  57059. */
  57060. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  57061. /**
  57062. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  57063. */
  57064. attachedBlocks: NodeMaterialBlock[];
  57065. /**
  57066. * Create a new node based material
  57067. * @param name defines the material name
  57068. * @param scene defines the hosting scene
  57069. * @param options defines creation option
  57070. */
  57071. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  57072. /**
  57073. * Gets the current class name of the material e.g. "NodeMaterial"
  57074. * @returns the class name
  57075. */
  57076. getClassName(): string;
  57077. /**
  57078. * Keep track of the image processing observer to allow dispose and replace.
  57079. */
  57080. private _imageProcessingObserver;
  57081. /**
  57082. * Attaches a new image processing configuration to the Standard Material.
  57083. * @param configuration
  57084. */
  57085. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  57086. /**
  57087. * Get a block by its name
  57088. * @param name defines the name of the block to retrieve
  57089. * @returns the required block or null if not found
  57090. */
  57091. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  57092. /**
  57093. * Get a block by its name
  57094. * @param predicate defines the predicate used to find the good candidate
  57095. * @returns the required block or null if not found
  57096. */
  57097. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  57098. /**
  57099. * Get an input block by its name
  57100. * @param predicate defines the predicate used to find the good candidate
  57101. * @returns the required input block or null if not found
  57102. */
  57103. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  57104. /**
  57105. * Gets the list of input blocks attached to this material
  57106. * @returns an array of InputBlocks
  57107. */
  57108. getInputBlocks(): InputBlock[];
  57109. /**
  57110. * Adds a new optimizer to the list of optimizers
  57111. * @param optimizer defines the optimizers to add
  57112. * @returns the current material
  57113. */
  57114. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  57115. /**
  57116. * Remove an optimizer from the list of optimizers
  57117. * @param optimizer defines the optimizers to remove
  57118. * @returns the current material
  57119. */
  57120. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  57121. /**
  57122. * Add a new block to the list of output nodes
  57123. * @param node defines the node to add
  57124. * @returns the current material
  57125. */
  57126. addOutputNode(node: NodeMaterialBlock): this;
  57127. /**
  57128. * Remove a block from the list of root nodes
  57129. * @param node defines the node to remove
  57130. * @returns the current material
  57131. */
  57132. removeOutputNode(node: NodeMaterialBlock): this;
  57133. private _addVertexOutputNode;
  57134. private _removeVertexOutputNode;
  57135. private _addFragmentOutputNode;
  57136. private _removeFragmentOutputNode;
  57137. /**
  57138. * Specifies if the material will require alpha blending
  57139. * @returns a boolean specifying if alpha blending is needed
  57140. */
  57141. needAlphaBlending(): boolean;
  57142. /**
  57143. * Specifies if this material should be rendered in alpha test mode
  57144. * @returns a boolean specifying if an alpha test is needed.
  57145. */
  57146. needAlphaTesting(): boolean;
  57147. private _initializeBlock;
  57148. private _resetDualBlocks;
  57149. /**
  57150. * Remove a block from the current node material
  57151. * @param block defines the block to remove
  57152. */
  57153. removeBlock(block: NodeMaterialBlock): void;
  57154. /**
  57155. * Build the material and generates the inner effect
  57156. * @param verbose defines if the build should log activity
  57157. */
  57158. build(verbose?: boolean): void;
  57159. /**
  57160. * Runs an otpimization phase to try to improve the shader code
  57161. */
  57162. optimize(): void;
  57163. private _prepareDefinesForAttributes;
  57164. /**
  57165. * Get if the submesh is ready to be used and all its information available.
  57166. * Child classes can use it to update shaders
  57167. * @param mesh defines the mesh to check
  57168. * @param subMesh defines which submesh to check
  57169. * @param useInstances specifies that instances should be used
  57170. * @returns a boolean indicating that the submesh is ready or not
  57171. */
  57172. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  57173. /**
  57174. * Get a string representing the shaders built by the current node graph
  57175. */
  57176. get compiledShaders(): string;
  57177. /**
  57178. * Binds the world matrix to the material
  57179. * @param world defines the world transformation matrix
  57180. */
  57181. bindOnlyWorldMatrix(world: Matrix): void;
  57182. /**
  57183. * Binds the submesh to this material by preparing the effect and shader to draw
  57184. * @param world defines the world transformation matrix
  57185. * @param mesh defines the mesh containing the submesh
  57186. * @param subMesh defines the submesh to bind the material to
  57187. */
  57188. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  57189. /**
  57190. * Gets the active textures from the material
  57191. * @returns an array of textures
  57192. */
  57193. getActiveTextures(): BaseTexture[];
  57194. /**
  57195. * Gets the list of texture blocks
  57196. * @returns an array of texture blocks
  57197. */
  57198. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  57199. /**
  57200. * Specifies if the material uses a texture
  57201. * @param texture defines the texture to check against the material
  57202. * @returns a boolean specifying if the material uses the texture
  57203. */
  57204. hasTexture(texture: BaseTexture): boolean;
  57205. /**
  57206. * Disposes the material
  57207. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  57208. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  57209. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  57210. */
  57211. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  57212. /** Creates the node editor window. */
  57213. private _createNodeEditor;
  57214. /**
  57215. * Launch the node material editor
  57216. * @param config Define the configuration of the editor
  57217. * @return a promise fulfilled when the node editor is visible
  57218. */
  57219. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  57220. /**
  57221. * Clear the current material
  57222. */
  57223. clear(): void;
  57224. /**
  57225. * Clear the current material and set it to a default state
  57226. */
  57227. setToDefault(): void;
  57228. /**
  57229. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  57230. * @param url defines the url to load from
  57231. * @returns a promise that will fullfil when the material is fully loaded
  57232. */
  57233. loadAsync(url: string): Promise<void>;
  57234. private _gatherBlocks;
  57235. /**
  57236. * Generate a string containing the code declaration required to create an equivalent of this material
  57237. * @returns a string
  57238. */
  57239. generateCode(): string;
  57240. /**
  57241. * Serializes this material in a JSON representation
  57242. * @returns the serialized material object
  57243. */
  57244. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  57245. private _restoreConnections;
  57246. /**
  57247. * Clear the current graph and load a new one from a serialization object
  57248. * @param source defines the JSON representation of the material
  57249. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  57250. */
  57251. loadFromSerialization(source: any, rootUrl?: string): void;
  57252. /**
  57253. * Creates a node material from parsed material data
  57254. * @param source defines the JSON representation of the material
  57255. * @param scene defines the hosting scene
  57256. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  57257. * @returns a new node material
  57258. */
  57259. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  57260. /**
  57261. * Creates a node material from a snippet saved in a remote file
  57262. * @param name defines the name of the material to create
  57263. * @param url defines the url to load from
  57264. * @param scene defines the hosting scene
  57265. * @returns a promise that will resolve to the new node material
  57266. */
  57267. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  57268. /**
  57269. * Creates a node material from a snippet saved by the node material editor
  57270. * @param snippetId defines the snippet to load
  57271. * @param scene defines the hosting scene
  57272. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  57273. * @returns a promise that will resolve to the new node material
  57274. */
  57275. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<NodeMaterial>;
  57276. /**
  57277. * Creates a new node material set to default basic configuration
  57278. * @param name defines the name of the material
  57279. * @param scene defines the hosting scene
  57280. * @returns a new NodeMaterial
  57281. */
  57282. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  57283. }
  57284. }
  57285. declare module BABYLON {
  57286. /**
  57287. * Block used to read a texture from a sampler
  57288. */
  57289. export class TextureBlock extends NodeMaterialBlock {
  57290. private _defineName;
  57291. private _linearDefineName;
  57292. private _tempTextureRead;
  57293. private _samplerName;
  57294. private _transformedUVName;
  57295. private _textureTransformName;
  57296. private _textureInfoName;
  57297. private _mainUVName;
  57298. private _mainUVDefineName;
  57299. /**
  57300. * Gets or sets the texture associated with the node
  57301. */
  57302. texture: Nullable<Texture>;
  57303. /**
  57304. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  57305. */
  57306. convertToGammaSpace: boolean;
  57307. /**
  57308. * Create a new TextureBlock
  57309. * @param name defines the block name
  57310. */
  57311. constructor(name: string);
  57312. /**
  57313. * Gets the current class name
  57314. * @returns the class name
  57315. */
  57316. getClassName(): string;
  57317. /**
  57318. * Gets the uv input component
  57319. */
  57320. get uv(): NodeMaterialConnectionPoint;
  57321. /**
  57322. * Gets the rgba output component
  57323. */
  57324. get rgba(): NodeMaterialConnectionPoint;
  57325. /**
  57326. * Gets the rgb output component
  57327. */
  57328. get rgb(): NodeMaterialConnectionPoint;
  57329. /**
  57330. * Gets the r output component
  57331. */
  57332. get r(): NodeMaterialConnectionPoint;
  57333. /**
  57334. * Gets the g output component
  57335. */
  57336. get g(): NodeMaterialConnectionPoint;
  57337. /**
  57338. * Gets the b output component
  57339. */
  57340. get b(): NodeMaterialConnectionPoint;
  57341. /**
  57342. * Gets the a output component
  57343. */
  57344. get a(): NodeMaterialConnectionPoint;
  57345. get target(): NodeMaterialBlockTargets;
  57346. autoConfigure(material: NodeMaterial): void;
  57347. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  57348. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57349. isReady(): boolean;
  57350. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57351. private get _isMixed();
  57352. private _injectVertexCode;
  57353. private _writeTextureRead;
  57354. private _writeOutput;
  57355. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  57356. protected _dumpPropertiesCode(): string;
  57357. serialize(): any;
  57358. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57359. }
  57360. }
  57361. declare module BABYLON {
  57362. /**
  57363. * Class used to store shared data between 2 NodeMaterialBuildState
  57364. */
  57365. export class NodeMaterialBuildStateSharedData {
  57366. /**
  57367. * Gets the list of emitted varyings
  57368. */
  57369. temps: string[];
  57370. /**
  57371. * Gets the list of emitted varyings
  57372. */
  57373. varyings: string[];
  57374. /**
  57375. * Gets the varying declaration string
  57376. */
  57377. varyingDeclaration: string;
  57378. /**
  57379. * Input blocks
  57380. */
  57381. inputBlocks: InputBlock[];
  57382. /**
  57383. * Input blocks
  57384. */
  57385. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  57386. /**
  57387. * Bindable blocks (Blocks that need to set data to the effect)
  57388. */
  57389. bindableBlocks: NodeMaterialBlock[];
  57390. /**
  57391. * List of blocks that can provide a compilation fallback
  57392. */
  57393. blocksWithFallbacks: NodeMaterialBlock[];
  57394. /**
  57395. * List of blocks that can provide a define update
  57396. */
  57397. blocksWithDefines: NodeMaterialBlock[];
  57398. /**
  57399. * List of blocks that can provide a repeatable content
  57400. */
  57401. repeatableContentBlocks: NodeMaterialBlock[];
  57402. /**
  57403. * List of blocks that can provide a dynamic list of uniforms
  57404. */
  57405. dynamicUniformBlocks: NodeMaterialBlock[];
  57406. /**
  57407. * List of blocks that can block the isReady function for the material
  57408. */
  57409. blockingBlocks: NodeMaterialBlock[];
  57410. /**
  57411. * Gets the list of animated inputs
  57412. */
  57413. animatedInputs: InputBlock[];
  57414. /**
  57415. * Build Id used to avoid multiple recompilations
  57416. */
  57417. buildId: number;
  57418. /** List of emitted variables */
  57419. variableNames: {
  57420. [key: string]: number;
  57421. };
  57422. /** List of emitted defines */
  57423. defineNames: {
  57424. [key: string]: number;
  57425. };
  57426. /** Should emit comments? */
  57427. emitComments: boolean;
  57428. /** Emit build activity */
  57429. verbose: boolean;
  57430. /** Gets or sets the hosting scene */
  57431. scene: Scene;
  57432. /**
  57433. * Gets the compilation hints emitted at compilation time
  57434. */
  57435. hints: {
  57436. needWorldViewMatrix: boolean;
  57437. needWorldViewProjectionMatrix: boolean;
  57438. needAlphaBlending: boolean;
  57439. needAlphaTesting: boolean;
  57440. };
  57441. /**
  57442. * List of compilation checks
  57443. */
  57444. checks: {
  57445. emitVertex: boolean;
  57446. emitFragment: boolean;
  57447. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  57448. };
  57449. /** Creates a new shared data */
  57450. constructor();
  57451. /**
  57452. * Emits console errors and exceptions if there is a failing check
  57453. */
  57454. emitErrors(): void;
  57455. }
  57456. }
  57457. declare module BABYLON {
  57458. /**
  57459. * Class used to store node based material build state
  57460. */
  57461. export class NodeMaterialBuildState {
  57462. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  57463. supportUniformBuffers: boolean;
  57464. /**
  57465. * Gets the list of emitted attributes
  57466. */
  57467. attributes: string[];
  57468. /**
  57469. * Gets the list of emitted uniforms
  57470. */
  57471. uniforms: string[];
  57472. /**
  57473. * Gets the list of emitted constants
  57474. */
  57475. constants: string[];
  57476. /**
  57477. * Gets the list of emitted samplers
  57478. */
  57479. samplers: string[];
  57480. /**
  57481. * Gets the list of emitted functions
  57482. */
  57483. functions: {
  57484. [key: string]: string;
  57485. };
  57486. /**
  57487. * Gets the list of emitted extensions
  57488. */
  57489. extensions: {
  57490. [key: string]: string;
  57491. };
  57492. /**
  57493. * Gets the target of the compilation state
  57494. */
  57495. target: NodeMaterialBlockTargets;
  57496. /**
  57497. * Gets the list of emitted counters
  57498. */
  57499. counters: {
  57500. [key: string]: number;
  57501. };
  57502. /**
  57503. * Shared data between multiple NodeMaterialBuildState instances
  57504. */
  57505. sharedData: NodeMaterialBuildStateSharedData;
  57506. /** @hidden */
  57507. _vertexState: NodeMaterialBuildState;
  57508. /** @hidden */
  57509. _attributeDeclaration: string;
  57510. /** @hidden */
  57511. _uniformDeclaration: string;
  57512. /** @hidden */
  57513. _constantDeclaration: string;
  57514. /** @hidden */
  57515. _samplerDeclaration: string;
  57516. /** @hidden */
  57517. _varyingTransfer: string;
  57518. private _repeatableContentAnchorIndex;
  57519. /** @hidden */
  57520. _builtCompilationString: string;
  57521. /**
  57522. * Gets the emitted compilation strings
  57523. */
  57524. compilationString: string;
  57525. /**
  57526. * Finalize the compilation strings
  57527. * @param state defines the current compilation state
  57528. */
  57529. finalize(state: NodeMaterialBuildState): void;
  57530. /** @hidden */
  57531. get _repeatableContentAnchor(): string;
  57532. /** @hidden */
  57533. _getFreeVariableName(prefix: string): string;
  57534. /** @hidden */
  57535. _getFreeDefineName(prefix: string): string;
  57536. /** @hidden */
  57537. _excludeVariableName(name: string): void;
  57538. /** @hidden */
  57539. _emit2DSampler(name: string): void;
  57540. /** @hidden */
  57541. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  57542. /** @hidden */
  57543. _emitExtension(name: string, extension: string): void;
  57544. /** @hidden */
  57545. _emitFunction(name: string, code: string, comments: string): void;
  57546. /** @hidden */
  57547. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  57548. replaceStrings?: {
  57549. search: RegExp;
  57550. replace: string;
  57551. }[];
  57552. repeatKey?: string;
  57553. }): string;
  57554. /** @hidden */
  57555. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  57556. repeatKey?: string;
  57557. removeAttributes?: boolean;
  57558. removeUniforms?: boolean;
  57559. removeVaryings?: boolean;
  57560. removeIfDef?: boolean;
  57561. replaceStrings?: {
  57562. search: RegExp;
  57563. replace: string;
  57564. }[];
  57565. }, storeKey?: string): void;
  57566. /** @hidden */
  57567. _registerTempVariable(name: string): boolean;
  57568. /** @hidden */
  57569. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  57570. /** @hidden */
  57571. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  57572. /** @hidden */
  57573. _emitFloat(value: number): string;
  57574. }
  57575. }
  57576. declare module BABYLON {
  57577. /**
  57578. * Defines a block that can be used inside a node based material
  57579. */
  57580. export class NodeMaterialBlock {
  57581. private _buildId;
  57582. private _buildTarget;
  57583. private _target;
  57584. private _isFinalMerger;
  57585. private _isInput;
  57586. protected _isUnique: boolean;
  57587. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  57588. inputsAreExclusive: boolean;
  57589. /** @hidden */
  57590. _codeVariableName: string;
  57591. /** @hidden */
  57592. _inputs: NodeMaterialConnectionPoint[];
  57593. /** @hidden */
  57594. _outputs: NodeMaterialConnectionPoint[];
  57595. /** @hidden */
  57596. _preparationId: number;
  57597. /**
  57598. * Gets or sets the name of the block
  57599. */
  57600. name: string;
  57601. /**
  57602. * Gets or sets the unique id of the node
  57603. */
  57604. uniqueId: number;
  57605. /**
  57606. * Gets or sets the comments associated with this block
  57607. */
  57608. comments: string;
  57609. /**
  57610. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  57611. */
  57612. get isUnique(): boolean;
  57613. /**
  57614. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  57615. */
  57616. get isFinalMerger(): boolean;
  57617. /**
  57618. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  57619. */
  57620. get isInput(): boolean;
  57621. /**
  57622. * Gets or sets the build Id
  57623. */
  57624. get buildId(): number;
  57625. set buildId(value: number);
  57626. /**
  57627. * Gets or sets the target of the block
  57628. */
  57629. get target(): NodeMaterialBlockTargets;
  57630. set target(value: NodeMaterialBlockTargets);
  57631. /**
  57632. * Gets the list of input points
  57633. */
  57634. get inputs(): NodeMaterialConnectionPoint[];
  57635. /** Gets the list of output points */
  57636. get outputs(): NodeMaterialConnectionPoint[];
  57637. /**
  57638. * Find an input by its name
  57639. * @param name defines the name of the input to look for
  57640. * @returns the input or null if not found
  57641. */
  57642. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  57643. /**
  57644. * Find an output by its name
  57645. * @param name defines the name of the outputto look for
  57646. * @returns the output or null if not found
  57647. */
  57648. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  57649. /**
  57650. * Creates a new NodeMaterialBlock
  57651. * @param name defines the block name
  57652. * @param target defines the target of that block (Vertex by default)
  57653. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  57654. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  57655. */
  57656. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  57657. /**
  57658. * Initialize the block and prepare the context for build
  57659. * @param state defines the state that will be used for the build
  57660. */
  57661. initialize(state: NodeMaterialBuildState): void;
  57662. /**
  57663. * Bind data to effect. Will only be called for blocks with isBindable === true
  57664. * @param effect defines the effect to bind data to
  57665. * @param nodeMaterial defines the hosting NodeMaterial
  57666. * @param mesh defines the mesh that will be rendered
  57667. */
  57668. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57669. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  57670. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  57671. protected _writeFloat(value: number): string;
  57672. /**
  57673. * Gets the current class name e.g. "NodeMaterialBlock"
  57674. * @returns the class name
  57675. */
  57676. getClassName(): string;
  57677. /**
  57678. * Register a new input. Must be called inside a block constructor
  57679. * @param name defines the connection point name
  57680. * @param type defines the connection point type
  57681. * @param isOptional defines a boolean indicating that this input can be omitted
  57682. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  57683. * @returns the current block
  57684. */
  57685. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  57686. /**
  57687. * Register a new output. Must be called inside a block constructor
  57688. * @param name defines the connection point name
  57689. * @param type defines the connection point type
  57690. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  57691. * @returns the current block
  57692. */
  57693. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  57694. /**
  57695. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  57696. * @param forOutput defines an optional connection point to check compatibility with
  57697. * @returns the first available input or null
  57698. */
  57699. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  57700. /**
  57701. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  57702. * @param forBlock defines an optional block to check compatibility with
  57703. * @returns the first available input or null
  57704. */
  57705. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  57706. /**
  57707. * Gets the sibling of the given output
  57708. * @param current defines the current output
  57709. * @returns the next output in the list or null
  57710. */
  57711. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  57712. /**
  57713. * Connect current block with another block
  57714. * @param other defines the block to connect with
  57715. * @param options define the various options to help pick the right connections
  57716. * @returns the current block
  57717. */
  57718. connectTo(other: NodeMaterialBlock, options?: {
  57719. input?: string;
  57720. output?: string;
  57721. outputSwizzle?: string;
  57722. }): this | undefined;
  57723. protected _buildBlock(state: NodeMaterialBuildState): void;
  57724. /**
  57725. * Add uniforms, samplers and uniform buffers at compilation time
  57726. * @param state defines the state to update
  57727. * @param nodeMaterial defines the node material requesting the update
  57728. * @param defines defines the material defines to update
  57729. * @param uniformBuffers defines the list of uniform buffer names
  57730. */
  57731. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  57732. /**
  57733. * Add potential fallbacks if shader compilation fails
  57734. * @param mesh defines the mesh to be rendered
  57735. * @param fallbacks defines the current prioritized list of fallbacks
  57736. */
  57737. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  57738. /**
  57739. * Initialize defines for shader compilation
  57740. * @param mesh defines the mesh to be rendered
  57741. * @param nodeMaterial defines the node material requesting the update
  57742. * @param defines defines the material defines to update
  57743. * @param useInstances specifies that instances should be used
  57744. */
  57745. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  57746. /**
  57747. * Update defines for shader compilation
  57748. * @param mesh defines the mesh to be rendered
  57749. * @param nodeMaterial defines the node material requesting the update
  57750. * @param defines defines the material defines to update
  57751. * @param useInstances specifies that instances should be used
  57752. */
  57753. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  57754. /**
  57755. * Lets the block try to connect some inputs automatically
  57756. * @param material defines the hosting NodeMaterial
  57757. */
  57758. autoConfigure(material: NodeMaterial): void;
  57759. /**
  57760. * Function called when a block is declared as repeatable content generator
  57761. * @param vertexShaderState defines the current compilation state for the vertex shader
  57762. * @param fragmentShaderState defines the current compilation state for the fragment shader
  57763. * @param mesh defines the mesh to be rendered
  57764. * @param defines defines the material defines to update
  57765. */
  57766. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  57767. /**
  57768. * Checks if the block is ready
  57769. * @param mesh defines the mesh to be rendered
  57770. * @param nodeMaterial defines the node material requesting the update
  57771. * @param defines defines the material defines to update
  57772. * @param useInstances specifies that instances should be used
  57773. * @returns true if the block is ready
  57774. */
  57775. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  57776. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  57777. private _processBuild;
  57778. /**
  57779. * Compile the current node and generate the shader code
  57780. * @param state defines the current compilation state (uniforms, samplers, current string)
  57781. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  57782. * @returns true if already built
  57783. */
  57784. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  57785. protected _inputRename(name: string): string;
  57786. protected _outputRename(name: string): string;
  57787. protected _dumpPropertiesCode(): string;
  57788. /** @hidden */
  57789. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  57790. /** @hidden */
  57791. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  57792. /**
  57793. * Clone the current block to a new identical block
  57794. * @param scene defines the hosting scene
  57795. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  57796. * @returns a copy of the current block
  57797. */
  57798. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  57799. /**
  57800. * Serializes this block in a JSON representation
  57801. * @returns the serialized block object
  57802. */
  57803. serialize(): any;
  57804. /** @hidden */
  57805. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57806. /**
  57807. * Release resources
  57808. */
  57809. dispose(): void;
  57810. }
  57811. }
  57812. declare module BABYLON {
  57813. /**
  57814. * Enum defining the type of animations supported by InputBlock
  57815. */
  57816. export enum AnimatedInputBlockTypes {
  57817. /** No animation */
  57818. None = 0,
  57819. /** Time based animation. Will only work for floats */
  57820. Time = 1
  57821. }
  57822. }
  57823. declare module BABYLON {
  57824. /**
  57825. * Block used to expose an input value
  57826. */
  57827. export class InputBlock extends NodeMaterialBlock {
  57828. private _mode;
  57829. private _associatedVariableName;
  57830. private _storedValue;
  57831. private _valueCallback;
  57832. private _type;
  57833. private _animationType;
  57834. /** Gets or set a value used to limit the range of float values */
  57835. min: number;
  57836. /** Gets or set a value used to limit the range of float values */
  57837. max: number;
  57838. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  57839. isBoolean: boolean;
  57840. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  57841. matrixMode: number;
  57842. /** @hidden */
  57843. _systemValue: Nullable<NodeMaterialSystemValues>;
  57844. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  57845. visibleInInspector: boolean;
  57846. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  57847. isConstant: boolean;
  57848. /** Gets or sets the group to use to display this block in the Inspector */
  57849. groupInInspector: string;
  57850. /**
  57851. * Gets or sets the connection point type (default is float)
  57852. */
  57853. get type(): NodeMaterialBlockConnectionPointTypes;
  57854. /**
  57855. * Creates a new InputBlock
  57856. * @param name defines the block name
  57857. * @param target defines the target of that block (Vertex by default)
  57858. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  57859. */
  57860. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  57861. /**
  57862. * Gets the output component
  57863. */
  57864. get output(): NodeMaterialConnectionPoint;
  57865. /**
  57866. * Set the source of this connection point to a vertex attribute
  57867. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  57868. * @returns the current connection point
  57869. */
  57870. setAsAttribute(attributeName?: string): InputBlock;
  57871. /**
  57872. * Set the source of this connection point to a system value
  57873. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  57874. * @returns the current connection point
  57875. */
  57876. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  57877. /**
  57878. * Gets or sets the value of that point.
  57879. * Please note that this value will be ignored if valueCallback is defined
  57880. */
  57881. get value(): any;
  57882. set value(value: any);
  57883. /**
  57884. * Gets or sets a callback used to get the value of that point.
  57885. * Please note that setting this value will force the connection point to ignore the value property
  57886. */
  57887. get valueCallback(): () => any;
  57888. set valueCallback(value: () => any);
  57889. /**
  57890. * Gets or sets the associated variable name in the shader
  57891. */
  57892. get associatedVariableName(): string;
  57893. set associatedVariableName(value: string);
  57894. /** Gets or sets the type of animation applied to the input */
  57895. get animationType(): AnimatedInputBlockTypes;
  57896. set animationType(value: AnimatedInputBlockTypes);
  57897. /**
  57898. * Gets a boolean indicating that this connection point not defined yet
  57899. */
  57900. get isUndefined(): boolean;
  57901. /**
  57902. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  57903. * In this case the connection point name must be the name of the uniform to use.
  57904. * Can only be set on inputs
  57905. */
  57906. get isUniform(): boolean;
  57907. set isUniform(value: boolean);
  57908. /**
  57909. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  57910. * In this case the connection point name must be the name of the attribute to use
  57911. * Can only be set on inputs
  57912. */
  57913. get isAttribute(): boolean;
  57914. set isAttribute(value: boolean);
  57915. /**
  57916. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  57917. * Can only be set on exit points
  57918. */
  57919. get isVarying(): boolean;
  57920. set isVarying(value: boolean);
  57921. /**
  57922. * Gets a boolean indicating that the current connection point is a system value
  57923. */
  57924. get isSystemValue(): boolean;
  57925. /**
  57926. * Gets or sets the current well known value or null if not defined as a system value
  57927. */
  57928. get systemValue(): Nullable<NodeMaterialSystemValues>;
  57929. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  57930. /**
  57931. * Gets the current class name
  57932. * @returns the class name
  57933. */
  57934. getClassName(): string;
  57935. /**
  57936. * Animate the input if animationType !== None
  57937. * @param scene defines the rendering scene
  57938. */
  57939. animate(scene: Scene): void;
  57940. private _emitDefine;
  57941. initialize(state: NodeMaterialBuildState): void;
  57942. /**
  57943. * Set the input block to its default value (based on its type)
  57944. */
  57945. setDefaultValue(): void;
  57946. private _emitConstant;
  57947. private _emit;
  57948. /** @hidden */
  57949. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  57950. /** @hidden */
  57951. _transmit(effect: Effect, scene: Scene): void;
  57952. protected _buildBlock(state: NodeMaterialBuildState): void;
  57953. protected _dumpPropertiesCode(): string;
  57954. serialize(): any;
  57955. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57956. }
  57957. }
  57958. declare module BABYLON {
  57959. /**
  57960. * Enum used to define the compatibility state between two connection points
  57961. */
  57962. export enum NodeMaterialConnectionPointCompatibilityStates {
  57963. /** Points are compatibles */
  57964. Compatible = 0,
  57965. /** Points are incompatible because of their types */
  57966. TypeIncompatible = 1,
  57967. /** Points are incompatible because of their targets (vertex vs fragment) */
  57968. TargetIncompatible = 2
  57969. }
  57970. /**
  57971. * Defines the direction of a connection point
  57972. */
  57973. export enum NodeMaterialConnectionPointDirection {
  57974. /** Input */
  57975. Input = 0,
  57976. /** Output */
  57977. Output = 1
  57978. }
  57979. /**
  57980. * Defines a connection point for a block
  57981. */
  57982. export class NodeMaterialConnectionPoint {
  57983. /** @hidden */
  57984. _ownerBlock: NodeMaterialBlock;
  57985. /** @hidden */
  57986. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  57987. private _endpoints;
  57988. private _associatedVariableName;
  57989. private _direction;
  57990. /** @hidden */
  57991. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  57992. /** @hidden */
  57993. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  57994. private _type;
  57995. /** @hidden */
  57996. _enforceAssociatedVariableName: boolean;
  57997. /** Gets the direction of the point */
  57998. get direction(): NodeMaterialConnectionPointDirection;
  57999. /**
  58000. * Gets or sets the additional types supported by this connection point
  58001. */
  58002. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  58003. /**
  58004. * Gets or sets the additional types excluded by this connection point
  58005. */
  58006. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  58007. /**
  58008. * Observable triggered when this point is connected
  58009. */
  58010. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  58011. /**
  58012. * Gets or sets the associated variable name in the shader
  58013. */
  58014. get associatedVariableName(): string;
  58015. set associatedVariableName(value: string);
  58016. /** Get the inner type (ie AutoDetect for isntance instead of the inferred one) */
  58017. get innerType(): NodeMaterialBlockConnectionPointTypes;
  58018. /**
  58019. * Gets or sets the connection point type (default is float)
  58020. */
  58021. get type(): NodeMaterialBlockConnectionPointTypes;
  58022. set type(value: NodeMaterialBlockConnectionPointTypes);
  58023. /**
  58024. * Gets or sets the connection point name
  58025. */
  58026. name: string;
  58027. /**
  58028. * Gets or sets a boolean indicating that this connection point can be omitted
  58029. */
  58030. isOptional: boolean;
  58031. /**
  58032. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  58033. */
  58034. define: string;
  58035. /** @hidden */
  58036. _prioritizeVertex: boolean;
  58037. private _target;
  58038. /** Gets or sets the target of that connection point */
  58039. get target(): NodeMaterialBlockTargets;
  58040. set target(value: NodeMaterialBlockTargets);
  58041. /**
  58042. * Gets a boolean indicating that the current point is connected
  58043. */
  58044. get isConnected(): boolean;
  58045. /**
  58046. * Gets a boolean indicating that the current point is connected to an input block
  58047. */
  58048. get isConnectedToInputBlock(): boolean;
  58049. /**
  58050. * Gets a the connected input block (if any)
  58051. */
  58052. get connectInputBlock(): Nullable<InputBlock>;
  58053. /** Get the other side of the connection (if any) */
  58054. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  58055. /** Get the block that owns this connection point */
  58056. get ownerBlock(): NodeMaterialBlock;
  58057. /** Get the block connected on the other side of this connection (if any) */
  58058. get sourceBlock(): Nullable<NodeMaterialBlock>;
  58059. /** Get the block connected on the endpoints of this connection (if any) */
  58060. get connectedBlocks(): Array<NodeMaterialBlock>;
  58061. /** Gets the list of connected endpoints */
  58062. get endpoints(): NodeMaterialConnectionPoint[];
  58063. /** Gets a boolean indicating if that output point is connected to at least one input */
  58064. get hasEndpoints(): boolean;
  58065. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  58066. get isConnectedInVertexShader(): boolean;
  58067. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  58068. get isConnectedInFragmentShader(): boolean;
  58069. /**
  58070. * Creates a new connection point
  58071. * @param name defines the connection point name
  58072. * @param ownerBlock defines the block hosting this connection point
  58073. * @param direction defines the direction of the connection point
  58074. */
  58075. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  58076. /**
  58077. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  58078. * @returns the class name
  58079. */
  58080. getClassName(): string;
  58081. /**
  58082. * Gets a boolean indicating if the current point can be connected to another point
  58083. * @param connectionPoint defines the other connection point
  58084. * @returns a boolean
  58085. */
  58086. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  58087. /**
  58088. * Gets a number indicating if the current point can be connected to another point
  58089. * @param connectionPoint defines the other connection point
  58090. * @returns a number defining the compatibility state
  58091. */
  58092. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  58093. /**
  58094. * Connect this point to another connection point
  58095. * @param connectionPoint defines the other connection point
  58096. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  58097. * @returns the current connection point
  58098. */
  58099. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  58100. /**
  58101. * Disconnect this point from one of his endpoint
  58102. * @param endpoint defines the other connection point
  58103. * @returns the current connection point
  58104. */
  58105. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  58106. /**
  58107. * Serializes this point in a JSON representation
  58108. * @returns the serialized point object
  58109. */
  58110. serialize(): any;
  58111. /**
  58112. * Release resources
  58113. */
  58114. dispose(): void;
  58115. }
  58116. }
  58117. declare module BABYLON {
  58118. /**
  58119. * Block used to add support for vertex skinning (bones)
  58120. */
  58121. export class BonesBlock extends NodeMaterialBlock {
  58122. /**
  58123. * Creates a new BonesBlock
  58124. * @param name defines the block name
  58125. */
  58126. constructor(name: string);
  58127. /**
  58128. * Initialize the block and prepare the context for build
  58129. * @param state defines the state that will be used for the build
  58130. */
  58131. initialize(state: NodeMaterialBuildState): void;
  58132. /**
  58133. * Gets the current class name
  58134. * @returns the class name
  58135. */
  58136. getClassName(): string;
  58137. /**
  58138. * Gets the matrix indices input component
  58139. */
  58140. get matricesIndices(): NodeMaterialConnectionPoint;
  58141. /**
  58142. * Gets the matrix weights input component
  58143. */
  58144. get matricesWeights(): NodeMaterialConnectionPoint;
  58145. /**
  58146. * Gets the extra matrix indices input component
  58147. */
  58148. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  58149. /**
  58150. * Gets the extra matrix weights input component
  58151. */
  58152. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  58153. /**
  58154. * Gets the world input component
  58155. */
  58156. get world(): NodeMaterialConnectionPoint;
  58157. /**
  58158. * Gets the output component
  58159. */
  58160. get output(): NodeMaterialConnectionPoint;
  58161. autoConfigure(material: NodeMaterial): void;
  58162. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  58163. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58164. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58165. protected _buildBlock(state: NodeMaterialBuildState): this;
  58166. }
  58167. }
  58168. declare module BABYLON {
  58169. /**
  58170. * Block used to add support for instances
  58171. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  58172. */
  58173. export class InstancesBlock extends NodeMaterialBlock {
  58174. /**
  58175. * Creates a new InstancesBlock
  58176. * @param name defines the block name
  58177. */
  58178. constructor(name: string);
  58179. /**
  58180. * Gets the current class name
  58181. * @returns the class name
  58182. */
  58183. getClassName(): string;
  58184. /**
  58185. * Gets the first world row input component
  58186. */
  58187. get world0(): NodeMaterialConnectionPoint;
  58188. /**
  58189. * Gets the second world row input component
  58190. */
  58191. get world1(): NodeMaterialConnectionPoint;
  58192. /**
  58193. * Gets the third world row input component
  58194. */
  58195. get world2(): NodeMaterialConnectionPoint;
  58196. /**
  58197. * Gets the forth world row input component
  58198. */
  58199. get world3(): NodeMaterialConnectionPoint;
  58200. /**
  58201. * Gets the world input component
  58202. */
  58203. get world(): NodeMaterialConnectionPoint;
  58204. /**
  58205. * Gets the output component
  58206. */
  58207. get output(): NodeMaterialConnectionPoint;
  58208. /**
  58209. * Gets the isntanceID component
  58210. */
  58211. get instanceID(): NodeMaterialConnectionPoint;
  58212. autoConfigure(material: NodeMaterial): void;
  58213. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  58214. protected _buildBlock(state: NodeMaterialBuildState): this;
  58215. }
  58216. }
  58217. declare module BABYLON {
  58218. /**
  58219. * Block used to add morph targets support to vertex shader
  58220. */
  58221. export class MorphTargetsBlock extends NodeMaterialBlock {
  58222. private _repeatableContentAnchor;
  58223. /**
  58224. * Create a new MorphTargetsBlock
  58225. * @param name defines the block name
  58226. */
  58227. constructor(name: string);
  58228. /**
  58229. * Gets the current class name
  58230. * @returns the class name
  58231. */
  58232. getClassName(): string;
  58233. /**
  58234. * Gets the position input component
  58235. */
  58236. get position(): NodeMaterialConnectionPoint;
  58237. /**
  58238. * Gets the normal input component
  58239. */
  58240. get normal(): NodeMaterialConnectionPoint;
  58241. /**
  58242. * Gets the tangent input component
  58243. */
  58244. get tangent(): NodeMaterialConnectionPoint;
  58245. /**
  58246. * Gets the tangent input component
  58247. */
  58248. get uv(): NodeMaterialConnectionPoint;
  58249. /**
  58250. * Gets the position output component
  58251. */
  58252. get positionOutput(): NodeMaterialConnectionPoint;
  58253. /**
  58254. * Gets the normal output component
  58255. */
  58256. get normalOutput(): NodeMaterialConnectionPoint;
  58257. /**
  58258. * Gets the tangent output component
  58259. */
  58260. get tangentOutput(): NodeMaterialConnectionPoint;
  58261. /**
  58262. * Gets the tangent output component
  58263. */
  58264. get uvOutput(): NodeMaterialConnectionPoint;
  58265. initialize(state: NodeMaterialBuildState): void;
  58266. autoConfigure(material: NodeMaterial): void;
  58267. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58268. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58269. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  58270. protected _buildBlock(state: NodeMaterialBuildState): this;
  58271. }
  58272. }
  58273. declare module BABYLON {
  58274. /**
  58275. * Block used to get data information from a light
  58276. */
  58277. export class LightInformationBlock extends NodeMaterialBlock {
  58278. private _lightDataUniformName;
  58279. private _lightColorUniformName;
  58280. private _lightTypeDefineName;
  58281. /**
  58282. * Gets or sets the light associated with this block
  58283. */
  58284. light: Nullable<Light>;
  58285. /**
  58286. * Creates a new LightInformationBlock
  58287. * @param name defines the block name
  58288. */
  58289. constructor(name: string);
  58290. /**
  58291. * Gets the current class name
  58292. * @returns the class name
  58293. */
  58294. getClassName(): string;
  58295. /**
  58296. * Gets the world position input component
  58297. */
  58298. get worldPosition(): NodeMaterialConnectionPoint;
  58299. /**
  58300. * Gets the direction output component
  58301. */
  58302. get direction(): NodeMaterialConnectionPoint;
  58303. /**
  58304. * Gets the direction output component
  58305. */
  58306. get color(): NodeMaterialConnectionPoint;
  58307. /**
  58308. * Gets the direction output component
  58309. */
  58310. get intensity(): NodeMaterialConnectionPoint;
  58311. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58312. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58313. protected _buildBlock(state: NodeMaterialBuildState): this;
  58314. serialize(): any;
  58315. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58316. }
  58317. }
  58318. declare module BABYLON {
  58319. /**
  58320. * Block used to add image processing support to fragment shader
  58321. */
  58322. export class ImageProcessingBlock extends NodeMaterialBlock {
  58323. /**
  58324. * Create a new ImageProcessingBlock
  58325. * @param name defines the block name
  58326. */
  58327. constructor(name: string);
  58328. /**
  58329. * Gets the current class name
  58330. * @returns the class name
  58331. */
  58332. getClassName(): string;
  58333. /**
  58334. * Gets the color input component
  58335. */
  58336. get color(): NodeMaterialConnectionPoint;
  58337. /**
  58338. * Gets the output component
  58339. */
  58340. get output(): NodeMaterialConnectionPoint;
  58341. /**
  58342. * Initialize the block and prepare the context for build
  58343. * @param state defines the state that will be used for the build
  58344. */
  58345. initialize(state: NodeMaterialBuildState): void;
  58346. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  58347. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58348. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58349. protected _buildBlock(state: NodeMaterialBuildState): this;
  58350. }
  58351. }
  58352. declare module BABYLON {
  58353. /**
  58354. * Block used to pertub normals based on a normal map
  58355. */
  58356. export class PerturbNormalBlock extends NodeMaterialBlock {
  58357. private _tangentSpaceParameterName;
  58358. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  58359. invertX: boolean;
  58360. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  58361. invertY: boolean;
  58362. /**
  58363. * Create a new PerturbNormalBlock
  58364. * @param name defines the block name
  58365. */
  58366. constructor(name: string);
  58367. /**
  58368. * Gets the current class name
  58369. * @returns the class name
  58370. */
  58371. getClassName(): string;
  58372. /**
  58373. * Gets the world position input component
  58374. */
  58375. get worldPosition(): NodeMaterialConnectionPoint;
  58376. /**
  58377. * Gets the world normal input component
  58378. */
  58379. get worldNormal(): NodeMaterialConnectionPoint;
  58380. /**
  58381. * Gets the world tangent input component
  58382. */
  58383. get worldTangent(): NodeMaterialConnectionPoint;
  58384. /**
  58385. * Gets the uv input component
  58386. */
  58387. get uv(): NodeMaterialConnectionPoint;
  58388. /**
  58389. * Gets the normal map color input component
  58390. */
  58391. get normalMapColor(): NodeMaterialConnectionPoint;
  58392. /**
  58393. * Gets the strength input component
  58394. */
  58395. get strength(): NodeMaterialConnectionPoint;
  58396. /**
  58397. * Gets the output component
  58398. */
  58399. get output(): NodeMaterialConnectionPoint;
  58400. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58401. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58402. autoConfigure(material: NodeMaterial): void;
  58403. protected _buildBlock(state: NodeMaterialBuildState): this;
  58404. protected _dumpPropertiesCode(): string;
  58405. serialize(): any;
  58406. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58407. }
  58408. }
  58409. declare module BABYLON {
  58410. /**
  58411. * Block used to discard a pixel if a value is smaller than a cutoff
  58412. */
  58413. export class DiscardBlock extends NodeMaterialBlock {
  58414. /**
  58415. * Create a new DiscardBlock
  58416. * @param name defines the block name
  58417. */
  58418. constructor(name: string);
  58419. /**
  58420. * Gets the current class name
  58421. * @returns the class name
  58422. */
  58423. getClassName(): string;
  58424. /**
  58425. * Gets the color input component
  58426. */
  58427. get value(): NodeMaterialConnectionPoint;
  58428. /**
  58429. * Gets the cutoff input component
  58430. */
  58431. get cutoff(): NodeMaterialConnectionPoint;
  58432. protected _buildBlock(state: NodeMaterialBuildState): this;
  58433. }
  58434. }
  58435. declare module BABYLON {
  58436. /**
  58437. * Block used to test if the fragment shader is front facing
  58438. */
  58439. export class FrontFacingBlock extends NodeMaterialBlock {
  58440. /**
  58441. * Creates a new FrontFacingBlock
  58442. * @param name defines the block name
  58443. */
  58444. constructor(name: string);
  58445. /**
  58446. * Gets the current class name
  58447. * @returns the class name
  58448. */
  58449. getClassName(): string;
  58450. /**
  58451. * Gets the output component
  58452. */
  58453. get output(): NodeMaterialConnectionPoint;
  58454. protected _buildBlock(state: NodeMaterialBuildState): this;
  58455. }
  58456. }
  58457. declare module BABYLON {
  58458. /**
  58459. * Block used to get the derivative value on x and y of a given input
  58460. */
  58461. export class DerivativeBlock extends NodeMaterialBlock {
  58462. /**
  58463. * Create a new DerivativeBlock
  58464. * @param name defines the block name
  58465. */
  58466. constructor(name: string);
  58467. /**
  58468. * Gets the current class name
  58469. * @returns the class name
  58470. */
  58471. getClassName(): string;
  58472. /**
  58473. * Gets the input component
  58474. */
  58475. get input(): NodeMaterialConnectionPoint;
  58476. /**
  58477. * Gets the derivative output on x
  58478. */
  58479. get dx(): NodeMaterialConnectionPoint;
  58480. /**
  58481. * Gets the derivative output on y
  58482. */
  58483. get dy(): NodeMaterialConnectionPoint;
  58484. protected _buildBlock(state: NodeMaterialBuildState): this;
  58485. }
  58486. }
  58487. declare module BABYLON {
  58488. /**
  58489. * Block used to add support for scene fog
  58490. */
  58491. export class FogBlock extends NodeMaterialBlock {
  58492. private _fogDistanceName;
  58493. private _fogParameters;
  58494. /**
  58495. * Create a new FogBlock
  58496. * @param name defines the block name
  58497. */
  58498. constructor(name: string);
  58499. /**
  58500. * Gets the current class name
  58501. * @returns the class name
  58502. */
  58503. getClassName(): string;
  58504. /**
  58505. * Gets the world position input component
  58506. */
  58507. get worldPosition(): NodeMaterialConnectionPoint;
  58508. /**
  58509. * Gets the view input component
  58510. */
  58511. get view(): NodeMaterialConnectionPoint;
  58512. /**
  58513. * Gets the color input component
  58514. */
  58515. get input(): NodeMaterialConnectionPoint;
  58516. /**
  58517. * Gets the fog color input component
  58518. */
  58519. get fogColor(): NodeMaterialConnectionPoint;
  58520. /**
  58521. * Gets the output component
  58522. */
  58523. get output(): NodeMaterialConnectionPoint;
  58524. autoConfigure(material: NodeMaterial): void;
  58525. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58526. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58527. protected _buildBlock(state: NodeMaterialBuildState): this;
  58528. }
  58529. }
  58530. declare module BABYLON {
  58531. /**
  58532. * Block used to add light in the fragment shader
  58533. */
  58534. export class LightBlock extends NodeMaterialBlock {
  58535. private _lightId;
  58536. /**
  58537. * Gets or sets the light associated with this block
  58538. */
  58539. light: Nullable<Light>;
  58540. /**
  58541. * Create a new LightBlock
  58542. * @param name defines the block name
  58543. */
  58544. constructor(name: string);
  58545. /**
  58546. * Gets the current class name
  58547. * @returns the class name
  58548. */
  58549. getClassName(): string;
  58550. /**
  58551. * Gets the world position input component
  58552. */
  58553. get worldPosition(): NodeMaterialConnectionPoint;
  58554. /**
  58555. * Gets the world normal input component
  58556. */
  58557. get worldNormal(): NodeMaterialConnectionPoint;
  58558. /**
  58559. * Gets the camera (or eye) position component
  58560. */
  58561. get cameraPosition(): NodeMaterialConnectionPoint;
  58562. /**
  58563. * Gets the glossiness component
  58564. */
  58565. get glossiness(): NodeMaterialConnectionPoint;
  58566. /**
  58567. * Gets the glossinness power component
  58568. */
  58569. get glossPower(): NodeMaterialConnectionPoint;
  58570. /**
  58571. * Gets the diffuse color component
  58572. */
  58573. get diffuseColor(): NodeMaterialConnectionPoint;
  58574. /**
  58575. * Gets the specular color component
  58576. */
  58577. get specularColor(): NodeMaterialConnectionPoint;
  58578. /**
  58579. * Gets the diffuse output component
  58580. */
  58581. get diffuseOutput(): NodeMaterialConnectionPoint;
  58582. /**
  58583. * Gets the specular output component
  58584. */
  58585. get specularOutput(): NodeMaterialConnectionPoint;
  58586. /**
  58587. * Gets the shadow output component
  58588. */
  58589. get shadow(): NodeMaterialConnectionPoint;
  58590. autoConfigure(material: NodeMaterial): void;
  58591. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58592. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  58593. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58594. private _injectVertexCode;
  58595. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  58596. serialize(): any;
  58597. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58598. }
  58599. }
  58600. declare module BABYLON {
  58601. /**
  58602. * Block used to multiply 2 values
  58603. */
  58604. export class MultiplyBlock extends NodeMaterialBlock {
  58605. /**
  58606. * Creates a new MultiplyBlock
  58607. * @param name defines the block name
  58608. */
  58609. constructor(name: string);
  58610. /**
  58611. * Gets the current class name
  58612. * @returns the class name
  58613. */
  58614. getClassName(): string;
  58615. /**
  58616. * Gets the left operand input component
  58617. */
  58618. get left(): NodeMaterialConnectionPoint;
  58619. /**
  58620. * Gets the right operand input component
  58621. */
  58622. get right(): NodeMaterialConnectionPoint;
  58623. /**
  58624. * Gets the output component
  58625. */
  58626. get output(): NodeMaterialConnectionPoint;
  58627. protected _buildBlock(state: NodeMaterialBuildState): this;
  58628. }
  58629. }
  58630. declare module BABYLON {
  58631. /**
  58632. * Block used to add 2 vectors
  58633. */
  58634. export class AddBlock extends NodeMaterialBlock {
  58635. /**
  58636. * Creates a new AddBlock
  58637. * @param name defines the block name
  58638. */
  58639. constructor(name: string);
  58640. /**
  58641. * Gets the current class name
  58642. * @returns the class name
  58643. */
  58644. getClassName(): string;
  58645. /**
  58646. * Gets the left operand input component
  58647. */
  58648. get left(): NodeMaterialConnectionPoint;
  58649. /**
  58650. * Gets the right operand input component
  58651. */
  58652. get right(): NodeMaterialConnectionPoint;
  58653. /**
  58654. * Gets the output component
  58655. */
  58656. get output(): NodeMaterialConnectionPoint;
  58657. protected _buildBlock(state: NodeMaterialBuildState): this;
  58658. }
  58659. }
  58660. declare module BABYLON {
  58661. /**
  58662. * Block used to scale a vector by a float
  58663. */
  58664. export class ScaleBlock extends NodeMaterialBlock {
  58665. /**
  58666. * Creates a new ScaleBlock
  58667. * @param name defines the block name
  58668. */
  58669. constructor(name: string);
  58670. /**
  58671. * Gets the current class name
  58672. * @returns the class name
  58673. */
  58674. getClassName(): string;
  58675. /**
  58676. * Gets the input component
  58677. */
  58678. get input(): NodeMaterialConnectionPoint;
  58679. /**
  58680. * Gets the factor input component
  58681. */
  58682. get factor(): NodeMaterialConnectionPoint;
  58683. /**
  58684. * Gets the output component
  58685. */
  58686. get output(): NodeMaterialConnectionPoint;
  58687. protected _buildBlock(state: NodeMaterialBuildState): this;
  58688. }
  58689. }
  58690. declare module BABYLON {
  58691. /**
  58692. * Block used to clamp a float
  58693. */
  58694. export class ClampBlock extends NodeMaterialBlock {
  58695. /** Gets or sets the minimum range */
  58696. minimum: number;
  58697. /** Gets or sets the maximum range */
  58698. maximum: number;
  58699. /**
  58700. * Creates a new ClampBlock
  58701. * @param name defines the block name
  58702. */
  58703. constructor(name: string);
  58704. /**
  58705. * Gets the current class name
  58706. * @returns the class name
  58707. */
  58708. getClassName(): string;
  58709. /**
  58710. * Gets the value input component
  58711. */
  58712. get value(): NodeMaterialConnectionPoint;
  58713. /**
  58714. * Gets the output component
  58715. */
  58716. get output(): NodeMaterialConnectionPoint;
  58717. protected _buildBlock(state: NodeMaterialBuildState): this;
  58718. protected _dumpPropertiesCode(): string;
  58719. serialize(): any;
  58720. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58721. }
  58722. }
  58723. declare module BABYLON {
  58724. /**
  58725. * Block used to apply a cross product between 2 vectors
  58726. */
  58727. export class CrossBlock extends NodeMaterialBlock {
  58728. /**
  58729. * Creates a new CrossBlock
  58730. * @param name defines the block name
  58731. */
  58732. constructor(name: string);
  58733. /**
  58734. * Gets the current class name
  58735. * @returns the class name
  58736. */
  58737. getClassName(): string;
  58738. /**
  58739. * Gets the left operand input component
  58740. */
  58741. get left(): NodeMaterialConnectionPoint;
  58742. /**
  58743. * Gets the right operand input component
  58744. */
  58745. get right(): NodeMaterialConnectionPoint;
  58746. /**
  58747. * Gets the output component
  58748. */
  58749. get output(): NodeMaterialConnectionPoint;
  58750. protected _buildBlock(state: NodeMaterialBuildState): this;
  58751. }
  58752. }
  58753. declare module BABYLON {
  58754. /**
  58755. * Block used to apply a dot product between 2 vectors
  58756. */
  58757. export class DotBlock extends NodeMaterialBlock {
  58758. /**
  58759. * Creates a new DotBlock
  58760. * @param name defines the block name
  58761. */
  58762. constructor(name: string);
  58763. /**
  58764. * Gets the current class name
  58765. * @returns the class name
  58766. */
  58767. getClassName(): string;
  58768. /**
  58769. * Gets the left operand input component
  58770. */
  58771. get left(): NodeMaterialConnectionPoint;
  58772. /**
  58773. * Gets the right operand input component
  58774. */
  58775. get right(): NodeMaterialConnectionPoint;
  58776. /**
  58777. * Gets the output component
  58778. */
  58779. get output(): NodeMaterialConnectionPoint;
  58780. protected _buildBlock(state: NodeMaterialBuildState): this;
  58781. }
  58782. }
  58783. declare module BABYLON {
  58784. /**
  58785. * Block used to remap a float from a range to a new one
  58786. */
  58787. export class RemapBlock extends NodeMaterialBlock {
  58788. /**
  58789. * Gets or sets the source range
  58790. */
  58791. sourceRange: Vector2;
  58792. /**
  58793. * Gets or sets the target range
  58794. */
  58795. targetRange: Vector2;
  58796. /**
  58797. * Creates a new RemapBlock
  58798. * @param name defines the block name
  58799. */
  58800. constructor(name: string);
  58801. /**
  58802. * Gets the current class name
  58803. * @returns the class name
  58804. */
  58805. getClassName(): string;
  58806. /**
  58807. * Gets the input component
  58808. */
  58809. get input(): NodeMaterialConnectionPoint;
  58810. /**
  58811. * Gets the source min input component
  58812. */
  58813. get sourceMin(): NodeMaterialConnectionPoint;
  58814. /**
  58815. * Gets the source max input component
  58816. */
  58817. get sourceMax(): NodeMaterialConnectionPoint;
  58818. /**
  58819. * Gets the target min input component
  58820. */
  58821. get targetMin(): NodeMaterialConnectionPoint;
  58822. /**
  58823. * Gets the target max input component
  58824. */
  58825. get targetMax(): NodeMaterialConnectionPoint;
  58826. /**
  58827. * Gets the output component
  58828. */
  58829. get output(): NodeMaterialConnectionPoint;
  58830. protected _buildBlock(state: NodeMaterialBuildState): this;
  58831. protected _dumpPropertiesCode(): string;
  58832. serialize(): any;
  58833. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58834. }
  58835. }
  58836. declare module BABYLON {
  58837. /**
  58838. * Block used to normalize a vector
  58839. */
  58840. export class NormalizeBlock extends NodeMaterialBlock {
  58841. /**
  58842. * Creates a new NormalizeBlock
  58843. * @param name defines the block name
  58844. */
  58845. constructor(name: string);
  58846. /**
  58847. * Gets the current class name
  58848. * @returns the class name
  58849. */
  58850. getClassName(): string;
  58851. /**
  58852. * Gets the input component
  58853. */
  58854. get input(): NodeMaterialConnectionPoint;
  58855. /**
  58856. * Gets the output component
  58857. */
  58858. get output(): NodeMaterialConnectionPoint;
  58859. protected _buildBlock(state: NodeMaterialBuildState): this;
  58860. }
  58861. }
  58862. declare module BABYLON {
  58863. /**
  58864. * Operations supported by the Trigonometry block
  58865. */
  58866. export enum TrigonometryBlockOperations {
  58867. /** Cos */
  58868. Cos = 0,
  58869. /** Sin */
  58870. Sin = 1,
  58871. /** Abs */
  58872. Abs = 2,
  58873. /** Exp */
  58874. Exp = 3,
  58875. /** Exp2 */
  58876. Exp2 = 4,
  58877. /** Round */
  58878. Round = 5,
  58879. /** Floor */
  58880. Floor = 6,
  58881. /** Ceiling */
  58882. Ceiling = 7,
  58883. /** Square root */
  58884. Sqrt = 8,
  58885. /** Log */
  58886. Log = 9,
  58887. /** Tangent */
  58888. Tan = 10,
  58889. /** Arc tangent */
  58890. ArcTan = 11,
  58891. /** Arc cosinus */
  58892. ArcCos = 12,
  58893. /** Arc sinus */
  58894. ArcSin = 13,
  58895. /** Fraction */
  58896. Fract = 14,
  58897. /** Sign */
  58898. Sign = 15,
  58899. /** To radians (from degrees) */
  58900. Radians = 16,
  58901. /** To degrees (from radians) */
  58902. Degrees = 17
  58903. }
  58904. /**
  58905. * Block used to apply trigonometry operation to floats
  58906. */
  58907. export class TrigonometryBlock extends NodeMaterialBlock {
  58908. /**
  58909. * Gets or sets the operation applied by the block
  58910. */
  58911. operation: TrigonometryBlockOperations;
  58912. /**
  58913. * Creates a new TrigonometryBlock
  58914. * @param name defines the block name
  58915. */
  58916. constructor(name: string);
  58917. /**
  58918. * Gets the current class name
  58919. * @returns the class name
  58920. */
  58921. getClassName(): string;
  58922. /**
  58923. * Gets the input component
  58924. */
  58925. get input(): NodeMaterialConnectionPoint;
  58926. /**
  58927. * Gets the output component
  58928. */
  58929. get output(): NodeMaterialConnectionPoint;
  58930. protected _buildBlock(state: NodeMaterialBuildState): this;
  58931. serialize(): any;
  58932. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58933. protected _dumpPropertiesCode(): string;
  58934. }
  58935. }
  58936. declare module BABYLON {
  58937. /**
  58938. * Block used to create a Color3/4 out of individual inputs (one for each component)
  58939. */
  58940. export class ColorMergerBlock extends NodeMaterialBlock {
  58941. /**
  58942. * Create a new ColorMergerBlock
  58943. * @param name defines the block name
  58944. */
  58945. constructor(name: string);
  58946. /**
  58947. * Gets the current class name
  58948. * @returns the class name
  58949. */
  58950. getClassName(): string;
  58951. /**
  58952. * Gets the rgb component (input)
  58953. */
  58954. get rgbIn(): NodeMaterialConnectionPoint;
  58955. /**
  58956. * Gets the r component (input)
  58957. */
  58958. get r(): NodeMaterialConnectionPoint;
  58959. /**
  58960. * Gets the g component (input)
  58961. */
  58962. get g(): NodeMaterialConnectionPoint;
  58963. /**
  58964. * Gets the b component (input)
  58965. */
  58966. get b(): NodeMaterialConnectionPoint;
  58967. /**
  58968. * Gets the a component (input)
  58969. */
  58970. get a(): NodeMaterialConnectionPoint;
  58971. /**
  58972. * Gets the rgba component (output)
  58973. */
  58974. get rgba(): NodeMaterialConnectionPoint;
  58975. /**
  58976. * Gets the rgb component (output)
  58977. */
  58978. get rgbOut(): NodeMaterialConnectionPoint;
  58979. /**
  58980. * Gets the rgb component (output)
  58981. * @deprecated Please use rgbOut instead.
  58982. */
  58983. get rgb(): NodeMaterialConnectionPoint;
  58984. protected _buildBlock(state: NodeMaterialBuildState): this;
  58985. }
  58986. }
  58987. declare module BABYLON {
  58988. /**
  58989. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  58990. */
  58991. export class VectorMergerBlock extends NodeMaterialBlock {
  58992. /**
  58993. * Create a new VectorMergerBlock
  58994. * @param name defines the block name
  58995. */
  58996. constructor(name: string);
  58997. /**
  58998. * Gets the current class name
  58999. * @returns the class name
  59000. */
  59001. getClassName(): string;
  59002. /**
  59003. * Gets the xyz component (input)
  59004. */
  59005. get xyzIn(): NodeMaterialConnectionPoint;
  59006. /**
  59007. * Gets the xy component (input)
  59008. */
  59009. get xyIn(): NodeMaterialConnectionPoint;
  59010. /**
  59011. * Gets the x component (input)
  59012. */
  59013. get x(): NodeMaterialConnectionPoint;
  59014. /**
  59015. * Gets the y component (input)
  59016. */
  59017. get y(): NodeMaterialConnectionPoint;
  59018. /**
  59019. * Gets the z component (input)
  59020. */
  59021. get z(): NodeMaterialConnectionPoint;
  59022. /**
  59023. * Gets the w component (input)
  59024. */
  59025. get w(): NodeMaterialConnectionPoint;
  59026. /**
  59027. * Gets the xyzw component (output)
  59028. */
  59029. get xyzw(): NodeMaterialConnectionPoint;
  59030. /**
  59031. * Gets the xyz component (output)
  59032. */
  59033. get xyzOut(): NodeMaterialConnectionPoint;
  59034. /**
  59035. * Gets the xy component (output)
  59036. */
  59037. get xyOut(): NodeMaterialConnectionPoint;
  59038. /**
  59039. * Gets the xy component (output)
  59040. * @deprecated Please use xyOut instead.
  59041. */
  59042. get xy(): NodeMaterialConnectionPoint;
  59043. /**
  59044. * Gets the xyz component (output)
  59045. * @deprecated Please use xyzOut instead.
  59046. */
  59047. get xyz(): NodeMaterialConnectionPoint;
  59048. protected _buildBlock(state: NodeMaterialBuildState): this;
  59049. }
  59050. }
  59051. declare module BABYLON {
  59052. /**
  59053. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  59054. */
  59055. export class ColorSplitterBlock extends NodeMaterialBlock {
  59056. /**
  59057. * Create a new ColorSplitterBlock
  59058. * @param name defines the block name
  59059. */
  59060. constructor(name: string);
  59061. /**
  59062. * Gets the current class name
  59063. * @returns the class name
  59064. */
  59065. getClassName(): string;
  59066. /**
  59067. * Gets the rgba component (input)
  59068. */
  59069. get rgba(): NodeMaterialConnectionPoint;
  59070. /**
  59071. * Gets the rgb component (input)
  59072. */
  59073. get rgbIn(): NodeMaterialConnectionPoint;
  59074. /**
  59075. * Gets the rgb component (output)
  59076. */
  59077. get rgbOut(): NodeMaterialConnectionPoint;
  59078. /**
  59079. * Gets the r component (output)
  59080. */
  59081. get r(): NodeMaterialConnectionPoint;
  59082. /**
  59083. * Gets the g component (output)
  59084. */
  59085. get g(): NodeMaterialConnectionPoint;
  59086. /**
  59087. * Gets the b component (output)
  59088. */
  59089. get b(): NodeMaterialConnectionPoint;
  59090. /**
  59091. * Gets the a component (output)
  59092. */
  59093. get a(): NodeMaterialConnectionPoint;
  59094. protected _inputRename(name: string): string;
  59095. protected _outputRename(name: string): string;
  59096. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  59097. }
  59098. }
  59099. declare module BABYLON {
  59100. /**
  59101. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  59102. */
  59103. export class VectorSplitterBlock extends NodeMaterialBlock {
  59104. /**
  59105. * Create a new VectorSplitterBlock
  59106. * @param name defines the block name
  59107. */
  59108. constructor(name: string);
  59109. /**
  59110. * Gets the current class name
  59111. * @returns the class name
  59112. */
  59113. getClassName(): string;
  59114. /**
  59115. * Gets the xyzw component (input)
  59116. */
  59117. get xyzw(): NodeMaterialConnectionPoint;
  59118. /**
  59119. * Gets the xyz component (input)
  59120. */
  59121. get xyzIn(): NodeMaterialConnectionPoint;
  59122. /**
  59123. * Gets the xy component (input)
  59124. */
  59125. get xyIn(): NodeMaterialConnectionPoint;
  59126. /**
  59127. * Gets the xyz component (output)
  59128. */
  59129. get xyzOut(): NodeMaterialConnectionPoint;
  59130. /**
  59131. * Gets the xy component (output)
  59132. */
  59133. get xyOut(): NodeMaterialConnectionPoint;
  59134. /**
  59135. * Gets the x component (output)
  59136. */
  59137. get x(): NodeMaterialConnectionPoint;
  59138. /**
  59139. * Gets the y component (output)
  59140. */
  59141. get y(): NodeMaterialConnectionPoint;
  59142. /**
  59143. * Gets the z component (output)
  59144. */
  59145. get z(): NodeMaterialConnectionPoint;
  59146. /**
  59147. * Gets the w component (output)
  59148. */
  59149. get w(): NodeMaterialConnectionPoint;
  59150. protected _inputRename(name: string): string;
  59151. protected _outputRename(name: string): string;
  59152. protected _buildBlock(state: NodeMaterialBuildState): this;
  59153. }
  59154. }
  59155. declare module BABYLON {
  59156. /**
  59157. * Block used to lerp between 2 values
  59158. */
  59159. export class LerpBlock extends NodeMaterialBlock {
  59160. /**
  59161. * Creates a new LerpBlock
  59162. * @param name defines the block name
  59163. */
  59164. constructor(name: string);
  59165. /**
  59166. * Gets the current class name
  59167. * @returns the class name
  59168. */
  59169. getClassName(): string;
  59170. /**
  59171. * Gets the left operand input component
  59172. */
  59173. get left(): NodeMaterialConnectionPoint;
  59174. /**
  59175. * Gets the right operand input component
  59176. */
  59177. get right(): NodeMaterialConnectionPoint;
  59178. /**
  59179. * Gets the gradient operand input component
  59180. */
  59181. get gradient(): NodeMaterialConnectionPoint;
  59182. /**
  59183. * Gets the output component
  59184. */
  59185. get output(): NodeMaterialConnectionPoint;
  59186. protected _buildBlock(state: NodeMaterialBuildState): this;
  59187. }
  59188. }
  59189. declare module BABYLON {
  59190. /**
  59191. * Block used to divide 2 vectors
  59192. */
  59193. export class DivideBlock extends NodeMaterialBlock {
  59194. /**
  59195. * Creates a new DivideBlock
  59196. * @param name defines the block name
  59197. */
  59198. constructor(name: string);
  59199. /**
  59200. * Gets the current class name
  59201. * @returns the class name
  59202. */
  59203. getClassName(): string;
  59204. /**
  59205. * Gets the left operand input component
  59206. */
  59207. get left(): NodeMaterialConnectionPoint;
  59208. /**
  59209. * Gets the right operand input component
  59210. */
  59211. get right(): NodeMaterialConnectionPoint;
  59212. /**
  59213. * Gets the output component
  59214. */
  59215. get output(): NodeMaterialConnectionPoint;
  59216. protected _buildBlock(state: NodeMaterialBuildState): this;
  59217. }
  59218. }
  59219. declare module BABYLON {
  59220. /**
  59221. * Block used to subtract 2 vectors
  59222. */
  59223. export class SubtractBlock extends NodeMaterialBlock {
  59224. /**
  59225. * Creates a new SubtractBlock
  59226. * @param name defines the block name
  59227. */
  59228. constructor(name: string);
  59229. /**
  59230. * Gets the current class name
  59231. * @returns the class name
  59232. */
  59233. getClassName(): string;
  59234. /**
  59235. * Gets the left operand input component
  59236. */
  59237. get left(): NodeMaterialConnectionPoint;
  59238. /**
  59239. * Gets the right operand input component
  59240. */
  59241. get right(): NodeMaterialConnectionPoint;
  59242. /**
  59243. * Gets the output component
  59244. */
  59245. get output(): NodeMaterialConnectionPoint;
  59246. protected _buildBlock(state: NodeMaterialBuildState): this;
  59247. }
  59248. }
  59249. declare module BABYLON {
  59250. /**
  59251. * Block used to step a value
  59252. */
  59253. export class StepBlock extends NodeMaterialBlock {
  59254. /**
  59255. * Creates a new StepBlock
  59256. * @param name defines the block name
  59257. */
  59258. constructor(name: string);
  59259. /**
  59260. * Gets the current class name
  59261. * @returns the class name
  59262. */
  59263. getClassName(): string;
  59264. /**
  59265. * Gets the value operand input component
  59266. */
  59267. get value(): NodeMaterialConnectionPoint;
  59268. /**
  59269. * Gets the edge operand input component
  59270. */
  59271. get edge(): NodeMaterialConnectionPoint;
  59272. /**
  59273. * Gets the output component
  59274. */
  59275. get output(): NodeMaterialConnectionPoint;
  59276. protected _buildBlock(state: NodeMaterialBuildState): this;
  59277. }
  59278. }
  59279. declare module BABYLON {
  59280. /**
  59281. * Block used to get the opposite (1 - x) of a value
  59282. */
  59283. export class OneMinusBlock extends NodeMaterialBlock {
  59284. /**
  59285. * Creates a new OneMinusBlock
  59286. * @param name defines the block name
  59287. */
  59288. constructor(name: string);
  59289. /**
  59290. * Gets the current class name
  59291. * @returns the class name
  59292. */
  59293. getClassName(): string;
  59294. /**
  59295. * Gets the input component
  59296. */
  59297. get input(): NodeMaterialConnectionPoint;
  59298. /**
  59299. * Gets the output component
  59300. */
  59301. get output(): NodeMaterialConnectionPoint;
  59302. protected _buildBlock(state: NodeMaterialBuildState): this;
  59303. }
  59304. }
  59305. declare module BABYLON {
  59306. /**
  59307. * Block used to get the view direction
  59308. */
  59309. export class ViewDirectionBlock extends NodeMaterialBlock {
  59310. /**
  59311. * Creates a new ViewDirectionBlock
  59312. * @param name defines the block name
  59313. */
  59314. constructor(name: string);
  59315. /**
  59316. * Gets the current class name
  59317. * @returns the class name
  59318. */
  59319. getClassName(): string;
  59320. /**
  59321. * Gets the world position component
  59322. */
  59323. get worldPosition(): NodeMaterialConnectionPoint;
  59324. /**
  59325. * Gets the camera position component
  59326. */
  59327. get cameraPosition(): NodeMaterialConnectionPoint;
  59328. /**
  59329. * Gets the output component
  59330. */
  59331. get output(): NodeMaterialConnectionPoint;
  59332. autoConfigure(material: NodeMaterial): void;
  59333. protected _buildBlock(state: NodeMaterialBuildState): this;
  59334. }
  59335. }
  59336. declare module BABYLON {
  59337. /**
  59338. * Block used to compute fresnel value
  59339. */
  59340. export class FresnelBlock extends NodeMaterialBlock {
  59341. /**
  59342. * Create a new FresnelBlock
  59343. * @param name defines the block name
  59344. */
  59345. constructor(name: string);
  59346. /**
  59347. * Gets the current class name
  59348. * @returns the class name
  59349. */
  59350. getClassName(): string;
  59351. /**
  59352. * Gets the world normal input component
  59353. */
  59354. get worldNormal(): NodeMaterialConnectionPoint;
  59355. /**
  59356. * Gets the view direction input component
  59357. */
  59358. get viewDirection(): NodeMaterialConnectionPoint;
  59359. /**
  59360. * Gets the bias input component
  59361. */
  59362. get bias(): NodeMaterialConnectionPoint;
  59363. /**
  59364. * Gets the camera (or eye) position component
  59365. */
  59366. get power(): NodeMaterialConnectionPoint;
  59367. /**
  59368. * Gets the fresnel output component
  59369. */
  59370. get fresnel(): NodeMaterialConnectionPoint;
  59371. autoConfigure(material: NodeMaterial): void;
  59372. protected _buildBlock(state: NodeMaterialBuildState): this;
  59373. }
  59374. }
  59375. declare module BABYLON {
  59376. /**
  59377. * Block used to get the max of 2 values
  59378. */
  59379. export class MaxBlock extends NodeMaterialBlock {
  59380. /**
  59381. * Creates a new MaxBlock
  59382. * @param name defines the block name
  59383. */
  59384. constructor(name: string);
  59385. /**
  59386. * Gets the current class name
  59387. * @returns the class name
  59388. */
  59389. getClassName(): string;
  59390. /**
  59391. * Gets the left operand input component
  59392. */
  59393. get left(): NodeMaterialConnectionPoint;
  59394. /**
  59395. * Gets the right operand input component
  59396. */
  59397. get right(): NodeMaterialConnectionPoint;
  59398. /**
  59399. * Gets the output component
  59400. */
  59401. get output(): NodeMaterialConnectionPoint;
  59402. protected _buildBlock(state: NodeMaterialBuildState): this;
  59403. }
  59404. }
  59405. declare module BABYLON {
  59406. /**
  59407. * Block used to get the min of 2 values
  59408. */
  59409. export class MinBlock extends NodeMaterialBlock {
  59410. /**
  59411. * Creates a new MinBlock
  59412. * @param name defines the block name
  59413. */
  59414. constructor(name: string);
  59415. /**
  59416. * Gets the current class name
  59417. * @returns the class name
  59418. */
  59419. getClassName(): string;
  59420. /**
  59421. * Gets the left operand input component
  59422. */
  59423. get left(): NodeMaterialConnectionPoint;
  59424. /**
  59425. * Gets the right operand input component
  59426. */
  59427. get right(): NodeMaterialConnectionPoint;
  59428. /**
  59429. * Gets the output component
  59430. */
  59431. get output(): NodeMaterialConnectionPoint;
  59432. protected _buildBlock(state: NodeMaterialBuildState): this;
  59433. }
  59434. }
  59435. declare module BABYLON {
  59436. /**
  59437. * Block used to get the distance between 2 values
  59438. */
  59439. export class DistanceBlock extends NodeMaterialBlock {
  59440. /**
  59441. * Creates a new DistanceBlock
  59442. * @param name defines the block name
  59443. */
  59444. constructor(name: string);
  59445. /**
  59446. * Gets the current class name
  59447. * @returns the class name
  59448. */
  59449. getClassName(): string;
  59450. /**
  59451. * Gets the left operand input component
  59452. */
  59453. get left(): NodeMaterialConnectionPoint;
  59454. /**
  59455. * Gets the right operand input component
  59456. */
  59457. get right(): NodeMaterialConnectionPoint;
  59458. /**
  59459. * Gets the output component
  59460. */
  59461. get output(): NodeMaterialConnectionPoint;
  59462. protected _buildBlock(state: NodeMaterialBuildState): this;
  59463. }
  59464. }
  59465. declare module BABYLON {
  59466. /**
  59467. * Block used to get the length of a vector
  59468. */
  59469. export class LengthBlock extends NodeMaterialBlock {
  59470. /**
  59471. * Creates a new LengthBlock
  59472. * @param name defines the block name
  59473. */
  59474. constructor(name: string);
  59475. /**
  59476. * Gets the current class name
  59477. * @returns the class name
  59478. */
  59479. getClassName(): string;
  59480. /**
  59481. * Gets the value input component
  59482. */
  59483. get value(): NodeMaterialConnectionPoint;
  59484. /**
  59485. * Gets the output component
  59486. */
  59487. get output(): NodeMaterialConnectionPoint;
  59488. protected _buildBlock(state: NodeMaterialBuildState): this;
  59489. }
  59490. }
  59491. declare module BABYLON {
  59492. /**
  59493. * Block used to get negative version of a value (i.e. x * -1)
  59494. */
  59495. export class NegateBlock extends NodeMaterialBlock {
  59496. /**
  59497. * Creates a new NegateBlock
  59498. * @param name defines the block name
  59499. */
  59500. constructor(name: string);
  59501. /**
  59502. * Gets the current class name
  59503. * @returns the class name
  59504. */
  59505. getClassName(): string;
  59506. /**
  59507. * Gets the value input component
  59508. */
  59509. get value(): NodeMaterialConnectionPoint;
  59510. /**
  59511. * Gets the output component
  59512. */
  59513. get output(): NodeMaterialConnectionPoint;
  59514. protected _buildBlock(state: NodeMaterialBuildState): this;
  59515. }
  59516. }
  59517. declare module BABYLON {
  59518. /**
  59519. * Block used to get the value of the first parameter raised to the power of the second
  59520. */
  59521. export class PowBlock extends NodeMaterialBlock {
  59522. /**
  59523. * Creates a new PowBlock
  59524. * @param name defines the block name
  59525. */
  59526. constructor(name: string);
  59527. /**
  59528. * Gets the current class name
  59529. * @returns the class name
  59530. */
  59531. getClassName(): string;
  59532. /**
  59533. * Gets the value operand input component
  59534. */
  59535. get value(): NodeMaterialConnectionPoint;
  59536. /**
  59537. * Gets the power operand input component
  59538. */
  59539. get power(): NodeMaterialConnectionPoint;
  59540. /**
  59541. * Gets the output component
  59542. */
  59543. get output(): NodeMaterialConnectionPoint;
  59544. protected _buildBlock(state: NodeMaterialBuildState): this;
  59545. }
  59546. }
  59547. declare module BABYLON {
  59548. /**
  59549. * Block used to get a random number
  59550. */
  59551. export class RandomNumberBlock extends NodeMaterialBlock {
  59552. /**
  59553. * Creates a new RandomNumberBlock
  59554. * @param name defines the block name
  59555. */
  59556. constructor(name: string);
  59557. /**
  59558. * Gets the current class name
  59559. * @returns the class name
  59560. */
  59561. getClassName(): string;
  59562. /**
  59563. * Gets the seed input component
  59564. */
  59565. get seed(): NodeMaterialConnectionPoint;
  59566. /**
  59567. * Gets the output component
  59568. */
  59569. get output(): NodeMaterialConnectionPoint;
  59570. protected _buildBlock(state: NodeMaterialBuildState): this;
  59571. }
  59572. }
  59573. declare module BABYLON {
  59574. /**
  59575. * Block used to compute arc tangent of 2 values
  59576. */
  59577. export class ArcTan2Block extends NodeMaterialBlock {
  59578. /**
  59579. * Creates a new ArcTan2Block
  59580. * @param name defines the block name
  59581. */
  59582. constructor(name: string);
  59583. /**
  59584. * Gets the current class name
  59585. * @returns the class name
  59586. */
  59587. getClassName(): string;
  59588. /**
  59589. * Gets the x operand input component
  59590. */
  59591. get x(): NodeMaterialConnectionPoint;
  59592. /**
  59593. * Gets the y operand input component
  59594. */
  59595. get y(): NodeMaterialConnectionPoint;
  59596. /**
  59597. * Gets the output component
  59598. */
  59599. get output(): NodeMaterialConnectionPoint;
  59600. protected _buildBlock(state: NodeMaterialBuildState): this;
  59601. }
  59602. }
  59603. declare module BABYLON {
  59604. /**
  59605. * Block used to smooth step a value
  59606. */
  59607. export class SmoothStepBlock extends NodeMaterialBlock {
  59608. /**
  59609. * Creates a new SmoothStepBlock
  59610. * @param name defines the block name
  59611. */
  59612. constructor(name: string);
  59613. /**
  59614. * Gets the current class name
  59615. * @returns the class name
  59616. */
  59617. getClassName(): string;
  59618. /**
  59619. * Gets the value operand input component
  59620. */
  59621. get value(): NodeMaterialConnectionPoint;
  59622. /**
  59623. * Gets the first edge operand input component
  59624. */
  59625. get edge0(): NodeMaterialConnectionPoint;
  59626. /**
  59627. * Gets the second edge operand input component
  59628. */
  59629. get edge1(): NodeMaterialConnectionPoint;
  59630. /**
  59631. * Gets the output component
  59632. */
  59633. get output(): NodeMaterialConnectionPoint;
  59634. protected _buildBlock(state: NodeMaterialBuildState): this;
  59635. }
  59636. }
  59637. declare module BABYLON {
  59638. /**
  59639. * Block used to get the reciprocal (1 / x) of a value
  59640. */
  59641. export class ReciprocalBlock extends NodeMaterialBlock {
  59642. /**
  59643. * Creates a new ReciprocalBlock
  59644. * @param name defines the block name
  59645. */
  59646. constructor(name: string);
  59647. /**
  59648. * Gets the current class name
  59649. * @returns the class name
  59650. */
  59651. getClassName(): string;
  59652. /**
  59653. * Gets the input component
  59654. */
  59655. get input(): NodeMaterialConnectionPoint;
  59656. /**
  59657. * Gets the output component
  59658. */
  59659. get output(): NodeMaterialConnectionPoint;
  59660. protected _buildBlock(state: NodeMaterialBuildState): this;
  59661. }
  59662. }
  59663. declare module BABYLON {
  59664. /**
  59665. * Block used to replace a color by another one
  59666. */
  59667. export class ReplaceColorBlock extends NodeMaterialBlock {
  59668. /**
  59669. * Creates a new ReplaceColorBlock
  59670. * @param name defines the block name
  59671. */
  59672. constructor(name: string);
  59673. /**
  59674. * Gets the current class name
  59675. * @returns the class name
  59676. */
  59677. getClassName(): string;
  59678. /**
  59679. * Gets the value input component
  59680. */
  59681. get value(): NodeMaterialConnectionPoint;
  59682. /**
  59683. * Gets the reference input component
  59684. */
  59685. get reference(): NodeMaterialConnectionPoint;
  59686. /**
  59687. * Gets the distance input component
  59688. */
  59689. get distance(): NodeMaterialConnectionPoint;
  59690. /**
  59691. * Gets the replacement input component
  59692. */
  59693. get replacement(): NodeMaterialConnectionPoint;
  59694. /**
  59695. * Gets the output component
  59696. */
  59697. get output(): NodeMaterialConnectionPoint;
  59698. protected _buildBlock(state: NodeMaterialBuildState): this;
  59699. }
  59700. }
  59701. declare module BABYLON {
  59702. /**
  59703. * Block used to posterize a value
  59704. * @see https://en.wikipedia.org/wiki/Posterization
  59705. */
  59706. export class PosterizeBlock extends NodeMaterialBlock {
  59707. /**
  59708. * Creates a new PosterizeBlock
  59709. * @param name defines the block name
  59710. */
  59711. constructor(name: string);
  59712. /**
  59713. * Gets the current class name
  59714. * @returns the class name
  59715. */
  59716. getClassName(): string;
  59717. /**
  59718. * Gets the value input component
  59719. */
  59720. get value(): NodeMaterialConnectionPoint;
  59721. /**
  59722. * Gets the steps input component
  59723. */
  59724. get steps(): NodeMaterialConnectionPoint;
  59725. /**
  59726. * Gets the output component
  59727. */
  59728. get output(): NodeMaterialConnectionPoint;
  59729. protected _buildBlock(state: NodeMaterialBuildState): this;
  59730. }
  59731. }
  59732. declare module BABYLON {
  59733. /**
  59734. * Operations supported by the Wave block
  59735. */
  59736. export enum WaveBlockKind {
  59737. /** SawTooth */
  59738. SawTooth = 0,
  59739. /** Square */
  59740. Square = 1,
  59741. /** Triangle */
  59742. Triangle = 2
  59743. }
  59744. /**
  59745. * Block used to apply wave operation to floats
  59746. */
  59747. export class WaveBlock extends NodeMaterialBlock {
  59748. /**
  59749. * Gets or sets the kibnd of wave to be applied by the block
  59750. */
  59751. kind: WaveBlockKind;
  59752. /**
  59753. * Creates a new WaveBlock
  59754. * @param name defines the block name
  59755. */
  59756. constructor(name: string);
  59757. /**
  59758. * Gets the current class name
  59759. * @returns the class name
  59760. */
  59761. getClassName(): string;
  59762. /**
  59763. * Gets the input component
  59764. */
  59765. get input(): NodeMaterialConnectionPoint;
  59766. /**
  59767. * Gets the output component
  59768. */
  59769. get output(): NodeMaterialConnectionPoint;
  59770. protected _buildBlock(state: NodeMaterialBuildState): this;
  59771. serialize(): any;
  59772. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59773. }
  59774. }
  59775. declare module BABYLON {
  59776. /**
  59777. * Class used to store a color step for the GradientBlock
  59778. */
  59779. export class GradientBlockColorStep {
  59780. /**
  59781. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  59782. */
  59783. step: number;
  59784. /**
  59785. * Gets or sets the color associated with this step
  59786. */
  59787. color: Color3;
  59788. /**
  59789. * Creates a new GradientBlockColorStep
  59790. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  59791. * @param color defines the color associated with this step
  59792. */
  59793. constructor(
  59794. /**
  59795. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  59796. */
  59797. step: number,
  59798. /**
  59799. * Gets or sets the color associated with this step
  59800. */
  59801. color: Color3);
  59802. }
  59803. /**
  59804. * Block used to return a color from a gradient based on an input value between 0 and 1
  59805. */
  59806. export class GradientBlock extends NodeMaterialBlock {
  59807. /**
  59808. * Gets or sets the list of color steps
  59809. */
  59810. colorSteps: GradientBlockColorStep[];
  59811. /**
  59812. * Creates a new GradientBlock
  59813. * @param name defines the block name
  59814. */
  59815. constructor(name: string);
  59816. /**
  59817. * Gets the current class name
  59818. * @returns the class name
  59819. */
  59820. getClassName(): string;
  59821. /**
  59822. * Gets the gradient input component
  59823. */
  59824. get gradient(): NodeMaterialConnectionPoint;
  59825. /**
  59826. * Gets the output component
  59827. */
  59828. get output(): NodeMaterialConnectionPoint;
  59829. private _writeColorConstant;
  59830. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  59831. serialize(): any;
  59832. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59833. protected _dumpPropertiesCode(): string;
  59834. }
  59835. }
  59836. declare module BABYLON {
  59837. /**
  59838. * Block used to normalize lerp between 2 values
  59839. */
  59840. export class NLerpBlock extends NodeMaterialBlock {
  59841. /**
  59842. * Creates a new NLerpBlock
  59843. * @param name defines the block name
  59844. */
  59845. constructor(name: string);
  59846. /**
  59847. * Gets the current class name
  59848. * @returns the class name
  59849. */
  59850. getClassName(): string;
  59851. /**
  59852. * Gets the left operand input component
  59853. */
  59854. get left(): NodeMaterialConnectionPoint;
  59855. /**
  59856. * Gets the right operand input component
  59857. */
  59858. get right(): NodeMaterialConnectionPoint;
  59859. /**
  59860. * Gets the gradient operand input component
  59861. */
  59862. get gradient(): NodeMaterialConnectionPoint;
  59863. /**
  59864. * Gets the output component
  59865. */
  59866. get output(): NodeMaterialConnectionPoint;
  59867. protected _buildBlock(state: NodeMaterialBuildState): this;
  59868. }
  59869. }
  59870. declare module BABYLON {
  59871. /**
  59872. * block used to Generate a Worley Noise 3D Noise Pattern
  59873. */
  59874. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  59875. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  59876. manhattanDistance: boolean;
  59877. /**
  59878. * Creates a new WorleyNoise3DBlock
  59879. * @param name defines the block name
  59880. */
  59881. constructor(name: string);
  59882. /**
  59883. * Gets the current class name
  59884. * @returns the class name
  59885. */
  59886. getClassName(): string;
  59887. /**
  59888. * Gets the seed input component
  59889. */
  59890. get seed(): NodeMaterialConnectionPoint;
  59891. /**
  59892. * Gets the jitter input component
  59893. */
  59894. get jitter(): NodeMaterialConnectionPoint;
  59895. /**
  59896. * Gets the output component
  59897. */
  59898. get output(): NodeMaterialConnectionPoint;
  59899. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  59900. /**
  59901. * Exposes the properties to the UI?
  59902. */
  59903. protected _dumpPropertiesCode(): string;
  59904. /**
  59905. * Exposes the properties to the Seralize?
  59906. */
  59907. serialize(): any;
  59908. /**
  59909. * Exposes the properties to the deseralize?
  59910. */
  59911. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59912. }
  59913. }
  59914. declare module BABYLON {
  59915. /**
  59916. * block used to Generate a Simplex Perlin 3d Noise Pattern
  59917. */
  59918. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  59919. /**
  59920. * Creates a new SimplexPerlin3DBlock
  59921. * @param name defines the block name
  59922. */
  59923. constructor(name: string);
  59924. /**
  59925. * Gets the current class name
  59926. * @returns the class name
  59927. */
  59928. getClassName(): string;
  59929. /**
  59930. * Gets the seed operand input component
  59931. */
  59932. get seed(): NodeMaterialConnectionPoint;
  59933. /**
  59934. * Gets the output component
  59935. */
  59936. get output(): NodeMaterialConnectionPoint;
  59937. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  59938. }
  59939. }
  59940. declare module BABYLON {
  59941. /**
  59942. * Block used to blend normals
  59943. */
  59944. export class NormalBlendBlock extends NodeMaterialBlock {
  59945. /**
  59946. * Creates a new NormalBlendBlock
  59947. * @param name defines the block name
  59948. */
  59949. constructor(name: string);
  59950. /**
  59951. * Gets the current class name
  59952. * @returns the class name
  59953. */
  59954. getClassName(): string;
  59955. /**
  59956. * Gets the first input component
  59957. */
  59958. get normalMap0(): NodeMaterialConnectionPoint;
  59959. /**
  59960. * Gets the second input component
  59961. */
  59962. get normalMap1(): NodeMaterialConnectionPoint;
  59963. /**
  59964. * Gets the output component
  59965. */
  59966. get output(): NodeMaterialConnectionPoint;
  59967. protected _buildBlock(state: NodeMaterialBuildState): this;
  59968. }
  59969. }
  59970. declare module BABYLON {
  59971. /**
  59972. * Block used to rotate a 2d vector by a given angle
  59973. */
  59974. export class Rotate2dBlock extends NodeMaterialBlock {
  59975. /**
  59976. * Creates a new Rotate2dBlock
  59977. * @param name defines the block name
  59978. */
  59979. constructor(name: string);
  59980. /**
  59981. * Gets the current class name
  59982. * @returns the class name
  59983. */
  59984. getClassName(): string;
  59985. /**
  59986. * Gets the input vector
  59987. */
  59988. get input(): NodeMaterialConnectionPoint;
  59989. /**
  59990. * Gets the input angle
  59991. */
  59992. get angle(): NodeMaterialConnectionPoint;
  59993. /**
  59994. * Gets the output component
  59995. */
  59996. get output(): NodeMaterialConnectionPoint;
  59997. autoConfigure(material: NodeMaterial): void;
  59998. protected _buildBlock(state: NodeMaterialBuildState): this;
  59999. }
  60000. }
  60001. declare module BABYLON {
  60002. /**
  60003. * Block used to get the reflected vector from a direction and a normal
  60004. */
  60005. export class ReflectBlock extends NodeMaterialBlock {
  60006. /**
  60007. * Creates a new ReflectBlock
  60008. * @param name defines the block name
  60009. */
  60010. constructor(name: string);
  60011. /**
  60012. * Gets the current class name
  60013. * @returns the class name
  60014. */
  60015. getClassName(): string;
  60016. /**
  60017. * Gets the incident component
  60018. */
  60019. get incident(): NodeMaterialConnectionPoint;
  60020. /**
  60021. * Gets the normal component
  60022. */
  60023. get normal(): NodeMaterialConnectionPoint;
  60024. /**
  60025. * Gets the output component
  60026. */
  60027. get output(): NodeMaterialConnectionPoint;
  60028. protected _buildBlock(state: NodeMaterialBuildState): this;
  60029. }
  60030. }
  60031. declare module BABYLON {
  60032. /**
  60033. * Block used to get the refracted vector from a direction and a normal
  60034. */
  60035. export class RefractBlock extends NodeMaterialBlock {
  60036. /**
  60037. * Creates a new RefractBlock
  60038. * @param name defines the block name
  60039. */
  60040. constructor(name: string);
  60041. /**
  60042. * Gets the current class name
  60043. * @returns the class name
  60044. */
  60045. getClassName(): string;
  60046. /**
  60047. * Gets the incident component
  60048. */
  60049. get incident(): NodeMaterialConnectionPoint;
  60050. /**
  60051. * Gets the normal component
  60052. */
  60053. get normal(): NodeMaterialConnectionPoint;
  60054. /**
  60055. * Gets the index of refraction component
  60056. */
  60057. get ior(): NodeMaterialConnectionPoint;
  60058. /**
  60059. * Gets the output component
  60060. */
  60061. get output(): NodeMaterialConnectionPoint;
  60062. protected _buildBlock(state: NodeMaterialBuildState): this;
  60063. }
  60064. }
  60065. declare module BABYLON {
  60066. /**
  60067. * Block used to desaturate a color
  60068. */
  60069. export class DesaturateBlock extends NodeMaterialBlock {
  60070. /**
  60071. * Creates a new DesaturateBlock
  60072. * @param name defines the block name
  60073. */
  60074. constructor(name: string);
  60075. /**
  60076. * Gets the current class name
  60077. * @returns the class name
  60078. */
  60079. getClassName(): string;
  60080. /**
  60081. * Gets the color operand input component
  60082. */
  60083. get color(): NodeMaterialConnectionPoint;
  60084. /**
  60085. * Gets the level operand input component
  60086. */
  60087. get level(): NodeMaterialConnectionPoint;
  60088. /**
  60089. * Gets the output component
  60090. */
  60091. get output(): NodeMaterialConnectionPoint;
  60092. protected _buildBlock(state: NodeMaterialBuildState): this;
  60093. }
  60094. }
  60095. declare module BABYLON {
  60096. /**
  60097. * Effect Render Options
  60098. */
  60099. export interface IEffectRendererOptions {
  60100. /**
  60101. * Defines the vertices positions.
  60102. */
  60103. positions?: number[];
  60104. /**
  60105. * Defines the indices.
  60106. */
  60107. indices?: number[];
  60108. }
  60109. /**
  60110. * Helper class to render one or more effects
  60111. */
  60112. export class EffectRenderer {
  60113. private engine;
  60114. private static _DefaultOptions;
  60115. private _vertexBuffers;
  60116. private _indexBuffer;
  60117. private _ringBufferIndex;
  60118. private _ringScreenBuffer;
  60119. private _fullscreenViewport;
  60120. private _getNextFrameBuffer;
  60121. /**
  60122. * Creates an effect renderer
  60123. * @param engine the engine to use for rendering
  60124. * @param options defines the options of the effect renderer
  60125. */
  60126. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  60127. /**
  60128. * Sets the current viewport in normalized coordinates 0-1
  60129. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  60130. */
  60131. setViewport(viewport?: Viewport): void;
  60132. /**
  60133. * Binds the embedded attributes buffer to the effect.
  60134. * @param effect Defines the effect to bind the attributes for
  60135. */
  60136. bindBuffers(effect: Effect): void;
  60137. /**
  60138. * Sets the current effect wrapper to use during draw.
  60139. * The effect needs to be ready before calling this api.
  60140. * This also sets the default full screen position attribute.
  60141. * @param effectWrapper Defines the effect to draw with
  60142. */
  60143. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  60144. /**
  60145. * Draws a full screen quad.
  60146. */
  60147. draw(): void;
  60148. /**
  60149. * renders one or more effects to a specified texture
  60150. * @param effectWrappers list of effects to renderer
  60151. * @param outputTexture texture to draw to, if null it will render to the screen
  60152. */
  60153. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  60154. /**
  60155. * Disposes of the effect renderer
  60156. */
  60157. dispose(): void;
  60158. }
  60159. /**
  60160. * Options to create an EffectWrapper
  60161. */
  60162. interface EffectWrapperCreationOptions {
  60163. /**
  60164. * Engine to use to create the effect
  60165. */
  60166. engine: ThinEngine;
  60167. /**
  60168. * Fragment shader for the effect
  60169. */
  60170. fragmentShader: string;
  60171. /**
  60172. * Vertex shader for the effect
  60173. */
  60174. vertexShader?: string;
  60175. /**
  60176. * Attributes to use in the shader
  60177. */
  60178. attributeNames?: Array<string>;
  60179. /**
  60180. * Uniforms to use in the shader
  60181. */
  60182. uniformNames?: Array<string>;
  60183. /**
  60184. * Texture sampler names to use in the shader
  60185. */
  60186. samplerNames?: Array<string>;
  60187. /**
  60188. * The friendly name of the effect displayed in Spector.
  60189. */
  60190. name?: string;
  60191. }
  60192. /**
  60193. * Wraps an effect to be used for rendering
  60194. */
  60195. export class EffectWrapper {
  60196. /**
  60197. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  60198. */
  60199. onApplyObservable: Observable<{}>;
  60200. /**
  60201. * The underlying effect
  60202. */
  60203. effect: Effect;
  60204. /**
  60205. * Creates an effect to be renderer
  60206. * @param creationOptions options to create the effect
  60207. */
  60208. constructor(creationOptions: EffectWrapperCreationOptions);
  60209. /**
  60210. * Disposes of the effect wrapper
  60211. */
  60212. dispose(): void;
  60213. }
  60214. }
  60215. declare module BABYLON {
  60216. /**
  60217. * Helper class to push actions to a pool of workers.
  60218. */
  60219. export class WorkerPool implements IDisposable {
  60220. private _workerInfos;
  60221. private _pendingActions;
  60222. /**
  60223. * Constructor
  60224. * @param workers Array of workers to use for actions
  60225. */
  60226. constructor(workers: Array<Worker>);
  60227. /**
  60228. * Terminates all workers and clears any pending actions.
  60229. */
  60230. dispose(): void;
  60231. /**
  60232. * Pushes an action to the worker pool. If all the workers are active, the action will be
  60233. * pended until a worker has completed its action.
  60234. * @param action The action to perform. Call onComplete when the action is complete.
  60235. */
  60236. push(action: (worker: Worker, onComplete: () => void) => void): void;
  60237. private _execute;
  60238. }
  60239. }
  60240. declare module BABYLON {
  60241. /**
  60242. * Configuration for Draco compression
  60243. */
  60244. export interface IDracoCompressionConfiguration {
  60245. /**
  60246. * Configuration for the decoder.
  60247. */
  60248. decoder: {
  60249. /**
  60250. * The url to the WebAssembly module.
  60251. */
  60252. wasmUrl?: string;
  60253. /**
  60254. * The url to the WebAssembly binary.
  60255. */
  60256. wasmBinaryUrl?: string;
  60257. /**
  60258. * The url to the fallback JavaScript module.
  60259. */
  60260. fallbackUrl?: string;
  60261. };
  60262. }
  60263. /**
  60264. * Draco compression (https://google.github.io/draco/)
  60265. *
  60266. * This class wraps the Draco module.
  60267. *
  60268. * **Encoder**
  60269. *
  60270. * The encoder is not currently implemented.
  60271. *
  60272. * **Decoder**
  60273. *
  60274. * 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.
  60275. *
  60276. * To update the configuration, use the following code:
  60277. * ```javascript
  60278. * DracoCompression.Configuration = {
  60279. * decoder: {
  60280. * wasmUrl: "<url to the WebAssembly library>",
  60281. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  60282. * fallbackUrl: "<url to the fallback JavaScript library>",
  60283. * }
  60284. * };
  60285. * ```
  60286. *
  60287. * 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.
  60288. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  60289. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  60290. *
  60291. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  60292. * ```javascript
  60293. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  60294. * ```
  60295. *
  60296. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  60297. */
  60298. export class DracoCompression implements IDisposable {
  60299. private _workerPoolPromise?;
  60300. private _decoderModulePromise?;
  60301. /**
  60302. * The configuration. Defaults to the following urls:
  60303. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  60304. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  60305. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  60306. */
  60307. static Configuration: IDracoCompressionConfiguration;
  60308. /**
  60309. * Returns true if the decoder configuration is available.
  60310. */
  60311. static get DecoderAvailable(): boolean;
  60312. /**
  60313. * Default number of workers to create when creating the draco compression object.
  60314. */
  60315. static DefaultNumWorkers: number;
  60316. private static GetDefaultNumWorkers;
  60317. private static _Default;
  60318. /**
  60319. * Default instance for the draco compression object.
  60320. */
  60321. static get Default(): DracoCompression;
  60322. /**
  60323. * Constructor
  60324. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  60325. */
  60326. constructor(numWorkers?: number);
  60327. /**
  60328. * Stop all async operations and release resources.
  60329. */
  60330. dispose(): void;
  60331. /**
  60332. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  60333. * @returns a promise that resolves when ready
  60334. */
  60335. whenReadyAsync(): Promise<void>;
  60336. /**
  60337. * Decode Draco compressed mesh data to vertex data.
  60338. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  60339. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  60340. * @returns A promise that resolves with the decoded vertex data
  60341. */
  60342. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  60343. [kind: string]: number;
  60344. }): Promise<VertexData>;
  60345. }
  60346. }
  60347. declare module BABYLON {
  60348. /**
  60349. * Class for building Constructive Solid Geometry
  60350. */
  60351. export class CSG {
  60352. private polygons;
  60353. /**
  60354. * The world matrix
  60355. */
  60356. matrix: Matrix;
  60357. /**
  60358. * Stores the position
  60359. */
  60360. position: Vector3;
  60361. /**
  60362. * Stores the rotation
  60363. */
  60364. rotation: Vector3;
  60365. /**
  60366. * Stores the rotation quaternion
  60367. */
  60368. rotationQuaternion: Nullable<Quaternion>;
  60369. /**
  60370. * Stores the scaling vector
  60371. */
  60372. scaling: Vector3;
  60373. /**
  60374. * Convert the Mesh to CSG
  60375. * @param mesh The Mesh to convert to CSG
  60376. * @returns A new CSG from the Mesh
  60377. */
  60378. static FromMesh(mesh: Mesh): CSG;
  60379. /**
  60380. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  60381. * @param polygons Polygons used to construct a CSG solid
  60382. */
  60383. private static FromPolygons;
  60384. /**
  60385. * Clones, or makes a deep copy, of the CSG
  60386. * @returns A new CSG
  60387. */
  60388. clone(): CSG;
  60389. /**
  60390. * Unions this CSG with another CSG
  60391. * @param csg The CSG to union against this CSG
  60392. * @returns The unioned CSG
  60393. */
  60394. union(csg: CSG): CSG;
  60395. /**
  60396. * Unions this CSG with another CSG in place
  60397. * @param csg The CSG to union against this CSG
  60398. */
  60399. unionInPlace(csg: CSG): void;
  60400. /**
  60401. * Subtracts this CSG with another CSG
  60402. * @param csg The CSG to subtract against this CSG
  60403. * @returns A new CSG
  60404. */
  60405. subtract(csg: CSG): CSG;
  60406. /**
  60407. * Subtracts this CSG with another CSG in place
  60408. * @param csg The CSG to subtact against this CSG
  60409. */
  60410. subtractInPlace(csg: CSG): void;
  60411. /**
  60412. * Intersect this CSG with another CSG
  60413. * @param csg The CSG to intersect against this CSG
  60414. * @returns A new CSG
  60415. */
  60416. intersect(csg: CSG): CSG;
  60417. /**
  60418. * Intersects this CSG with another CSG in place
  60419. * @param csg The CSG to intersect against this CSG
  60420. */
  60421. intersectInPlace(csg: CSG): void;
  60422. /**
  60423. * Return a new CSG solid with solid and empty space switched. This solid is
  60424. * not modified.
  60425. * @returns A new CSG solid with solid and empty space switched
  60426. */
  60427. inverse(): CSG;
  60428. /**
  60429. * Inverses the CSG in place
  60430. */
  60431. inverseInPlace(): void;
  60432. /**
  60433. * This is used to keep meshes transformations so they can be restored
  60434. * when we build back a Babylon Mesh
  60435. * NB : All CSG operations are performed in world coordinates
  60436. * @param csg The CSG to copy the transform attributes from
  60437. * @returns This CSG
  60438. */
  60439. copyTransformAttributes(csg: CSG): CSG;
  60440. /**
  60441. * Build Raw mesh from CSG
  60442. * Coordinates here are in world space
  60443. * @param name The name of the mesh geometry
  60444. * @param scene The Scene
  60445. * @param keepSubMeshes Specifies if the submeshes should be kept
  60446. * @returns A new Mesh
  60447. */
  60448. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  60449. /**
  60450. * Build Mesh from CSG taking material and transforms into account
  60451. * @param name The name of the Mesh
  60452. * @param material The material of the Mesh
  60453. * @param scene The Scene
  60454. * @param keepSubMeshes Specifies if submeshes should be kept
  60455. * @returns The new Mesh
  60456. */
  60457. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  60458. }
  60459. }
  60460. declare module BABYLON {
  60461. /**
  60462. * Class used to create a trail following a mesh
  60463. */
  60464. export class TrailMesh extends Mesh {
  60465. private _generator;
  60466. private _autoStart;
  60467. private _running;
  60468. private _diameter;
  60469. private _length;
  60470. private _sectionPolygonPointsCount;
  60471. private _sectionVectors;
  60472. private _sectionNormalVectors;
  60473. private _beforeRenderObserver;
  60474. /**
  60475. * @constructor
  60476. * @param name The value used by scene.getMeshByName() to do a lookup.
  60477. * @param generator The mesh or transform node to generate a trail.
  60478. * @param scene The scene to add this mesh to.
  60479. * @param diameter Diameter of trailing mesh. Default is 1.
  60480. * @param length Length of trailing mesh. Default is 60.
  60481. * @param autoStart Automatically start trailing mesh. Default true.
  60482. */
  60483. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  60484. /**
  60485. * "TrailMesh"
  60486. * @returns "TrailMesh"
  60487. */
  60488. getClassName(): string;
  60489. private _createMesh;
  60490. /**
  60491. * Start trailing mesh.
  60492. */
  60493. start(): void;
  60494. /**
  60495. * Stop trailing mesh.
  60496. */
  60497. stop(): void;
  60498. /**
  60499. * Update trailing mesh geometry.
  60500. */
  60501. update(): void;
  60502. /**
  60503. * Returns a new TrailMesh object.
  60504. * @param name is a string, the name given to the new mesh
  60505. * @param newGenerator use new generator object for cloned trail mesh
  60506. * @returns a new mesh
  60507. */
  60508. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  60509. /**
  60510. * Serializes this trail mesh
  60511. * @param serializationObject object to write serialization to
  60512. */
  60513. serialize(serializationObject: any): void;
  60514. /**
  60515. * Parses a serialized trail mesh
  60516. * @param parsedMesh the serialized mesh
  60517. * @param scene the scene to create the trail mesh in
  60518. * @returns the created trail mesh
  60519. */
  60520. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  60521. }
  60522. }
  60523. declare module BABYLON {
  60524. /**
  60525. * Class containing static functions to help procedurally build meshes
  60526. */
  60527. export class TiledBoxBuilder {
  60528. /**
  60529. * Creates a box mesh
  60530. * 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)
  60531. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  60532. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60533. * * 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
  60534. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60535. * @param name defines the name of the mesh
  60536. * @param options defines the options used to create the mesh
  60537. * @param scene defines the hosting scene
  60538. * @returns the box mesh
  60539. */
  60540. static CreateTiledBox(name: string, options: {
  60541. pattern?: number;
  60542. width?: number;
  60543. height?: number;
  60544. depth?: number;
  60545. tileSize?: number;
  60546. tileWidth?: number;
  60547. tileHeight?: number;
  60548. alignHorizontal?: number;
  60549. alignVertical?: number;
  60550. faceUV?: Vector4[];
  60551. faceColors?: Color4[];
  60552. sideOrientation?: number;
  60553. updatable?: boolean;
  60554. }, scene?: Nullable<Scene>): Mesh;
  60555. }
  60556. }
  60557. declare module BABYLON {
  60558. /**
  60559. * Class containing static functions to help procedurally build meshes
  60560. */
  60561. export class TorusKnotBuilder {
  60562. /**
  60563. * Creates a torus knot mesh
  60564. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  60565. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  60566. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  60567. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  60568. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60569. * * 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
  60570. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  60571. * @param name defines the name of the mesh
  60572. * @param options defines the options used to create the mesh
  60573. * @param scene defines the hosting scene
  60574. * @returns the torus knot mesh
  60575. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  60576. */
  60577. static CreateTorusKnot(name: string, options: {
  60578. radius?: number;
  60579. tube?: number;
  60580. radialSegments?: number;
  60581. tubularSegments?: number;
  60582. p?: number;
  60583. q?: number;
  60584. updatable?: boolean;
  60585. sideOrientation?: number;
  60586. frontUVs?: Vector4;
  60587. backUVs?: Vector4;
  60588. }, scene: any): Mesh;
  60589. }
  60590. }
  60591. declare module BABYLON {
  60592. /**
  60593. * Polygon
  60594. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  60595. */
  60596. export class Polygon {
  60597. /**
  60598. * Creates a rectangle
  60599. * @param xmin bottom X coord
  60600. * @param ymin bottom Y coord
  60601. * @param xmax top X coord
  60602. * @param ymax top Y coord
  60603. * @returns points that make the resulting rectation
  60604. */
  60605. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  60606. /**
  60607. * Creates a circle
  60608. * @param radius radius of circle
  60609. * @param cx scale in x
  60610. * @param cy scale in y
  60611. * @param numberOfSides number of sides that make up the circle
  60612. * @returns points that make the resulting circle
  60613. */
  60614. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  60615. /**
  60616. * Creates a polygon from input string
  60617. * @param input Input polygon data
  60618. * @returns the parsed points
  60619. */
  60620. static Parse(input: string): Vector2[];
  60621. /**
  60622. * Starts building a polygon from x and y coordinates
  60623. * @param x x coordinate
  60624. * @param y y coordinate
  60625. * @returns the started path2
  60626. */
  60627. static StartingAt(x: number, y: number): Path2;
  60628. }
  60629. /**
  60630. * Builds a polygon
  60631. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  60632. */
  60633. export class PolygonMeshBuilder {
  60634. private _points;
  60635. private _outlinepoints;
  60636. private _holes;
  60637. private _name;
  60638. private _scene;
  60639. private _epoints;
  60640. private _eholes;
  60641. private _addToepoint;
  60642. /**
  60643. * Babylon reference to the earcut plugin.
  60644. */
  60645. bjsEarcut: any;
  60646. /**
  60647. * Creates a PolygonMeshBuilder
  60648. * @param name name of the builder
  60649. * @param contours Path of the polygon
  60650. * @param scene scene to add to when creating the mesh
  60651. * @param earcutInjection can be used to inject your own earcut reference
  60652. */
  60653. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  60654. /**
  60655. * Adds a whole within the polygon
  60656. * @param hole Array of points defining the hole
  60657. * @returns this
  60658. */
  60659. addHole(hole: Vector2[]): PolygonMeshBuilder;
  60660. /**
  60661. * Creates the polygon
  60662. * @param updatable If the mesh should be updatable
  60663. * @param depth The depth of the mesh created
  60664. * @returns the created mesh
  60665. */
  60666. build(updatable?: boolean, depth?: number): Mesh;
  60667. /**
  60668. * Creates the polygon
  60669. * @param depth The depth of the mesh created
  60670. * @returns the created VertexData
  60671. */
  60672. buildVertexData(depth?: number): VertexData;
  60673. /**
  60674. * Adds a side to the polygon
  60675. * @param positions points that make the polygon
  60676. * @param normals normals of the polygon
  60677. * @param uvs uvs of the polygon
  60678. * @param indices indices of the polygon
  60679. * @param bounds bounds of the polygon
  60680. * @param points points of the polygon
  60681. * @param depth depth of the polygon
  60682. * @param flip flip of the polygon
  60683. */
  60684. private addSide;
  60685. }
  60686. }
  60687. declare module BABYLON {
  60688. /**
  60689. * Class containing static functions to help procedurally build meshes
  60690. */
  60691. export class PolygonBuilder {
  60692. /**
  60693. * Creates a polygon mesh
  60694. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  60695. * * 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
  60696. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  60697. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60698. * * 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)
  60699. * * Remember you can only change the shape positions, not their number when updating a polygon
  60700. * @param name defines the name of the mesh
  60701. * @param options defines the options used to create the mesh
  60702. * @param scene defines the hosting scene
  60703. * @param earcutInjection can be used to inject your own earcut reference
  60704. * @returns the polygon mesh
  60705. */
  60706. static CreatePolygon(name: string, options: {
  60707. shape: Vector3[];
  60708. holes?: Vector3[][];
  60709. depth?: number;
  60710. faceUV?: Vector4[];
  60711. faceColors?: Color4[];
  60712. updatable?: boolean;
  60713. sideOrientation?: number;
  60714. frontUVs?: Vector4;
  60715. backUVs?: Vector4;
  60716. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  60717. /**
  60718. * Creates an extruded polygon mesh, with depth in the Y direction.
  60719. * * 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)
  60720. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  60721. * @param name defines the name of the mesh
  60722. * @param options defines the options used to create the mesh
  60723. * @param scene defines the hosting scene
  60724. * @param earcutInjection can be used to inject your own earcut reference
  60725. * @returns the polygon mesh
  60726. */
  60727. static ExtrudePolygon(name: string, options: {
  60728. shape: Vector3[];
  60729. holes?: Vector3[][];
  60730. depth?: number;
  60731. faceUV?: Vector4[];
  60732. faceColors?: Color4[];
  60733. updatable?: boolean;
  60734. sideOrientation?: number;
  60735. frontUVs?: Vector4;
  60736. backUVs?: Vector4;
  60737. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  60738. }
  60739. }
  60740. declare module BABYLON {
  60741. /**
  60742. * Class containing static functions to help procedurally build meshes
  60743. */
  60744. export class LatheBuilder {
  60745. /**
  60746. * Creates lathe mesh.
  60747. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  60748. * * 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
  60749. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  60750. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  60751. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  60752. * * 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
  60753. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  60754. * * 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
  60755. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60756. * * 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
  60757. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  60758. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60759. * @param name defines the name of the mesh
  60760. * @param options defines the options used to create the mesh
  60761. * @param scene defines the hosting scene
  60762. * @returns the lathe mesh
  60763. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  60764. */
  60765. static CreateLathe(name: string, options: {
  60766. shape: Vector3[];
  60767. radius?: number;
  60768. tessellation?: number;
  60769. clip?: number;
  60770. arc?: number;
  60771. closed?: boolean;
  60772. updatable?: boolean;
  60773. sideOrientation?: number;
  60774. frontUVs?: Vector4;
  60775. backUVs?: Vector4;
  60776. cap?: number;
  60777. invertUV?: boolean;
  60778. }, scene?: Nullable<Scene>): Mesh;
  60779. }
  60780. }
  60781. declare module BABYLON {
  60782. /**
  60783. * Class containing static functions to help procedurally build meshes
  60784. */
  60785. export class TiledPlaneBuilder {
  60786. /**
  60787. * Creates a tiled plane mesh
  60788. * * The parameter `pattern` will, depending on value, do nothing or
  60789. * * * flip (reflect about central vertical) alternate tiles across and up
  60790. * * * flip every tile on alternate rows
  60791. * * * rotate (180 degs) alternate tiles across and up
  60792. * * * rotate every tile on alternate rows
  60793. * * * flip and rotate alternate tiles across and up
  60794. * * * flip and rotate every tile on alternate rows
  60795. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  60796. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  60797. * * 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
  60798. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  60799. * * 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)
  60800. * * 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)
  60801. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  60802. * @param name defines the name of the mesh
  60803. * @param options defines the options used to create the mesh
  60804. * @param scene defines the hosting scene
  60805. * @returns the box mesh
  60806. */
  60807. static CreateTiledPlane(name: string, options: {
  60808. pattern?: number;
  60809. tileSize?: number;
  60810. tileWidth?: number;
  60811. tileHeight?: number;
  60812. size?: number;
  60813. width?: number;
  60814. height?: number;
  60815. alignHorizontal?: number;
  60816. alignVertical?: number;
  60817. sideOrientation?: number;
  60818. frontUVs?: Vector4;
  60819. backUVs?: Vector4;
  60820. updatable?: boolean;
  60821. }, scene?: Nullable<Scene>): Mesh;
  60822. }
  60823. }
  60824. declare module BABYLON {
  60825. /**
  60826. * Class containing static functions to help procedurally build meshes
  60827. */
  60828. export class TubeBuilder {
  60829. /**
  60830. * Creates a tube mesh.
  60831. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  60832. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  60833. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  60834. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  60835. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  60836. * * 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)
  60837. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  60838. * * The parameter `cap` sets the way the extruded shape is capped. Possible values : BABYLON.Mesh.NO_CAP (default), BABYLON.Mesh.CAP_START, BABYLON.Mesh.CAP_END, BABYLON.Mesh.CAP_ALL
  60839. * * 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
  60840. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60841. * * 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
  60842. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  60843. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60844. * @param name defines the name of the mesh
  60845. * @param options defines the options used to create the mesh
  60846. * @param scene defines the hosting scene
  60847. * @returns the tube mesh
  60848. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  60849. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  60850. */
  60851. static CreateTube(name: string, options: {
  60852. path: Vector3[];
  60853. radius?: number;
  60854. tessellation?: number;
  60855. radiusFunction?: {
  60856. (i: number, distance: number): number;
  60857. };
  60858. cap?: number;
  60859. arc?: number;
  60860. updatable?: boolean;
  60861. sideOrientation?: number;
  60862. frontUVs?: Vector4;
  60863. backUVs?: Vector4;
  60864. instance?: Mesh;
  60865. invertUV?: boolean;
  60866. }, scene?: Nullable<Scene>): Mesh;
  60867. }
  60868. }
  60869. declare module BABYLON {
  60870. /**
  60871. * Class containing static functions to help procedurally build meshes
  60872. */
  60873. export class IcoSphereBuilder {
  60874. /**
  60875. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  60876. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  60877. * * 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`)
  60878. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  60879. * * 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
  60880. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60881. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60882. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60883. * @param name defines the name of the mesh
  60884. * @param options defines the options used to create the mesh
  60885. * @param scene defines the hosting scene
  60886. * @returns the icosahedron mesh
  60887. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  60888. */
  60889. static CreateIcoSphere(name: string, options: {
  60890. radius?: number;
  60891. radiusX?: number;
  60892. radiusY?: number;
  60893. radiusZ?: number;
  60894. flat?: boolean;
  60895. subdivisions?: number;
  60896. sideOrientation?: number;
  60897. frontUVs?: Vector4;
  60898. backUVs?: Vector4;
  60899. updatable?: boolean;
  60900. }, scene?: Nullable<Scene>): Mesh;
  60901. }
  60902. }
  60903. declare module BABYLON {
  60904. /**
  60905. * Class containing static functions to help procedurally build meshes
  60906. */
  60907. export class DecalBuilder {
  60908. /**
  60909. * Creates a decal mesh.
  60910. * 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
  60911. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  60912. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  60913. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  60914. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  60915. * @param name defines the name of the mesh
  60916. * @param sourceMesh defines the mesh where the decal must be applied
  60917. * @param options defines the options used to create the mesh
  60918. * @param scene defines the hosting scene
  60919. * @returns the decal mesh
  60920. * @see https://doc.babylonjs.com/how_to/decals
  60921. */
  60922. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  60923. position?: Vector3;
  60924. normal?: Vector3;
  60925. size?: Vector3;
  60926. angle?: number;
  60927. }): Mesh;
  60928. }
  60929. }
  60930. declare module BABYLON {
  60931. /**
  60932. * Class containing static functions to help procedurally build meshes
  60933. */
  60934. export class MeshBuilder {
  60935. /**
  60936. * Creates a box mesh
  60937. * * The parameter `size` sets the size (float) of each box side (default 1)
  60938. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  60939. * * 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)
  60940. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  60941. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60942. * * 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
  60943. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60944. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  60945. * @param name defines the name of the mesh
  60946. * @param options defines the options used to create the mesh
  60947. * @param scene defines the hosting scene
  60948. * @returns the box mesh
  60949. */
  60950. static CreateBox(name: string, options: {
  60951. size?: number;
  60952. width?: number;
  60953. height?: number;
  60954. depth?: number;
  60955. faceUV?: Vector4[];
  60956. faceColors?: Color4[];
  60957. sideOrientation?: number;
  60958. frontUVs?: Vector4;
  60959. backUVs?: Vector4;
  60960. updatable?: boolean;
  60961. }, scene?: Nullable<Scene>): Mesh;
  60962. /**
  60963. * Creates a tiled box mesh
  60964. * * faceTiles sets the pattern, tile size and number of tiles for a face
  60965. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60966. * @param name defines the name of the mesh
  60967. * @param options defines the options used to create the mesh
  60968. * @param scene defines the hosting scene
  60969. * @returns the tiled box mesh
  60970. */
  60971. static CreateTiledBox(name: string, options: {
  60972. pattern?: number;
  60973. size?: number;
  60974. width?: number;
  60975. height?: number;
  60976. depth: number;
  60977. tileSize?: number;
  60978. tileWidth?: number;
  60979. tileHeight?: number;
  60980. faceUV?: Vector4[];
  60981. faceColors?: Color4[];
  60982. alignHorizontal?: number;
  60983. alignVertical?: number;
  60984. sideOrientation?: number;
  60985. updatable?: boolean;
  60986. }, scene?: Nullable<Scene>): Mesh;
  60987. /**
  60988. * Creates a sphere mesh
  60989. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  60990. * * 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`)
  60991. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  60992. * * 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
  60993. * * 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)
  60994. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60995. * * 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
  60996. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60997. * @param name defines the name of the mesh
  60998. * @param options defines the options used to create the mesh
  60999. * @param scene defines the hosting scene
  61000. * @returns the sphere mesh
  61001. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  61002. */
  61003. static CreateSphere(name: string, options: {
  61004. segments?: number;
  61005. diameter?: number;
  61006. diameterX?: number;
  61007. diameterY?: number;
  61008. diameterZ?: number;
  61009. arc?: number;
  61010. slice?: number;
  61011. sideOrientation?: number;
  61012. frontUVs?: Vector4;
  61013. backUVs?: Vector4;
  61014. updatable?: boolean;
  61015. }, scene?: Nullable<Scene>): Mesh;
  61016. /**
  61017. * Creates a plane polygonal mesh. By default, this is a disc
  61018. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  61019. * * 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
  61020. * * 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
  61021. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61022. * * 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
  61023. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61024. * @param name defines the name of the mesh
  61025. * @param options defines the options used to create the mesh
  61026. * @param scene defines the hosting scene
  61027. * @returns the plane polygonal mesh
  61028. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  61029. */
  61030. static CreateDisc(name: string, options: {
  61031. radius?: number;
  61032. tessellation?: number;
  61033. arc?: number;
  61034. updatable?: boolean;
  61035. sideOrientation?: number;
  61036. frontUVs?: Vector4;
  61037. backUVs?: Vector4;
  61038. }, scene?: Nullable<Scene>): Mesh;
  61039. /**
  61040. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  61041. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  61042. * * 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`)
  61043. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  61044. * * 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
  61045. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61046. * * 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
  61047. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61048. * @param name defines the name of the mesh
  61049. * @param options defines the options used to create the mesh
  61050. * @param scene defines the hosting scene
  61051. * @returns the icosahedron mesh
  61052. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  61053. */
  61054. static CreateIcoSphere(name: string, options: {
  61055. radius?: number;
  61056. radiusX?: number;
  61057. radiusY?: number;
  61058. radiusZ?: number;
  61059. flat?: boolean;
  61060. subdivisions?: number;
  61061. sideOrientation?: number;
  61062. frontUVs?: Vector4;
  61063. backUVs?: Vector4;
  61064. updatable?: boolean;
  61065. }, scene?: Nullable<Scene>): Mesh;
  61066. /**
  61067. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  61068. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  61069. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  61070. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  61071. * * 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
  61072. * * 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
  61073. * * 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
  61074. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61075. * * 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
  61076. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61077. * * 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
  61078. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  61079. * * 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
  61080. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  61081. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61082. * @param name defines the name of the mesh
  61083. * @param options defines the options used to create the mesh
  61084. * @param scene defines the hosting scene
  61085. * @returns the ribbon mesh
  61086. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  61087. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  61088. */
  61089. static CreateRibbon(name: string, options: {
  61090. pathArray: Vector3[][];
  61091. closeArray?: boolean;
  61092. closePath?: boolean;
  61093. offset?: number;
  61094. updatable?: boolean;
  61095. sideOrientation?: number;
  61096. frontUVs?: Vector4;
  61097. backUVs?: Vector4;
  61098. instance?: Mesh;
  61099. invertUV?: boolean;
  61100. uvs?: Vector2[];
  61101. colors?: Color4[];
  61102. }, scene?: Nullable<Scene>): Mesh;
  61103. /**
  61104. * Creates a cylinder or a cone mesh
  61105. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  61106. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  61107. * * 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.
  61108. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  61109. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  61110. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  61111. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  61112. * * 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).
  61113. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  61114. * * 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).
  61115. * * 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
  61116. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  61117. * * 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
  61118. * * 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.
  61119. * * If `enclose` is false, a ring surface is one element.
  61120. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  61121. * * 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
  61122. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61123. * * 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
  61124. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61125. * @param name defines the name of the mesh
  61126. * @param options defines the options used to create the mesh
  61127. * @param scene defines the hosting scene
  61128. * @returns the cylinder mesh
  61129. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  61130. */
  61131. static CreateCylinder(name: string, options: {
  61132. height?: number;
  61133. diameterTop?: number;
  61134. diameterBottom?: number;
  61135. diameter?: number;
  61136. tessellation?: number;
  61137. subdivisions?: number;
  61138. arc?: number;
  61139. faceColors?: Color4[];
  61140. faceUV?: Vector4[];
  61141. updatable?: boolean;
  61142. hasRings?: boolean;
  61143. enclose?: boolean;
  61144. cap?: number;
  61145. sideOrientation?: number;
  61146. frontUVs?: Vector4;
  61147. backUVs?: Vector4;
  61148. }, scene?: Nullable<Scene>): Mesh;
  61149. /**
  61150. * Creates a torus mesh
  61151. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  61152. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  61153. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  61154. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61155. * * 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
  61156. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61157. * @param name defines the name of the mesh
  61158. * @param options defines the options used to create the mesh
  61159. * @param scene defines the hosting scene
  61160. * @returns the torus mesh
  61161. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  61162. */
  61163. static CreateTorus(name: string, options: {
  61164. diameter?: number;
  61165. thickness?: number;
  61166. tessellation?: number;
  61167. updatable?: boolean;
  61168. sideOrientation?: number;
  61169. frontUVs?: Vector4;
  61170. backUVs?: Vector4;
  61171. }, scene?: Nullable<Scene>): Mesh;
  61172. /**
  61173. * Creates a torus knot mesh
  61174. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  61175. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  61176. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  61177. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  61178. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61179. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  61180. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61181. * @param name defines the name of the mesh
  61182. * @param options defines the options used to create the mesh
  61183. * @param scene defines the hosting scene
  61184. * @returns the torus knot mesh
  61185. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  61186. */
  61187. static CreateTorusKnot(name: string, options: {
  61188. radius?: number;
  61189. tube?: number;
  61190. radialSegments?: number;
  61191. tubularSegments?: number;
  61192. p?: number;
  61193. q?: number;
  61194. updatable?: boolean;
  61195. sideOrientation?: number;
  61196. frontUVs?: Vector4;
  61197. backUVs?: Vector4;
  61198. }, scene?: Nullable<Scene>): Mesh;
  61199. /**
  61200. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  61201. * * 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
  61202. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  61203. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  61204. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  61205. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  61206. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  61207. * * 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
  61208. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  61209. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61210. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  61211. * @param name defines the name of the new line system
  61212. * @param options defines the options used to create the line system
  61213. * @param scene defines the hosting scene
  61214. * @returns a new line system mesh
  61215. */
  61216. static CreateLineSystem(name: string, options: {
  61217. lines: Vector3[][];
  61218. updatable?: boolean;
  61219. instance?: Nullable<LinesMesh>;
  61220. colors?: Nullable<Color4[][]>;
  61221. useVertexAlpha?: boolean;
  61222. }, scene: Nullable<Scene>): LinesMesh;
  61223. /**
  61224. * Creates a line mesh
  61225. * 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
  61226. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  61227. * * The parameter `points` is an array successive Vector3
  61228. * * 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
  61229. * * The optional parameter `colors` is an array of successive Color4, one per line point
  61230. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  61231. * * When updating an instance, remember that only point positions can change, not the number of points
  61232. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61233. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  61234. * @param name defines the name of the new line system
  61235. * @param options defines the options used to create the line system
  61236. * @param scene defines the hosting scene
  61237. * @returns a new line mesh
  61238. */
  61239. static CreateLines(name: string, options: {
  61240. points: Vector3[];
  61241. updatable?: boolean;
  61242. instance?: Nullable<LinesMesh>;
  61243. colors?: Color4[];
  61244. useVertexAlpha?: boolean;
  61245. }, scene?: Nullable<Scene>): LinesMesh;
  61246. /**
  61247. * Creates a dashed line mesh
  61248. * * 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
  61249. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  61250. * * The parameter `points` is an array successive Vector3
  61251. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  61252. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  61253. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  61254. * * 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
  61255. * * When updating an instance, remember that only point positions can change, not the number of points
  61256. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61257. * @param name defines the name of the mesh
  61258. * @param options defines the options used to create the mesh
  61259. * @param scene defines the hosting scene
  61260. * @returns the dashed line mesh
  61261. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  61262. */
  61263. static CreateDashedLines(name: string, options: {
  61264. points: Vector3[];
  61265. dashSize?: number;
  61266. gapSize?: number;
  61267. dashNb?: number;
  61268. updatable?: boolean;
  61269. instance?: LinesMesh;
  61270. }, scene?: Nullable<Scene>): LinesMesh;
  61271. /**
  61272. * 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.
  61273. * * 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.
  61274. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  61275. * * 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.
  61276. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  61277. * * 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
  61278. * * 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
  61279. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  61280. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61281. * * 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
  61282. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  61283. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61284. * @param name defines the name of the mesh
  61285. * @param options defines the options used to create the mesh
  61286. * @param scene defines the hosting scene
  61287. * @returns the extruded shape mesh
  61288. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  61289. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  61290. */
  61291. static ExtrudeShape(name: string, options: {
  61292. shape: Vector3[];
  61293. path: Vector3[];
  61294. scale?: number;
  61295. rotation?: number;
  61296. cap?: number;
  61297. updatable?: boolean;
  61298. sideOrientation?: number;
  61299. frontUVs?: Vector4;
  61300. backUVs?: Vector4;
  61301. instance?: Mesh;
  61302. invertUV?: boolean;
  61303. }, scene?: Nullable<Scene>): Mesh;
  61304. /**
  61305. * Creates an custom extruded shape mesh.
  61306. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  61307. * * 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.
  61308. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  61309. * * 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
  61310. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  61311. * * 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
  61312. * * It must returns a float value that will be the scale value applied to the shape on each path point
  61313. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  61314. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  61315. * * 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
  61316. * * 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
  61317. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  61318. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61319. * * 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
  61320. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61321. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61322. * @param name defines the name of the mesh
  61323. * @param options defines the options used to create the mesh
  61324. * @param scene defines the hosting scene
  61325. * @returns the custom extruded shape mesh
  61326. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  61327. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  61328. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  61329. */
  61330. static ExtrudeShapeCustom(name: string, options: {
  61331. shape: Vector3[];
  61332. path: Vector3[];
  61333. scaleFunction?: any;
  61334. rotationFunction?: any;
  61335. ribbonCloseArray?: boolean;
  61336. ribbonClosePath?: boolean;
  61337. cap?: number;
  61338. updatable?: boolean;
  61339. sideOrientation?: number;
  61340. frontUVs?: Vector4;
  61341. backUVs?: Vector4;
  61342. instance?: Mesh;
  61343. invertUV?: boolean;
  61344. }, scene?: Nullable<Scene>): Mesh;
  61345. /**
  61346. * Creates lathe mesh.
  61347. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  61348. * * 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
  61349. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  61350. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  61351. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  61352. * * 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
  61353. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  61354. * * 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
  61355. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61356. * * 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
  61357. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61358. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61359. * @param name defines the name of the mesh
  61360. * @param options defines the options used to create the mesh
  61361. * @param scene defines the hosting scene
  61362. * @returns the lathe mesh
  61363. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  61364. */
  61365. static CreateLathe(name: string, options: {
  61366. shape: Vector3[];
  61367. radius?: number;
  61368. tessellation?: number;
  61369. clip?: number;
  61370. arc?: number;
  61371. closed?: boolean;
  61372. updatable?: boolean;
  61373. sideOrientation?: number;
  61374. frontUVs?: Vector4;
  61375. backUVs?: Vector4;
  61376. cap?: number;
  61377. invertUV?: boolean;
  61378. }, scene?: Nullable<Scene>): Mesh;
  61379. /**
  61380. * Creates a tiled plane mesh
  61381. * * You can set a limited pattern arrangement with the tiles
  61382. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61383. * * 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
  61384. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61385. * @param name defines the name of the mesh
  61386. * @param options defines the options used to create the mesh
  61387. * @param scene defines the hosting scene
  61388. * @returns the plane mesh
  61389. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  61390. */
  61391. static CreateTiledPlane(name: string, options: {
  61392. pattern?: number;
  61393. tileSize?: number;
  61394. tileWidth?: number;
  61395. tileHeight?: number;
  61396. size?: number;
  61397. width?: number;
  61398. height?: number;
  61399. alignHorizontal?: number;
  61400. alignVertical?: number;
  61401. sideOrientation?: number;
  61402. frontUVs?: Vector4;
  61403. backUVs?: Vector4;
  61404. updatable?: boolean;
  61405. }, scene?: Nullable<Scene>): Mesh;
  61406. /**
  61407. * Creates a plane mesh
  61408. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  61409. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  61410. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  61411. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61412. * * 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
  61413. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61414. * @param name defines the name of the mesh
  61415. * @param options defines the options used to create the mesh
  61416. * @param scene defines the hosting scene
  61417. * @returns the plane mesh
  61418. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  61419. */
  61420. static CreatePlane(name: string, options: {
  61421. size?: number;
  61422. width?: number;
  61423. height?: number;
  61424. sideOrientation?: number;
  61425. frontUVs?: Vector4;
  61426. backUVs?: Vector4;
  61427. updatable?: boolean;
  61428. sourcePlane?: Plane;
  61429. }, scene?: Nullable<Scene>): Mesh;
  61430. /**
  61431. * Creates a ground mesh
  61432. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  61433. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  61434. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61435. * @param name defines the name of the mesh
  61436. * @param options defines the options used to create the mesh
  61437. * @param scene defines the hosting scene
  61438. * @returns the ground mesh
  61439. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  61440. */
  61441. static CreateGround(name: string, options: {
  61442. width?: number;
  61443. height?: number;
  61444. subdivisions?: number;
  61445. subdivisionsX?: number;
  61446. subdivisionsY?: number;
  61447. updatable?: boolean;
  61448. }, scene?: Nullable<Scene>): Mesh;
  61449. /**
  61450. * Creates a tiled ground mesh
  61451. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  61452. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  61453. * * 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
  61454. * * 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
  61455. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61456. * @param name defines the name of the mesh
  61457. * @param options defines the options used to create the mesh
  61458. * @param scene defines the hosting scene
  61459. * @returns the tiled ground mesh
  61460. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  61461. */
  61462. static CreateTiledGround(name: string, options: {
  61463. xmin: number;
  61464. zmin: number;
  61465. xmax: number;
  61466. zmax: number;
  61467. subdivisions?: {
  61468. w: number;
  61469. h: number;
  61470. };
  61471. precision?: {
  61472. w: number;
  61473. h: number;
  61474. };
  61475. updatable?: boolean;
  61476. }, scene?: Nullable<Scene>): Mesh;
  61477. /**
  61478. * Creates a ground mesh from a height map
  61479. * * The parameter `url` sets the URL of the height map image resource.
  61480. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  61481. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  61482. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  61483. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  61484. * * 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.
  61485. * * 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).
  61486. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  61487. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61488. * @param name defines the name of the mesh
  61489. * @param url defines the url to the height map
  61490. * @param options defines the options used to create the mesh
  61491. * @param scene defines the hosting scene
  61492. * @returns the ground mesh
  61493. * @see https://doc.babylonjs.com/babylon101/height_map
  61494. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  61495. */
  61496. static CreateGroundFromHeightMap(name: string, url: string, options: {
  61497. width?: number;
  61498. height?: number;
  61499. subdivisions?: number;
  61500. minHeight?: number;
  61501. maxHeight?: number;
  61502. colorFilter?: Color3;
  61503. alphaFilter?: number;
  61504. updatable?: boolean;
  61505. onReady?: (mesh: GroundMesh) => void;
  61506. }, scene?: Nullable<Scene>): GroundMesh;
  61507. /**
  61508. * Creates a polygon mesh
  61509. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  61510. * * 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
  61511. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  61512. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61513. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  61514. * * Remember you can only change the shape positions, not their number when updating a polygon
  61515. * @param name defines the name of the mesh
  61516. * @param options defines the options used to create the mesh
  61517. * @param scene defines the hosting scene
  61518. * @param earcutInjection can be used to inject your own earcut reference
  61519. * @returns the polygon mesh
  61520. */
  61521. static CreatePolygon(name: string, options: {
  61522. shape: Vector3[];
  61523. holes?: Vector3[][];
  61524. depth?: number;
  61525. faceUV?: Vector4[];
  61526. faceColors?: Color4[];
  61527. updatable?: boolean;
  61528. sideOrientation?: number;
  61529. frontUVs?: Vector4;
  61530. backUVs?: Vector4;
  61531. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  61532. /**
  61533. * Creates an extruded polygon mesh, with depth in the Y direction.
  61534. * * 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)
  61535. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  61536. * @param name defines the name of the mesh
  61537. * @param options defines the options used to create the mesh
  61538. * @param scene defines the hosting scene
  61539. * @param earcutInjection can be used to inject your own earcut reference
  61540. * @returns the polygon mesh
  61541. */
  61542. static ExtrudePolygon(name: string, options: {
  61543. shape: Vector3[];
  61544. holes?: Vector3[][];
  61545. depth?: number;
  61546. faceUV?: Vector4[];
  61547. faceColors?: Color4[];
  61548. updatable?: boolean;
  61549. sideOrientation?: number;
  61550. frontUVs?: Vector4;
  61551. backUVs?: Vector4;
  61552. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  61553. /**
  61554. * Creates a tube mesh.
  61555. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  61556. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  61557. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  61558. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  61559. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  61560. * * 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)
  61561. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  61562. * * 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
  61563. * * 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
  61564. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61565. * * 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
  61566. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61567. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61568. * @param name defines the name of the mesh
  61569. * @param options defines the options used to create the mesh
  61570. * @param scene defines the hosting scene
  61571. * @returns the tube mesh
  61572. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  61573. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  61574. */
  61575. static CreateTube(name: string, options: {
  61576. path: Vector3[];
  61577. radius?: number;
  61578. tessellation?: number;
  61579. radiusFunction?: {
  61580. (i: number, distance: number): number;
  61581. };
  61582. cap?: number;
  61583. arc?: number;
  61584. updatable?: boolean;
  61585. sideOrientation?: number;
  61586. frontUVs?: Vector4;
  61587. backUVs?: Vector4;
  61588. instance?: Mesh;
  61589. invertUV?: boolean;
  61590. }, scene?: Nullable<Scene>): Mesh;
  61591. /**
  61592. * Creates a polyhedron mesh
  61593. * * 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
  61594. * * The parameter `size` (positive float, default 1) sets the polygon size
  61595. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  61596. * * 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`
  61597. * * 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
  61598. * * 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)`)
  61599. * * 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
  61600. * * 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
  61601. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61602. * * 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
  61603. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61604. * @param name defines the name of the mesh
  61605. * @param options defines the options used to create the mesh
  61606. * @param scene defines the hosting scene
  61607. * @returns the polyhedron mesh
  61608. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  61609. */
  61610. static CreatePolyhedron(name: string, options: {
  61611. type?: number;
  61612. size?: number;
  61613. sizeX?: number;
  61614. sizeY?: number;
  61615. sizeZ?: number;
  61616. custom?: any;
  61617. faceUV?: Vector4[];
  61618. faceColors?: Color4[];
  61619. flat?: boolean;
  61620. updatable?: boolean;
  61621. sideOrientation?: number;
  61622. frontUVs?: Vector4;
  61623. backUVs?: Vector4;
  61624. }, scene?: Nullable<Scene>): Mesh;
  61625. /**
  61626. * Creates a decal mesh.
  61627. * 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
  61628. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  61629. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  61630. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  61631. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  61632. * @param name defines the name of the mesh
  61633. * @param sourceMesh defines the mesh where the decal must be applied
  61634. * @param options defines the options used to create the mesh
  61635. * @param scene defines the hosting scene
  61636. * @returns the decal mesh
  61637. * @see https://doc.babylonjs.com/how_to/decals
  61638. */
  61639. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  61640. position?: Vector3;
  61641. normal?: Vector3;
  61642. size?: Vector3;
  61643. angle?: number;
  61644. }): Mesh;
  61645. }
  61646. }
  61647. declare module BABYLON {
  61648. /**
  61649. * A simplifier interface for future simplification implementations
  61650. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  61651. */
  61652. export interface ISimplifier {
  61653. /**
  61654. * Simplification of a given mesh according to the given settings.
  61655. * Since this requires computation, it is assumed that the function runs async.
  61656. * @param settings The settings of the simplification, including quality and distance
  61657. * @param successCallback A callback that will be called after the mesh was simplified.
  61658. * @param errorCallback in case of an error, this callback will be called. optional.
  61659. */
  61660. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  61661. }
  61662. /**
  61663. * Expected simplification settings.
  61664. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  61665. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  61666. */
  61667. export interface ISimplificationSettings {
  61668. /**
  61669. * Gets or sets the expected quality
  61670. */
  61671. quality: number;
  61672. /**
  61673. * Gets or sets the distance when this optimized version should be used
  61674. */
  61675. distance: number;
  61676. /**
  61677. * Gets an already optimized mesh
  61678. */
  61679. optimizeMesh?: boolean;
  61680. }
  61681. /**
  61682. * Class used to specify simplification options
  61683. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  61684. */
  61685. export class SimplificationSettings implements ISimplificationSettings {
  61686. /** expected quality */
  61687. quality: number;
  61688. /** distance when this optimized version should be used */
  61689. distance: number;
  61690. /** already optimized mesh */
  61691. optimizeMesh?: boolean | undefined;
  61692. /**
  61693. * Creates a SimplificationSettings
  61694. * @param quality expected quality
  61695. * @param distance distance when this optimized version should be used
  61696. * @param optimizeMesh already optimized mesh
  61697. */
  61698. constructor(
  61699. /** expected quality */
  61700. quality: number,
  61701. /** distance when this optimized version should be used */
  61702. distance: number,
  61703. /** already optimized mesh */
  61704. optimizeMesh?: boolean | undefined);
  61705. }
  61706. /**
  61707. * Interface used to define a simplification task
  61708. */
  61709. export interface ISimplificationTask {
  61710. /**
  61711. * Array of settings
  61712. */
  61713. settings: Array<ISimplificationSettings>;
  61714. /**
  61715. * Simplification type
  61716. */
  61717. simplificationType: SimplificationType;
  61718. /**
  61719. * Mesh to simplify
  61720. */
  61721. mesh: Mesh;
  61722. /**
  61723. * Callback called on success
  61724. */
  61725. successCallback?: () => void;
  61726. /**
  61727. * Defines if parallel processing can be used
  61728. */
  61729. parallelProcessing: boolean;
  61730. }
  61731. /**
  61732. * Queue used to order the simplification tasks
  61733. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  61734. */
  61735. export class SimplificationQueue {
  61736. private _simplificationArray;
  61737. /**
  61738. * Gets a boolean indicating that the process is still running
  61739. */
  61740. running: boolean;
  61741. /**
  61742. * Creates a new queue
  61743. */
  61744. constructor();
  61745. /**
  61746. * Adds a new simplification task
  61747. * @param task defines a task to add
  61748. */
  61749. addTask(task: ISimplificationTask): void;
  61750. /**
  61751. * Execute next task
  61752. */
  61753. executeNext(): void;
  61754. /**
  61755. * Execute a simplification task
  61756. * @param task defines the task to run
  61757. */
  61758. runSimplification(task: ISimplificationTask): void;
  61759. private getSimplifier;
  61760. }
  61761. /**
  61762. * The implemented types of simplification
  61763. * At the moment only Quadratic Error Decimation is implemented
  61764. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  61765. */
  61766. export enum SimplificationType {
  61767. /** Quadratic error decimation */
  61768. QUADRATIC = 0
  61769. }
  61770. }
  61771. declare module BABYLON {
  61772. interface Scene {
  61773. /** @hidden (Backing field) */
  61774. _simplificationQueue: SimplificationQueue;
  61775. /**
  61776. * Gets or sets the simplification queue attached to the scene
  61777. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  61778. */
  61779. simplificationQueue: SimplificationQueue;
  61780. }
  61781. interface Mesh {
  61782. /**
  61783. * Simplify the mesh according to the given array of settings.
  61784. * Function will return immediately and will simplify async
  61785. * @param settings a collection of simplification settings
  61786. * @param parallelProcessing should all levels calculate parallel or one after the other
  61787. * @param simplificationType the type of simplification to run
  61788. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  61789. * @returns the current mesh
  61790. */
  61791. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  61792. }
  61793. /**
  61794. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  61795. * created in a scene
  61796. */
  61797. export class SimplicationQueueSceneComponent implements ISceneComponent {
  61798. /**
  61799. * The component name helpfull to identify the component in the list of scene components.
  61800. */
  61801. readonly name: string;
  61802. /**
  61803. * The scene the component belongs to.
  61804. */
  61805. scene: Scene;
  61806. /**
  61807. * Creates a new instance of the component for the given scene
  61808. * @param scene Defines the scene to register the component in
  61809. */
  61810. constructor(scene: Scene);
  61811. /**
  61812. * Registers the component in a given scene
  61813. */
  61814. register(): void;
  61815. /**
  61816. * Rebuilds the elements related to this component in case of
  61817. * context lost for instance.
  61818. */
  61819. rebuild(): void;
  61820. /**
  61821. * Disposes the component and the associated ressources
  61822. */
  61823. dispose(): void;
  61824. private _beforeCameraUpdate;
  61825. }
  61826. }
  61827. declare module BABYLON {
  61828. /**
  61829. * Navigation plugin interface to add navigation constrained by a navigation mesh
  61830. */
  61831. export interface INavigationEnginePlugin {
  61832. /**
  61833. * plugin name
  61834. */
  61835. name: string;
  61836. /**
  61837. * Creates a navigation mesh
  61838. * @param meshes array of all the geometry used to compute the navigatio mesh
  61839. * @param parameters bunch of parameters used to filter geometry
  61840. */
  61841. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  61842. /**
  61843. * Create a navigation mesh debug mesh
  61844. * @param scene is where the mesh will be added
  61845. * @returns debug display mesh
  61846. */
  61847. createDebugNavMesh(scene: Scene): Mesh;
  61848. /**
  61849. * Get a navigation mesh constrained position, closest to the parameter position
  61850. * @param position world position
  61851. * @returns the closest point to position constrained by the navigation mesh
  61852. */
  61853. getClosestPoint(position: Vector3): Vector3;
  61854. /**
  61855. * Get a navigation mesh constrained position, within a particular radius
  61856. * @param position world position
  61857. * @param maxRadius the maximum distance to the constrained world position
  61858. * @returns the closest point to position constrained by the navigation mesh
  61859. */
  61860. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  61861. /**
  61862. * Compute the final position from a segment made of destination-position
  61863. * @param position world position
  61864. * @param destination world position
  61865. * @returns the resulting point along the navmesh
  61866. */
  61867. moveAlong(position: Vector3, destination: Vector3): Vector3;
  61868. /**
  61869. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  61870. * @param start world position
  61871. * @param end world position
  61872. * @returns array containing world position composing the path
  61873. */
  61874. computePath(start: Vector3, end: Vector3): Vector3[];
  61875. /**
  61876. * If this plugin is supported
  61877. * @returns true if plugin is supported
  61878. */
  61879. isSupported(): boolean;
  61880. /**
  61881. * Create a new Crowd so you can add agents
  61882. * @param maxAgents the maximum agent count in the crowd
  61883. * @param maxAgentRadius the maximum radius an agent can have
  61884. * @param scene to attach the crowd to
  61885. * @returns the crowd you can add agents to
  61886. */
  61887. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  61888. /**
  61889. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  61890. * The queries will try to find a solution within those bounds
  61891. * default is (1,1,1)
  61892. * @param extent x,y,z value that define the extent around the queries point of reference
  61893. */
  61894. setDefaultQueryExtent(extent: Vector3): void;
  61895. /**
  61896. * Get the Bounding box extent specified by setDefaultQueryExtent
  61897. * @returns the box extent values
  61898. */
  61899. getDefaultQueryExtent(): Vector3;
  61900. /**
  61901. * Release all resources
  61902. */
  61903. dispose(): void;
  61904. }
  61905. /**
  61906. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  61907. */
  61908. export interface ICrowd {
  61909. /**
  61910. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  61911. * You can attach anything to that node. The node position is updated in the scene update tick.
  61912. * @param pos world position that will be constrained by the navigation mesh
  61913. * @param parameters agent parameters
  61914. * @param transform hooked to the agent that will be update by the scene
  61915. * @returns agent index
  61916. */
  61917. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  61918. /**
  61919. * Returns the agent position in world space
  61920. * @param index agent index returned by addAgent
  61921. * @returns world space position
  61922. */
  61923. getAgentPosition(index: number): Vector3;
  61924. /**
  61925. * Gets the agent velocity in world space
  61926. * @param index agent index returned by addAgent
  61927. * @returns world space velocity
  61928. */
  61929. getAgentVelocity(index: number): Vector3;
  61930. /**
  61931. * remove a particular agent previously created
  61932. * @param index agent index returned by addAgent
  61933. */
  61934. removeAgent(index: number): void;
  61935. /**
  61936. * get the list of all agents attached to this crowd
  61937. * @returns list of agent indices
  61938. */
  61939. getAgents(): number[];
  61940. /**
  61941. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  61942. * @param deltaTime in seconds
  61943. */
  61944. update(deltaTime: number): void;
  61945. /**
  61946. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  61947. * @param index agent index returned by addAgent
  61948. * @param destination targeted world position
  61949. */
  61950. agentGoto(index: number, destination: Vector3): void;
  61951. /**
  61952. * Teleport the agent to a new position
  61953. * @param index agent index returned by addAgent
  61954. * @param destination targeted world position
  61955. */
  61956. agentTeleport(index: number, destination: Vector3): void;
  61957. /**
  61958. * Update agent parameters
  61959. * @param index agent index returned by addAgent
  61960. * @param parameters agent parameters
  61961. */
  61962. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  61963. /**
  61964. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  61965. * The queries will try to find a solution within those bounds
  61966. * default is (1,1,1)
  61967. * @param extent x,y,z value that define the extent around the queries point of reference
  61968. */
  61969. setDefaultQueryExtent(extent: Vector3): void;
  61970. /**
  61971. * Get the Bounding box extent specified by setDefaultQueryExtent
  61972. * @returns the box extent values
  61973. */
  61974. getDefaultQueryExtent(): Vector3;
  61975. /**
  61976. * Release all resources
  61977. */
  61978. dispose(): void;
  61979. }
  61980. /**
  61981. * Configures an agent
  61982. */
  61983. export interface IAgentParameters {
  61984. /**
  61985. * Agent radius. [Limit: >= 0]
  61986. */
  61987. radius: number;
  61988. /**
  61989. * Agent height. [Limit: > 0]
  61990. */
  61991. height: number;
  61992. /**
  61993. * Maximum allowed acceleration. [Limit: >= 0]
  61994. */
  61995. maxAcceleration: number;
  61996. /**
  61997. * Maximum allowed speed. [Limit: >= 0]
  61998. */
  61999. maxSpeed: number;
  62000. /**
  62001. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  62002. */
  62003. collisionQueryRange: number;
  62004. /**
  62005. * The path visibility optimization range. [Limit: > 0]
  62006. */
  62007. pathOptimizationRange: number;
  62008. /**
  62009. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  62010. */
  62011. separationWeight: number;
  62012. }
  62013. /**
  62014. * Configures the navigation mesh creation
  62015. */
  62016. export interface INavMeshParameters {
  62017. /**
  62018. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  62019. */
  62020. cs: number;
  62021. /**
  62022. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  62023. */
  62024. ch: number;
  62025. /**
  62026. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  62027. */
  62028. walkableSlopeAngle: number;
  62029. /**
  62030. * Minimum floor to 'ceiling' height that will still allow the floor area to
  62031. * be considered walkable. [Limit: >= 3] [Units: vx]
  62032. */
  62033. walkableHeight: number;
  62034. /**
  62035. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  62036. */
  62037. walkableClimb: number;
  62038. /**
  62039. * The distance to erode/shrink the walkable area of the heightfield away from
  62040. * obstructions. [Limit: >=0] [Units: vx]
  62041. */
  62042. walkableRadius: number;
  62043. /**
  62044. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  62045. */
  62046. maxEdgeLen: number;
  62047. /**
  62048. * The maximum distance a simplfied contour's border edges should deviate
  62049. * the original raw contour. [Limit: >=0] [Units: vx]
  62050. */
  62051. maxSimplificationError: number;
  62052. /**
  62053. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  62054. */
  62055. minRegionArea: number;
  62056. /**
  62057. * Any regions with a span count smaller than this value will, if possible,
  62058. * be merged with larger regions. [Limit: >=0] [Units: vx]
  62059. */
  62060. mergeRegionArea: number;
  62061. /**
  62062. * The maximum number of vertices allowed for polygons generated during the
  62063. * contour to polygon conversion process. [Limit: >= 3]
  62064. */
  62065. maxVertsPerPoly: number;
  62066. /**
  62067. * Sets the sampling distance to use when generating the detail mesh.
  62068. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  62069. */
  62070. detailSampleDist: number;
  62071. /**
  62072. * The maximum distance the detail mesh surface should deviate from heightfield
  62073. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  62074. */
  62075. detailSampleMaxError: number;
  62076. }
  62077. }
  62078. declare module BABYLON {
  62079. /**
  62080. * RecastJS navigation plugin
  62081. */
  62082. export class RecastJSPlugin implements INavigationEnginePlugin {
  62083. /**
  62084. * Reference to the Recast library
  62085. */
  62086. bjsRECAST: any;
  62087. /**
  62088. * plugin name
  62089. */
  62090. name: string;
  62091. /**
  62092. * the first navmesh created. We might extend this to support multiple navmeshes
  62093. */
  62094. navMesh: any;
  62095. /**
  62096. * Initializes the recastJS plugin
  62097. * @param recastInjection can be used to inject your own recast reference
  62098. */
  62099. constructor(recastInjection?: any);
  62100. /**
  62101. * Creates a navigation mesh
  62102. * @param meshes array of all the geometry used to compute the navigatio mesh
  62103. * @param parameters bunch of parameters used to filter geometry
  62104. */
  62105. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  62106. /**
  62107. * Create a navigation mesh debug mesh
  62108. * @param scene is where the mesh will be added
  62109. * @returns debug display mesh
  62110. */
  62111. createDebugNavMesh(scene: Scene): Mesh;
  62112. /**
  62113. * Get a navigation mesh constrained position, closest to the parameter position
  62114. * @param position world position
  62115. * @returns the closest point to position constrained by the navigation mesh
  62116. */
  62117. getClosestPoint(position: Vector3): Vector3;
  62118. /**
  62119. * Get a navigation mesh constrained position, within a particular radius
  62120. * @param position world position
  62121. * @param maxRadius the maximum distance to the constrained world position
  62122. * @returns the closest point to position constrained by the navigation mesh
  62123. */
  62124. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  62125. /**
  62126. * Compute the final position from a segment made of destination-position
  62127. * @param position world position
  62128. * @param destination world position
  62129. * @returns the resulting point along the navmesh
  62130. */
  62131. moveAlong(position: Vector3, destination: Vector3): Vector3;
  62132. /**
  62133. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  62134. * @param start world position
  62135. * @param end world position
  62136. * @returns array containing world position composing the path
  62137. */
  62138. computePath(start: Vector3, end: Vector3): Vector3[];
  62139. /**
  62140. * Create a new Crowd so you can add agents
  62141. * @param maxAgents the maximum agent count in the crowd
  62142. * @param maxAgentRadius the maximum radius an agent can have
  62143. * @param scene to attach the crowd to
  62144. * @returns the crowd you can add agents to
  62145. */
  62146. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  62147. /**
  62148. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  62149. * The queries will try to find a solution within those bounds
  62150. * default is (1,1,1)
  62151. * @param extent x,y,z value that define the extent around the queries point of reference
  62152. */
  62153. setDefaultQueryExtent(extent: Vector3): void;
  62154. /**
  62155. * Get the Bounding box extent specified by setDefaultQueryExtent
  62156. * @returns the box extent values
  62157. */
  62158. getDefaultQueryExtent(): Vector3;
  62159. /**
  62160. * Disposes
  62161. */
  62162. dispose(): void;
  62163. /**
  62164. * If this plugin is supported
  62165. * @returns true if plugin is supported
  62166. */
  62167. isSupported(): boolean;
  62168. }
  62169. /**
  62170. * Recast detour crowd implementation
  62171. */
  62172. export class RecastJSCrowd implements ICrowd {
  62173. /**
  62174. * Recast/detour plugin
  62175. */
  62176. bjsRECASTPlugin: RecastJSPlugin;
  62177. /**
  62178. * Link to the detour crowd
  62179. */
  62180. recastCrowd: any;
  62181. /**
  62182. * One transform per agent
  62183. */
  62184. transforms: TransformNode[];
  62185. /**
  62186. * All agents created
  62187. */
  62188. agents: number[];
  62189. /**
  62190. * Link to the scene is kept to unregister the crowd from the scene
  62191. */
  62192. private _scene;
  62193. /**
  62194. * Observer for crowd updates
  62195. */
  62196. private _onBeforeAnimationsObserver;
  62197. /**
  62198. * Constructor
  62199. * @param plugin recastJS plugin
  62200. * @param maxAgents the maximum agent count in the crowd
  62201. * @param maxAgentRadius the maximum radius an agent can have
  62202. * @param scene to attach the crowd to
  62203. * @returns the crowd you can add agents to
  62204. */
  62205. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  62206. /**
  62207. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  62208. * You can attach anything to that node. The node position is updated in the scene update tick.
  62209. * @param pos world position that will be constrained by the navigation mesh
  62210. * @param parameters agent parameters
  62211. * @param transform hooked to the agent that will be update by the scene
  62212. * @returns agent index
  62213. */
  62214. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  62215. /**
  62216. * Returns the agent position in world space
  62217. * @param index agent index returned by addAgent
  62218. * @returns world space position
  62219. */
  62220. getAgentPosition(index: number): Vector3;
  62221. /**
  62222. * Returns the agent velocity in world space
  62223. * @param index agent index returned by addAgent
  62224. * @returns world space velocity
  62225. */
  62226. getAgentVelocity(index: number): Vector3;
  62227. /**
  62228. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  62229. * @param index agent index returned by addAgent
  62230. * @param destination targeted world position
  62231. */
  62232. agentGoto(index: number, destination: Vector3): void;
  62233. /**
  62234. * Teleport the agent to a new position
  62235. * @param index agent index returned by addAgent
  62236. * @param destination targeted world position
  62237. */
  62238. agentTeleport(index: number, destination: Vector3): void;
  62239. /**
  62240. * Update agent parameters
  62241. * @param index agent index returned by addAgent
  62242. * @param parameters agent parameters
  62243. */
  62244. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  62245. /**
  62246. * remove a particular agent previously created
  62247. * @param index agent index returned by addAgent
  62248. */
  62249. removeAgent(index: number): void;
  62250. /**
  62251. * get the list of all agents attached to this crowd
  62252. * @returns list of agent indices
  62253. */
  62254. getAgents(): number[];
  62255. /**
  62256. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  62257. * @param deltaTime in seconds
  62258. */
  62259. update(deltaTime: number): void;
  62260. /**
  62261. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  62262. * The queries will try to find a solution within those bounds
  62263. * default is (1,1,1)
  62264. * @param extent x,y,z value that define the extent around the queries point of reference
  62265. */
  62266. setDefaultQueryExtent(extent: Vector3): void;
  62267. /**
  62268. * Get the Bounding box extent specified by setDefaultQueryExtent
  62269. * @returns the box extent values
  62270. */
  62271. getDefaultQueryExtent(): Vector3;
  62272. /**
  62273. * Release all resources
  62274. */
  62275. dispose(): void;
  62276. }
  62277. }
  62278. declare module BABYLON {
  62279. /**
  62280. * Class used to enable access to IndexedDB
  62281. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  62282. */
  62283. export class Database implements IOfflineProvider {
  62284. private _callbackManifestChecked;
  62285. private _currentSceneUrl;
  62286. private _db;
  62287. private _enableSceneOffline;
  62288. private _enableTexturesOffline;
  62289. private _manifestVersionFound;
  62290. private _mustUpdateRessources;
  62291. private _hasReachedQuota;
  62292. private _isSupported;
  62293. private _idbFactory;
  62294. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  62295. private static IsUASupportingBlobStorage;
  62296. /**
  62297. * Gets a boolean indicating if Database storate is enabled (off by default)
  62298. */
  62299. static IDBStorageEnabled: boolean;
  62300. /**
  62301. * Gets a boolean indicating if scene must be saved in the database
  62302. */
  62303. get enableSceneOffline(): boolean;
  62304. /**
  62305. * Gets a boolean indicating if textures must be saved in the database
  62306. */
  62307. get enableTexturesOffline(): boolean;
  62308. /**
  62309. * Creates a new Database
  62310. * @param urlToScene defines the url to load the scene
  62311. * @param callbackManifestChecked defines the callback to use when manifest is checked
  62312. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  62313. */
  62314. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  62315. private static _ParseURL;
  62316. private static _ReturnFullUrlLocation;
  62317. private _checkManifestFile;
  62318. /**
  62319. * Open the database and make it available
  62320. * @param successCallback defines the callback to call on success
  62321. * @param errorCallback defines the callback to call on error
  62322. */
  62323. open(successCallback: () => void, errorCallback: () => void): void;
  62324. /**
  62325. * Loads an image from the database
  62326. * @param url defines the url to load from
  62327. * @param image defines the target DOM image
  62328. */
  62329. loadImage(url: string, image: HTMLImageElement): void;
  62330. private _loadImageFromDBAsync;
  62331. private _saveImageIntoDBAsync;
  62332. private _checkVersionFromDB;
  62333. private _loadVersionFromDBAsync;
  62334. private _saveVersionIntoDBAsync;
  62335. /**
  62336. * Loads a file from database
  62337. * @param url defines the URL to load from
  62338. * @param sceneLoaded defines a callback to call on success
  62339. * @param progressCallBack defines a callback to call when progress changed
  62340. * @param errorCallback defines a callback to call on error
  62341. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  62342. */
  62343. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  62344. private _loadFileAsync;
  62345. private _saveFileAsync;
  62346. /**
  62347. * Validates if xhr data is correct
  62348. * @param xhr defines the request to validate
  62349. * @param dataType defines the expected data type
  62350. * @returns true if data is correct
  62351. */
  62352. private static _ValidateXHRData;
  62353. }
  62354. }
  62355. declare module BABYLON {
  62356. /** @hidden */
  62357. export var gpuUpdateParticlesPixelShader: {
  62358. name: string;
  62359. shader: string;
  62360. };
  62361. }
  62362. declare module BABYLON {
  62363. /** @hidden */
  62364. export var gpuUpdateParticlesVertexShader: {
  62365. name: string;
  62366. shader: string;
  62367. };
  62368. }
  62369. declare module BABYLON {
  62370. /** @hidden */
  62371. export var clipPlaneFragmentDeclaration2: {
  62372. name: string;
  62373. shader: string;
  62374. };
  62375. }
  62376. declare module BABYLON {
  62377. /** @hidden */
  62378. export var gpuRenderParticlesPixelShader: {
  62379. name: string;
  62380. shader: string;
  62381. };
  62382. }
  62383. declare module BABYLON {
  62384. /** @hidden */
  62385. export var clipPlaneVertexDeclaration2: {
  62386. name: string;
  62387. shader: string;
  62388. };
  62389. }
  62390. declare module BABYLON {
  62391. /** @hidden */
  62392. export var gpuRenderParticlesVertexShader: {
  62393. name: string;
  62394. shader: string;
  62395. };
  62396. }
  62397. declare module BABYLON {
  62398. /**
  62399. * This represents a GPU particle system in Babylon
  62400. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  62401. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  62402. */
  62403. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  62404. /**
  62405. * The layer mask we are rendering the particles through.
  62406. */
  62407. layerMask: number;
  62408. private _capacity;
  62409. private _activeCount;
  62410. private _currentActiveCount;
  62411. private _accumulatedCount;
  62412. private _renderEffect;
  62413. private _updateEffect;
  62414. private _buffer0;
  62415. private _buffer1;
  62416. private _spriteBuffer;
  62417. private _updateVAO;
  62418. private _renderVAO;
  62419. private _targetIndex;
  62420. private _sourceBuffer;
  62421. private _targetBuffer;
  62422. private _engine;
  62423. private _currentRenderId;
  62424. private _started;
  62425. private _stopped;
  62426. private _timeDelta;
  62427. private _randomTexture;
  62428. private _randomTexture2;
  62429. private _attributesStrideSize;
  62430. private _updateEffectOptions;
  62431. private _randomTextureSize;
  62432. private _actualFrame;
  62433. private readonly _rawTextureWidth;
  62434. /**
  62435. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  62436. */
  62437. static get IsSupported(): boolean;
  62438. /**
  62439. * An event triggered when the system is disposed.
  62440. */
  62441. onDisposeObservable: Observable<GPUParticleSystem>;
  62442. /**
  62443. * Gets the maximum number of particles active at the same time.
  62444. * @returns The max number of active particles.
  62445. */
  62446. getCapacity(): number;
  62447. /**
  62448. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  62449. * to override the particles.
  62450. */
  62451. forceDepthWrite: boolean;
  62452. /**
  62453. * Gets or set the number of active particles
  62454. */
  62455. get activeParticleCount(): number;
  62456. set activeParticleCount(value: number);
  62457. private _preWarmDone;
  62458. /**
  62459. * Is this system ready to be used/rendered
  62460. * @return true if the system is ready
  62461. */
  62462. isReady(): boolean;
  62463. /**
  62464. * Gets if the system has been started. (Note: this will still be true after stop is called)
  62465. * @returns True if it has been started, otherwise false.
  62466. */
  62467. isStarted(): boolean;
  62468. /**
  62469. * Starts the particle system and begins to emit
  62470. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  62471. */
  62472. start(delay?: number): void;
  62473. /**
  62474. * Stops the particle system.
  62475. */
  62476. stop(): void;
  62477. /**
  62478. * Remove all active particles
  62479. */
  62480. reset(): void;
  62481. /**
  62482. * Returns the string "GPUParticleSystem"
  62483. * @returns a string containing the class name
  62484. */
  62485. getClassName(): string;
  62486. private _colorGradientsTexture;
  62487. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  62488. /**
  62489. * Adds a new color gradient
  62490. * @param gradient defines the gradient to use (between 0 and 1)
  62491. * @param color1 defines the color to affect to the specified gradient
  62492. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  62493. * @returns the current particle system
  62494. */
  62495. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  62496. /**
  62497. * Remove a specific color gradient
  62498. * @param gradient defines the gradient to remove
  62499. * @returns the current particle system
  62500. */
  62501. removeColorGradient(gradient: number): GPUParticleSystem;
  62502. private _angularSpeedGradientsTexture;
  62503. private _sizeGradientsTexture;
  62504. private _velocityGradientsTexture;
  62505. private _limitVelocityGradientsTexture;
  62506. private _dragGradientsTexture;
  62507. private _addFactorGradient;
  62508. /**
  62509. * Adds a new size gradient
  62510. * @param gradient defines the gradient to use (between 0 and 1)
  62511. * @param factor defines the size factor to affect to the specified gradient
  62512. * @returns the current particle system
  62513. */
  62514. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  62515. /**
  62516. * Remove a specific size gradient
  62517. * @param gradient defines the gradient to remove
  62518. * @returns the current particle system
  62519. */
  62520. removeSizeGradient(gradient: number): GPUParticleSystem;
  62521. /**
  62522. * Adds a new angular speed gradient
  62523. * @param gradient defines the gradient to use (between 0 and 1)
  62524. * @param factor defines the angular speed to affect to the specified gradient
  62525. * @returns the current particle system
  62526. */
  62527. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  62528. /**
  62529. * Remove a specific angular speed gradient
  62530. * @param gradient defines the gradient to remove
  62531. * @returns the current particle system
  62532. */
  62533. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  62534. /**
  62535. * Adds a new velocity gradient
  62536. * @param gradient defines the gradient to use (between 0 and 1)
  62537. * @param factor defines the velocity to affect to the specified gradient
  62538. * @returns the current particle system
  62539. */
  62540. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  62541. /**
  62542. * Remove a specific velocity gradient
  62543. * @param gradient defines the gradient to remove
  62544. * @returns the current particle system
  62545. */
  62546. removeVelocityGradient(gradient: number): GPUParticleSystem;
  62547. /**
  62548. * Adds a new limit velocity gradient
  62549. * @param gradient defines the gradient to use (between 0 and 1)
  62550. * @param factor defines the limit velocity value to affect to the specified gradient
  62551. * @returns the current particle system
  62552. */
  62553. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  62554. /**
  62555. * Remove a specific limit velocity gradient
  62556. * @param gradient defines the gradient to remove
  62557. * @returns the current particle system
  62558. */
  62559. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  62560. /**
  62561. * Adds a new drag gradient
  62562. * @param gradient defines the gradient to use (between 0 and 1)
  62563. * @param factor defines the drag value to affect to the specified gradient
  62564. * @returns the current particle system
  62565. */
  62566. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  62567. /**
  62568. * Remove a specific drag gradient
  62569. * @param gradient defines the gradient to remove
  62570. * @returns the current particle system
  62571. */
  62572. removeDragGradient(gradient: number): GPUParticleSystem;
  62573. /**
  62574. * Not supported by GPUParticleSystem
  62575. * @param gradient defines the gradient to use (between 0 and 1)
  62576. * @param factor defines the emit rate value to affect to the specified gradient
  62577. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  62578. * @returns the current particle system
  62579. */
  62580. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  62581. /**
  62582. * Not supported by GPUParticleSystem
  62583. * @param gradient defines the gradient to remove
  62584. * @returns the current particle system
  62585. */
  62586. removeEmitRateGradient(gradient: number): IParticleSystem;
  62587. /**
  62588. * Not supported by GPUParticleSystem
  62589. * @param gradient defines the gradient to use (between 0 and 1)
  62590. * @param factor defines the start size value to affect to the specified gradient
  62591. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  62592. * @returns the current particle system
  62593. */
  62594. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  62595. /**
  62596. * Not supported by GPUParticleSystem
  62597. * @param gradient defines the gradient to remove
  62598. * @returns the current particle system
  62599. */
  62600. removeStartSizeGradient(gradient: number): IParticleSystem;
  62601. /**
  62602. * Not supported by GPUParticleSystem
  62603. * @param gradient defines the gradient to use (between 0 and 1)
  62604. * @param min defines the color remap minimal range
  62605. * @param max defines the color remap maximal range
  62606. * @returns the current particle system
  62607. */
  62608. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  62609. /**
  62610. * Not supported by GPUParticleSystem
  62611. * @param gradient defines the gradient to remove
  62612. * @returns the current particle system
  62613. */
  62614. removeColorRemapGradient(): IParticleSystem;
  62615. /**
  62616. * Not supported by GPUParticleSystem
  62617. * @param gradient defines the gradient to use (between 0 and 1)
  62618. * @param min defines the alpha remap minimal range
  62619. * @param max defines the alpha remap maximal range
  62620. * @returns the current particle system
  62621. */
  62622. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  62623. /**
  62624. * Not supported by GPUParticleSystem
  62625. * @param gradient defines the gradient to remove
  62626. * @returns the current particle system
  62627. */
  62628. removeAlphaRemapGradient(): IParticleSystem;
  62629. /**
  62630. * Not supported by GPUParticleSystem
  62631. * @param gradient defines the gradient to use (between 0 and 1)
  62632. * @param color defines the color to affect to the specified gradient
  62633. * @returns the current particle system
  62634. */
  62635. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  62636. /**
  62637. * Not supported by GPUParticleSystem
  62638. * @param gradient defines the gradient to remove
  62639. * @returns the current particle system
  62640. */
  62641. removeRampGradient(): IParticleSystem;
  62642. /**
  62643. * Not supported by GPUParticleSystem
  62644. * @returns the list of ramp gradients
  62645. */
  62646. getRampGradients(): Nullable<Array<Color3Gradient>>;
  62647. /**
  62648. * Not supported by GPUParticleSystem
  62649. * Gets or sets a boolean indicating that ramp gradients must be used
  62650. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  62651. */
  62652. get useRampGradients(): boolean;
  62653. set useRampGradients(value: boolean);
  62654. /**
  62655. * Not supported by GPUParticleSystem
  62656. * @param gradient defines the gradient to use (between 0 and 1)
  62657. * @param factor defines the life time factor to affect to the specified gradient
  62658. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  62659. * @returns the current particle system
  62660. */
  62661. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  62662. /**
  62663. * Not supported by GPUParticleSystem
  62664. * @param gradient defines the gradient to remove
  62665. * @returns the current particle system
  62666. */
  62667. removeLifeTimeGradient(gradient: number): IParticleSystem;
  62668. /**
  62669. * Instantiates a GPU particle system.
  62670. * 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.
  62671. * @param name The name of the particle system
  62672. * @param options The options used to create the system
  62673. * @param scene The scene the particle system belongs to
  62674. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  62675. */
  62676. constructor(name: string, options: Partial<{
  62677. capacity: number;
  62678. randomTextureSize: number;
  62679. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  62680. protected _reset(): void;
  62681. private _createUpdateVAO;
  62682. private _createRenderVAO;
  62683. private _initialize;
  62684. /** @hidden */
  62685. _recreateUpdateEffect(): void;
  62686. /** @hidden */
  62687. _recreateRenderEffect(): void;
  62688. /**
  62689. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  62690. * @param preWarm defines if we are in the pre-warmimg phase
  62691. */
  62692. animate(preWarm?: boolean): void;
  62693. private _createFactorGradientTexture;
  62694. private _createSizeGradientTexture;
  62695. private _createAngularSpeedGradientTexture;
  62696. private _createVelocityGradientTexture;
  62697. private _createLimitVelocityGradientTexture;
  62698. private _createDragGradientTexture;
  62699. private _createColorGradientTexture;
  62700. /**
  62701. * Renders the particle system in its current state
  62702. * @param preWarm defines if the system should only update the particles but not render them
  62703. * @returns the current number of particles
  62704. */
  62705. render(preWarm?: boolean): number;
  62706. /**
  62707. * Rebuilds the particle system
  62708. */
  62709. rebuild(): void;
  62710. private _releaseBuffers;
  62711. private _releaseVAOs;
  62712. /**
  62713. * Disposes the particle system and free the associated resources
  62714. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  62715. */
  62716. dispose(disposeTexture?: boolean): void;
  62717. /**
  62718. * Clones the particle system.
  62719. * @param name The name of the cloned object
  62720. * @param newEmitter The new emitter to use
  62721. * @returns the cloned particle system
  62722. */
  62723. clone(name: string, newEmitter: any): GPUParticleSystem;
  62724. /**
  62725. * Serializes the particle system to a JSON object.
  62726. * @returns the JSON object
  62727. */
  62728. serialize(): any;
  62729. /**
  62730. * Parses a JSON object to create a GPU particle system.
  62731. * @param parsedParticleSystem The JSON object to parse
  62732. * @param scene The scene to create the particle system in
  62733. * @param rootUrl The root url to use to load external dependencies like texture
  62734. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  62735. * @returns the parsed GPU particle system
  62736. */
  62737. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  62738. }
  62739. }
  62740. declare module BABYLON {
  62741. /**
  62742. * Represents a set of particle systems working together to create a specific effect
  62743. */
  62744. export class ParticleSystemSet implements IDisposable {
  62745. /**
  62746. * Gets or sets base Assets URL
  62747. */
  62748. static BaseAssetsUrl: string;
  62749. private _emitterCreationOptions;
  62750. private _emitterNode;
  62751. /**
  62752. * Gets the particle system list
  62753. */
  62754. systems: IParticleSystem[];
  62755. /**
  62756. * Gets the emitter node used with this set
  62757. */
  62758. get emitterNode(): Nullable<TransformNode>;
  62759. /**
  62760. * Creates a new emitter mesh as a sphere
  62761. * @param options defines the options used to create the sphere
  62762. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  62763. * @param scene defines the hosting scene
  62764. */
  62765. setEmitterAsSphere(options: {
  62766. diameter: number;
  62767. segments: number;
  62768. color: Color3;
  62769. }, renderingGroupId: number, scene: Scene): void;
  62770. /**
  62771. * Starts all particle systems of the set
  62772. * @param emitter defines an optional mesh to use as emitter for the particle systems
  62773. */
  62774. start(emitter?: AbstractMesh): void;
  62775. /**
  62776. * Release all associated resources
  62777. */
  62778. dispose(): void;
  62779. /**
  62780. * Serialize the set into a JSON compatible object
  62781. * @returns a JSON compatible representation of the set
  62782. */
  62783. serialize(): any;
  62784. /**
  62785. * Parse a new ParticleSystemSet from a serialized source
  62786. * @param data defines a JSON compatible representation of the set
  62787. * @param scene defines the hosting scene
  62788. * @param gpu defines if we want GPU particles or CPU particles
  62789. * @returns a new ParticleSystemSet
  62790. */
  62791. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  62792. }
  62793. }
  62794. declare module BABYLON {
  62795. /**
  62796. * This class is made for on one-liner static method to help creating particle system set.
  62797. */
  62798. export class ParticleHelper {
  62799. /**
  62800. * Gets or sets base Assets URL
  62801. */
  62802. static BaseAssetsUrl: string;
  62803. /**
  62804. * Create a default particle system that you can tweak
  62805. * @param emitter defines the emitter to use
  62806. * @param capacity defines the system capacity (default is 500 particles)
  62807. * @param scene defines the hosting scene
  62808. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  62809. * @returns the new Particle system
  62810. */
  62811. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  62812. /**
  62813. * This is the main static method (one-liner) of this helper to create different particle systems
  62814. * @param type This string represents the type to the particle system to create
  62815. * @param scene The scene where the particle system should live
  62816. * @param gpu If the system will use gpu
  62817. * @returns the ParticleSystemSet created
  62818. */
  62819. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  62820. /**
  62821. * Static function used to export a particle system to a ParticleSystemSet variable.
  62822. * Please note that the emitter shape is not exported
  62823. * @param systems defines the particle systems to export
  62824. * @returns the created particle system set
  62825. */
  62826. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  62827. }
  62828. }
  62829. declare module BABYLON {
  62830. interface Engine {
  62831. /**
  62832. * Create an effect to use with particle systems.
  62833. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  62834. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  62835. * @param uniformsNames defines a list of attribute names
  62836. * @param samplers defines an array of string used to represent textures
  62837. * @param defines defines the string containing the defines to use to compile the shaders
  62838. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  62839. * @param onCompiled defines a function to call when the effect creation is successful
  62840. * @param onError defines a function to call when the effect creation has failed
  62841. * @returns the new Effect
  62842. */
  62843. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  62844. }
  62845. interface Mesh {
  62846. /**
  62847. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  62848. * @returns an array of IParticleSystem
  62849. */
  62850. getEmittedParticleSystems(): IParticleSystem[];
  62851. /**
  62852. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  62853. * @returns an array of IParticleSystem
  62854. */
  62855. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  62856. }
  62857. /**
  62858. * @hidden
  62859. */
  62860. export var _IDoNeedToBeInTheBuild: number;
  62861. }
  62862. declare module BABYLON {
  62863. /** Defines the 4 color options */
  62864. export enum PointColor {
  62865. /** color value */
  62866. Color = 2,
  62867. /** uv value */
  62868. UV = 1,
  62869. /** random value */
  62870. Random = 0,
  62871. /** stated value */
  62872. Stated = 3
  62873. }
  62874. /**
  62875. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  62876. * 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.
  62877. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  62878. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  62879. *
  62880. * Full documentation here : TO BE ENTERED
  62881. */
  62882. export class PointsCloudSystem implements IDisposable {
  62883. /**
  62884. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  62885. * Example : var p = SPS.particles[i];
  62886. */
  62887. particles: CloudPoint[];
  62888. /**
  62889. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  62890. */
  62891. nbParticles: number;
  62892. /**
  62893. * This a counter for your own usage. It's not set by any SPS functions.
  62894. */
  62895. counter: number;
  62896. /**
  62897. * The PCS name. This name is also given to the underlying mesh.
  62898. */
  62899. name: string;
  62900. /**
  62901. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  62902. */
  62903. mesh: Mesh;
  62904. /**
  62905. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  62906. * Please read :
  62907. */
  62908. vars: any;
  62909. /**
  62910. * @hidden
  62911. */
  62912. _size: number;
  62913. private _scene;
  62914. private _promises;
  62915. private _positions;
  62916. private _indices;
  62917. private _normals;
  62918. private _colors;
  62919. private _uvs;
  62920. private _indices32;
  62921. private _positions32;
  62922. private _colors32;
  62923. private _uvs32;
  62924. private _updatable;
  62925. private _isVisibilityBoxLocked;
  62926. private _alwaysVisible;
  62927. private _groups;
  62928. private _groupCounter;
  62929. private _computeParticleColor;
  62930. private _computeParticleTexture;
  62931. private _computeParticleRotation;
  62932. private _computeBoundingBox;
  62933. private _isReady;
  62934. /**
  62935. * Creates a PCS (Points Cloud System) object
  62936. * @param name (String) is the PCS name, this will be the underlying mesh name
  62937. * @param pointSize (number) is the size for each point
  62938. * @param scene (Scene) is the scene in which the PCS is added
  62939. * @param options defines the options of the PCS e.g.
  62940. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  62941. */
  62942. constructor(name: string, pointSize: number, scene: Scene, options?: {
  62943. updatable?: boolean;
  62944. });
  62945. /**
  62946. * Builds the PCS underlying mesh. Returns a standard Mesh.
  62947. * If no points were added to the PCS, the returned mesh is just a single point.
  62948. * @returns a promise for the created mesh
  62949. */
  62950. buildMeshAsync(): Promise<Mesh>;
  62951. /**
  62952. * @hidden
  62953. */
  62954. private _buildMesh;
  62955. private _addParticle;
  62956. private _randomUnitVector;
  62957. private _getColorIndicesForCoord;
  62958. private _setPointsColorOrUV;
  62959. private _colorFromTexture;
  62960. private _calculateDensity;
  62961. /**
  62962. * Adds points to the PCS in random positions within a unit sphere
  62963. * @param nb (positive integer) the number of particles to be created from this model
  62964. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  62965. * @returns the number of groups in the system
  62966. */
  62967. addPoints(nb: number, pointFunction?: any): number;
  62968. /**
  62969. * Adds points to the PCS from the surface of the model shape
  62970. * @param mesh is any Mesh object that will be used as a surface model for the points
  62971. * @param nb (positive integer) the number of particles to be created from this model
  62972. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  62973. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  62974. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  62975. * @returns the number of groups in the system
  62976. */
  62977. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  62978. /**
  62979. * Adds points to the PCS inside the model shape
  62980. * @param mesh is any Mesh object that will be used as a surface model for the points
  62981. * @param nb (positive integer) the number of particles to be created from this model
  62982. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  62983. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  62984. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  62985. * @returns the number of groups in the system
  62986. */
  62987. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  62988. /**
  62989. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  62990. * This method calls `updateParticle()` for each particle of the SPS.
  62991. * For an animated SPS, it is usually called within the render loop.
  62992. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  62993. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  62994. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  62995. * @returns the PCS.
  62996. */
  62997. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  62998. /**
  62999. * Disposes the PCS.
  63000. */
  63001. dispose(): void;
  63002. /**
  63003. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  63004. * doc :
  63005. * @returns the PCS.
  63006. */
  63007. refreshVisibleSize(): PointsCloudSystem;
  63008. /**
  63009. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  63010. * @param size the size (float) of the visibility box
  63011. * note : this doesn't lock the PCS mesh bounding box.
  63012. * doc :
  63013. */
  63014. setVisibilityBox(size: number): void;
  63015. /**
  63016. * Gets whether the PCS is always visible or not
  63017. * doc :
  63018. */
  63019. get isAlwaysVisible(): boolean;
  63020. /**
  63021. * Sets the PCS as always visible or not
  63022. * doc :
  63023. */
  63024. set isAlwaysVisible(val: boolean);
  63025. /**
  63026. * Tells to `setParticles()` to compute the particle rotations or not
  63027. * Default value : false. The PCS is faster when it's set to false
  63028. * Note : particle rotations are only applied to parent particles
  63029. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  63030. */
  63031. set computeParticleRotation(val: boolean);
  63032. /**
  63033. * Tells to `setParticles()` to compute the particle colors or not.
  63034. * Default value : true. The PCS is faster when it's set to false.
  63035. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  63036. */
  63037. set computeParticleColor(val: boolean);
  63038. set computeParticleTexture(val: boolean);
  63039. /**
  63040. * Gets if `setParticles()` computes the particle colors or not.
  63041. * Default value : false. The PCS is faster when it's set to false.
  63042. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  63043. */
  63044. get computeParticleColor(): boolean;
  63045. /**
  63046. * Gets if `setParticles()` computes the particle textures or not.
  63047. * Default value : false. The PCS is faster when it's set to false.
  63048. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  63049. */
  63050. get computeParticleTexture(): boolean;
  63051. /**
  63052. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  63053. */
  63054. set computeBoundingBox(val: boolean);
  63055. /**
  63056. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  63057. */
  63058. get computeBoundingBox(): boolean;
  63059. /**
  63060. * This function does nothing. It may be overwritten to set all the particle first values.
  63061. * The PCS doesn't call this function, you may have to call it by your own.
  63062. * doc :
  63063. */
  63064. initParticles(): void;
  63065. /**
  63066. * This function does nothing. It may be overwritten to recycle a particle
  63067. * The PCS doesn't call this function, you can to call it
  63068. * doc :
  63069. * @param particle The particle to recycle
  63070. * @returns the recycled particle
  63071. */
  63072. recycleParticle(particle: CloudPoint): CloudPoint;
  63073. /**
  63074. * Updates a particle : this function should be overwritten by the user.
  63075. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  63076. * doc :
  63077. * @example : just set a particle position or velocity and recycle conditions
  63078. * @param particle The particle to update
  63079. * @returns the updated particle
  63080. */
  63081. updateParticle(particle: CloudPoint): CloudPoint;
  63082. /**
  63083. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  63084. * This does nothing and may be overwritten by the user.
  63085. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  63086. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  63087. * @param update the boolean update value actually passed to setParticles()
  63088. */
  63089. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  63090. /**
  63091. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  63092. * This will be passed three parameters.
  63093. * This does nothing and may be overwritten by the user.
  63094. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  63095. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  63096. * @param update the boolean update value actually passed to setParticles()
  63097. */
  63098. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  63099. }
  63100. }
  63101. declare module BABYLON {
  63102. /**
  63103. * Represents one particle of a points cloud system.
  63104. */
  63105. export class CloudPoint {
  63106. /**
  63107. * particle global index
  63108. */
  63109. idx: number;
  63110. /**
  63111. * The color of the particle
  63112. */
  63113. color: Nullable<Color4>;
  63114. /**
  63115. * The world space position of the particle.
  63116. */
  63117. position: Vector3;
  63118. /**
  63119. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  63120. */
  63121. rotation: Vector3;
  63122. /**
  63123. * The world space rotation quaternion of the particle.
  63124. */
  63125. rotationQuaternion: Nullable<Quaternion>;
  63126. /**
  63127. * The uv of the particle.
  63128. */
  63129. uv: Nullable<Vector2>;
  63130. /**
  63131. * The current speed of the particle.
  63132. */
  63133. velocity: Vector3;
  63134. /**
  63135. * The pivot point in the particle local space.
  63136. */
  63137. pivot: Vector3;
  63138. /**
  63139. * Must the particle be translated from its pivot point in its local space ?
  63140. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  63141. * Default : false
  63142. */
  63143. translateFromPivot: boolean;
  63144. /**
  63145. * Index of this particle in the global "positions" array (Internal use)
  63146. * @hidden
  63147. */
  63148. _pos: number;
  63149. /**
  63150. * @hidden Index of this particle in the global "indices" array (Internal use)
  63151. */
  63152. _ind: number;
  63153. /**
  63154. * Group this particle belongs to
  63155. */
  63156. _group: PointsGroup;
  63157. /**
  63158. * Group id of this particle
  63159. */
  63160. groupId: number;
  63161. /**
  63162. * Index of the particle in its group id (Internal use)
  63163. */
  63164. idxInGroup: number;
  63165. /**
  63166. * @hidden Particle BoundingInfo object (Internal use)
  63167. */
  63168. _boundingInfo: BoundingInfo;
  63169. /**
  63170. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  63171. */
  63172. _pcs: PointsCloudSystem;
  63173. /**
  63174. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  63175. */
  63176. _stillInvisible: boolean;
  63177. /**
  63178. * @hidden Last computed particle rotation matrix
  63179. */
  63180. _rotationMatrix: number[];
  63181. /**
  63182. * Parent particle Id, if any.
  63183. * Default null.
  63184. */
  63185. parentId: Nullable<number>;
  63186. /**
  63187. * @hidden Internal global position in the PCS.
  63188. */
  63189. _globalPosition: Vector3;
  63190. /**
  63191. * Creates a Point Cloud object.
  63192. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  63193. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  63194. * @param group (PointsGroup) is the group the particle belongs to
  63195. * @param groupId (integer) is the group identifier in the PCS.
  63196. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  63197. * @param pcs defines the PCS it is associated to
  63198. */
  63199. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  63200. /**
  63201. * get point size
  63202. */
  63203. get size(): Vector3;
  63204. /**
  63205. * Set point size
  63206. */
  63207. set size(scale: Vector3);
  63208. /**
  63209. * Legacy support, changed quaternion to rotationQuaternion
  63210. */
  63211. get quaternion(): Nullable<Quaternion>;
  63212. /**
  63213. * Legacy support, changed quaternion to rotationQuaternion
  63214. */
  63215. set quaternion(q: Nullable<Quaternion>);
  63216. /**
  63217. * Returns a boolean. True if the particle intersects a mesh, else false
  63218. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  63219. * @param target is the object (point or mesh) what the intersection is computed against
  63220. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  63221. * @returns true if it intersects
  63222. */
  63223. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  63224. /**
  63225. * get the rotation matrix of the particle
  63226. * @hidden
  63227. */
  63228. getRotationMatrix(m: Matrix): void;
  63229. }
  63230. /**
  63231. * Represents a group of points in a points cloud system
  63232. * * PCS internal tool, don't use it manually.
  63233. */
  63234. export class PointsGroup {
  63235. /**
  63236. * The group id
  63237. * @hidden
  63238. */
  63239. groupID: number;
  63240. /**
  63241. * image data for group (internal use)
  63242. * @hidden
  63243. */
  63244. _groupImageData: Nullable<ArrayBufferView>;
  63245. /**
  63246. * Image Width (internal use)
  63247. * @hidden
  63248. */
  63249. _groupImgWidth: number;
  63250. /**
  63251. * Image Height (internal use)
  63252. * @hidden
  63253. */
  63254. _groupImgHeight: number;
  63255. /**
  63256. * Custom position function (internal use)
  63257. * @hidden
  63258. */
  63259. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  63260. /**
  63261. * density per facet for surface points
  63262. * @hidden
  63263. */
  63264. _groupDensity: number[];
  63265. /**
  63266. * Only when points are colored by texture carries pointer to texture list array
  63267. * @hidden
  63268. */
  63269. _textureNb: number;
  63270. /**
  63271. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  63272. * PCS internal tool, don't use it manually.
  63273. * @hidden
  63274. */
  63275. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  63276. }
  63277. }
  63278. declare module BABYLON {
  63279. interface Scene {
  63280. /** @hidden (Backing field) */
  63281. _physicsEngine: Nullable<IPhysicsEngine>;
  63282. /** @hidden */
  63283. _physicsTimeAccumulator: number;
  63284. /**
  63285. * Gets the current physics engine
  63286. * @returns a IPhysicsEngine or null if none attached
  63287. */
  63288. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  63289. /**
  63290. * Enables physics to the current scene
  63291. * @param gravity defines the scene's gravity for the physics engine
  63292. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  63293. * @return a boolean indicating if the physics engine was initialized
  63294. */
  63295. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  63296. /**
  63297. * Disables and disposes the physics engine associated with the scene
  63298. */
  63299. disablePhysicsEngine(): void;
  63300. /**
  63301. * Gets a boolean indicating if there is an active physics engine
  63302. * @returns a boolean indicating if there is an active physics engine
  63303. */
  63304. isPhysicsEnabled(): boolean;
  63305. /**
  63306. * Deletes a physics compound impostor
  63307. * @param compound defines the compound to delete
  63308. */
  63309. deleteCompoundImpostor(compound: any): void;
  63310. /**
  63311. * An event triggered when physic simulation is about to be run
  63312. */
  63313. onBeforePhysicsObservable: Observable<Scene>;
  63314. /**
  63315. * An event triggered when physic simulation has been done
  63316. */
  63317. onAfterPhysicsObservable: Observable<Scene>;
  63318. }
  63319. interface AbstractMesh {
  63320. /** @hidden */
  63321. _physicsImpostor: Nullable<PhysicsImpostor>;
  63322. /**
  63323. * Gets or sets impostor used for physic simulation
  63324. * @see http://doc.babylonjs.com/features/physics_engine
  63325. */
  63326. physicsImpostor: Nullable<PhysicsImpostor>;
  63327. /**
  63328. * Gets the current physics impostor
  63329. * @see http://doc.babylonjs.com/features/physics_engine
  63330. * @returns a physics impostor or null
  63331. */
  63332. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  63333. /** Apply a physic impulse to the mesh
  63334. * @param force defines the force to apply
  63335. * @param contactPoint defines where to apply the force
  63336. * @returns the current mesh
  63337. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  63338. */
  63339. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  63340. /**
  63341. * Creates a physic joint between two meshes
  63342. * @param otherMesh defines the other mesh to use
  63343. * @param pivot1 defines the pivot to use on this mesh
  63344. * @param pivot2 defines the pivot to use on the other mesh
  63345. * @param options defines additional options (can be plugin dependent)
  63346. * @returns the current mesh
  63347. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  63348. */
  63349. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  63350. /** @hidden */
  63351. _disposePhysicsObserver: Nullable<Observer<Node>>;
  63352. }
  63353. /**
  63354. * Defines the physics engine scene component responsible to manage a physics engine
  63355. */
  63356. export class PhysicsEngineSceneComponent implements ISceneComponent {
  63357. /**
  63358. * The component name helpful to identify the component in the list of scene components.
  63359. */
  63360. readonly name: string;
  63361. /**
  63362. * The scene the component belongs to.
  63363. */
  63364. scene: Scene;
  63365. /**
  63366. * Creates a new instance of the component for the given scene
  63367. * @param scene Defines the scene to register the component in
  63368. */
  63369. constructor(scene: Scene);
  63370. /**
  63371. * Registers the component in a given scene
  63372. */
  63373. register(): void;
  63374. /**
  63375. * Rebuilds the elements related to this component in case of
  63376. * context lost for instance.
  63377. */
  63378. rebuild(): void;
  63379. /**
  63380. * Disposes the component and the associated ressources
  63381. */
  63382. dispose(): void;
  63383. }
  63384. }
  63385. declare module BABYLON {
  63386. /**
  63387. * A helper for physics simulations
  63388. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63389. */
  63390. export class PhysicsHelper {
  63391. private _scene;
  63392. private _physicsEngine;
  63393. /**
  63394. * Initializes the Physics helper
  63395. * @param scene Babylon.js scene
  63396. */
  63397. constructor(scene: Scene);
  63398. /**
  63399. * Applies a radial explosion impulse
  63400. * @param origin the origin of the explosion
  63401. * @param radiusOrEventOptions the radius or the options of radial explosion
  63402. * @param strength the explosion strength
  63403. * @param falloff possible options: Constant & Linear. Defaults to Constant
  63404. * @returns A physics radial explosion event, or null
  63405. */
  63406. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  63407. /**
  63408. * Applies a radial explosion force
  63409. * @param origin the origin of the explosion
  63410. * @param radiusOrEventOptions the radius or the options of radial explosion
  63411. * @param strength the explosion strength
  63412. * @param falloff possible options: Constant & Linear. Defaults to Constant
  63413. * @returns A physics radial explosion event, or null
  63414. */
  63415. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  63416. /**
  63417. * Creates a gravitational field
  63418. * @param origin the origin of the explosion
  63419. * @param radiusOrEventOptions the radius or the options of radial explosion
  63420. * @param strength the explosion strength
  63421. * @param falloff possible options: Constant & Linear. Defaults to Constant
  63422. * @returns A physics gravitational field event, or null
  63423. */
  63424. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  63425. /**
  63426. * Creates a physics updraft event
  63427. * @param origin the origin of the updraft
  63428. * @param radiusOrEventOptions the radius or the options of the updraft
  63429. * @param strength the strength of the updraft
  63430. * @param height the height of the updraft
  63431. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  63432. * @returns A physics updraft event, or null
  63433. */
  63434. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  63435. /**
  63436. * Creates a physics vortex event
  63437. * @param origin the of the vortex
  63438. * @param radiusOrEventOptions the radius or the options of the vortex
  63439. * @param strength the strength of the vortex
  63440. * @param height the height of the vortex
  63441. * @returns a Physics vortex event, or null
  63442. * A physics vortex event or null
  63443. */
  63444. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  63445. }
  63446. /**
  63447. * Represents a physics radial explosion event
  63448. */
  63449. class PhysicsRadialExplosionEvent {
  63450. private _scene;
  63451. private _options;
  63452. private _sphere;
  63453. private _dataFetched;
  63454. /**
  63455. * Initializes a radial explosioin event
  63456. * @param _scene BabylonJS scene
  63457. * @param _options The options for the vortex event
  63458. */
  63459. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  63460. /**
  63461. * Returns the data related to the radial explosion event (sphere).
  63462. * @returns The radial explosion event data
  63463. */
  63464. getData(): PhysicsRadialExplosionEventData;
  63465. /**
  63466. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  63467. * @param impostor A physics imposter
  63468. * @param origin the origin of the explosion
  63469. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  63470. */
  63471. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  63472. /**
  63473. * Triggers affecterd impostors callbacks
  63474. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  63475. */
  63476. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  63477. /**
  63478. * Disposes the sphere.
  63479. * @param force Specifies if the sphere should be disposed by force
  63480. */
  63481. dispose(force?: boolean): void;
  63482. /*** Helpers ***/
  63483. private _prepareSphere;
  63484. private _intersectsWithSphere;
  63485. }
  63486. /**
  63487. * Represents a gravitational field event
  63488. */
  63489. class PhysicsGravitationalFieldEvent {
  63490. private _physicsHelper;
  63491. private _scene;
  63492. private _origin;
  63493. private _options;
  63494. private _tickCallback;
  63495. private _sphere;
  63496. private _dataFetched;
  63497. /**
  63498. * Initializes the physics gravitational field event
  63499. * @param _physicsHelper A physics helper
  63500. * @param _scene BabylonJS scene
  63501. * @param _origin The origin position of the gravitational field event
  63502. * @param _options The options for the vortex event
  63503. */
  63504. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  63505. /**
  63506. * Returns the data related to the gravitational field event (sphere).
  63507. * @returns A gravitational field event
  63508. */
  63509. getData(): PhysicsGravitationalFieldEventData;
  63510. /**
  63511. * Enables the gravitational field.
  63512. */
  63513. enable(): void;
  63514. /**
  63515. * Disables the gravitational field.
  63516. */
  63517. disable(): void;
  63518. /**
  63519. * Disposes the sphere.
  63520. * @param force The force to dispose from the gravitational field event
  63521. */
  63522. dispose(force?: boolean): void;
  63523. private _tick;
  63524. }
  63525. /**
  63526. * Represents a physics updraft event
  63527. */
  63528. class PhysicsUpdraftEvent {
  63529. private _scene;
  63530. private _origin;
  63531. private _options;
  63532. private _physicsEngine;
  63533. private _originTop;
  63534. private _originDirection;
  63535. private _tickCallback;
  63536. private _cylinder;
  63537. private _cylinderPosition;
  63538. private _dataFetched;
  63539. /**
  63540. * Initializes the physics updraft event
  63541. * @param _scene BabylonJS scene
  63542. * @param _origin The origin position of the updraft
  63543. * @param _options The options for the updraft event
  63544. */
  63545. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  63546. /**
  63547. * Returns the data related to the updraft event (cylinder).
  63548. * @returns A physics updraft event
  63549. */
  63550. getData(): PhysicsUpdraftEventData;
  63551. /**
  63552. * Enables the updraft.
  63553. */
  63554. enable(): void;
  63555. /**
  63556. * Disables the updraft.
  63557. */
  63558. disable(): void;
  63559. /**
  63560. * Disposes the cylinder.
  63561. * @param force Specifies if the updraft should be disposed by force
  63562. */
  63563. dispose(force?: boolean): void;
  63564. private getImpostorHitData;
  63565. private _tick;
  63566. /*** Helpers ***/
  63567. private _prepareCylinder;
  63568. private _intersectsWithCylinder;
  63569. }
  63570. /**
  63571. * Represents a physics vortex event
  63572. */
  63573. class PhysicsVortexEvent {
  63574. private _scene;
  63575. private _origin;
  63576. private _options;
  63577. private _physicsEngine;
  63578. private _originTop;
  63579. private _tickCallback;
  63580. private _cylinder;
  63581. private _cylinderPosition;
  63582. private _dataFetched;
  63583. /**
  63584. * Initializes the physics vortex event
  63585. * @param _scene The BabylonJS scene
  63586. * @param _origin The origin position of the vortex
  63587. * @param _options The options for the vortex event
  63588. */
  63589. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  63590. /**
  63591. * Returns the data related to the vortex event (cylinder).
  63592. * @returns The physics vortex event data
  63593. */
  63594. getData(): PhysicsVortexEventData;
  63595. /**
  63596. * Enables the vortex.
  63597. */
  63598. enable(): void;
  63599. /**
  63600. * Disables the cortex.
  63601. */
  63602. disable(): void;
  63603. /**
  63604. * Disposes the sphere.
  63605. * @param force
  63606. */
  63607. dispose(force?: boolean): void;
  63608. private getImpostorHitData;
  63609. private _tick;
  63610. /*** Helpers ***/
  63611. private _prepareCylinder;
  63612. private _intersectsWithCylinder;
  63613. }
  63614. /**
  63615. * Options fot the radial explosion event
  63616. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63617. */
  63618. export class PhysicsRadialExplosionEventOptions {
  63619. /**
  63620. * The radius of the sphere for the radial explosion.
  63621. */
  63622. radius: number;
  63623. /**
  63624. * The strenth of the explosion.
  63625. */
  63626. strength: number;
  63627. /**
  63628. * The strenght of the force in correspondence to the distance of the affected object
  63629. */
  63630. falloff: PhysicsRadialImpulseFalloff;
  63631. /**
  63632. * Sphere options for the radial explosion.
  63633. */
  63634. sphere: {
  63635. segments: number;
  63636. diameter: number;
  63637. };
  63638. /**
  63639. * Sphere options for the radial explosion.
  63640. */
  63641. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  63642. }
  63643. /**
  63644. * Options fot the updraft event
  63645. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63646. */
  63647. export class PhysicsUpdraftEventOptions {
  63648. /**
  63649. * The radius of the cylinder for the vortex
  63650. */
  63651. radius: number;
  63652. /**
  63653. * The strenth of the updraft.
  63654. */
  63655. strength: number;
  63656. /**
  63657. * The height of the cylinder for the updraft.
  63658. */
  63659. height: number;
  63660. /**
  63661. * The mode for the the updraft.
  63662. */
  63663. updraftMode: PhysicsUpdraftMode;
  63664. }
  63665. /**
  63666. * Options fot the vortex event
  63667. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63668. */
  63669. export class PhysicsVortexEventOptions {
  63670. /**
  63671. * The radius of the cylinder for the vortex
  63672. */
  63673. radius: number;
  63674. /**
  63675. * The strenth of the vortex.
  63676. */
  63677. strength: number;
  63678. /**
  63679. * The height of the cylinder for the vortex.
  63680. */
  63681. height: number;
  63682. /**
  63683. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  63684. */
  63685. centripetalForceThreshold: number;
  63686. /**
  63687. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  63688. */
  63689. centripetalForceMultiplier: number;
  63690. /**
  63691. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  63692. */
  63693. centrifugalForceMultiplier: number;
  63694. /**
  63695. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  63696. */
  63697. updraftForceMultiplier: number;
  63698. }
  63699. /**
  63700. * The strenght of the force in correspondence to the distance of the affected object
  63701. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63702. */
  63703. export enum PhysicsRadialImpulseFalloff {
  63704. /** Defines that impulse is constant in strength across it's whole radius */
  63705. Constant = 0,
  63706. /** Defines that impulse gets weaker if it's further from the origin */
  63707. Linear = 1
  63708. }
  63709. /**
  63710. * The strength of the force in correspondence to the distance of the affected object
  63711. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63712. */
  63713. export enum PhysicsUpdraftMode {
  63714. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  63715. Center = 0,
  63716. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  63717. Perpendicular = 1
  63718. }
  63719. /**
  63720. * Interface for a physics hit data
  63721. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63722. */
  63723. export interface PhysicsHitData {
  63724. /**
  63725. * The force applied at the contact point
  63726. */
  63727. force: Vector3;
  63728. /**
  63729. * The contact point
  63730. */
  63731. contactPoint: Vector3;
  63732. /**
  63733. * The distance from the origin to the contact point
  63734. */
  63735. distanceFromOrigin: number;
  63736. }
  63737. /**
  63738. * Interface for radial explosion event data
  63739. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63740. */
  63741. export interface PhysicsRadialExplosionEventData {
  63742. /**
  63743. * A sphere used for the radial explosion event
  63744. */
  63745. sphere: Mesh;
  63746. }
  63747. /**
  63748. * Interface for gravitational field event data
  63749. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63750. */
  63751. export interface PhysicsGravitationalFieldEventData {
  63752. /**
  63753. * A sphere mesh used for the gravitational field event
  63754. */
  63755. sphere: Mesh;
  63756. }
  63757. /**
  63758. * Interface for updraft event data
  63759. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63760. */
  63761. export interface PhysicsUpdraftEventData {
  63762. /**
  63763. * A cylinder used for the updraft event
  63764. */
  63765. cylinder: Mesh;
  63766. }
  63767. /**
  63768. * Interface for vortex event data
  63769. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63770. */
  63771. export interface PhysicsVortexEventData {
  63772. /**
  63773. * A cylinder used for the vortex event
  63774. */
  63775. cylinder: Mesh;
  63776. }
  63777. /**
  63778. * Interface for an affected physics impostor
  63779. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63780. */
  63781. export interface PhysicsAffectedImpostorWithData {
  63782. /**
  63783. * The impostor affected by the effect
  63784. */
  63785. impostor: PhysicsImpostor;
  63786. /**
  63787. * The data about the hit/horce from the explosion
  63788. */
  63789. hitData: PhysicsHitData;
  63790. }
  63791. }
  63792. declare module BABYLON {
  63793. /** @hidden */
  63794. export var blackAndWhitePixelShader: {
  63795. name: string;
  63796. shader: string;
  63797. };
  63798. }
  63799. declare module BABYLON {
  63800. /**
  63801. * Post process used to render in black and white
  63802. */
  63803. export class BlackAndWhitePostProcess extends PostProcess {
  63804. /**
  63805. * Linear about to convert he result to black and white (default: 1)
  63806. */
  63807. degree: number;
  63808. /**
  63809. * Creates a black and white post process
  63810. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  63811. * @param name The name of the effect.
  63812. * @param options The required width/height ratio to downsize to before computing the render pass.
  63813. * @param camera The camera to apply the render pass to.
  63814. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63815. * @param engine The engine which the post process will be applied. (default: current engine)
  63816. * @param reusable If the post process can be reused on the same frame. (default: false)
  63817. */
  63818. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  63819. }
  63820. }
  63821. declare module BABYLON {
  63822. /**
  63823. * This represents a set of one or more post processes in Babylon.
  63824. * A post process can be used to apply a shader to a texture after it is rendered.
  63825. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  63826. */
  63827. export class PostProcessRenderEffect {
  63828. private _postProcesses;
  63829. private _getPostProcesses;
  63830. private _singleInstance;
  63831. private _cameras;
  63832. private _indicesForCamera;
  63833. /**
  63834. * Name of the effect
  63835. * @hidden
  63836. */
  63837. _name: string;
  63838. /**
  63839. * Instantiates a post process render effect.
  63840. * A post process can be used to apply a shader to a texture after it is rendered.
  63841. * @param engine The engine the effect is tied to
  63842. * @param name The name of the effect
  63843. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  63844. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  63845. */
  63846. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  63847. /**
  63848. * Checks if all the post processes in the effect are supported.
  63849. */
  63850. get isSupported(): boolean;
  63851. /**
  63852. * Updates the current state of the effect
  63853. * @hidden
  63854. */
  63855. _update(): void;
  63856. /**
  63857. * Attaches the effect on cameras
  63858. * @param cameras The camera to attach to.
  63859. * @hidden
  63860. */
  63861. _attachCameras(cameras: Camera): 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. * Detaches the effect on cameras
  63870. * @param cameras The camera to detatch from.
  63871. * @hidden
  63872. */
  63873. _detachCameras(cameras: Camera): void;
  63874. /**
  63875. * Detatches the effect on cameras
  63876. * @param cameras The camera to detatch from.
  63877. * @hidden
  63878. */
  63879. _detachCameras(cameras: Camera[]): void;
  63880. /**
  63881. * Enables the effect on given cameras
  63882. * @param cameras The camera to enable.
  63883. * @hidden
  63884. */
  63885. _enable(cameras: Camera): void;
  63886. /**
  63887. * Enables the effect on given cameras
  63888. * @param cameras The camera to enable.
  63889. * @hidden
  63890. */
  63891. _enable(cameras: Nullable<Camera[]>): void;
  63892. /**
  63893. * Disables the effect on the given cameras
  63894. * @param cameras The camera to disable.
  63895. * @hidden
  63896. */
  63897. _disable(cameras: Camera): void;
  63898. /**
  63899. * Disables the effect on the given cameras
  63900. * @param cameras The camera to disable.
  63901. * @hidden
  63902. */
  63903. _disable(cameras: Nullable<Camera[]>): void;
  63904. /**
  63905. * Gets a list of the post processes contained in the effect.
  63906. * @param camera The camera to get the post processes on.
  63907. * @returns The list of the post processes in the effect.
  63908. */
  63909. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  63910. }
  63911. }
  63912. declare module BABYLON {
  63913. /** @hidden */
  63914. export var extractHighlightsPixelShader: {
  63915. name: string;
  63916. shader: string;
  63917. };
  63918. }
  63919. declare module BABYLON {
  63920. /**
  63921. * 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.
  63922. */
  63923. export class ExtractHighlightsPostProcess extends PostProcess {
  63924. /**
  63925. * The luminance threshold, pixels below this value will be set to black.
  63926. */
  63927. threshold: number;
  63928. /** @hidden */
  63929. _exposure: number;
  63930. /**
  63931. * Post process which has the input texture to be used when performing highlight extraction
  63932. * @hidden
  63933. */
  63934. _inputPostProcess: Nullable<PostProcess>;
  63935. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  63936. }
  63937. }
  63938. declare module BABYLON {
  63939. /** @hidden */
  63940. export var bloomMergePixelShader: {
  63941. name: string;
  63942. shader: string;
  63943. };
  63944. }
  63945. declare module BABYLON {
  63946. /**
  63947. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  63948. */
  63949. export class BloomMergePostProcess extends PostProcess {
  63950. /** Weight of the bloom to be added to the original input. */
  63951. weight: number;
  63952. /**
  63953. * Creates a new instance of @see BloomMergePostProcess
  63954. * @param name The name of the effect.
  63955. * @param originalFromInput Post process which's input will be used for the merge.
  63956. * @param blurred Blurred highlights post process which's output will be used.
  63957. * @param weight Weight of the bloom to be added to the original input.
  63958. * @param options The required width/height ratio to downsize to before computing the render pass.
  63959. * @param camera The camera to apply the render pass to.
  63960. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63961. * @param engine The engine which the post process will be applied. (default: current engine)
  63962. * @param reusable If the post process can be reused on the same frame. (default: false)
  63963. * @param textureType Type of textures used when performing the post process. (default: 0)
  63964. * @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)
  63965. */
  63966. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  63967. /** Weight of the bloom to be added to the original input. */
  63968. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  63969. }
  63970. }
  63971. declare module BABYLON {
  63972. /**
  63973. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  63974. */
  63975. export class BloomEffect extends PostProcessRenderEffect {
  63976. private bloomScale;
  63977. /**
  63978. * @hidden Internal
  63979. */
  63980. _effects: Array<PostProcess>;
  63981. /**
  63982. * @hidden Internal
  63983. */
  63984. _downscale: ExtractHighlightsPostProcess;
  63985. private _blurX;
  63986. private _blurY;
  63987. private _merge;
  63988. /**
  63989. * The luminance threshold to find bright areas of the image to bloom.
  63990. */
  63991. get threshold(): number;
  63992. set threshold(value: number);
  63993. /**
  63994. * The strength of the bloom.
  63995. */
  63996. get weight(): number;
  63997. set weight(value: number);
  63998. /**
  63999. * Specifies the size of the bloom blur kernel, relative to the final output size
  64000. */
  64001. get kernel(): number;
  64002. set kernel(value: number);
  64003. /**
  64004. * Creates a new instance of @see BloomEffect
  64005. * @param scene The scene the effect belongs to.
  64006. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  64007. * @param bloomKernel The size of the kernel to be used when applying the blur.
  64008. * @param bloomWeight The the strength of bloom.
  64009. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  64010. * @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)
  64011. */
  64012. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  64013. /**
  64014. * Disposes each of the internal effects for a given camera.
  64015. * @param camera The camera to dispose the effect on.
  64016. */
  64017. disposeEffects(camera: Camera): void;
  64018. /**
  64019. * @hidden Internal
  64020. */
  64021. _updateEffects(): void;
  64022. /**
  64023. * Internal
  64024. * @returns if all the contained post processes are ready.
  64025. * @hidden
  64026. */
  64027. _isReady(): boolean;
  64028. }
  64029. }
  64030. declare module BABYLON {
  64031. /** @hidden */
  64032. export var chromaticAberrationPixelShader: {
  64033. name: string;
  64034. shader: string;
  64035. };
  64036. }
  64037. declare module BABYLON {
  64038. /**
  64039. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  64040. */
  64041. export class ChromaticAberrationPostProcess extends PostProcess {
  64042. /**
  64043. * The amount of seperation of rgb channels (default: 30)
  64044. */
  64045. aberrationAmount: number;
  64046. /**
  64047. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  64048. */
  64049. radialIntensity: number;
  64050. /**
  64051. * 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))
  64052. */
  64053. direction: Vector2;
  64054. /**
  64055. * 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))
  64056. */
  64057. centerPosition: Vector2;
  64058. /**
  64059. * Creates a new instance ChromaticAberrationPostProcess
  64060. * @param name The name of the effect.
  64061. * @param screenWidth The width of the screen to apply the effect on.
  64062. * @param screenHeight The height of the screen to apply the effect on.
  64063. * @param options The required width/height ratio to downsize to before computing the render pass.
  64064. * @param camera The camera to apply the render pass to.
  64065. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64066. * @param engine The engine which the post process will be applied. (default: current engine)
  64067. * @param reusable If the post process can be reused on the same frame. (default: false)
  64068. * @param textureType Type of textures used when performing the post process. (default: 0)
  64069. * @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)
  64070. */
  64071. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64072. }
  64073. }
  64074. declare module BABYLON {
  64075. /** @hidden */
  64076. export var circleOfConfusionPixelShader: {
  64077. name: string;
  64078. shader: string;
  64079. };
  64080. }
  64081. declare module BABYLON {
  64082. /**
  64083. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  64084. */
  64085. export class CircleOfConfusionPostProcess extends PostProcess {
  64086. /**
  64087. * 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.
  64088. */
  64089. lensSize: number;
  64090. /**
  64091. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  64092. */
  64093. fStop: number;
  64094. /**
  64095. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  64096. */
  64097. focusDistance: number;
  64098. /**
  64099. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  64100. */
  64101. focalLength: number;
  64102. private _depthTexture;
  64103. /**
  64104. * Creates a new instance CircleOfConfusionPostProcess
  64105. * @param name The name of the effect.
  64106. * @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.
  64107. * @param options The required width/height ratio to downsize to before computing the render pass.
  64108. * @param camera The camera to apply the render pass to.
  64109. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64110. * @param engine The engine which the post process will be applied. (default: current engine)
  64111. * @param reusable If the post process can be reused on the same frame. (default: false)
  64112. * @param textureType Type of textures used when performing the post process. (default: 0)
  64113. * @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)
  64114. */
  64115. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64116. /**
  64117. * 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.
  64118. */
  64119. set depthTexture(value: RenderTargetTexture);
  64120. }
  64121. }
  64122. declare module BABYLON {
  64123. /** @hidden */
  64124. export var colorCorrectionPixelShader: {
  64125. name: string;
  64126. shader: string;
  64127. };
  64128. }
  64129. declare module BABYLON {
  64130. /**
  64131. *
  64132. * This post-process allows the modification of rendered colors by using
  64133. * a 'look-up table' (LUT). This effect is also called Color Grading.
  64134. *
  64135. * The object needs to be provided an url to a texture containing the color
  64136. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  64137. * Use an image editing software to tweak the LUT to match your needs.
  64138. *
  64139. * For an example of a color LUT, see here:
  64140. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  64141. * For explanations on color grading, see here:
  64142. * @see http://udn.epicgames.com/Three/ColorGrading.html
  64143. *
  64144. */
  64145. export class ColorCorrectionPostProcess extends PostProcess {
  64146. private _colorTableTexture;
  64147. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  64148. }
  64149. }
  64150. declare module BABYLON {
  64151. /** @hidden */
  64152. export var convolutionPixelShader: {
  64153. name: string;
  64154. shader: string;
  64155. };
  64156. }
  64157. declare module BABYLON {
  64158. /**
  64159. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  64160. * input texture to perform effects such as edge detection or sharpening
  64161. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  64162. */
  64163. export class ConvolutionPostProcess extends PostProcess {
  64164. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  64165. kernel: number[];
  64166. /**
  64167. * Creates a new instance ConvolutionPostProcess
  64168. * @param name The name of the effect.
  64169. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  64170. * @param options The required width/height ratio to downsize to before computing the render pass.
  64171. * @param camera The camera to apply the render pass to.
  64172. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64173. * @param engine The engine which the post process will be applied. (default: current engine)
  64174. * @param reusable If the post process can be reused on the same frame. (default: false)
  64175. * @param textureType Type of textures used when performing the post process. (default: 0)
  64176. */
  64177. constructor(name: string,
  64178. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  64179. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  64180. /**
  64181. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64182. */
  64183. static EdgeDetect0Kernel: number[];
  64184. /**
  64185. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64186. */
  64187. static EdgeDetect1Kernel: number[];
  64188. /**
  64189. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64190. */
  64191. static EdgeDetect2Kernel: number[];
  64192. /**
  64193. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64194. */
  64195. static SharpenKernel: number[];
  64196. /**
  64197. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64198. */
  64199. static EmbossKernel: number[];
  64200. /**
  64201. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64202. */
  64203. static GaussianKernel: number[];
  64204. }
  64205. }
  64206. declare module BABYLON {
  64207. /**
  64208. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  64209. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  64210. * based on samples that have a large difference in distance than the center pixel.
  64211. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  64212. */
  64213. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  64214. direction: Vector2;
  64215. /**
  64216. * Creates a new instance CircleOfConfusionPostProcess
  64217. * @param name The name of the effect.
  64218. * @param scene The scene the effect belongs to.
  64219. * @param direction The direction the blur should be applied.
  64220. * @param kernel The size of the kernel used to blur.
  64221. * @param options The required width/height ratio to downsize to before computing the render pass.
  64222. * @param camera The camera to apply the render pass to.
  64223. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  64224. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  64225. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64226. * @param engine The engine which the post process will be applied. (default: current engine)
  64227. * @param reusable If the post process can be reused on the same frame. (default: false)
  64228. * @param textureType Type of textures used when performing the post process. (default: 0)
  64229. * @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)
  64230. */
  64231. 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);
  64232. }
  64233. }
  64234. declare module BABYLON {
  64235. /** @hidden */
  64236. export var depthOfFieldMergePixelShader: {
  64237. name: string;
  64238. shader: string;
  64239. };
  64240. }
  64241. declare module BABYLON {
  64242. /**
  64243. * Options to be set when merging outputs from the default pipeline.
  64244. */
  64245. export class DepthOfFieldMergePostProcessOptions {
  64246. /**
  64247. * The original image to merge on top of
  64248. */
  64249. originalFromInput: PostProcess;
  64250. /**
  64251. * Parameters to perform the merge of the depth of field effect
  64252. */
  64253. depthOfField?: {
  64254. circleOfConfusion: PostProcess;
  64255. blurSteps: Array<PostProcess>;
  64256. };
  64257. /**
  64258. * Parameters to perform the merge of bloom effect
  64259. */
  64260. bloom?: {
  64261. blurred: PostProcess;
  64262. weight: number;
  64263. };
  64264. }
  64265. /**
  64266. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  64267. */
  64268. export class DepthOfFieldMergePostProcess extends PostProcess {
  64269. private blurSteps;
  64270. /**
  64271. * Creates a new instance of DepthOfFieldMergePostProcess
  64272. * @param name The name of the effect.
  64273. * @param originalFromInput Post process which's input will be used for the merge.
  64274. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  64275. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  64276. * @param options The required width/height ratio to downsize to before computing the render pass.
  64277. * @param camera The camera to apply the render pass to.
  64278. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64279. * @param engine The engine which the post process will be applied. (default: current engine)
  64280. * @param reusable If the post process can be reused on the same frame. (default: false)
  64281. * @param textureType Type of textures used when performing the post process. (default: 0)
  64282. * @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)
  64283. */
  64284. 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);
  64285. /**
  64286. * Updates the effect with the current post process compile time values and recompiles the shader.
  64287. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  64288. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  64289. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  64290. * @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
  64291. * @param onCompiled Called when the shader has been compiled.
  64292. * @param onError Called if there is an error when compiling a shader.
  64293. */
  64294. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  64295. }
  64296. }
  64297. declare module BABYLON {
  64298. /**
  64299. * Specifies the level of max blur that should be applied when using the depth of field effect
  64300. */
  64301. export enum DepthOfFieldEffectBlurLevel {
  64302. /**
  64303. * Subtle blur
  64304. */
  64305. Low = 0,
  64306. /**
  64307. * Medium blur
  64308. */
  64309. Medium = 1,
  64310. /**
  64311. * Large blur
  64312. */
  64313. High = 2
  64314. }
  64315. /**
  64316. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  64317. */
  64318. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  64319. private _circleOfConfusion;
  64320. /**
  64321. * @hidden Internal, blurs from high to low
  64322. */
  64323. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  64324. private _depthOfFieldBlurY;
  64325. private _dofMerge;
  64326. /**
  64327. * @hidden Internal post processes in depth of field effect
  64328. */
  64329. _effects: Array<PostProcess>;
  64330. /**
  64331. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  64332. */
  64333. set focalLength(value: number);
  64334. get focalLength(): number;
  64335. /**
  64336. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  64337. */
  64338. set fStop(value: number);
  64339. get fStop(): number;
  64340. /**
  64341. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  64342. */
  64343. set focusDistance(value: number);
  64344. get focusDistance(): number;
  64345. /**
  64346. * 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.
  64347. */
  64348. set lensSize(value: number);
  64349. get lensSize(): number;
  64350. /**
  64351. * Creates a new instance DepthOfFieldEffect
  64352. * @param scene The scene the effect belongs to.
  64353. * @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.
  64354. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  64355. * @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)
  64356. */
  64357. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  64358. /**
  64359. * Get the current class name of the current effet
  64360. * @returns "DepthOfFieldEffect"
  64361. */
  64362. getClassName(): string;
  64363. /**
  64364. * 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.
  64365. */
  64366. set depthTexture(value: RenderTargetTexture);
  64367. /**
  64368. * Disposes each of the internal effects for a given camera.
  64369. * @param camera The camera to dispose the effect on.
  64370. */
  64371. disposeEffects(camera: Camera): void;
  64372. /**
  64373. * @hidden Internal
  64374. */
  64375. _updateEffects(): void;
  64376. /**
  64377. * Internal
  64378. * @returns if all the contained post processes are ready.
  64379. * @hidden
  64380. */
  64381. _isReady(): boolean;
  64382. }
  64383. }
  64384. declare module BABYLON {
  64385. /** @hidden */
  64386. export var displayPassPixelShader: {
  64387. name: string;
  64388. shader: string;
  64389. };
  64390. }
  64391. declare module BABYLON {
  64392. /**
  64393. * DisplayPassPostProcess which produces an output the same as it's input
  64394. */
  64395. export class DisplayPassPostProcess extends PostProcess {
  64396. /**
  64397. * Creates the DisplayPassPostProcess
  64398. * @param name The name of the effect.
  64399. * @param options The required width/height ratio to downsize to before computing the render pass.
  64400. * @param camera The camera to apply the render pass to.
  64401. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64402. * @param engine The engine which the post process will be applied. (default: current engine)
  64403. * @param reusable If the post process can be reused on the same frame. (default: false)
  64404. */
  64405. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  64406. }
  64407. }
  64408. declare module BABYLON {
  64409. /** @hidden */
  64410. export var filterPixelShader: {
  64411. name: string;
  64412. shader: string;
  64413. };
  64414. }
  64415. declare module BABYLON {
  64416. /**
  64417. * Applies a kernel filter to the image
  64418. */
  64419. export class FilterPostProcess extends PostProcess {
  64420. /** The matrix to be applied to the image */
  64421. kernelMatrix: Matrix;
  64422. /**
  64423. *
  64424. * @param name The name of the effect.
  64425. * @param kernelMatrix The matrix to be applied to the image
  64426. * @param options The required width/height ratio to downsize to before computing the render pass.
  64427. * @param camera The camera to apply the render pass to.
  64428. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64429. * @param engine The engine which the post process will be applied. (default: current engine)
  64430. * @param reusable If the post process can be reused on the same frame. (default: false)
  64431. */
  64432. constructor(name: string,
  64433. /** The matrix to be applied to the image */
  64434. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  64435. }
  64436. }
  64437. declare module BABYLON {
  64438. /** @hidden */
  64439. export var fxaaPixelShader: {
  64440. name: string;
  64441. shader: string;
  64442. };
  64443. }
  64444. declare module BABYLON {
  64445. /** @hidden */
  64446. export var fxaaVertexShader: {
  64447. name: string;
  64448. shader: string;
  64449. };
  64450. }
  64451. declare module BABYLON {
  64452. /**
  64453. * Fxaa post process
  64454. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  64455. */
  64456. export class FxaaPostProcess extends PostProcess {
  64457. /** @hidden */
  64458. texelWidth: number;
  64459. /** @hidden */
  64460. texelHeight: number;
  64461. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  64462. private _getDefines;
  64463. }
  64464. }
  64465. declare module BABYLON {
  64466. /** @hidden */
  64467. export var grainPixelShader: {
  64468. name: string;
  64469. shader: string;
  64470. };
  64471. }
  64472. declare module BABYLON {
  64473. /**
  64474. * The GrainPostProcess adds noise to the image at mid luminance levels
  64475. */
  64476. export class GrainPostProcess extends PostProcess {
  64477. /**
  64478. * The intensity of the grain added (default: 30)
  64479. */
  64480. intensity: number;
  64481. /**
  64482. * If the grain should be randomized on every frame
  64483. */
  64484. animated: boolean;
  64485. /**
  64486. * Creates a new instance of @see GrainPostProcess
  64487. * @param name The name of the effect.
  64488. * @param options The required width/height ratio to downsize to before computing the render pass.
  64489. * @param camera The camera to apply the render pass to.
  64490. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64491. * @param engine The engine which the post process will be applied. (default: current engine)
  64492. * @param reusable If the post process can be reused on the same frame. (default: false)
  64493. * @param textureType Type of textures used when performing the post process. (default: 0)
  64494. * @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)
  64495. */
  64496. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64497. }
  64498. }
  64499. declare module BABYLON {
  64500. /** @hidden */
  64501. export var highlightsPixelShader: {
  64502. name: string;
  64503. shader: string;
  64504. };
  64505. }
  64506. declare module BABYLON {
  64507. /**
  64508. * Extracts highlights from the image
  64509. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  64510. */
  64511. export class HighlightsPostProcess extends PostProcess {
  64512. /**
  64513. * Extracts highlights from the image
  64514. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  64515. * @param name The name of the effect.
  64516. * @param options The required width/height ratio to downsize to before computing the render pass.
  64517. * @param camera The camera to apply the render pass to.
  64518. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64519. * @param engine The engine which the post process will be applied. (default: current engine)
  64520. * @param reusable If the post process can be reused on the same frame. (default: false)
  64521. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  64522. */
  64523. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  64524. }
  64525. }
  64526. declare module BABYLON {
  64527. /** @hidden */
  64528. export var mrtFragmentDeclaration: {
  64529. name: string;
  64530. shader: string;
  64531. };
  64532. }
  64533. declare module BABYLON {
  64534. /** @hidden */
  64535. export var geometryPixelShader: {
  64536. name: string;
  64537. shader: string;
  64538. };
  64539. }
  64540. declare module BABYLON {
  64541. /** @hidden */
  64542. export var geometryVertexShader: {
  64543. name: string;
  64544. shader: string;
  64545. };
  64546. }
  64547. declare module BABYLON {
  64548. /** @hidden */
  64549. interface ISavedTransformationMatrix {
  64550. world: Matrix;
  64551. viewProjection: Matrix;
  64552. }
  64553. /**
  64554. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  64555. */
  64556. export class GeometryBufferRenderer {
  64557. /**
  64558. * Constant used to retrieve the position texture index in the G-Buffer textures array
  64559. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  64560. */
  64561. static readonly POSITION_TEXTURE_TYPE: number;
  64562. /**
  64563. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  64564. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  64565. */
  64566. static readonly VELOCITY_TEXTURE_TYPE: number;
  64567. /**
  64568. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  64569. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  64570. */
  64571. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  64572. /**
  64573. * Dictionary used to store the previous transformation matrices of each rendered mesh
  64574. * in order to compute objects velocities when enableVelocity is set to "true"
  64575. * @hidden
  64576. */
  64577. _previousTransformationMatrices: {
  64578. [index: number]: ISavedTransformationMatrix;
  64579. };
  64580. /**
  64581. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  64582. * in order to compute objects velocities when enableVelocity is set to "true"
  64583. * @hidden
  64584. */
  64585. _previousBonesTransformationMatrices: {
  64586. [index: number]: Float32Array;
  64587. };
  64588. /**
  64589. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  64590. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  64591. */
  64592. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  64593. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  64594. renderTransparentMeshes: boolean;
  64595. private _scene;
  64596. private _multiRenderTarget;
  64597. private _ratio;
  64598. private _enablePosition;
  64599. private _enableVelocity;
  64600. private _enableReflectivity;
  64601. private _positionIndex;
  64602. private _velocityIndex;
  64603. private _reflectivityIndex;
  64604. protected _effect: Effect;
  64605. protected _cachedDefines: string;
  64606. /**
  64607. * Set the render list (meshes to be rendered) used in the G buffer.
  64608. */
  64609. set renderList(meshes: Mesh[]);
  64610. /**
  64611. * Gets wether or not G buffer are supported by the running hardware.
  64612. * This requires draw buffer supports
  64613. */
  64614. get isSupported(): boolean;
  64615. /**
  64616. * Returns the index of the given texture type in the G-Buffer textures array
  64617. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  64618. * @returns the index of the given texture type in the G-Buffer textures array
  64619. */
  64620. getTextureIndex(textureType: number): number;
  64621. /**
  64622. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  64623. */
  64624. get enablePosition(): boolean;
  64625. /**
  64626. * Sets whether or not objects positions are enabled for the G buffer.
  64627. */
  64628. set enablePosition(enable: boolean);
  64629. /**
  64630. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  64631. */
  64632. get enableVelocity(): boolean;
  64633. /**
  64634. * Sets wether or not objects velocities are enabled for the G buffer.
  64635. */
  64636. set enableVelocity(enable: boolean);
  64637. /**
  64638. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  64639. */
  64640. get enableReflectivity(): boolean;
  64641. /**
  64642. * Sets wether or not objects roughness are enabled for the G buffer.
  64643. */
  64644. set enableReflectivity(enable: boolean);
  64645. /**
  64646. * Gets the scene associated with the buffer.
  64647. */
  64648. get scene(): Scene;
  64649. /**
  64650. * Gets the ratio used by the buffer during its creation.
  64651. * How big is the buffer related to the main canvas.
  64652. */
  64653. get ratio(): number;
  64654. /** @hidden */
  64655. static _SceneComponentInitialization: (scene: Scene) => void;
  64656. /**
  64657. * Creates a new G Buffer for the scene
  64658. * @param scene The scene the buffer belongs to
  64659. * @param ratio How big is the buffer related to the main canvas.
  64660. */
  64661. constructor(scene: Scene, ratio?: number);
  64662. /**
  64663. * Checks wether everything is ready to render a submesh to the G buffer.
  64664. * @param subMesh the submesh to check readiness for
  64665. * @param useInstances is the mesh drawn using instance or not
  64666. * @returns true if ready otherwise false
  64667. */
  64668. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  64669. /**
  64670. * Gets the current underlying G Buffer.
  64671. * @returns the buffer
  64672. */
  64673. getGBuffer(): MultiRenderTarget;
  64674. /**
  64675. * Gets the number of samples used to render the buffer (anti aliasing).
  64676. */
  64677. get samples(): number;
  64678. /**
  64679. * Sets the number of samples used to render the buffer (anti aliasing).
  64680. */
  64681. set samples(value: number);
  64682. /**
  64683. * Disposes the renderer and frees up associated resources.
  64684. */
  64685. dispose(): void;
  64686. protected _createRenderTargets(): void;
  64687. private _copyBonesTransformationMatrices;
  64688. }
  64689. }
  64690. declare module BABYLON {
  64691. interface Scene {
  64692. /** @hidden (Backing field) */
  64693. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  64694. /**
  64695. * Gets or Sets the current geometry buffer associated to the scene.
  64696. */
  64697. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  64698. /**
  64699. * Enables a GeometryBufferRender and associates it with the scene
  64700. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  64701. * @returns the GeometryBufferRenderer
  64702. */
  64703. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  64704. /**
  64705. * Disables the GeometryBufferRender associated with the scene
  64706. */
  64707. disableGeometryBufferRenderer(): void;
  64708. }
  64709. /**
  64710. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  64711. * in several rendering techniques.
  64712. */
  64713. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  64714. /**
  64715. * The component name helpful to identify the component in the list of scene components.
  64716. */
  64717. readonly name: string;
  64718. /**
  64719. * The scene the component belongs to.
  64720. */
  64721. scene: Scene;
  64722. /**
  64723. * Creates a new instance of the component for the given scene
  64724. * @param scene Defines the scene to register the component in
  64725. */
  64726. constructor(scene: Scene);
  64727. /**
  64728. * Registers the component in a given scene
  64729. */
  64730. register(): void;
  64731. /**
  64732. * Rebuilds the elements related to this component in case of
  64733. * context lost for instance.
  64734. */
  64735. rebuild(): void;
  64736. /**
  64737. * Disposes the component and the associated ressources
  64738. */
  64739. dispose(): void;
  64740. private _gatherRenderTargets;
  64741. }
  64742. }
  64743. declare module BABYLON {
  64744. /** @hidden */
  64745. export var motionBlurPixelShader: {
  64746. name: string;
  64747. shader: string;
  64748. };
  64749. }
  64750. declare module BABYLON {
  64751. /**
  64752. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  64753. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  64754. * As an example, all you have to do is to create the post-process:
  64755. * var mb = new BABYLON.MotionBlurPostProcess(
  64756. * 'mb', // The name of the effect.
  64757. * scene, // The scene containing the objects to blur according to their velocity.
  64758. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  64759. * camera // The camera to apply the render pass to.
  64760. * );
  64761. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  64762. */
  64763. export class MotionBlurPostProcess extends PostProcess {
  64764. /**
  64765. * Defines how much the image is blurred by the movement. Default value is equal to 1
  64766. */
  64767. motionStrength: number;
  64768. /**
  64769. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  64770. */
  64771. get motionBlurSamples(): number;
  64772. /**
  64773. * Sets the number of iterations to be used for motion blur quality
  64774. */
  64775. set motionBlurSamples(samples: number);
  64776. private _motionBlurSamples;
  64777. private _geometryBufferRenderer;
  64778. /**
  64779. * Creates a new instance MotionBlurPostProcess
  64780. * @param name The name of the effect.
  64781. * @param scene The scene containing the objects to blur according to their velocity.
  64782. * @param options The required width/height ratio to downsize to before computing the render pass.
  64783. * @param camera The camera to apply the render pass to.
  64784. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64785. * @param engine The engine which the post process will be applied. (default: current engine)
  64786. * @param reusable If the post process can be reused on the same frame. (default: false)
  64787. * @param textureType Type of textures used when performing the post process. (default: 0)
  64788. * @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)
  64789. */
  64790. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64791. /**
  64792. * Excludes the given skinned mesh from computing bones velocities.
  64793. * 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.
  64794. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  64795. */
  64796. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  64797. /**
  64798. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  64799. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  64800. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  64801. */
  64802. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  64803. /**
  64804. * Disposes the post process.
  64805. * @param camera The camera to dispose the post process on.
  64806. */
  64807. dispose(camera?: Camera): void;
  64808. }
  64809. }
  64810. declare module BABYLON {
  64811. /** @hidden */
  64812. export var refractionPixelShader: {
  64813. name: string;
  64814. shader: string;
  64815. };
  64816. }
  64817. declare module BABYLON {
  64818. /**
  64819. * Post process which applies a refractin texture
  64820. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  64821. */
  64822. export class RefractionPostProcess extends PostProcess {
  64823. /** the base color of the refraction (used to taint the rendering) */
  64824. color: Color3;
  64825. /** simulated refraction depth */
  64826. depth: number;
  64827. /** the coefficient of the base color (0 to remove base color tainting) */
  64828. colorLevel: number;
  64829. private _refTexture;
  64830. private _ownRefractionTexture;
  64831. /**
  64832. * Gets or sets the refraction texture
  64833. * Please note that you are responsible for disposing the texture if you set it manually
  64834. */
  64835. get refractionTexture(): Texture;
  64836. set refractionTexture(value: Texture);
  64837. /**
  64838. * Initializes the RefractionPostProcess
  64839. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  64840. * @param name The name of the effect.
  64841. * @param refractionTextureUrl Url of the refraction texture to use
  64842. * @param color the base color of the refraction (used to taint the rendering)
  64843. * @param depth simulated refraction depth
  64844. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  64845. * @param camera The camera to apply the render pass to.
  64846. * @param options The required width/height ratio to downsize to before computing the render pass.
  64847. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64848. * @param engine The engine which the post process will be applied. (default: current engine)
  64849. * @param reusable If the post process can be reused on the same frame. (default: false)
  64850. */
  64851. constructor(name: string, refractionTextureUrl: string,
  64852. /** the base color of the refraction (used to taint the rendering) */
  64853. color: Color3,
  64854. /** simulated refraction depth */
  64855. depth: number,
  64856. /** the coefficient of the base color (0 to remove base color tainting) */
  64857. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  64858. /**
  64859. * Disposes of the post process
  64860. * @param camera Camera to dispose post process on
  64861. */
  64862. dispose(camera: Camera): void;
  64863. }
  64864. }
  64865. declare module BABYLON {
  64866. /** @hidden */
  64867. export var sharpenPixelShader: {
  64868. name: string;
  64869. shader: string;
  64870. };
  64871. }
  64872. declare module BABYLON {
  64873. /**
  64874. * The SharpenPostProcess applies a sharpen kernel to every pixel
  64875. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  64876. */
  64877. export class SharpenPostProcess extends PostProcess {
  64878. /**
  64879. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  64880. */
  64881. colorAmount: number;
  64882. /**
  64883. * How much sharpness should be applied (default: 0.3)
  64884. */
  64885. edgeAmount: number;
  64886. /**
  64887. * Creates a new instance ConvolutionPostProcess
  64888. * @param name The name of the effect.
  64889. * @param options The required width/height ratio to downsize to before computing the render pass.
  64890. * @param camera The camera to apply the render pass to.
  64891. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64892. * @param engine The engine which the post process will be applied. (default: current engine)
  64893. * @param reusable If the post process can be reused on the same frame. (default: false)
  64894. * @param textureType Type of textures used when performing the post process. (default: 0)
  64895. * @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)
  64896. */
  64897. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64898. }
  64899. }
  64900. declare module BABYLON {
  64901. /**
  64902. * PostProcessRenderPipeline
  64903. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  64904. */
  64905. export class PostProcessRenderPipeline {
  64906. private engine;
  64907. private _renderEffects;
  64908. private _renderEffectsForIsolatedPass;
  64909. /**
  64910. * List of inspectable custom properties (used by the Inspector)
  64911. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  64912. */
  64913. inspectableCustomProperties: IInspectable[];
  64914. /**
  64915. * @hidden
  64916. */
  64917. protected _cameras: Camera[];
  64918. /** @hidden */
  64919. _name: string;
  64920. /**
  64921. * Gets pipeline name
  64922. */
  64923. get name(): string;
  64924. /** Gets the list of attached cameras */
  64925. get cameras(): Camera[];
  64926. /**
  64927. * Initializes a PostProcessRenderPipeline
  64928. * @param engine engine to add the pipeline to
  64929. * @param name name of the pipeline
  64930. */
  64931. constructor(engine: Engine, name: string);
  64932. /**
  64933. * Gets the class name
  64934. * @returns "PostProcessRenderPipeline"
  64935. */
  64936. getClassName(): string;
  64937. /**
  64938. * If all the render effects in the pipeline are supported
  64939. */
  64940. get isSupported(): boolean;
  64941. /**
  64942. * Adds an effect to the pipeline
  64943. * @param renderEffect the effect to add
  64944. */
  64945. addEffect(renderEffect: PostProcessRenderEffect): void;
  64946. /** @hidden */
  64947. _rebuild(): void;
  64948. /** @hidden */
  64949. _enableEffect(renderEffectName: string, cameras: Camera): void;
  64950. /** @hidden */
  64951. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  64952. /** @hidden */
  64953. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  64954. /** @hidden */
  64955. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  64956. /** @hidden */
  64957. _attachCameras(cameras: Camera, unique: boolean): void;
  64958. /** @hidden */
  64959. _attachCameras(cameras: Camera[], unique: boolean): void;
  64960. /** @hidden */
  64961. _detachCameras(cameras: Camera): void;
  64962. /** @hidden */
  64963. _detachCameras(cameras: Nullable<Camera[]>): void;
  64964. /** @hidden */
  64965. _update(): void;
  64966. /** @hidden */
  64967. _reset(): void;
  64968. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  64969. /**
  64970. * Disposes of the pipeline
  64971. */
  64972. dispose(): void;
  64973. }
  64974. }
  64975. declare module BABYLON {
  64976. /**
  64977. * PostProcessRenderPipelineManager class
  64978. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  64979. */
  64980. export class PostProcessRenderPipelineManager {
  64981. private _renderPipelines;
  64982. /**
  64983. * Initializes a PostProcessRenderPipelineManager
  64984. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  64985. */
  64986. constructor();
  64987. /**
  64988. * Gets the list of supported render pipelines
  64989. */
  64990. get supportedPipelines(): PostProcessRenderPipeline[];
  64991. /**
  64992. * Adds a pipeline to the manager
  64993. * @param renderPipeline The pipeline to add
  64994. */
  64995. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  64996. /**
  64997. * Attaches a camera to the pipeline
  64998. * @param renderPipelineName The name of the pipeline to attach to
  64999. * @param cameras the camera to attach
  65000. * @param unique if the camera can be attached multiple times to the pipeline
  65001. */
  65002. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  65003. /**
  65004. * Detaches a camera from the pipeline
  65005. * @param renderPipelineName The name of the pipeline to detach from
  65006. * @param cameras the camera to detach
  65007. */
  65008. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  65009. /**
  65010. * Enables an effect by name on a pipeline
  65011. * @param renderPipelineName the name of the pipeline to enable the effect in
  65012. * @param renderEffectName the name of the effect to enable
  65013. * @param cameras the cameras that the effect should be enabled on
  65014. */
  65015. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  65016. /**
  65017. * Disables an effect by name on a pipeline
  65018. * @param renderPipelineName the name of the pipeline to disable the effect in
  65019. * @param renderEffectName the name of the effect to disable
  65020. * @param cameras the cameras that the effect should be disabled on
  65021. */
  65022. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  65023. /**
  65024. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  65025. */
  65026. update(): void;
  65027. /** @hidden */
  65028. _rebuild(): void;
  65029. /**
  65030. * Disposes of the manager and pipelines
  65031. */
  65032. dispose(): void;
  65033. }
  65034. }
  65035. declare module BABYLON {
  65036. interface Scene {
  65037. /** @hidden (Backing field) */
  65038. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  65039. /**
  65040. * Gets the postprocess render pipeline manager
  65041. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  65042. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  65043. */
  65044. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  65045. }
  65046. /**
  65047. * Defines the Render Pipeline scene component responsible to rendering pipelines
  65048. */
  65049. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  65050. /**
  65051. * The component name helpfull to identify the component in the list of scene components.
  65052. */
  65053. readonly name: string;
  65054. /**
  65055. * The scene the component belongs to.
  65056. */
  65057. scene: Scene;
  65058. /**
  65059. * Creates a new instance of the component for the given scene
  65060. * @param scene Defines the scene to register the component in
  65061. */
  65062. constructor(scene: Scene);
  65063. /**
  65064. * Registers the component in a given scene
  65065. */
  65066. register(): void;
  65067. /**
  65068. * Rebuilds the elements related to this component in case of
  65069. * context lost for instance.
  65070. */
  65071. rebuild(): void;
  65072. /**
  65073. * Disposes the component and the associated ressources
  65074. */
  65075. dispose(): void;
  65076. private _gatherRenderTargets;
  65077. }
  65078. }
  65079. declare module BABYLON {
  65080. /**
  65081. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  65082. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  65083. */
  65084. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  65085. private _scene;
  65086. private _camerasToBeAttached;
  65087. /**
  65088. * ID of the sharpen post process,
  65089. */
  65090. private readonly SharpenPostProcessId;
  65091. /**
  65092. * @ignore
  65093. * ID of the image processing post process;
  65094. */
  65095. readonly ImageProcessingPostProcessId: string;
  65096. /**
  65097. * @ignore
  65098. * ID of the Fast Approximate Anti-Aliasing post process;
  65099. */
  65100. readonly FxaaPostProcessId: string;
  65101. /**
  65102. * ID of the chromatic aberration post process,
  65103. */
  65104. private readonly ChromaticAberrationPostProcessId;
  65105. /**
  65106. * ID of the grain post process
  65107. */
  65108. private readonly GrainPostProcessId;
  65109. /**
  65110. * Sharpen post process which will apply a sharpen convolution to enhance edges
  65111. */
  65112. sharpen: SharpenPostProcess;
  65113. private _sharpenEffect;
  65114. private bloom;
  65115. /**
  65116. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  65117. */
  65118. depthOfField: DepthOfFieldEffect;
  65119. /**
  65120. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  65121. */
  65122. fxaa: FxaaPostProcess;
  65123. /**
  65124. * Image post processing pass used to perform operations such as tone mapping or color grading.
  65125. */
  65126. imageProcessing: ImageProcessingPostProcess;
  65127. /**
  65128. * Chromatic aberration post process which will shift rgb colors in the image
  65129. */
  65130. chromaticAberration: ChromaticAberrationPostProcess;
  65131. private _chromaticAberrationEffect;
  65132. /**
  65133. * Grain post process which add noise to the image
  65134. */
  65135. grain: GrainPostProcess;
  65136. private _grainEffect;
  65137. /**
  65138. * Glow post process which adds a glow to emissive areas of the image
  65139. */
  65140. private _glowLayer;
  65141. /**
  65142. * Animations which can be used to tweak settings over a period of time
  65143. */
  65144. animations: Animation[];
  65145. private _imageProcessingConfigurationObserver;
  65146. private _sharpenEnabled;
  65147. private _bloomEnabled;
  65148. private _depthOfFieldEnabled;
  65149. private _depthOfFieldBlurLevel;
  65150. private _fxaaEnabled;
  65151. private _imageProcessingEnabled;
  65152. private _defaultPipelineTextureType;
  65153. private _bloomScale;
  65154. private _chromaticAberrationEnabled;
  65155. private _grainEnabled;
  65156. private _buildAllowed;
  65157. /**
  65158. * Gets active scene
  65159. */
  65160. get scene(): Scene;
  65161. /**
  65162. * Enable or disable the sharpen process from the pipeline
  65163. */
  65164. set sharpenEnabled(enabled: boolean);
  65165. get sharpenEnabled(): boolean;
  65166. private _resizeObserver;
  65167. private _hardwareScaleLevel;
  65168. private _bloomKernel;
  65169. /**
  65170. * Specifies the size of the bloom blur kernel, relative to the final output size
  65171. */
  65172. get bloomKernel(): number;
  65173. set bloomKernel(value: number);
  65174. /**
  65175. * Specifies the weight of the bloom in the final rendering
  65176. */
  65177. private _bloomWeight;
  65178. /**
  65179. * Specifies the luma threshold for the area that will be blurred by the bloom
  65180. */
  65181. private _bloomThreshold;
  65182. private _hdr;
  65183. /**
  65184. * The strength of the bloom.
  65185. */
  65186. set bloomWeight(value: number);
  65187. get bloomWeight(): number;
  65188. /**
  65189. * The strength of the bloom.
  65190. */
  65191. set bloomThreshold(value: number);
  65192. get bloomThreshold(): number;
  65193. /**
  65194. * The scale of the bloom, lower value will provide better performance.
  65195. */
  65196. set bloomScale(value: number);
  65197. get bloomScale(): number;
  65198. /**
  65199. * Enable or disable the bloom from the pipeline
  65200. */
  65201. set bloomEnabled(enabled: boolean);
  65202. get bloomEnabled(): boolean;
  65203. private _rebuildBloom;
  65204. /**
  65205. * If the depth of field is enabled.
  65206. */
  65207. get depthOfFieldEnabled(): boolean;
  65208. set depthOfFieldEnabled(enabled: boolean);
  65209. /**
  65210. * Blur level of the depth of field effect. (Higher blur will effect performance)
  65211. */
  65212. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  65213. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  65214. /**
  65215. * If the anti aliasing is enabled.
  65216. */
  65217. set fxaaEnabled(enabled: boolean);
  65218. get fxaaEnabled(): boolean;
  65219. private _samples;
  65220. /**
  65221. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  65222. */
  65223. set samples(sampleCount: number);
  65224. get samples(): number;
  65225. /**
  65226. * If image processing is enabled.
  65227. */
  65228. set imageProcessingEnabled(enabled: boolean);
  65229. get imageProcessingEnabled(): boolean;
  65230. /**
  65231. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  65232. */
  65233. set glowLayerEnabled(enabled: boolean);
  65234. get glowLayerEnabled(): boolean;
  65235. /**
  65236. * Gets the glow layer (or null if not defined)
  65237. */
  65238. get glowLayer(): Nullable<GlowLayer>;
  65239. /**
  65240. * Enable or disable the chromaticAberration process from the pipeline
  65241. */
  65242. set chromaticAberrationEnabled(enabled: boolean);
  65243. get chromaticAberrationEnabled(): boolean;
  65244. /**
  65245. * Enable or disable the grain process from the pipeline
  65246. */
  65247. set grainEnabled(enabled: boolean);
  65248. get grainEnabled(): boolean;
  65249. /**
  65250. * @constructor
  65251. * @param name - The rendering pipeline name (default: "")
  65252. * @param hdr - If high dynamic range textures should be used (default: true)
  65253. * @param scene - The scene linked to this pipeline (default: the last created scene)
  65254. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  65255. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  65256. */
  65257. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  65258. /**
  65259. * Get the class name
  65260. * @returns "DefaultRenderingPipeline"
  65261. */
  65262. getClassName(): string;
  65263. /**
  65264. * Force the compilation of the entire pipeline.
  65265. */
  65266. prepare(): void;
  65267. private _hasCleared;
  65268. private _prevPostProcess;
  65269. private _prevPrevPostProcess;
  65270. private _setAutoClearAndTextureSharing;
  65271. private _depthOfFieldSceneObserver;
  65272. private _buildPipeline;
  65273. private _disposePostProcesses;
  65274. /**
  65275. * Adds a camera to the pipeline
  65276. * @param camera the camera to be added
  65277. */
  65278. addCamera(camera: Camera): void;
  65279. /**
  65280. * Removes a camera from the pipeline
  65281. * @param camera the camera to remove
  65282. */
  65283. removeCamera(camera: Camera): void;
  65284. /**
  65285. * Dispose of the pipeline and stop all post processes
  65286. */
  65287. dispose(): void;
  65288. /**
  65289. * Serialize the rendering pipeline (Used when exporting)
  65290. * @returns the serialized object
  65291. */
  65292. serialize(): any;
  65293. /**
  65294. * Parse the serialized pipeline
  65295. * @param source Source pipeline.
  65296. * @param scene The scene to load the pipeline to.
  65297. * @param rootUrl The URL of the serialized pipeline.
  65298. * @returns An instantiated pipeline from the serialized object.
  65299. */
  65300. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  65301. }
  65302. }
  65303. declare module BABYLON {
  65304. /** @hidden */
  65305. export var lensHighlightsPixelShader: {
  65306. name: string;
  65307. shader: string;
  65308. };
  65309. }
  65310. declare module BABYLON {
  65311. /** @hidden */
  65312. export var depthOfFieldPixelShader: {
  65313. name: string;
  65314. shader: string;
  65315. };
  65316. }
  65317. declare module BABYLON {
  65318. /**
  65319. * BABYLON.JS Chromatic Aberration GLSL Shader
  65320. * Author: Olivier Guyot
  65321. * Separates very slightly R, G and B colors on the edges of the screen
  65322. * Inspired by Francois Tarlier & Martins Upitis
  65323. */
  65324. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  65325. /**
  65326. * @ignore
  65327. * The chromatic aberration PostProcess id in the pipeline
  65328. */
  65329. LensChromaticAberrationEffect: string;
  65330. /**
  65331. * @ignore
  65332. * The highlights enhancing PostProcess id in the pipeline
  65333. */
  65334. HighlightsEnhancingEffect: string;
  65335. /**
  65336. * @ignore
  65337. * The depth-of-field PostProcess id in the pipeline
  65338. */
  65339. LensDepthOfFieldEffect: string;
  65340. private _scene;
  65341. private _depthTexture;
  65342. private _grainTexture;
  65343. private _chromaticAberrationPostProcess;
  65344. private _highlightsPostProcess;
  65345. private _depthOfFieldPostProcess;
  65346. private _edgeBlur;
  65347. private _grainAmount;
  65348. private _chromaticAberration;
  65349. private _distortion;
  65350. private _highlightsGain;
  65351. private _highlightsThreshold;
  65352. private _dofDistance;
  65353. private _dofAperture;
  65354. private _dofDarken;
  65355. private _dofPentagon;
  65356. private _blurNoise;
  65357. /**
  65358. * @constructor
  65359. *
  65360. * Effect parameters are as follow:
  65361. * {
  65362. * chromatic_aberration: number; // from 0 to x (1 for realism)
  65363. * edge_blur: number; // from 0 to x (1 for realism)
  65364. * distortion: number; // from 0 to x (1 for realism)
  65365. * grain_amount: number; // from 0 to 1
  65366. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  65367. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  65368. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  65369. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  65370. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  65371. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  65372. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  65373. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  65374. * }
  65375. * Note: if an effect parameter is unset, effect is disabled
  65376. *
  65377. * @param name The rendering pipeline name
  65378. * @param parameters - An object containing all parameters (see above)
  65379. * @param scene The scene linked to this pipeline
  65380. * @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)
  65381. * @param cameras The array of cameras that the rendering pipeline will be attached to
  65382. */
  65383. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  65384. /**
  65385. * Get the class name
  65386. * @returns "LensRenderingPipeline"
  65387. */
  65388. getClassName(): string;
  65389. /**
  65390. * Gets associated scene
  65391. */
  65392. get scene(): Scene;
  65393. /**
  65394. * Gets or sets the edge blur
  65395. */
  65396. get edgeBlur(): number;
  65397. set edgeBlur(value: number);
  65398. /**
  65399. * Gets or sets the grain amount
  65400. */
  65401. get grainAmount(): number;
  65402. set grainAmount(value: number);
  65403. /**
  65404. * Gets or sets the chromatic aberration amount
  65405. */
  65406. get chromaticAberration(): number;
  65407. set chromaticAberration(value: number);
  65408. /**
  65409. * Gets or sets the depth of field aperture
  65410. */
  65411. get dofAperture(): number;
  65412. set dofAperture(value: number);
  65413. /**
  65414. * Gets or sets the edge distortion
  65415. */
  65416. get edgeDistortion(): number;
  65417. set edgeDistortion(value: number);
  65418. /**
  65419. * Gets or sets the depth of field distortion
  65420. */
  65421. get dofDistortion(): number;
  65422. set dofDistortion(value: number);
  65423. /**
  65424. * Gets or sets the darken out of focus amount
  65425. */
  65426. get darkenOutOfFocus(): number;
  65427. set darkenOutOfFocus(value: number);
  65428. /**
  65429. * Gets or sets a boolean indicating if blur noise is enabled
  65430. */
  65431. get blurNoise(): boolean;
  65432. set blurNoise(value: boolean);
  65433. /**
  65434. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  65435. */
  65436. get pentagonBokeh(): boolean;
  65437. set pentagonBokeh(value: boolean);
  65438. /**
  65439. * Gets or sets the highlight grain amount
  65440. */
  65441. get highlightsGain(): number;
  65442. set highlightsGain(value: number);
  65443. /**
  65444. * Gets or sets the highlight threshold
  65445. */
  65446. get highlightsThreshold(): number;
  65447. set highlightsThreshold(value: number);
  65448. /**
  65449. * Sets the amount of blur at the edges
  65450. * @param amount blur amount
  65451. */
  65452. setEdgeBlur(amount: number): void;
  65453. /**
  65454. * Sets edge blur to 0
  65455. */
  65456. disableEdgeBlur(): void;
  65457. /**
  65458. * Sets the amout of grain
  65459. * @param amount Amount of grain
  65460. */
  65461. setGrainAmount(amount: number): void;
  65462. /**
  65463. * Set grain amount to 0
  65464. */
  65465. disableGrain(): void;
  65466. /**
  65467. * Sets the chromatic aberration amount
  65468. * @param amount amount of chromatic aberration
  65469. */
  65470. setChromaticAberration(amount: number): void;
  65471. /**
  65472. * Sets chromatic aberration amount to 0
  65473. */
  65474. disableChromaticAberration(): void;
  65475. /**
  65476. * Sets the EdgeDistortion amount
  65477. * @param amount amount of EdgeDistortion
  65478. */
  65479. setEdgeDistortion(amount: number): void;
  65480. /**
  65481. * Sets edge distortion to 0
  65482. */
  65483. disableEdgeDistortion(): void;
  65484. /**
  65485. * Sets the FocusDistance amount
  65486. * @param amount amount of FocusDistance
  65487. */
  65488. setFocusDistance(amount: number): void;
  65489. /**
  65490. * Disables depth of field
  65491. */
  65492. disableDepthOfField(): void;
  65493. /**
  65494. * Sets the Aperture amount
  65495. * @param amount amount of Aperture
  65496. */
  65497. setAperture(amount: number): void;
  65498. /**
  65499. * Sets the DarkenOutOfFocus amount
  65500. * @param amount amount of DarkenOutOfFocus
  65501. */
  65502. setDarkenOutOfFocus(amount: number): void;
  65503. private _pentagonBokehIsEnabled;
  65504. /**
  65505. * Creates a pentagon bokeh effect
  65506. */
  65507. enablePentagonBokeh(): void;
  65508. /**
  65509. * Disables the pentagon bokeh effect
  65510. */
  65511. disablePentagonBokeh(): void;
  65512. /**
  65513. * Enables noise blur
  65514. */
  65515. enableNoiseBlur(): void;
  65516. /**
  65517. * Disables noise blur
  65518. */
  65519. disableNoiseBlur(): void;
  65520. /**
  65521. * Sets the HighlightsGain amount
  65522. * @param amount amount of HighlightsGain
  65523. */
  65524. setHighlightsGain(amount: number): void;
  65525. /**
  65526. * Sets the HighlightsThreshold amount
  65527. * @param amount amount of HighlightsThreshold
  65528. */
  65529. setHighlightsThreshold(amount: number): void;
  65530. /**
  65531. * Disables highlights
  65532. */
  65533. disableHighlights(): void;
  65534. /**
  65535. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  65536. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  65537. */
  65538. dispose(disableDepthRender?: boolean): void;
  65539. private _createChromaticAberrationPostProcess;
  65540. private _createHighlightsPostProcess;
  65541. private _createDepthOfFieldPostProcess;
  65542. private _createGrainTexture;
  65543. }
  65544. }
  65545. declare module BABYLON {
  65546. /** @hidden */
  65547. export var ssao2PixelShader: {
  65548. name: string;
  65549. shader: string;
  65550. };
  65551. }
  65552. declare module BABYLON {
  65553. /** @hidden */
  65554. export var ssaoCombinePixelShader: {
  65555. name: string;
  65556. shader: string;
  65557. };
  65558. }
  65559. declare module BABYLON {
  65560. /**
  65561. * Render pipeline to produce ssao effect
  65562. */
  65563. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  65564. /**
  65565. * @ignore
  65566. * The PassPostProcess id in the pipeline that contains the original scene color
  65567. */
  65568. SSAOOriginalSceneColorEffect: string;
  65569. /**
  65570. * @ignore
  65571. * The SSAO PostProcess id in the pipeline
  65572. */
  65573. SSAORenderEffect: string;
  65574. /**
  65575. * @ignore
  65576. * The horizontal blur PostProcess id in the pipeline
  65577. */
  65578. SSAOBlurHRenderEffect: string;
  65579. /**
  65580. * @ignore
  65581. * The vertical blur PostProcess id in the pipeline
  65582. */
  65583. SSAOBlurVRenderEffect: string;
  65584. /**
  65585. * @ignore
  65586. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  65587. */
  65588. SSAOCombineRenderEffect: string;
  65589. /**
  65590. * The output strength of the SSAO post-process. Default value is 1.0.
  65591. */
  65592. totalStrength: number;
  65593. /**
  65594. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  65595. */
  65596. maxZ: number;
  65597. /**
  65598. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  65599. */
  65600. minZAspect: number;
  65601. private _samples;
  65602. /**
  65603. * Number of samples used for the SSAO calculations. Default value is 8
  65604. */
  65605. set samples(n: number);
  65606. get samples(): number;
  65607. private _textureSamples;
  65608. /**
  65609. * Number of samples to use for antialiasing
  65610. */
  65611. set textureSamples(n: number);
  65612. get textureSamples(): number;
  65613. /**
  65614. * Ratio object used for SSAO ratio and blur ratio
  65615. */
  65616. private _ratio;
  65617. /**
  65618. * Dynamically generated sphere sampler.
  65619. */
  65620. private _sampleSphere;
  65621. /**
  65622. * Blur filter offsets
  65623. */
  65624. private _samplerOffsets;
  65625. private _expensiveBlur;
  65626. /**
  65627. * If bilateral blur should be used
  65628. */
  65629. set expensiveBlur(b: boolean);
  65630. get expensiveBlur(): boolean;
  65631. /**
  65632. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  65633. */
  65634. radius: number;
  65635. /**
  65636. * The base color of the SSAO post-process
  65637. * The final result is "base + ssao" between [0, 1]
  65638. */
  65639. base: number;
  65640. /**
  65641. * Support test.
  65642. */
  65643. static get IsSupported(): boolean;
  65644. private _scene;
  65645. private _depthTexture;
  65646. private _normalTexture;
  65647. private _randomTexture;
  65648. private _originalColorPostProcess;
  65649. private _ssaoPostProcess;
  65650. private _blurHPostProcess;
  65651. private _blurVPostProcess;
  65652. private _ssaoCombinePostProcess;
  65653. /**
  65654. * Gets active scene
  65655. */
  65656. get scene(): Scene;
  65657. /**
  65658. * @constructor
  65659. * @param name The rendering pipeline name
  65660. * @param scene The scene linked to this pipeline
  65661. * @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 }
  65662. * @param cameras The array of cameras that the rendering pipeline will be attached to
  65663. */
  65664. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  65665. /**
  65666. * Get the class name
  65667. * @returns "SSAO2RenderingPipeline"
  65668. */
  65669. getClassName(): string;
  65670. /**
  65671. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  65672. */
  65673. dispose(disableGeometryBufferRenderer?: boolean): void;
  65674. private _createBlurPostProcess;
  65675. /** @hidden */
  65676. _rebuild(): void;
  65677. private _bits;
  65678. private _radicalInverse_VdC;
  65679. private _hammersley;
  65680. private _hemisphereSample_uniform;
  65681. private _generateHemisphere;
  65682. private _createSSAOPostProcess;
  65683. private _createSSAOCombinePostProcess;
  65684. private _createRandomTexture;
  65685. /**
  65686. * Serialize the rendering pipeline (Used when exporting)
  65687. * @returns the serialized object
  65688. */
  65689. serialize(): any;
  65690. /**
  65691. * Parse the serialized pipeline
  65692. * @param source Source pipeline.
  65693. * @param scene The scene to load the pipeline to.
  65694. * @param rootUrl The URL of the serialized pipeline.
  65695. * @returns An instantiated pipeline from the serialized object.
  65696. */
  65697. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  65698. }
  65699. }
  65700. declare module BABYLON {
  65701. /** @hidden */
  65702. export var ssaoPixelShader: {
  65703. name: string;
  65704. shader: string;
  65705. };
  65706. }
  65707. declare module BABYLON {
  65708. /**
  65709. * Render pipeline to produce ssao effect
  65710. */
  65711. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  65712. /**
  65713. * @ignore
  65714. * The PassPostProcess id in the pipeline that contains the original scene color
  65715. */
  65716. SSAOOriginalSceneColorEffect: string;
  65717. /**
  65718. * @ignore
  65719. * The SSAO PostProcess id in the pipeline
  65720. */
  65721. SSAORenderEffect: string;
  65722. /**
  65723. * @ignore
  65724. * The horizontal blur PostProcess id in the pipeline
  65725. */
  65726. SSAOBlurHRenderEffect: string;
  65727. /**
  65728. * @ignore
  65729. * The vertical blur PostProcess id in the pipeline
  65730. */
  65731. SSAOBlurVRenderEffect: string;
  65732. /**
  65733. * @ignore
  65734. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  65735. */
  65736. SSAOCombineRenderEffect: string;
  65737. /**
  65738. * The output strength of the SSAO post-process. Default value is 1.0.
  65739. */
  65740. totalStrength: number;
  65741. /**
  65742. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  65743. */
  65744. radius: number;
  65745. /**
  65746. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  65747. * Must not be equal to fallOff and superior to fallOff.
  65748. * Default value is 0.0075
  65749. */
  65750. area: number;
  65751. /**
  65752. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  65753. * Must not be equal to area and inferior to area.
  65754. * Default value is 0.000001
  65755. */
  65756. fallOff: number;
  65757. /**
  65758. * The base color of the SSAO post-process
  65759. * The final result is "base + ssao" between [0, 1]
  65760. */
  65761. base: number;
  65762. private _scene;
  65763. private _depthTexture;
  65764. private _randomTexture;
  65765. private _originalColorPostProcess;
  65766. private _ssaoPostProcess;
  65767. private _blurHPostProcess;
  65768. private _blurVPostProcess;
  65769. private _ssaoCombinePostProcess;
  65770. private _firstUpdate;
  65771. /**
  65772. * Gets active scene
  65773. */
  65774. get scene(): Scene;
  65775. /**
  65776. * @constructor
  65777. * @param name - The rendering pipeline name
  65778. * @param scene - The scene linked to this pipeline
  65779. * @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 }
  65780. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  65781. */
  65782. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  65783. /**
  65784. * Get the class name
  65785. * @returns "SSAORenderingPipeline"
  65786. */
  65787. getClassName(): string;
  65788. /**
  65789. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  65790. */
  65791. dispose(disableDepthRender?: boolean): void;
  65792. private _createBlurPostProcess;
  65793. /** @hidden */
  65794. _rebuild(): void;
  65795. private _createSSAOPostProcess;
  65796. private _createSSAOCombinePostProcess;
  65797. private _createRandomTexture;
  65798. }
  65799. }
  65800. declare module BABYLON {
  65801. /** @hidden */
  65802. export var screenSpaceReflectionPixelShader: {
  65803. name: string;
  65804. shader: string;
  65805. };
  65806. }
  65807. declare module BABYLON {
  65808. /**
  65809. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  65810. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  65811. */
  65812. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  65813. /**
  65814. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  65815. */
  65816. threshold: number;
  65817. /**
  65818. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  65819. */
  65820. strength: number;
  65821. /**
  65822. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  65823. */
  65824. reflectionSpecularFalloffExponent: number;
  65825. /**
  65826. * 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]
  65827. */
  65828. step: number;
  65829. /**
  65830. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  65831. */
  65832. roughnessFactor: number;
  65833. private _geometryBufferRenderer;
  65834. private _enableSmoothReflections;
  65835. private _reflectionSamples;
  65836. private _smoothSteps;
  65837. /**
  65838. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  65839. * @param name The name of the effect.
  65840. * @param scene The scene containing the objects to calculate reflections.
  65841. * @param options The required width/height ratio to downsize to before computing the render pass.
  65842. * @param camera The camera to apply the render pass to.
  65843. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65844. * @param engine The engine which the post process will be applied. (default: current engine)
  65845. * @param reusable If the post process can be reused on the same frame. (default: false)
  65846. * @param textureType Type of textures used when performing the post process. (default: 0)
  65847. * @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)
  65848. */
  65849. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  65850. /**
  65851. * Gets wether or not smoothing reflections is enabled.
  65852. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  65853. */
  65854. get enableSmoothReflections(): boolean;
  65855. /**
  65856. * Sets wether or not smoothing reflections is enabled.
  65857. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  65858. */
  65859. set enableSmoothReflections(enabled: boolean);
  65860. /**
  65861. * Gets the number of samples taken while computing reflections. More samples count is high,
  65862. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  65863. */
  65864. get reflectionSamples(): number;
  65865. /**
  65866. * Sets the number of samples taken while computing reflections. More samples count is high,
  65867. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  65868. */
  65869. set reflectionSamples(samples: number);
  65870. /**
  65871. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  65872. * more the post-process will require GPU power and can generate a drop in FPS.
  65873. * Default value (5.0) work pretty well in all cases but can be adjusted.
  65874. */
  65875. get smoothSteps(): number;
  65876. set smoothSteps(steps: number);
  65877. private _updateEffectDefines;
  65878. }
  65879. }
  65880. declare module BABYLON {
  65881. /** @hidden */
  65882. export var standardPixelShader: {
  65883. name: string;
  65884. shader: string;
  65885. };
  65886. }
  65887. declare module BABYLON {
  65888. /**
  65889. * Standard rendering pipeline
  65890. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  65891. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  65892. */
  65893. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  65894. /**
  65895. * Public members
  65896. */
  65897. /**
  65898. * Post-process which contains the original scene color before the pipeline applies all the effects
  65899. */
  65900. originalPostProcess: Nullable<PostProcess>;
  65901. /**
  65902. * Post-process used to down scale an image x4
  65903. */
  65904. downSampleX4PostProcess: Nullable<PostProcess>;
  65905. /**
  65906. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  65907. */
  65908. brightPassPostProcess: Nullable<PostProcess>;
  65909. /**
  65910. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  65911. */
  65912. blurHPostProcesses: PostProcess[];
  65913. /**
  65914. * Post-process array storing all the vertical blur post-processes used by the pipeline
  65915. */
  65916. blurVPostProcesses: PostProcess[];
  65917. /**
  65918. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  65919. */
  65920. textureAdderPostProcess: Nullable<PostProcess>;
  65921. /**
  65922. * Post-process used to create volumetric lighting effect
  65923. */
  65924. volumetricLightPostProcess: Nullable<PostProcess>;
  65925. /**
  65926. * Post-process used to smooth the previous volumetric light post-process on the X axis
  65927. */
  65928. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  65929. /**
  65930. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  65931. */
  65932. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  65933. /**
  65934. * Post-process used to merge the volumetric light effect and the real scene color
  65935. */
  65936. volumetricLightMergePostProces: Nullable<PostProcess>;
  65937. /**
  65938. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  65939. */
  65940. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  65941. /**
  65942. * Base post-process used to calculate the average luminance of the final image for HDR
  65943. */
  65944. luminancePostProcess: Nullable<PostProcess>;
  65945. /**
  65946. * Post-processes used to create down sample post-processes in order to get
  65947. * the average luminance of the final image for HDR
  65948. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  65949. */
  65950. luminanceDownSamplePostProcesses: PostProcess[];
  65951. /**
  65952. * Post-process used to create a HDR effect (light adaptation)
  65953. */
  65954. hdrPostProcess: Nullable<PostProcess>;
  65955. /**
  65956. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  65957. */
  65958. textureAdderFinalPostProcess: Nullable<PostProcess>;
  65959. /**
  65960. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  65961. */
  65962. lensFlareFinalPostProcess: Nullable<PostProcess>;
  65963. /**
  65964. * Post-process used to merge the final HDR post-process and the real scene color
  65965. */
  65966. hdrFinalPostProcess: Nullable<PostProcess>;
  65967. /**
  65968. * Post-process used to create a lens flare effect
  65969. */
  65970. lensFlarePostProcess: Nullable<PostProcess>;
  65971. /**
  65972. * Post-process that merges the result of the lens flare post-process and the real scene color
  65973. */
  65974. lensFlareComposePostProcess: Nullable<PostProcess>;
  65975. /**
  65976. * Post-process used to create a motion blur effect
  65977. */
  65978. motionBlurPostProcess: Nullable<PostProcess>;
  65979. /**
  65980. * Post-process used to create a depth of field effect
  65981. */
  65982. depthOfFieldPostProcess: Nullable<PostProcess>;
  65983. /**
  65984. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  65985. */
  65986. fxaaPostProcess: Nullable<FxaaPostProcess>;
  65987. /**
  65988. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  65989. */
  65990. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  65991. /**
  65992. * Represents the brightness threshold in order to configure the illuminated surfaces
  65993. */
  65994. brightThreshold: number;
  65995. /**
  65996. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  65997. */
  65998. blurWidth: number;
  65999. /**
  66000. * Sets if the blur for highlighted surfaces must be only horizontal
  66001. */
  66002. horizontalBlur: boolean;
  66003. /**
  66004. * Gets the overall exposure used by the pipeline
  66005. */
  66006. get exposure(): number;
  66007. /**
  66008. * Sets the overall exposure used by the pipeline
  66009. */
  66010. set exposure(value: number);
  66011. /**
  66012. * Texture used typically to simulate "dirty" on camera lens
  66013. */
  66014. lensTexture: Nullable<Texture>;
  66015. /**
  66016. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  66017. */
  66018. volumetricLightCoefficient: number;
  66019. /**
  66020. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  66021. */
  66022. volumetricLightPower: number;
  66023. /**
  66024. * Used the set the blur intensity to smooth the volumetric lights
  66025. */
  66026. volumetricLightBlurScale: number;
  66027. /**
  66028. * Light (spot or directional) used to generate the volumetric lights rays
  66029. * The source light must have a shadow generate so the pipeline can get its
  66030. * depth map
  66031. */
  66032. sourceLight: Nullable<SpotLight | DirectionalLight>;
  66033. /**
  66034. * For eye adaptation, represents the minimum luminance the eye can see
  66035. */
  66036. hdrMinimumLuminance: number;
  66037. /**
  66038. * For eye adaptation, represents the decrease luminance speed
  66039. */
  66040. hdrDecreaseRate: number;
  66041. /**
  66042. * For eye adaptation, represents the increase luminance speed
  66043. */
  66044. hdrIncreaseRate: number;
  66045. /**
  66046. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  66047. */
  66048. get hdrAutoExposure(): boolean;
  66049. /**
  66050. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  66051. */
  66052. set hdrAutoExposure(value: boolean);
  66053. /**
  66054. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  66055. */
  66056. lensColorTexture: Nullable<Texture>;
  66057. /**
  66058. * The overall strengh for the lens flare effect
  66059. */
  66060. lensFlareStrength: number;
  66061. /**
  66062. * Dispersion coefficient for lens flare ghosts
  66063. */
  66064. lensFlareGhostDispersal: number;
  66065. /**
  66066. * Main lens flare halo width
  66067. */
  66068. lensFlareHaloWidth: number;
  66069. /**
  66070. * Based on the lens distortion effect, defines how much the lens flare result
  66071. * is distorted
  66072. */
  66073. lensFlareDistortionStrength: number;
  66074. /**
  66075. * Configures the blur intensity used for for lens flare (halo)
  66076. */
  66077. lensFlareBlurWidth: number;
  66078. /**
  66079. * Lens star texture must be used to simulate rays on the flares and is available
  66080. * in the documentation
  66081. */
  66082. lensStarTexture: Nullable<Texture>;
  66083. /**
  66084. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  66085. * flare effect by taking account of the dirt texture
  66086. */
  66087. lensFlareDirtTexture: Nullable<Texture>;
  66088. /**
  66089. * Represents the focal length for the depth of field effect
  66090. */
  66091. depthOfFieldDistance: number;
  66092. /**
  66093. * Represents the blur intensity for the blurred part of the depth of field effect
  66094. */
  66095. depthOfFieldBlurWidth: number;
  66096. /**
  66097. * Gets how much the image is blurred by the movement while using the motion blur post-process
  66098. */
  66099. get motionStrength(): number;
  66100. /**
  66101. * Sets how much the image is blurred by the movement while using the motion blur post-process
  66102. */
  66103. set motionStrength(strength: number);
  66104. /**
  66105. * Gets wether or not the motion blur post-process is object based or screen based.
  66106. */
  66107. get objectBasedMotionBlur(): boolean;
  66108. /**
  66109. * Sets wether or not the motion blur post-process should be object based or screen based
  66110. */
  66111. set objectBasedMotionBlur(value: boolean);
  66112. /**
  66113. * List of animations for the pipeline (IAnimatable implementation)
  66114. */
  66115. animations: Animation[];
  66116. /**
  66117. * Private members
  66118. */
  66119. private _scene;
  66120. private _currentDepthOfFieldSource;
  66121. private _basePostProcess;
  66122. private _fixedExposure;
  66123. private _currentExposure;
  66124. private _hdrAutoExposure;
  66125. private _hdrCurrentLuminance;
  66126. private _motionStrength;
  66127. private _isObjectBasedMotionBlur;
  66128. private _floatTextureType;
  66129. private _camerasToBeAttached;
  66130. private _ratio;
  66131. private _bloomEnabled;
  66132. private _depthOfFieldEnabled;
  66133. private _vlsEnabled;
  66134. private _lensFlareEnabled;
  66135. private _hdrEnabled;
  66136. private _motionBlurEnabled;
  66137. private _fxaaEnabled;
  66138. private _screenSpaceReflectionsEnabled;
  66139. private _motionBlurSamples;
  66140. private _volumetricLightStepsCount;
  66141. private _samples;
  66142. /**
  66143. * @ignore
  66144. * Specifies if the bloom pipeline is enabled
  66145. */
  66146. get BloomEnabled(): boolean;
  66147. set BloomEnabled(enabled: boolean);
  66148. /**
  66149. * @ignore
  66150. * Specifies if the depth of field pipeline is enabed
  66151. */
  66152. get DepthOfFieldEnabled(): boolean;
  66153. set DepthOfFieldEnabled(enabled: boolean);
  66154. /**
  66155. * @ignore
  66156. * Specifies if the lens flare pipeline is enabed
  66157. */
  66158. get LensFlareEnabled(): boolean;
  66159. set LensFlareEnabled(enabled: boolean);
  66160. /**
  66161. * @ignore
  66162. * Specifies if the HDR pipeline is enabled
  66163. */
  66164. get HDREnabled(): boolean;
  66165. set HDREnabled(enabled: boolean);
  66166. /**
  66167. * @ignore
  66168. * Specifies if the volumetric lights scattering effect is enabled
  66169. */
  66170. get VLSEnabled(): boolean;
  66171. set VLSEnabled(enabled: boolean);
  66172. /**
  66173. * @ignore
  66174. * Specifies if the motion blur effect is enabled
  66175. */
  66176. get MotionBlurEnabled(): boolean;
  66177. set MotionBlurEnabled(enabled: boolean);
  66178. /**
  66179. * Specifies if anti-aliasing is enabled
  66180. */
  66181. get fxaaEnabled(): boolean;
  66182. set fxaaEnabled(enabled: boolean);
  66183. /**
  66184. * Specifies if screen space reflections are enabled.
  66185. */
  66186. get screenSpaceReflectionsEnabled(): boolean;
  66187. set screenSpaceReflectionsEnabled(enabled: boolean);
  66188. /**
  66189. * Specifies the number of steps used to calculate the volumetric lights
  66190. * Typically in interval [50, 200]
  66191. */
  66192. get volumetricLightStepsCount(): number;
  66193. set volumetricLightStepsCount(count: number);
  66194. /**
  66195. * Specifies the number of samples used for the motion blur effect
  66196. * Typically in interval [16, 64]
  66197. */
  66198. get motionBlurSamples(): number;
  66199. set motionBlurSamples(samples: number);
  66200. /**
  66201. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  66202. */
  66203. get samples(): number;
  66204. set samples(sampleCount: number);
  66205. /**
  66206. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  66207. * @constructor
  66208. * @param name The rendering pipeline name
  66209. * @param scene The scene linked to this pipeline
  66210. * @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)
  66211. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  66212. * @param cameras The array of cameras that the rendering pipeline will be attached to
  66213. */
  66214. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  66215. private _buildPipeline;
  66216. private _createDownSampleX4PostProcess;
  66217. private _createBrightPassPostProcess;
  66218. private _createBlurPostProcesses;
  66219. private _createTextureAdderPostProcess;
  66220. private _createVolumetricLightPostProcess;
  66221. private _createLuminancePostProcesses;
  66222. private _createHdrPostProcess;
  66223. private _createLensFlarePostProcess;
  66224. private _createDepthOfFieldPostProcess;
  66225. private _createMotionBlurPostProcess;
  66226. private _getDepthTexture;
  66227. private _disposePostProcesses;
  66228. /**
  66229. * Dispose of the pipeline and stop all post processes
  66230. */
  66231. dispose(): void;
  66232. /**
  66233. * Serialize the rendering pipeline (Used when exporting)
  66234. * @returns the serialized object
  66235. */
  66236. serialize(): any;
  66237. /**
  66238. * Parse the serialized pipeline
  66239. * @param source Source pipeline.
  66240. * @param scene The scene to load the pipeline to.
  66241. * @param rootUrl The URL of the serialized pipeline.
  66242. * @returns An instantiated pipeline from the serialized object.
  66243. */
  66244. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  66245. /**
  66246. * Luminance steps
  66247. */
  66248. static LuminanceSteps: number;
  66249. }
  66250. }
  66251. declare module BABYLON {
  66252. /** @hidden */
  66253. export var tonemapPixelShader: {
  66254. name: string;
  66255. shader: string;
  66256. };
  66257. }
  66258. declare module BABYLON {
  66259. /** Defines operator used for tonemapping */
  66260. export enum TonemappingOperator {
  66261. /** Hable */
  66262. Hable = 0,
  66263. /** Reinhard */
  66264. Reinhard = 1,
  66265. /** HejiDawson */
  66266. HejiDawson = 2,
  66267. /** Photographic */
  66268. Photographic = 3
  66269. }
  66270. /**
  66271. * Defines a post process to apply tone mapping
  66272. */
  66273. export class TonemapPostProcess extends PostProcess {
  66274. private _operator;
  66275. /** Defines the required exposure adjustement */
  66276. exposureAdjustment: number;
  66277. /**
  66278. * Creates a new TonemapPostProcess
  66279. * @param name defines the name of the postprocess
  66280. * @param _operator defines the operator to use
  66281. * @param exposureAdjustment defines the required exposure adjustement
  66282. * @param camera defines the camera to use (can be null)
  66283. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  66284. * @param engine defines the hosting engine (can be ignore if camera is set)
  66285. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  66286. */
  66287. constructor(name: string, _operator: TonemappingOperator,
  66288. /** Defines the required exposure adjustement */
  66289. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  66290. }
  66291. }
  66292. declare module BABYLON {
  66293. /** @hidden */
  66294. export var volumetricLightScatteringPixelShader: {
  66295. name: string;
  66296. shader: string;
  66297. };
  66298. }
  66299. declare module BABYLON {
  66300. /** @hidden */
  66301. export var volumetricLightScatteringPassVertexShader: {
  66302. name: string;
  66303. shader: string;
  66304. };
  66305. }
  66306. declare module BABYLON {
  66307. /** @hidden */
  66308. export var volumetricLightScatteringPassPixelShader: {
  66309. name: string;
  66310. shader: string;
  66311. };
  66312. }
  66313. declare module BABYLON {
  66314. /**
  66315. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  66316. */
  66317. export class VolumetricLightScatteringPostProcess extends PostProcess {
  66318. private _volumetricLightScatteringPass;
  66319. private _volumetricLightScatteringRTT;
  66320. private _viewPort;
  66321. private _screenCoordinates;
  66322. private _cachedDefines;
  66323. /**
  66324. * If not undefined, the mesh position is computed from the attached node position
  66325. */
  66326. attachedNode: {
  66327. position: Vector3;
  66328. };
  66329. /**
  66330. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  66331. */
  66332. customMeshPosition: Vector3;
  66333. /**
  66334. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  66335. */
  66336. useCustomMeshPosition: boolean;
  66337. /**
  66338. * If the post-process should inverse the light scattering direction
  66339. */
  66340. invert: boolean;
  66341. /**
  66342. * The internal mesh used by the post-process
  66343. */
  66344. mesh: Mesh;
  66345. /**
  66346. * @hidden
  66347. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  66348. */
  66349. get useDiffuseColor(): boolean;
  66350. set useDiffuseColor(useDiffuseColor: boolean);
  66351. /**
  66352. * Array containing the excluded meshes not rendered in the internal pass
  66353. */
  66354. excludedMeshes: AbstractMesh[];
  66355. /**
  66356. * Controls the overall intensity of the post-process
  66357. */
  66358. exposure: number;
  66359. /**
  66360. * Dissipates each sample's contribution in range [0, 1]
  66361. */
  66362. decay: number;
  66363. /**
  66364. * Controls the overall intensity of each sample
  66365. */
  66366. weight: number;
  66367. /**
  66368. * Controls the density of each sample
  66369. */
  66370. density: number;
  66371. /**
  66372. * @constructor
  66373. * @param name The post-process name
  66374. * @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)
  66375. * @param camera The camera that the post-process will be attached to
  66376. * @param mesh The mesh used to create the light scattering
  66377. * @param samples The post-process quality, default 100
  66378. * @param samplingModeThe post-process filtering mode
  66379. * @param engine The babylon engine
  66380. * @param reusable If the post-process is reusable
  66381. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  66382. */
  66383. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  66384. /**
  66385. * Returns the string "VolumetricLightScatteringPostProcess"
  66386. * @returns "VolumetricLightScatteringPostProcess"
  66387. */
  66388. getClassName(): string;
  66389. private _isReady;
  66390. /**
  66391. * Sets the new light position for light scattering effect
  66392. * @param position The new custom light position
  66393. */
  66394. setCustomMeshPosition(position: Vector3): void;
  66395. /**
  66396. * Returns the light position for light scattering effect
  66397. * @return Vector3 The custom light position
  66398. */
  66399. getCustomMeshPosition(): Vector3;
  66400. /**
  66401. * Disposes the internal assets and detaches the post-process from the camera
  66402. */
  66403. dispose(camera: Camera): void;
  66404. /**
  66405. * Returns the render target texture used by the post-process
  66406. * @return the render target texture used by the post-process
  66407. */
  66408. getPass(): RenderTargetTexture;
  66409. private _meshExcluded;
  66410. private _createPass;
  66411. private _updateMeshScreenCoordinates;
  66412. /**
  66413. * Creates a default mesh for the Volumeric Light Scattering post-process
  66414. * @param name The mesh name
  66415. * @param scene The scene where to create the mesh
  66416. * @return the default mesh
  66417. */
  66418. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  66419. }
  66420. }
  66421. declare module BABYLON {
  66422. interface Scene {
  66423. /** @hidden (Backing field) */
  66424. _boundingBoxRenderer: BoundingBoxRenderer;
  66425. /** @hidden (Backing field) */
  66426. _forceShowBoundingBoxes: boolean;
  66427. /**
  66428. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  66429. */
  66430. forceShowBoundingBoxes: boolean;
  66431. /**
  66432. * Gets the bounding box renderer associated with the scene
  66433. * @returns a BoundingBoxRenderer
  66434. */
  66435. getBoundingBoxRenderer(): BoundingBoxRenderer;
  66436. }
  66437. interface AbstractMesh {
  66438. /** @hidden (Backing field) */
  66439. _showBoundingBox: boolean;
  66440. /**
  66441. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  66442. */
  66443. showBoundingBox: boolean;
  66444. }
  66445. /**
  66446. * Component responsible of rendering the bounding box of the meshes in a scene.
  66447. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  66448. */
  66449. export class BoundingBoxRenderer implements ISceneComponent {
  66450. /**
  66451. * The component name helpfull to identify the component in the list of scene components.
  66452. */
  66453. readonly name: string;
  66454. /**
  66455. * The scene the component belongs to.
  66456. */
  66457. scene: Scene;
  66458. /**
  66459. * Color of the bounding box lines placed in front of an object
  66460. */
  66461. frontColor: Color3;
  66462. /**
  66463. * Color of the bounding box lines placed behind an object
  66464. */
  66465. backColor: Color3;
  66466. /**
  66467. * Defines if the renderer should show the back lines or not
  66468. */
  66469. showBackLines: boolean;
  66470. /**
  66471. * @hidden
  66472. */
  66473. renderList: SmartArray<BoundingBox>;
  66474. private _colorShader;
  66475. private _vertexBuffers;
  66476. private _indexBuffer;
  66477. private _fillIndexBuffer;
  66478. private _fillIndexData;
  66479. /**
  66480. * Instantiates a new bounding box renderer in a scene.
  66481. * @param scene the scene the renderer renders in
  66482. */
  66483. constructor(scene: Scene);
  66484. /**
  66485. * Registers the component in a given scene
  66486. */
  66487. register(): void;
  66488. private _evaluateSubMesh;
  66489. private _activeMesh;
  66490. private _prepareRessources;
  66491. private _createIndexBuffer;
  66492. /**
  66493. * Rebuilds the elements related to this component in case of
  66494. * context lost for instance.
  66495. */
  66496. rebuild(): void;
  66497. /**
  66498. * @hidden
  66499. */
  66500. reset(): void;
  66501. /**
  66502. * Render the bounding boxes of a specific rendering group
  66503. * @param renderingGroupId defines the rendering group to render
  66504. */
  66505. render(renderingGroupId: number): void;
  66506. /**
  66507. * In case of occlusion queries, we can render the occlusion bounding box through this method
  66508. * @param mesh Define the mesh to render the occlusion bounding box for
  66509. */
  66510. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  66511. /**
  66512. * Dispose and release the resources attached to this renderer.
  66513. */
  66514. dispose(): void;
  66515. }
  66516. }
  66517. declare module BABYLON {
  66518. interface Scene {
  66519. /** @hidden (Backing field) */
  66520. _depthRenderer: {
  66521. [id: string]: DepthRenderer;
  66522. };
  66523. /**
  66524. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  66525. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  66526. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  66527. * @returns the created depth renderer
  66528. */
  66529. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  66530. /**
  66531. * Disables a depth renderer for a given camera
  66532. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  66533. */
  66534. disableDepthRenderer(camera?: Nullable<Camera>): void;
  66535. }
  66536. /**
  66537. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  66538. * in several rendering techniques.
  66539. */
  66540. export class DepthRendererSceneComponent implements ISceneComponent {
  66541. /**
  66542. * The component name helpfull to identify the component in the list of scene components.
  66543. */
  66544. readonly name: string;
  66545. /**
  66546. * The scene the component belongs to.
  66547. */
  66548. scene: Scene;
  66549. /**
  66550. * Creates a new instance of the component for the given scene
  66551. * @param scene Defines the scene to register the component in
  66552. */
  66553. constructor(scene: Scene);
  66554. /**
  66555. * Registers the component in a given scene
  66556. */
  66557. register(): void;
  66558. /**
  66559. * Rebuilds the elements related to this component in case of
  66560. * context lost for instance.
  66561. */
  66562. rebuild(): void;
  66563. /**
  66564. * Disposes the component and the associated ressources
  66565. */
  66566. dispose(): void;
  66567. private _gatherRenderTargets;
  66568. private _gatherActiveCameraRenderTargets;
  66569. }
  66570. }
  66571. declare module BABYLON {
  66572. /** @hidden */
  66573. export var outlinePixelShader: {
  66574. name: string;
  66575. shader: string;
  66576. };
  66577. }
  66578. declare module BABYLON {
  66579. /** @hidden */
  66580. export var outlineVertexShader: {
  66581. name: string;
  66582. shader: string;
  66583. };
  66584. }
  66585. declare module BABYLON {
  66586. interface Scene {
  66587. /** @hidden */
  66588. _outlineRenderer: OutlineRenderer;
  66589. /**
  66590. * Gets the outline renderer associated with the scene
  66591. * @returns a OutlineRenderer
  66592. */
  66593. getOutlineRenderer(): OutlineRenderer;
  66594. }
  66595. interface AbstractMesh {
  66596. /** @hidden (Backing field) */
  66597. _renderOutline: boolean;
  66598. /**
  66599. * Gets or sets a boolean indicating if the outline must be rendered as well
  66600. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  66601. */
  66602. renderOutline: boolean;
  66603. /** @hidden (Backing field) */
  66604. _renderOverlay: boolean;
  66605. /**
  66606. * Gets or sets a boolean indicating if the overlay must be rendered as well
  66607. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  66608. */
  66609. renderOverlay: boolean;
  66610. }
  66611. /**
  66612. * This class is responsible to draw bothe outline/overlay of meshes.
  66613. * It should not be used directly but through the available method on mesh.
  66614. */
  66615. export class OutlineRenderer implements ISceneComponent {
  66616. /**
  66617. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  66618. */
  66619. private static _StencilReference;
  66620. /**
  66621. * The name of the component. Each component must have a unique name.
  66622. */
  66623. name: string;
  66624. /**
  66625. * The scene the component belongs to.
  66626. */
  66627. scene: Scene;
  66628. /**
  66629. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  66630. */
  66631. zOffset: number;
  66632. private _engine;
  66633. private _effect;
  66634. private _cachedDefines;
  66635. private _savedDepthWrite;
  66636. /**
  66637. * Instantiates a new outline renderer. (There could be only one per scene).
  66638. * @param scene Defines the scene it belongs to
  66639. */
  66640. constructor(scene: Scene);
  66641. /**
  66642. * Register the component to one instance of a scene.
  66643. */
  66644. register(): void;
  66645. /**
  66646. * Rebuilds the elements related to this component in case of
  66647. * context lost for instance.
  66648. */
  66649. rebuild(): void;
  66650. /**
  66651. * Disposes the component and the associated ressources.
  66652. */
  66653. dispose(): void;
  66654. /**
  66655. * Renders the outline in the canvas.
  66656. * @param subMesh Defines the sumesh to render
  66657. * @param batch Defines the batch of meshes in case of instances
  66658. * @param useOverlay Defines if the rendering is for the overlay or the outline
  66659. */
  66660. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  66661. /**
  66662. * Returns whether or not the outline renderer is ready for a given submesh.
  66663. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  66664. * @param subMesh Defines the submesh to check readyness for
  66665. * @param useInstances Defines wheter wee are trying to render instances or not
  66666. * @returns true if ready otherwise false
  66667. */
  66668. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  66669. private _beforeRenderingMesh;
  66670. private _afterRenderingMesh;
  66671. }
  66672. }
  66673. declare module BABYLON {
  66674. /**
  66675. * Defines the basic options interface of a Sprite Frame Source Size.
  66676. */
  66677. export interface ISpriteJSONSpriteSourceSize {
  66678. /**
  66679. * number of the original width of the Frame
  66680. */
  66681. w: number;
  66682. /**
  66683. * number of the original height of the Frame
  66684. */
  66685. h: number;
  66686. }
  66687. /**
  66688. * Defines the basic options interface of a Sprite Frame Data.
  66689. */
  66690. export interface ISpriteJSONSpriteFrameData {
  66691. /**
  66692. * number of the x offset of the Frame
  66693. */
  66694. x: number;
  66695. /**
  66696. * number of the y offset of the Frame
  66697. */
  66698. y: number;
  66699. /**
  66700. * number of the width of the Frame
  66701. */
  66702. w: number;
  66703. /**
  66704. * number of the height of the Frame
  66705. */
  66706. h: number;
  66707. }
  66708. /**
  66709. * Defines the basic options interface of a JSON Sprite.
  66710. */
  66711. export interface ISpriteJSONSprite {
  66712. /**
  66713. * string name of the Frame
  66714. */
  66715. filename: string;
  66716. /**
  66717. * ISpriteJSONSpriteFrame basic object of the frame data
  66718. */
  66719. frame: ISpriteJSONSpriteFrameData;
  66720. /**
  66721. * boolean to flag is the frame was rotated.
  66722. */
  66723. rotated: boolean;
  66724. /**
  66725. * boolean to flag is the frame was trimmed.
  66726. */
  66727. trimmed: boolean;
  66728. /**
  66729. * ISpriteJSONSpriteFrame basic object of the source data
  66730. */
  66731. spriteSourceSize: ISpriteJSONSpriteFrameData;
  66732. /**
  66733. * ISpriteJSONSpriteFrame basic object of the source data
  66734. */
  66735. sourceSize: ISpriteJSONSpriteSourceSize;
  66736. }
  66737. /**
  66738. * Defines the basic options interface of a JSON atlas.
  66739. */
  66740. export interface ISpriteJSONAtlas {
  66741. /**
  66742. * Array of objects that contain the frame data.
  66743. */
  66744. frames: Array<ISpriteJSONSprite>;
  66745. /**
  66746. * object basic object containing the sprite meta data.
  66747. */
  66748. meta?: object;
  66749. }
  66750. }
  66751. declare module BABYLON {
  66752. /** @hidden */
  66753. export var spriteMapPixelShader: {
  66754. name: string;
  66755. shader: string;
  66756. };
  66757. }
  66758. declare module BABYLON {
  66759. /** @hidden */
  66760. export var spriteMapVertexShader: {
  66761. name: string;
  66762. shader: string;
  66763. };
  66764. }
  66765. declare module BABYLON {
  66766. /**
  66767. * Defines the basic options interface of a SpriteMap
  66768. */
  66769. export interface ISpriteMapOptions {
  66770. /**
  66771. * Vector2 of the number of cells in the grid.
  66772. */
  66773. stageSize?: Vector2;
  66774. /**
  66775. * Vector2 of the size of the output plane in World Units.
  66776. */
  66777. outputSize?: Vector2;
  66778. /**
  66779. * Vector3 of the position of the output plane in World Units.
  66780. */
  66781. outputPosition?: Vector3;
  66782. /**
  66783. * Vector3 of the rotation of the output plane.
  66784. */
  66785. outputRotation?: Vector3;
  66786. /**
  66787. * number of layers that the system will reserve in resources.
  66788. */
  66789. layerCount?: number;
  66790. /**
  66791. * number of max animation frames a single cell will reserve in resources.
  66792. */
  66793. maxAnimationFrames?: number;
  66794. /**
  66795. * number cell index of the base tile when the system compiles.
  66796. */
  66797. baseTile?: number;
  66798. /**
  66799. * boolean flip the sprite after its been repositioned by the framing data.
  66800. */
  66801. flipU?: boolean;
  66802. /**
  66803. * Vector3 scalar of the global RGB values of the SpriteMap.
  66804. */
  66805. colorMultiply?: Vector3;
  66806. }
  66807. /**
  66808. * Defines the IDisposable interface in order to be cleanable from resources.
  66809. */
  66810. export interface ISpriteMap extends IDisposable {
  66811. /**
  66812. * String name of the SpriteMap.
  66813. */
  66814. name: string;
  66815. /**
  66816. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  66817. */
  66818. atlasJSON: ISpriteJSONAtlas;
  66819. /**
  66820. * Texture of the SpriteMap.
  66821. */
  66822. spriteSheet: Texture;
  66823. /**
  66824. * The parameters to initialize the SpriteMap with.
  66825. */
  66826. options: ISpriteMapOptions;
  66827. }
  66828. /**
  66829. * Class used to manage a grid restricted sprite deployment on an Output plane.
  66830. */
  66831. export class SpriteMap implements ISpriteMap {
  66832. /** The Name of the spriteMap */
  66833. name: string;
  66834. /** The JSON file with the frame and meta data */
  66835. atlasJSON: ISpriteJSONAtlas;
  66836. /** The systems Sprite Sheet Texture */
  66837. spriteSheet: Texture;
  66838. /** Arguments passed with the Constructor */
  66839. options: ISpriteMapOptions;
  66840. /** Public Sprite Storage array, parsed from atlasJSON */
  66841. sprites: Array<ISpriteJSONSprite>;
  66842. /** Returns the Number of Sprites in the System */
  66843. get spriteCount(): number;
  66844. /** Returns the Position of Output Plane*/
  66845. get position(): Vector3;
  66846. /** Returns the Position of Output Plane*/
  66847. set position(v: Vector3);
  66848. /** Returns the Rotation of Output Plane*/
  66849. get rotation(): Vector3;
  66850. /** Returns the Rotation of Output Plane*/
  66851. set rotation(v: Vector3);
  66852. /** Sets the AnimationMap*/
  66853. get animationMap(): RawTexture;
  66854. /** Sets the AnimationMap*/
  66855. set animationMap(v: RawTexture);
  66856. /** Scene that the SpriteMap was created in */
  66857. private _scene;
  66858. /** Texture Buffer of Float32 that holds tile frame data*/
  66859. private _frameMap;
  66860. /** Texture Buffers of Float32 that holds tileMap data*/
  66861. private _tileMaps;
  66862. /** Texture Buffer of Float32 that holds Animation Data*/
  66863. private _animationMap;
  66864. /** Custom ShaderMaterial Central to the System*/
  66865. private _material;
  66866. /** Custom ShaderMaterial Central to the System*/
  66867. private _output;
  66868. /** Systems Time Ticker*/
  66869. private _time;
  66870. /**
  66871. * Creates a new SpriteMap
  66872. * @param name defines the SpriteMaps Name
  66873. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  66874. * @param spriteSheet is the Texture that the Sprites are on.
  66875. * @param options a basic deployment configuration
  66876. * @param scene The Scene that the map is deployed on
  66877. */
  66878. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  66879. /**
  66880. * Returns tileID location
  66881. * @returns Vector2 the cell position ID
  66882. */
  66883. getTileID(): Vector2;
  66884. /**
  66885. * Gets the UV location of the mouse over the SpriteMap.
  66886. * @returns Vector2 the UV position of the mouse interaction
  66887. */
  66888. getMousePosition(): Vector2;
  66889. /**
  66890. * Creates the "frame" texture Buffer
  66891. * -------------------------------------
  66892. * Structure of frames
  66893. * "filename": "Falling-Water-2.png",
  66894. * "frame": {"x":69,"y":103,"w":24,"h":32},
  66895. * "rotated": true,
  66896. * "trimmed": true,
  66897. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  66898. * "sourceSize": {"w":32,"h":32}
  66899. * @returns RawTexture of the frameMap
  66900. */
  66901. private _createFrameBuffer;
  66902. /**
  66903. * Creates the tileMap texture Buffer
  66904. * @param buffer normally and array of numbers, or a false to generate from scratch
  66905. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  66906. * @returns RawTexture of the tileMap
  66907. */
  66908. private _createTileBuffer;
  66909. /**
  66910. * Modifies the data of the tileMaps
  66911. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  66912. * @param pos is the iVector2 Coordinates of the Tile
  66913. * @param tile The SpriteIndex of the new Tile
  66914. */
  66915. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  66916. /**
  66917. * Creates the animationMap texture Buffer
  66918. * @param buffer normally and array of numbers, or a false to generate from scratch
  66919. * @returns RawTexture of the animationMap
  66920. */
  66921. private _createTileAnimationBuffer;
  66922. /**
  66923. * Modifies the data of the animationMap
  66924. * @param cellID is the Index of the Sprite
  66925. * @param _frame is the target Animation frame
  66926. * @param toCell is the Target Index of the next frame of the animation
  66927. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  66928. * @param speed is a global scalar of the time variable on the map.
  66929. */
  66930. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  66931. /**
  66932. * Exports the .tilemaps file
  66933. */
  66934. saveTileMaps(): void;
  66935. /**
  66936. * Imports the .tilemaps file
  66937. * @param url of the .tilemaps file
  66938. */
  66939. loadTileMaps(url: string): void;
  66940. /**
  66941. * Release associated resources
  66942. */
  66943. dispose(): void;
  66944. }
  66945. }
  66946. declare module BABYLON {
  66947. /**
  66948. * Class used to manage multiple sprites of different sizes on the same spritesheet
  66949. * @see http://doc.babylonjs.com/babylon101/sprites
  66950. */
  66951. export class SpritePackedManager extends SpriteManager {
  66952. /** defines the packed manager's name */
  66953. name: string;
  66954. /**
  66955. * Creates a new sprite manager from a packed sprite sheet
  66956. * @param name defines the manager's name
  66957. * @param imgUrl defines the sprite sheet url
  66958. * @param capacity defines the maximum allowed number of sprites
  66959. * @param scene defines the hosting scene
  66960. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  66961. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  66962. * @param samplingMode defines the smapling mode to use with spritesheet
  66963. * @param fromPacked set to true; do not alter
  66964. */
  66965. constructor(
  66966. /** defines the packed manager's name */
  66967. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  66968. }
  66969. }
  66970. declare module BABYLON {
  66971. /**
  66972. * Defines the list of states available for a task inside a AssetsManager
  66973. */
  66974. export enum AssetTaskState {
  66975. /**
  66976. * Initialization
  66977. */
  66978. INIT = 0,
  66979. /**
  66980. * Running
  66981. */
  66982. RUNNING = 1,
  66983. /**
  66984. * Done
  66985. */
  66986. DONE = 2,
  66987. /**
  66988. * Error
  66989. */
  66990. ERROR = 3
  66991. }
  66992. /**
  66993. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  66994. */
  66995. export abstract class AbstractAssetTask {
  66996. /**
  66997. * Task name
  66998. */ name: string;
  66999. /**
  67000. * Callback called when the task is successful
  67001. */
  67002. onSuccess: (task: any) => void;
  67003. /**
  67004. * Callback called when the task is not successful
  67005. */
  67006. onError: (task: any, message?: string, exception?: any) => void;
  67007. /**
  67008. * Creates a new AssetsManager
  67009. * @param name defines the name of the task
  67010. */
  67011. constructor(
  67012. /**
  67013. * Task name
  67014. */ name: string);
  67015. private _isCompleted;
  67016. private _taskState;
  67017. private _errorObject;
  67018. /**
  67019. * Get if the task is completed
  67020. */
  67021. get isCompleted(): boolean;
  67022. /**
  67023. * Gets the current state of the task
  67024. */
  67025. get taskState(): AssetTaskState;
  67026. /**
  67027. * Gets the current error object (if task is in error)
  67028. */
  67029. get errorObject(): {
  67030. message?: string;
  67031. exception?: any;
  67032. };
  67033. /**
  67034. * Internal only
  67035. * @hidden
  67036. */
  67037. _setErrorObject(message?: string, exception?: any): void;
  67038. /**
  67039. * Execute the current task
  67040. * @param scene defines the scene where you want your assets to be loaded
  67041. * @param onSuccess is a callback called when the task is successfully executed
  67042. * @param onError is a callback called if an error occurs
  67043. */
  67044. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67045. /**
  67046. * Execute the current task
  67047. * @param scene defines the scene where you want your assets to be loaded
  67048. * @param onSuccess is a callback called when the task is successfully executed
  67049. * @param onError is a callback called if an error occurs
  67050. */
  67051. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67052. /**
  67053. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  67054. * This can be used with failed tasks that have the reason for failure fixed.
  67055. */
  67056. reset(): void;
  67057. private onErrorCallback;
  67058. private onDoneCallback;
  67059. }
  67060. /**
  67061. * Define the interface used by progress events raised during assets loading
  67062. */
  67063. export interface IAssetsProgressEvent {
  67064. /**
  67065. * Defines the number of remaining tasks to process
  67066. */
  67067. remainingCount: number;
  67068. /**
  67069. * Defines the total number of tasks
  67070. */
  67071. totalCount: number;
  67072. /**
  67073. * Defines the task that was just processed
  67074. */
  67075. task: AbstractAssetTask;
  67076. }
  67077. /**
  67078. * Class used to share progress information about assets loading
  67079. */
  67080. export class AssetsProgressEvent implements IAssetsProgressEvent {
  67081. /**
  67082. * Defines the number of remaining tasks to process
  67083. */
  67084. remainingCount: number;
  67085. /**
  67086. * Defines the total number of tasks
  67087. */
  67088. totalCount: number;
  67089. /**
  67090. * Defines the task that was just processed
  67091. */
  67092. task: AbstractAssetTask;
  67093. /**
  67094. * Creates a AssetsProgressEvent
  67095. * @param remainingCount defines the number of remaining tasks to process
  67096. * @param totalCount defines the total number of tasks
  67097. * @param task defines the task that was just processed
  67098. */
  67099. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  67100. }
  67101. /**
  67102. * Define a task used by AssetsManager to load meshes
  67103. */
  67104. export class MeshAssetTask extends AbstractAssetTask {
  67105. /**
  67106. * Defines the name of the task
  67107. */
  67108. name: string;
  67109. /**
  67110. * Defines the list of mesh's names you want to load
  67111. */
  67112. meshesNames: any;
  67113. /**
  67114. * Defines the root url to use as a base to load your meshes and associated resources
  67115. */
  67116. rootUrl: string;
  67117. /**
  67118. * Defines the filename of the scene to load from
  67119. */
  67120. sceneFilename: string;
  67121. /**
  67122. * Gets the list of loaded meshes
  67123. */
  67124. loadedMeshes: Array<AbstractMesh>;
  67125. /**
  67126. * Gets the list of loaded particle systems
  67127. */
  67128. loadedParticleSystems: Array<IParticleSystem>;
  67129. /**
  67130. * Gets the list of loaded skeletons
  67131. */
  67132. loadedSkeletons: Array<Skeleton>;
  67133. /**
  67134. * Gets the list of loaded animation groups
  67135. */
  67136. loadedAnimationGroups: Array<AnimationGroup>;
  67137. /**
  67138. * Callback called when the task is successful
  67139. */
  67140. onSuccess: (task: MeshAssetTask) => void;
  67141. /**
  67142. * Callback called when the task is successful
  67143. */
  67144. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  67145. /**
  67146. * Creates a new MeshAssetTask
  67147. * @param name defines the name of the task
  67148. * @param meshesNames defines the list of mesh's names you want to load
  67149. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  67150. * @param sceneFilename defines the filename of the scene to load from
  67151. */
  67152. constructor(
  67153. /**
  67154. * Defines the name of the task
  67155. */
  67156. name: string,
  67157. /**
  67158. * Defines the list of mesh's names you want to load
  67159. */
  67160. meshesNames: any,
  67161. /**
  67162. * Defines the root url to use as a base to load your meshes and associated resources
  67163. */
  67164. rootUrl: string,
  67165. /**
  67166. * Defines the filename of the scene to load from
  67167. */
  67168. sceneFilename: string);
  67169. /**
  67170. * Execute the current task
  67171. * @param scene defines the scene where you want your assets to be loaded
  67172. * @param onSuccess is a callback called when the task is successfully executed
  67173. * @param onError is a callback called if an error occurs
  67174. */
  67175. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67176. }
  67177. /**
  67178. * Define a task used by AssetsManager to load text content
  67179. */
  67180. export class TextFileAssetTask extends AbstractAssetTask {
  67181. /**
  67182. * Defines the name of the task
  67183. */
  67184. name: string;
  67185. /**
  67186. * Defines the location of the file to load
  67187. */
  67188. url: string;
  67189. /**
  67190. * Gets the loaded text string
  67191. */
  67192. text: string;
  67193. /**
  67194. * Callback called when the task is successful
  67195. */
  67196. onSuccess: (task: TextFileAssetTask) => void;
  67197. /**
  67198. * Callback called when the task is successful
  67199. */
  67200. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  67201. /**
  67202. * Creates a new TextFileAssetTask object
  67203. * @param name defines the name of the task
  67204. * @param url defines the location of the file to load
  67205. */
  67206. constructor(
  67207. /**
  67208. * Defines the name of the task
  67209. */
  67210. name: string,
  67211. /**
  67212. * Defines the location of the file to load
  67213. */
  67214. url: string);
  67215. /**
  67216. * Execute the current task
  67217. * @param scene defines the scene where you want your assets to be loaded
  67218. * @param onSuccess is a callback called when the task is successfully executed
  67219. * @param onError is a callback called if an error occurs
  67220. */
  67221. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67222. }
  67223. /**
  67224. * Define a task used by AssetsManager to load binary data
  67225. */
  67226. export class BinaryFileAssetTask extends AbstractAssetTask {
  67227. /**
  67228. * Defines the name of the task
  67229. */
  67230. name: string;
  67231. /**
  67232. * Defines the location of the file to load
  67233. */
  67234. url: string;
  67235. /**
  67236. * Gets the lodaded data (as an array buffer)
  67237. */
  67238. data: ArrayBuffer;
  67239. /**
  67240. * Callback called when the task is successful
  67241. */
  67242. onSuccess: (task: BinaryFileAssetTask) => void;
  67243. /**
  67244. * Callback called when the task is successful
  67245. */
  67246. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  67247. /**
  67248. * Creates a new BinaryFileAssetTask object
  67249. * @param name defines the name of the new task
  67250. * @param url defines the location of the file to load
  67251. */
  67252. constructor(
  67253. /**
  67254. * Defines the name of the task
  67255. */
  67256. name: string,
  67257. /**
  67258. * Defines the location of the file to load
  67259. */
  67260. url: string);
  67261. /**
  67262. * Execute the current task
  67263. * @param scene defines the scene where you want your assets to be loaded
  67264. * @param onSuccess is a callback called when the task is successfully executed
  67265. * @param onError is a callback called if an error occurs
  67266. */
  67267. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67268. }
  67269. /**
  67270. * Define a task used by AssetsManager to load images
  67271. */
  67272. export class ImageAssetTask extends AbstractAssetTask {
  67273. /**
  67274. * Defines the name of the task
  67275. */
  67276. name: string;
  67277. /**
  67278. * Defines the location of the image to load
  67279. */
  67280. url: string;
  67281. /**
  67282. * Gets the loaded images
  67283. */
  67284. image: HTMLImageElement;
  67285. /**
  67286. * Callback called when the task is successful
  67287. */
  67288. onSuccess: (task: ImageAssetTask) => void;
  67289. /**
  67290. * Callback called when the task is successful
  67291. */
  67292. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  67293. /**
  67294. * Creates a new ImageAssetTask
  67295. * @param name defines the name of the task
  67296. * @param url defines the location of the image to load
  67297. */
  67298. constructor(
  67299. /**
  67300. * Defines the name of the task
  67301. */
  67302. name: string,
  67303. /**
  67304. * Defines the location of the image to load
  67305. */
  67306. url: string);
  67307. /**
  67308. * Execute the current task
  67309. * @param scene defines the scene where you want your assets to be loaded
  67310. * @param onSuccess is a callback called when the task is successfully executed
  67311. * @param onError is a callback called if an error occurs
  67312. */
  67313. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67314. }
  67315. /**
  67316. * Defines the interface used by texture loading tasks
  67317. */
  67318. export interface ITextureAssetTask<TEX extends BaseTexture> {
  67319. /**
  67320. * Gets the loaded texture
  67321. */
  67322. texture: TEX;
  67323. }
  67324. /**
  67325. * Define a task used by AssetsManager to load 2D textures
  67326. */
  67327. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  67328. /**
  67329. * Defines the name of the task
  67330. */
  67331. name: string;
  67332. /**
  67333. * Defines the location of the file to load
  67334. */
  67335. url: string;
  67336. /**
  67337. * Defines if mipmap should not be generated (default is false)
  67338. */
  67339. noMipmap?: boolean | undefined;
  67340. /**
  67341. * Defines if texture must be inverted on Y axis (default is false)
  67342. */
  67343. invertY?: boolean | undefined;
  67344. /**
  67345. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  67346. */
  67347. samplingMode: number;
  67348. /**
  67349. * Gets the loaded texture
  67350. */
  67351. texture: Texture;
  67352. /**
  67353. * Callback called when the task is successful
  67354. */
  67355. onSuccess: (task: TextureAssetTask) => void;
  67356. /**
  67357. * Callback called when the task is successful
  67358. */
  67359. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  67360. /**
  67361. * Creates a new TextureAssetTask object
  67362. * @param name defines the name of the task
  67363. * @param url defines the location of the file to load
  67364. * @param noMipmap defines if mipmap should not be generated (default is false)
  67365. * @param invertY defines if texture must be inverted on Y axis (default is false)
  67366. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  67367. */
  67368. constructor(
  67369. /**
  67370. * Defines the name of the task
  67371. */
  67372. name: string,
  67373. /**
  67374. * Defines the location of the file to load
  67375. */
  67376. url: string,
  67377. /**
  67378. * Defines if mipmap should not be generated (default is false)
  67379. */
  67380. noMipmap?: boolean | undefined,
  67381. /**
  67382. * Defines if texture must be inverted on Y axis (default is false)
  67383. */
  67384. invertY?: boolean | undefined,
  67385. /**
  67386. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  67387. */
  67388. samplingMode?: number);
  67389. /**
  67390. * Execute the current task
  67391. * @param scene defines the scene where you want your assets to be loaded
  67392. * @param onSuccess is a callback called when the task is successfully executed
  67393. * @param onError is a callback called if an error occurs
  67394. */
  67395. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67396. }
  67397. /**
  67398. * Define a task used by AssetsManager to load cube textures
  67399. */
  67400. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  67401. /**
  67402. * Defines the name of the task
  67403. */
  67404. name: string;
  67405. /**
  67406. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  67407. */
  67408. url: string;
  67409. /**
  67410. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  67411. */
  67412. extensions?: string[] | undefined;
  67413. /**
  67414. * Defines if mipmaps should not be generated (default is false)
  67415. */
  67416. noMipmap?: boolean | undefined;
  67417. /**
  67418. * Defines the explicit list of files (undefined by default)
  67419. */
  67420. files?: string[] | undefined;
  67421. /**
  67422. * Gets the loaded texture
  67423. */
  67424. texture: CubeTexture;
  67425. /**
  67426. * Callback called when the task is successful
  67427. */
  67428. onSuccess: (task: CubeTextureAssetTask) => void;
  67429. /**
  67430. * Callback called when the task is successful
  67431. */
  67432. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  67433. /**
  67434. * Creates a new CubeTextureAssetTask
  67435. * @param name defines the name of the task
  67436. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  67437. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  67438. * @param noMipmap defines if mipmaps should not be generated (default is false)
  67439. * @param files defines the explicit list of files (undefined by default)
  67440. */
  67441. constructor(
  67442. /**
  67443. * Defines the name of the task
  67444. */
  67445. name: string,
  67446. /**
  67447. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  67448. */
  67449. url: string,
  67450. /**
  67451. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  67452. */
  67453. extensions?: string[] | undefined,
  67454. /**
  67455. * Defines if mipmaps should not be generated (default is false)
  67456. */
  67457. noMipmap?: boolean | undefined,
  67458. /**
  67459. * Defines the explicit list of files (undefined by default)
  67460. */
  67461. files?: string[] | undefined);
  67462. /**
  67463. * Execute the current task
  67464. * @param scene defines the scene where you want your assets to be loaded
  67465. * @param onSuccess is a callback called when the task is successfully executed
  67466. * @param onError is a callback called if an error occurs
  67467. */
  67468. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67469. }
  67470. /**
  67471. * Define a task used by AssetsManager to load HDR cube textures
  67472. */
  67473. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  67474. /**
  67475. * Defines the name of the task
  67476. */
  67477. name: string;
  67478. /**
  67479. * Defines the location of the file to load
  67480. */
  67481. url: string;
  67482. /**
  67483. * Defines the desired size (the more it increases the longer the generation will be)
  67484. */
  67485. size: number;
  67486. /**
  67487. * Defines if mipmaps should not be generated (default is false)
  67488. */
  67489. noMipmap: boolean;
  67490. /**
  67491. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  67492. */
  67493. generateHarmonics: boolean;
  67494. /**
  67495. * 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)
  67496. */
  67497. gammaSpace: boolean;
  67498. /**
  67499. * Internal Use Only
  67500. */
  67501. reserved: boolean;
  67502. /**
  67503. * Gets the loaded texture
  67504. */
  67505. texture: HDRCubeTexture;
  67506. /**
  67507. * Callback called when the task is successful
  67508. */
  67509. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  67510. /**
  67511. * Callback called when the task is successful
  67512. */
  67513. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  67514. /**
  67515. * Creates a new HDRCubeTextureAssetTask object
  67516. * @param name defines the name of the task
  67517. * @param url defines the location of the file to load
  67518. * @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.
  67519. * @param noMipmap defines if mipmaps should not be generated (default is false)
  67520. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  67521. * @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)
  67522. * @param reserved Internal use only
  67523. */
  67524. constructor(
  67525. /**
  67526. * Defines the name of the task
  67527. */
  67528. name: string,
  67529. /**
  67530. * Defines the location of the file to load
  67531. */
  67532. url: string,
  67533. /**
  67534. * Defines the desired size (the more it increases the longer the generation will be)
  67535. */
  67536. size: number,
  67537. /**
  67538. * Defines if mipmaps should not be generated (default is false)
  67539. */
  67540. noMipmap?: boolean,
  67541. /**
  67542. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  67543. */
  67544. generateHarmonics?: boolean,
  67545. /**
  67546. * 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)
  67547. */
  67548. gammaSpace?: boolean,
  67549. /**
  67550. * Internal Use Only
  67551. */
  67552. reserved?: boolean);
  67553. /**
  67554. * Execute the current task
  67555. * @param scene defines the scene where you want your assets to be loaded
  67556. * @param onSuccess is a callback called when the task is successfully executed
  67557. * @param onError is a callback called if an error occurs
  67558. */
  67559. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67560. }
  67561. /**
  67562. * Define a task used by AssetsManager to load Equirectangular cube textures
  67563. */
  67564. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  67565. /**
  67566. * Defines the name of the task
  67567. */
  67568. name: string;
  67569. /**
  67570. * Defines the location of the file to load
  67571. */
  67572. url: string;
  67573. /**
  67574. * Defines the desired size (the more it increases the longer the generation will be)
  67575. */
  67576. size: number;
  67577. /**
  67578. * Defines if mipmaps should not be generated (default is false)
  67579. */
  67580. noMipmap: boolean;
  67581. /**
  67582. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  67583. * but the standard material would require them in Gamma space) (default is true)
  67584. */
  67585. gammaSpace: boolean;
  67586. /**
  67587. * Gets the loaded texture
  67588. */
  67589. texture: EquiRectangularCubeTexture;
  67590. /**
  67591. * Callback called when the task is successful
  67592. */
  67593. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  67594. /**
  67595. * Callback called when the task is successful
  67596. */
  67597. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  67598. /**
  67599. * Creates a new EquiRectangularCubeTextureAssetTask object
  67600. * @param name defines the name of the task
  67601. * @param url defines the location of the file to load
  67602. * @param size defines the desired size (the more it increases the longer the generation will be)
  67603. * If the size is omitted this implies you are using a preprocessed cubemap.
  67604. * @param noMipmap defines if mipmaps should not be generated (default is false)
  67605. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  67606. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  67607. * (default is true)
  67608. */
  67609. constructor(
  67610. /**
  67611. * Defines the name of the task
  67612. */
  67613. name: string,
  67614. /**
  67615. * Defines the location of the file to load
  67616. */
  67617. url: string,
  67618. /**
  67619. * Defines the desired size (the more it increases the longer the generation will be)
  67620. */
  67621. size: number,
  67622. /**
  67623. * Defines if mipmaps should not be generated (default is false)
  67624. */
  67625. noMipmap?: boolean,
  67626. /**
  67627. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  67628. * but the standard material would require them in Gamma space) (default is true)
  67629. */
  67630. gammaSpace?: boolean);
  67631. /**
  67632. * Execute the current task
  67633. * @param scene defines the scene where you want your assets to be loaded
  67634. * @param onSuccess is a callback called when the task is successfully executed
  67635. * @param onError is a callback called if an error occurs
  67636. */
  67637. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67638. }
  67639. /**
  67640. * This class can be used to easily import assets into a scene
  67641. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  67642. */
  67643. export class AssetsManager {
  67644. private _scene;
  67645. private _isLoading;
  67646. protected _tasks: AbstractAssetTask[];
  67647. protected _waitingTasksCount: number;
  67648. protected _totalTasksCount: number;
  67649. /**
  67650. * Callback called when all tasks are processed
  67651. */
  67652. onFinish: (tasks: AbstractAssetTask[]) => void;
  67653. /**
  67654. * Callback called when a task is successful
  67655. */
  67656. onTaskSuccess: (task: AbstractAssetTask) => void;
  67657. /**
  67658. * Callback called when a task had an error
  67659. */
  67660. onTaskError: (task: AbstractAssetTask) => void;
  67661. /**
  67662. * Callback called when a task is done (whatever the result is)
  67663. */
  67664. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  67665. /**
  67666. * Observable called when all tasks are processed
  67667. */
  67668. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  67669. /**
  67670. * Observable called when a task had an error
  67671. */
  67672. onTaskErrorObservable: Observable<AbstractAssetTask>;
  67673. /**
  67674. * Observable called when all tasks were executed
  67675. */
  67676. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  67677. /**
  67678. * Observable called when a task is done (whatever the result is)
  67679. */
  67680. onProgressObservable: Observable<IAssetsProgressEvent>;
  67681. /**
  67682. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  67683. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  67684. */
  67685. useDefaultLoadingScreen: boolean;
  67686. /**
  67687. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  67688. * when all assets have been downloaded.
  67689. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  67690. */
  67691. autoHideLoadingUI: boolean;
  67692. /**
  67693. * Creates a new AssetsManager
  67694. * @param scene defines the scene to work on
  67695. */
  67696. constructor(scene: Scene);
  67697. /**
  67698. * Add a MeshAssetTask to the list of active tasks
  67699. * @param taskName defines the name of the new task
  67700. * @param meshesNames defines the name of meshes to load
  67701. * @param rootUrl defines the root url to use to locate files
  67702. * @param sceneFilename defines the filename of the scene file
  67703. * @returns a new MeshAssetTask object
  67704. */
  67705. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  67706. /**
  67707. * Add a TextFileAssetTask to the list of active tasks
  67708. * @param taskName defines the name of the new task
  67709. * @param url defines the url of the file to load
  67710. * @returns a new TextFileAssetTask object
  67711. */
  67712. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  67713. /**
  67714. * Add a BinaryFileAssetTask to the list of active tasks
  67715. * @param taskName defines the name of the new task
  67716. * @param url defines the url of the file to load
  67717. * @returns a new BinaryFileAssetTask object
  67718. */
  67719. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  67720. /**
  67721. * Add a ImageAssetTask to the list of active tasks
  67722. * @param taskName defines the name of the new task
  67723. * @param url defines the url of the file to load
  67724. * @returns a new ImageAssetTask object
  67725. */
  67726. addImageTask(taskName: string, url: string): ImageAssetTask;
  67727. /**
  67728. * Add a TextureAssetTask to the list of active tasks
  67729. * @param taskName defines the name of the new task
  67730. * @param url defines the url of the file to load
  67731. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  67732. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  67733. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  67734. * @returns a new TextureAssetTask object
  67735. */
  67736. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  67737. /**
  67738. * Add a CubeTextureAssetTask to the list of active tasks
  67739. * @param taskName defines the name of the new task
  67740. * @param url defines the url of the file to load
  67741. * @param extensions defines the extension to use to load the cube map (can be null)
  67742. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  67743. * @param files defines the list of files to load (can be null)
  67744. * @returns a new CubeTextureAssetTask object
  67745. */
  67746. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  67747. /**
  67748. *
  67749. * Add a HDRCubeTextureAssetTask to the list of active tasks
  67750. * @param taskName defines the name of the new task
  67751. * @param url defines the url of the file to load
  67752. * @param size defines the size you want for the cubemap (can be null)
  67753. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  67754. * @param generateHarmonics defines if you want to automatically generate (true by default)
  67755. * @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)
  67756. * @param reserved Internal use only
  67757. * @returns a new HDRCubeTextureAssetTask object
  67758. */
  67759. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  67760. /**
  67761. *
  67762. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  67763. * @param taskName defines the name of the new task
  67764. * @param url defines the url of the file to load
  67765. * @param size defines the size you want for the cubemap (can be null)
  67766. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  67767. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  67768. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  67769. * @returns a new EquiRectangularCubeTextureAssetTask object
  67770. */
  67771. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  67772. /**
  67773. * Remove a task from the assets manager.
  67774. * @param task the task to remove
  67775. */
  67776. removeTask(task: AbstractAssetTask): void;
  67777. private _decreaseWaitingTasksCount;
  67778. private _runTask;
  67779. /**
  67780. * Reset the AssetsManager and remove all tasks
  67781. * @return the current instance of the AssetsManager
  67782. */
  67783. reset(): AssetsManager;
  67784. /**
  67785. * Start the loading process
  67786. * @return the current instance of the AssetsManager
  67787. */
  67788. load(): AssetsManager;
  67789. /**
  67790. * Start the loading process as an async operation
  67791. * @return a promise returning the list of failed tasks
  67792. */
  67793. loadAsync(): Promise<void>;
  67794. }
  67795. }
  67796. declare module BABYLON {
  67797. /**
  67798. * Wrapper class for promise with external resolve and reject.
  67799. */
  67800. export class Deferred<T> {
  67801. /**
  67802. * The promise associated with this deferred object.
  67803. */
  67804. readonly promise: Promise<T>;
  67805. private _resolve;
  67806. private _reject;
  67807. /**
  67808. * The resolve method of the promise associated with this deferred object.
  67809. */
  67810. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  67811. /**
  67812. * The reject method of the promise associated with this deferred object.
  67813. */
  67814. get reject(): (reason?: any) => void;
  67815. /**
  67816. * Constructor for this deferred object.
  67817. */
  67818. constructor();
  67819. }
  67820. }
  67821. declare module BABYLON {
  67822. /**
  67823. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  67824. */
  67825. export class MeshExploder {
  67826. private _centerMesh;
  67827. private _meshes;
  67828. private _meshesOrigins;
  67829. private _toCenterVectors;
  67830. private _scaledDirection;
  67831. private _newPosition;
  67832. private _centerPosition;
  67833. /**
  67834. * Explodes meshes from a center mesh.
  67835. * @param meshes The meshes to explode.
  67836. * @param centerMesh The mesh to be center of explosion.
  67837. */
  67838. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  67839. private _setCenterMesh;
  67840. /**
  67841. * Get class name
  67842. * @returns "MeshExploder"
  67843. */
  67844. getClassName(): string;
  67845. /**
  67846. * "Exploded meshes"
  67847. * @returns Array of meshes with the centerMesh at index 0.
  67848. */
  67849. getMeshes(): Array<Mesh>;
  67850. /**
  67851. * Explodes meshes giving a specific direction
  67852. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  67853. */
  67854. explode(direction?: number): void;
  67855. }
  67856. }
  67857. declare module BABYLON {
  67858. /**
  67859. * Class used to help managing file picking and drag'n'drop
  67860. */
  67861. export class FilesInput {
  67862. /**
  67863. * List of files ready to be loaded
  67864. */
  67865. static get FilesToLoad(): {
  67866. [key: string]: File;
  67867. };
  67868. /**
  67869. * Callback called when a file is processed
  67870. */
  67871. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  67872. private _engine;
  67873. private _currentScene;
  67874. private _sceneLoadedCallback;
  67875. private _progressCallback;
  67876. private _additionalRenderLoopLogicCallback;
  67877. private _textureLoadingCallback;
  67878. private _startingProcessingFilesCallback;
  67879. private _onReloadCallback;
  67880. private _errorCallback;
  67881. private _elementToMonitor;
  67882. private _sceneFileToLoad;
  67883. private _filesToLoad;
  67884. /**
  67885. * Creates a new FilesInput
  67886. * @param engine defines the rendering engine
  67887. * @param scene defines the hosting scene
  67888. * @param sceneLoadedCallback callback called when scene is loaded
  67889. * @param progressCallback callback called to track progress
  67890. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  67891. * @param textureLoadingCallback callback called when a texture is loading
  67892. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  67893. * @param onReloadCallback callback called when a reload is requested
  67894. * @param errorCallback callback call if an error occurs
  67895. */
  67896. 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);
  67897. private _dragEnterHandler;
  67898. private _dragOverHandler;
  67899. private _dropHandler;
  67900. /**
  67901. * Calls this function to listen to drag'n'drop events on a specific DOM element
  67902. * @param elementToMonitor defines the DOM element to track
  67903. */
  67904. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  67905. /**
  67906. * Release all associated resources
  67907. */
  67908. dispose(): void;
  67909. private renderFunction;
  67910. private drag;
  67911. private drop;
  67912. private _traverseFolder;
  67913. private _processFiles;
  67914. /**
  67915. * Load files from a drop event
  67916. * @param event defines the drop event to use as source
  67917. */
  67918. loadFiles(event: any): void;
  67919. private _processReload;
  67920. /**
  67921. * Reload the current scene from the loaded files
  67922. */
  67923. reload(): void;
  67924. }
  67925. }
  67926. declare module BABYLON {
  67927. /**
  67928. * Defines the root class used to create scene optimization to use with SceneOptimizer
  67929. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  67930. */
  67931. export class SceneOptimization {
  67932. /**
  67933. * Defines the priority of this optimization (0 by default which means first in the list)
  67934. */
  67935. priority: number;
  67936. /**
  67937. * Gets a string describing the action executed by the current optimization
  67938. * @returns description string
  67939. */
  67940. getDescription(): string;
  67941. /**
  67942. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  67943. * @param scene defines the current scene where to apply this optimization
  67944. * @param optimizer defines the current optimizer
  67945. * @returns true if everything that can be done was applied
  67946. */
  67947. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  67948. /**
  67949. * Creates the SceneOptimization object
  67950. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  67951. * @param desc defines the description associated with the optimization
  67952. */
  67953. constructor(
  67954. /**
  67955. * Defines the priority of this optimization (0 by default which means first in the list)
  67956. */
  67957. priority?: number);
  67958. }
  67959. /**
  67960. * Defines an optimization used to reduce the size of render target textures
  67961. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  67962. */
  67963. export class TextureOptimization extends SceneOptimization {
  67964. /**
  67965. * Defines the priority of this optimization (0 by default which means first in the list)
  67966. */
  67967. priority: number;
  67968. /**
  67969. * 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
  67970. */
  67971. maximumSize: number;
  67972. /**
  67973. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  67974. */
  67975. step: number;
  67976. /**
  67977. * Gets a string describing the action executed by the current optimization
  67978. * @returns description string
  67979. */
  67980. getDescription(): string;
  67981. /**
  67982. * Creates the TextureOptimization object
  67983. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  67984. * @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
  67985. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  67986. */
  67987. constructor(
  67988. /**
  67989. * Defines the priority of this optimization (0 by default which means first in the list)
  67990. */
  67991. priority?: number,
  67992. /**
  67993. * 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
  67994. */
  67995. maximumSize?: number,
  67996. /**
  67997. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  67998. */
  67999. step?: number);
  68000. /**
  68001. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68002. * @param scene defines the current scene where to apply this optimization
  68003. * @param optimizer defines the current optimizer
  68004. * @returns true if everything that can be done was applied
  68005. */
  68006. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68007. }
  68008. /**
  68009. * Defines an optimization used to increase or decrease the rendering resolution
  68010. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68011. */
  68012. export class HardwareScalingOptimization extends SceneOptimization {
  68013. /**
  68014. * Defines the priority of this optimization (0 by default which means first in the list)
  68015. */
  68016. priority: number;
  68017. /**
  68018. * Defines the maximum scale to use (2 by default)
  68019. */
  68020. maximumScale: number;
  68021. /**
  68022. * Defines the step to use between two passes (0.5 by default)
  68023. */
  68024. step: number;
  68025. private _currentScale;
  68026. private _directionOffset;
  68027. /**
  68028. * Gets a string describing the action executed by the current optimization
  68029. * @return description string
  68030. */
  68031. getDescription(): string;
  68032. /**
  68033. * Creates the HardwareScalingOptimization object
  68034. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  68035. * @param maximumScale defines the maximum scale to use (2 by default)
  68036. * @param step defines the step to use between two passes (0.5 by default)
  68037. */
  68038. constructor(
  68039. /**
  68040. * Defines the priority of this optimization (0 by default which means first in the list)
  68041. */
  68042. priority?: number,
  68043. /**
  68044. * Defines the maximum scale to use (2 by default)
  68045. */
  68046. maximumScale?: number,
  68047. /**
  68048. * Defines the step to use between two passes (0.5 by default)
  68049. */
  68050. step?: number);
  68051. /**
  68052. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68053. * @param scene defines the current scene where to apply this optimization
  68054. * @param optimizer defines the current optimizer
  68055. * @returns true if everything that can be done was applied
  68056. */
  68057. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68058. }
  68059. /**
  68060. * Defines an optimization used to remove shadows
  68061. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68062. */
  68063. export class ShadowsOptimization extends SceneOptimization {
  68064. /**
  68065. * Gets a string describing the action executed by the current optimization
  68066. * @return description string
  68067. */
  68068. getDescription(): string;
  68069. /**
  68070. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68071. * @param scene defines the current scene where to apply this optimization
  68072. * @param optimizer defines the current optimizer
  68073. * @returns true if everything that can be done was applied
  68074. */
  68075. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68076. }
  68077. /**
  68078. * Defines an optimization used to turn post-processes off
  68079. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68080. */
  68081. export class PostProcessesOptimization extends SceneOptimization {
  68082. /**
  68083. * Gets a string describing the action executed by the current optimization
  68084. * @return description string
  68085. */
  68086. getDescription(): string;
  68087. /**
  68088. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68089. * @param scene defines the current scene where to apply this optimization
  68090. * @param optimizer defines the current optimizer
  68091. * @returns true if everything that can be done was applied
  68092. */
  68093. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68094. }
  68095. /**
  68096. * Defines an optimization used to turn lens flares off
  68097. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68098. */
  68099. export class LensFlaresOptimization extends SceneOptimization {
  68100. /**
  68101. * Gets a string describing the action executed by the current optimization
  68102. * @return description string
  68103. */
  68104. getDescription(): string;
  68105. /**
  68106. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68107. * @param scene defines the current scene where to apply this optimization
  68108. * @param optimizer defines the current optimizer
  68109. * @returns true if everything that can be done was applied
  68110. */
  68111. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68112. }
  68113. /**
  68114. * Defines an optimization based on user defined callback.
  68115. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68116. */
  68117. export class CustomOptimization extends SceneOptimization {
  68118. /**
  68119. * Callback called to apply the custom optimization.
  68120. */
  68121. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  68122. /**
  68123. * Callback called to get custom description
  68124. */
  68125. onGetDescription: () => string;
  68126. /**
  68127. * Gets a string describing the action executed by the current optimization
  68128. * @returns description string
  68129. */
  68130. getDescription(): string;
  68131. /**
  68132. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68133. * @param scene defines the current scene where to apply this optimization
  68134. * @param optimizer defines the current optimizer
  68135. * @returns true if everything that can be done was applied
  68136. */
  68137. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68138. }
  68139. /**
  68140. * Defines an optimization used to turn particles off
  68141. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68142. */
  68143. export class ParticlesOptimization extends SceneOptimization {
  68144. /**
  68145. * Gets a string describing the action executed by the current optimization
  68146. * @return description string
  68147. */
  68148. getDescription(): string;
  68149. /**
  68150. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68151. * @param scene defines the current scene where to apply this optimization
  68152. * @param optimizer defines the current optimizer
  68153. * @returns true if everything that can be done was applied
  68154. */
  68155. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68156. }
  68157. /**
  68158. * Defines an optimization used to turn render targets off
  68159. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68160. */
  68161. export class RenderTargetsOptimization extends SceneOptimization {
  68162. /**
  68163. * Gets a string describing the action executed by the current optimization
  68164. * @return description string
  68165. */
  68166. getDescription(): string;
  68167. /**
  68168. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68169. * @param scene defines the current scene where to apply this optimization
  68170. * @param optimizer defines the current optimizer
  68171. * @returns true if everything that can be done was applied
  68172. */
  68173. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68174. }
  68175. /**
  68176. * Defines an optimization used to merge meshes with compatible materials
  68177. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68178. */
  68179. export class MergeMeshesOptimization extends SceneOptimization {
  68180. private static _UpdateSelectionTree;
  68181. /**
  68182. * Gets or sets a boolean which defines if optimization octree has to be updated
  68183. */
  68184. static get UpdateSelectionTree(): boolean;
  68185. /**
  68186. * Gets or sets a boolean which defines if optimization octree has to be updated
  68187. */
  68188. static set UpdateSelectionTree(value: boolean);
  68189. /**
  68190. * Gets a string describing the action executed by the current optimization
  68191. * @return description string
  68192. */
  68193. getDescription(): string;
  68194. private _canBeMerged;
  68195. /**
  68196. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68197. * @param scene defines the current scene where to apply this optimization
  68198. * @param optimizer defines the current optimizer
  68199. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  68200. * @returns true if everything that can be done was applied
  68201. */
  68202. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  68203. }
  68204. /**
  68205. * Defines a list of options used by SceneOptimizer
  68206. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68207. */
  68208. export class SceneOptimizerOptions {
  68209. /**
  68210. * Defines the target frame rate to reach (60 by default)
  68211. */
  68212. targetFrameRate: number;
  68213. /**
  68214. * Defines the interval between two checkes (2000ms by default)
  68215. */
  68216. trackerDuration: number;
  68217. /**
  68218. * Gets the list of optimizations to apply
  68219. */
  68220. optimizations: SceneOptimization[];
  68221. /**
  68222. * Creates a new list of options used by SceneOptimizer
  68223. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  68224. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  68225. */
  68226. constructor(
  68227. /**
  68228. * Defines the target frame rate to reach (60 by default)
  68229. */
  68230. targetFrameRate?: number,
  68231. /**
  68232. * Defines the interval between two checkes (2000ms by default)
  68233. */
  68234. trackerDuration?: number);
  68235. /**
  68236. * Add a new optimization
  68237. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  68238. * @returns the current SceneOptimizerOptions
  68239. */
  68240. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  68241. /**
  68242. * Add a new custom optimization
  68243. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  68244. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  68245. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  68246. * @returns the current SceneOptimizerOptions
  68247. */
  68248. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  68249. /**
  68250. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  68251. * @param targetFrameRate defines the target frame rate (60 by default)
  68252. * @returns a SceneOptimizerOptions object
  68253. */
  68254. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  68255. /**
  68256. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  68257. * @param targetFrameRate defines the target frame rate (60 by default)
  68258. * @returns a SceneOptimizerOptions object
  68259. */
  68260. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  68261. /**
  68262. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  68263. * @param targetFrameRate defines the target frame rate (60 by default)
  68264. * @returns a SceneOptimizerOptions object
  68265. */
  68266. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  68267. }
  68268. /**
  68269. * Class used to run optimizations in order to reach a target frame rate
  68270. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68271. */
  68272. export class SceneOptimizer implements IDisposable {
  68273. private _isRunning;
  68274. private _options;
  68275. private _scene;
  68276. private _currentPriorityLevel;
  68277. private _targetFrameRate;
  68278. private _trackerDuration;
  68279. private _currentFrameRate;
  68280. private _sceneDisposeObserver;
  68281. private _improvementMode;
  68282. /**
  68283. * Defines an observable called when the optimizer reaches the target frame rate
  68284. */
  68285. onSuccessObservable: Observable<SceneOptimizer>;
  68286. /**
  68287. * Defines an observable called when the optimizer enables an optimization
  68288. */
  68289. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  68290. /**
  68291. * Defines an observable called when the optimizer is not able to reach the target frame rate
  68292. */
  68293. onFailureObservable: Observable<SceneOptimizer>;
  68294. /**
  68295. * Gets a boolean indicating if the optimizer is in improvement mode
  68296. */
  68297. get isInImprovementMode(): boolean;
  68298. /**
  68299. * Gets the current priority level (0 at start)
  68300. */
  68301. get currentPriorityLevel(): number;
  68302. /**
  68303. * Gets the current frame rate checked by the SceneOptimizer
  68304. */
  68305. get currentFrameRate(): number;
  68306. /**
  68307. * Gets or sets the current target frame rate (60 by default)
  68308. */
  68309. get targetFrameRate(): number;
  68310. /**
  68311. * Gets or sets the current target frame rate (60 by default)
  68312. */
  68313. set targetFrameRate(value: number);
  68314. /**
  68315. * Gets or sets the current interval between two checks (every 2000ms by default)
  68316. */
  68317. get trackerDuration(): number;
  68318. /**
  68319. * Gets or sets the current interval between two checks (every 2000ms by default)
  68320. */
  68321. set trackerDuration(value: number);
  68322. /**
  68323. * Gets the list of active optimizations
  68324. */
  68325. get optimizations(): SceneOptimization[];
  68326. /**
  68327. * Creates a new SceneOptimizer
  68328. * @param scene defines the scene to work on
  68329. * @param options defines the options to use with the SceneOptimizer
  68330. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  68331. * @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)
  68332. */
  68333. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  68334. /**
  68335. * Stops the current optimizer
  68336. */
  68337. stop(): void;
  68338. /**
  68339. * Reset the optimizer to initial step (current priority level = 0)
  68340. */
  68341. reset(): void;
  68342. /**
  68343. * Start the optimizer. By default it will try to reach a specific framerate
  68344. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  68345. */
  68346. start(): void;
  68347. private _checkCurrentState;
  68348. /**
  68349. * Release all resources
  68350. */
  68351. dispose(): void;
  68352. /**
  68353. * Helper function to create a SceneOptimizer with one single line of code
  68354. * @param scene defines the scene to work on
  68355. * @param options defines the options to use with the SceneOptimizer
  68356. * @param onSuccess defines a callback to call on success
  68357. * @param onFailure defines a callback to call on failure
  68358. * @returns the new SceneOptimizer object
  68359. */
  68360. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  68361. }
  68362. }
  68363. declare module BABYLON {
  68364. /**
  68365. * Class used to serialize a scene into a string
  68366. */
  68367. export class SceneSerializer {
  68368. /**
  68369. * Clear cache used by a previous serialization
  68370. */
  68371. static ClearCache(): void;
  68372. /**
  68373. * Serialize a scene into a JSON compatible object
  68374. * @param scene defines the scene to serialize
  68375. * @returns a JSON compatible object
  68376. */
  68377. static Serialize(scene: Scene): any;
  68378. /**
  68379. * Serialize a mesh into a JSON compatible object
  68380. * @param toSerialize defines the mesh to serialize
  68381. * @param withParents defines if parents must be serialized as well
  68382. * @param withChildren defines if children must be serialized as well
  68383. * @returns a JSON compatible object
  68384. */
  68385. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  68386. }
  68387. }
  68388. declare module BABYLON {
  68389. /**
  68390. * Class used to host texture specific utilities
  68391. */
  68392. export class TextureTools {
  68393. /**
  68394. * Uses the GPU to create a copy texture rescaled at a given size
  68395. * @param texture Texture to copy from
  68396. * @param width defines the desired width
  68397. * @param height defines the desired height
  68398. * @param useBilinearMode defines if bilinear mode has to be used
  68399. * @return the generated texture
  68400. */
  68401. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  68402. }
  68403. }
  68404. declare module BABYLON {
  68405. /**
  68406. * This represents the different options available for the video capture.
  68407. */
  68408. export interface VideoRecorderOptions {
  68409. /** Defines the mime type of the video. */
  68410. mimeType: string;
  68411. /** Defines the FPS the video should be recorded at. */
  68412. fps: number;
  68413. /** Defines the chunk size for the recording data. */
  68414. recordChunckSize: number;
  68415. /** The audio tracks to attach to the recording. */
  68416. audioTracks?: MediaStreamTrack[];
  68417. }
  68418. /**
  68419. * This can help with recording videos from BabylonJS.
  68420. * This is based on the available WebRTC functionalities of the browser.
  68421. *
  68422. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  68423. */
  68424. export class VideoRecorder {
  68425. private static readonly _defaultOptions;
  68426. /**
  68427. * Returns whether or not the VideoRecorder is available in your browser.
  68428. * @param engine Defines the Babylon Engine.
  68429. * @returns true if supported otherwise false.
  68430. */
  68431. static IsSupported(engine: Engine): boolean;
  68432. private readonly _options;
  68433. private _canvas;
  68434. private _mediaRecorder;
  68435. private _recordedChunks;
  68436. private _fileName;
  68437. private _resolve;
  68438. private _reject;
  68439. /**
  68440. * True when a recording is already in progress.
  68441. */
  68442. get isRecording(): boolean;
  68443. /**
  68444. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  68445. * @param engine Defines the BabylonJS Engine you wish to record.
  68446. * @param options Defines options that can be used to customize the capture.
  68447. */
  68448. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  68449. /**
  68450. * Stops the current recording before the default capture timeout passed in the startRecording function.
  68451. */
  68452. stopRecording(): void;
  68453. /**
  68454. * Starts recording the canvas for a max duration specified in parameters.
  68455. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  68456. * If null no automatic download will start and you can rely on the promise to get the data back.
  68457. * @param maxDuration Defines the maximum recording time in seconds.
  68458. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  68459. * @return A promise callback at the end of the recording with the video data in Blob.
  68460. */
  68461. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  68462. /**
  68463. * Releases internal resources used during the recording.
  68464. */
  68465. dispose(): void;
  68466. private _handleDataAvailable;
  68467. private _handleError;
  68468. private _handleStop;
  68469. }
  68470. }
  68471. declare module BABYLON {
  68472. /**
  68473. * Class containing a set of static utilities functions for screenshots
  68474. */
  68475. export class ScreenshotTools {
  68476. /**
  68477. * Captures a screenshot of the current rendering
  68478. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  68479. * @param engine defines the rendering engine
  68480. * @param camera defines the source camera
  68481. * @param size This parameter can be set to a single number or to an object with the
  68482. * following (optional) properties: precision, width, height. If a single number is passed,
  68483. * it will be used for both width and height. If an object is passed, the screenshot size
  68484. * will be derived from the parameters. The precision property is a multiplier allowing
  68485. * rendering at a higher or lower resolution
  68486. * @param successCallback defines the callback receives a single parameter which contains the
  68487. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  68488. * src parameter of an <img> to display it
  68489. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  68490. * Check your browser for supported MIME types
  68491. */
  68492. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  68493. /**
  68494. * Captures a screenshot of the current rendering
  68495. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  68496. * @param engine defines the rendering engine
  68497. * @param camera defines the source camera
  68498. * @param size This parameter can be set to a single number or to an object with the
  68499. * following (optional) properties: precision, width, height. If a single number is passed,
  68500. * it will be used for both width and height. If an object is passed, the screenshot size
  68501. * will be derived from the parameters. The precision property is a multiplier allowing
  68502. * rendering at a higher or lower resolution
  68503. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  68504. * Check your browser for supported MIME types
  68505. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  68506. * to the src parameter of an <img> to display it
  68507. */
  68508. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  68509. /**
  68510. * Generates an image screenshot from the specified camera.
  68511. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  68512. * @param engine The engine to use for rendering
  68513. * @param camera The camera to use for rendering
  68514. * @param size This parameter can be set to a single number or to an object with the
  68515. * following (optional) properties: precision, width, height. If a single number is passed,
  68516. * it will be used for both width and height. If an object is passed, the screenshot size
  68517. * will be derived from the parameters. The precision property is a multiplier allowing
  68518. * rendering at a higher or lower resolution
  68519. * @param successCallback The callback receives a single parameter which contains the
  68520. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  68521. * src parameter of an <img> to display it
  68522. * @param mimeType The MIME type of the screenshot image (default: image/png).
  68523. * Check your browser for supported MIME types
  68524. * @param samples Texture samples (default: 1)
  68525. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  68526. * @param fileName A name for for the downloaded file.
  68527. */
  68528. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  68529. /**
  68530. * Generates an image screenshot from the specified camera.
  68531. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  68532. * @param engine The engine to use for rendering
  68533. * @param camera The camera to use for rendering
  68534. * @param size This parameter can be set to a single number or to an object with the
  68535. * following (optional) properties: precision, width, height. If a single number is passed,
  68536. * it will be used for both width and height. If an object is passed, the screenshot size
  68537. * will be derived from the parameters. The precision property is a multiplier allowing
  68538. * rendering at a higher or lower resolution
  68539. * @param mimeType The MIME type of the screenshot image (default: image/png).
  68540. * Check your browser for supported MIME types
  68541. * @param samples Texture samples (default: 1)
  68542. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  68543. * @param fileName A name for for the downloaded file.
  68544. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  68545. * to the src parameter of an <img> to display it
  68546. */
  68547. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  68548. /**
  68549. * Gets height and width for screenshot size
  68550. * @private
  68551. */
  68552. private static _getScreenshotSize;
  68553. }
  68554. }
  68555. declare module BABYLON {
  68556. /**
  68557. * Interface for a data buffer
  68558. */
  68559. export interface IDataBuffer {
  68560. /**
  68561. * Reads bytes from the data buffer.
  68562. * @param byteOffset The byte offset to read
  68563. * @param byteLength The byte length to read
  68564. * @returns A promise that resolves when the bytes are read
  68565. */
  68566. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  68567. /**
  68568. * The byte length of the buffer.
  68569. */
  68570. readonly byteLength: number;
  68571. }
  68572. /**
  68573. * Utility class for reading from a data buffer
  68574. */
  68575. export class DataReader {
  68576. /**
  68577. * The data buffer associated with this data reader.
  68578. */
  68579. readonly buffer: IDataBuffer;
  68580. /**
  68581. * The current byte offset from the beginning of the data buffer.
  68582. */
  68583. byteOffset: number;
  68584. private _dataView;
  68585. private _dataByteOffset;
  68586. /**
  68587. * Constructor
  68588. * @param buffer The buffer to read
  68589. */
  68590. constructor(buffer: IDataBuffer);
  68591. /**
  68592. * Loads the given byte length.
  68593. * @param byteLength The byte length to load
  68594. * @returns A promise that resolves when the load is complete
  68595. */
  68596. loadAsync(byteLength: number): Promise<void>;
  68597. /**
  68598. * Read a unsigned 32-bit integer from the currently loaded data range.
  68599. * @returns The 32-bit integer read
  68600. */
  68601. readUint32(): number;
  68602. /**
  68603. * Read a byte array from the currently loaded data range.
  68604. * @param byteLength The byte length to read
  68605. * @returns The byte array read
  68606. */
  68607. readUint8Array(byteLength: number): Uint8Array;
  68608. /**
  68609. * Read a string from the currently loaded data range.
  68610. * @param byteLength The byte length to read
  68611. * @returns The string read
  68612. */
  68613. readString(byteLength: number): string;
  68614. /**
  68615. * Skips the given byte length the currently loaded data range.
  68616. * @param byteLength The byte length to skip
  68617. */
  68618. skipBytes(byteLength: number): void;
  68619. }
  68620. }
  68621. declare module BABYLON {
  68622. /**
  68623. * Options used for hit testing
  68624. */
  68625. export interface IWebXRHitTestOptions {
  68626. /**
  68627. * Only test when user interacted with the scene. Default - hit test every frame
  68628. */
  68629. testOnPointerDownOnly?: boolean;
  68630. /**
  68631. * The node to use to transform the local results to world coordinates
  68632. */
  68633. worldParentNode?: TransformNode;
  68634. }
  68635. /**
  68636. * Interface defining the babylon result of raycasting/hit-test
  68637. */
  68638. export interface IWebXRHitResult {
  68639. /**
  68640. * The native hit test result
  68641. */
  68642. xrHitResult: XRHitResult;
  68643. /**
  68644. * Transformation matrix that can be applied to a node that will put it in the hit point location
  68645. */
  68646. transformationMatrix: Matrix;
  68647. }
  68648. /**
  68649. * The currently-working hit-test module.
  68650. * Hit test (or raycasting) is used to interact with the real world.
  68651. * For further information read here - https://github.com/immersive-web/hit-test
  68652. */
  68653. export class WebXRHitTestLegacy extends WebXRAbstractFeature {
  68654. /**
  68655. * options to use when constructing this feature
  68656. */
  68657. readonly options: IWebXRHitTestOptions;
  68658. /**
  68659. * The module's name
  68660. */
  68661. static readonly Name: string;
  68662. /**
  68663. * The (Babylon) version of this module.
  68664. * This is an integer representing the implementation version.
  68665. * This number does not correspond to the webxr specs version
  68666. */
  68667. static readonly Version: number;
  68668. /**
  68669. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  68670. * @param event the (select) event to use to select with
  68671. * @param referenceSpace the reference space to use for this hit test
  68672. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  68673. */
  68674. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  68675. /**
  68676. * execute a hit test with an XR Ray
  68677. *
  68678. * @param xrSession a native xrSession that will execute this hit test
  68679. * @param xrRay the ray (position and direction) to use for raycasting
  68680. * @param referenceSpace native XR reference space to use for the hit-test
  68681. * @param filter filter function that will filter the results
  68682. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  68683. */
  68684. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  68685. /**
  68686. * Triggered when new babylon (transformed) hit test results are available
  68687. */
  68688. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  68689. private _onSelectEnabled;
  68690. /**
  68691. * Creates a new instance of the (legacy version) hit test feature
  68692. * @param _xrSessionManager an instance of WebXRSessionManager
  68693. * @param options options to use when constructing this feature
  68694. */
  68695. constructor(_xrSessionManager: WebXRSessionManager,
  68696. /**
  68697. * options to use when constructing this feature
  68698. */
  68699. options?: IWebXRHitTestOptions);
  68700. /**
  68701. * Populated with the last native XR Hit Results
  68702. */
  68703. lastNativeXRHitResults: XRHitResult[];
  68704. /**
  68705. * attach this feature
  68706. * Will usually be called by the features manager
  68707. *
  68708. * @returns true if successful.
  68709. */
  68710. attach(): boolean;
  68711. /**
  68712. * detach this feature.
  68713. * Will usually be called by the features manager
  68714. *
  68715. * @returns true if successful.
  68716. */
  68717. detach(): boolean;
  68718. private _onHitTestResults;
  68719. private _origin;
  68720. private _direction;
  68721. private _mat;
  68722. protected _onXRFrame(frame: XRFrame): void;
  68723. private _onSelect;
  68724. /**
  68725. * Dispose this feature and all of the resources attached
  68726. */
  68727. dispose(): void;
  68728. }
  68729. }
  68730. declare module BABYLON {
  68731. /**
  68732. * Options used in the plane detector module
  68733. */
  68734. export interface IWebXRPlaneDetectorOptions {
  68735. /**
  68736. * The node to use to transform the local results to world coordinates
  68737. */
  68738. worldParentNode?: TransformNode;
  68739. }
  68740. /**
  68741. * A babylon interface for a webxr plane.
  68742. * A Plane is actually a polygon, built from N points in space
  68743. *
  68744. * Supported in chrome 79, not supported in canary 81 ATM
  68745. */
  68746. export interface IWebXRPlane {
  68747. /**
  68748. * a babylon-assigned ID for this polygon
  68749. */
  68750. id: number;
  68751. /**
  68752. * the native xr-plane object
  68753. */
  68754. xrPlane: XRPlane;
  68755. /**
  68756. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  68757. */
  68758. polygonDefinition: Array<Vector3>;
  68759. /**
  68760. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  68761. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  68762. */
  68763. transformationMatrix: Matrix;
  68764. }
  68765. /**
  68766. * The plane detector is used to detect planes in the real world when in AR
  68767. * For more information see https://github.com/immersive-web/real-world-geometry/
  68768. */
  68769. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  68770. private _options;
  68771. /**
  68772. * The module's name
  68773. */
  68774. static readonly Name: string;
  68775. /**
  68776. * The (Babylon) version of this module.
  68777. * This is an integer representing the implementation version.
  68778. * This number does not correspond to the webxr specs version
  68779. */
  68780. static readonly Version: number;
  68781. /**
  68782. * Observers registered here will be executed when a new plane was added to the session
  68783. */
  68784. onPlaneAddedObservable: Observable<IWebXRPlane>;
  68785. /**
  68786. * Observers registered here will be executed when a plane is no longer detected in the session
  68787. */
  68788. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  68789. /**
  68790. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  68791. * This can execute N times every frame
  68792. */
  68793. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  68794. private _enabled;
  68795. private _detectedPlanes;
  68796. private _lastFrameDetected;
  68797. /**
  68798. * construct a new Plane Detector
  68799. * @param _xrSessionManager an instance of xr Session manager
  68800. * @param _options configuration to use when constructing this feature
  68801. */
  68802. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  68803. private _init;
  68804. protected _onXRFrame(frame: XRFrame): void;
  68805. /**
  68806. * Dispose this feature and all of the resources attached
  68807. */
  68808. dispose(): void;
  68809. private _updatePlaneWithXRPlane;
  68810. /**
  68811. * avoiding using Array.find for global support.
  68812. * @param xrPlane the plane to find in the array
  68813. */
  68814. private findIndexInPlaneArray;
  68815. }
  68816. }
  68817. declare module BABYLON {
  68818. /**
  68819. * Configuration options of the anchor system
  68820. */
  68821. export interface IWebXRAnchorSystemOptions {
  68822. /**
  68823. * a node that will be used to convert local to world coordinates
  68824. */
  68825. worldParentNode?: TransformNode;
  68826. /**
  68827. * should the anchor system use plane detection.
  68828. * If set to true, the plane-detection feature should be set using setPlaneDetector
  68829. */
  68830. usePlaneDetection?: boolean;
  68831. /**
  68832. * Should a new anchor be added every time a select event is triggered
  68833. */
  68834. addAnchorOnSelect?: boolean;
  68835. }
  68836. /**
  68837. * A babylon container for an XR Anchor
  68838. */
  68839. export interface IWebXRAnchor {
  68840. /**
  68841. * A babylon-assigned ID for this anchor
  68842. */
  68843. id: number;
  68844. /**
  68845. * The native anchor object
  68846. */
  68847. xrAnchor: XRAnchor;
  68848. /**
  68849. * Transformation matrix to apply to an object attached to this anchor
  68850. */
  68851. transformationMatrix: Matrix;
  68852. }
  68853. /**
  68854. * An implementation of the anchor system of WebXR.
  68855. * Note that the current documented implementation is not available in any browser. Future implementations
  68856. * will use the frame to create an anchor and not the session or a detected plane
  68857. * For further information see https://github.com/immersive-web/anchors/
  68858. */
  68859. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  68860. private _options;
  68861. /**
  68862. * The module's name
  68863. */
  68864. static readonly Name: string;
  68865. /**
  68866. * The (Babylon) version of this module.
  68867. * This is an integer representing the implementation version.
  68868. * This number does not correspond to the webxr specs version
  68869. */
  68870. static readonly Version: number;
  68871. /**
  68872. * Observers registered here will be executed when a new anchor was added to the session
  68873. */
  68874. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  68875. /**
  68876. * Observers registered here will be executed when an existing anchor updates
  68877. * This can execute N times every frame
  68878. */
  68879. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  68880. /**
  68881. * Observers registered here will be executed when an anchor was removed from the session
  68882. */
  68883. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  68884. private _planeDetector;
  68885. private _hitTestModule;
  68886. private _enabled;
  68887. private _trackedAnchors;
  68888. private _lastFrameDetected;
  68889. /**
  68890. * constructs a new anchor system
  68891. * @param _xrSessionManager an instance of WebXRSessionManager
  68892. * @param _options configuration object for this feature
  68893. */
  68894. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  68895. /**
  68896. * set the plane detector to use in order to create anchors from frames
  68897. * @param planeDetector the plane-detector module to use
  68898. * @param enable enable plane-anchors. default is true
  68899. */
  68900. setPlaneDetector(planeDetector: WebXRPlaneDetector, enable?: boolean): void;
  68901. /**
  68902. * If set, it will improve performance by using the current hit-test results instead of executing a new hit-test
  68903. * @param hitTestModule the hit-test module to use.
  68904. */
  68905. setHitTestModule(hitTestModule: WebXRHitTestLegacy): void;
  68906. /**
  68907. * attach this feature
  68908. * Will usually be called by the features manager
  68909. *
  68910. * @returns true if successful.
  68911. */
  68912. attach(): boolean;
  68913. /**
  68914. * detach this feature.
  68915. * Will usually be called by the features manager
  68916. *
  68917. * @returns true if successful.
  68918. */
  68919. detach(): boolean;
  68920. /**
  68921. * Dispose this feature and all of the resources attached
  68922. */
  68923. dispose(): void;
  68924. protected _onXRFrame(frame: XRFrame): void;
  68925. private _onSelect;
  68926. /**
  68927. * Add anchor at a specific XR point.
  68928. *
  68929. * @param xrRigidTransformation xr-coordinates where a new anchor should be added
  68930. * @param anchorCreator the object o use to create an anchor with. either a session or a plane
  68931. * @returns a promise the fulfills when the anchor was created
  68932. */
  68933. addAnchorAtRigidTransformation(xrRigidTransformation: XRRigidTransform, anchorCreator?: XRAnchorCreator): Promise<XRAnchor>;
  68934. private _updateAnchorWithXRFrame;
  68935. /**
  68936. * avoiding using Array.find for global support.
  68937. * @param xrAnchor the plane to find in the array
  68938. */
  68939. private _findIndexInAnchorArray;
  68940. }
  68941. }
  68942. declare module BABYLON {
  68943. /**
  68944. * Options interface for the background remover plugin
  68945. */
  68946. export interface IWebXRBackgroundRemoverOptions {
  68947. /**
  68948. * don't disable the environment helper
  68949. */
  68950. ignoreEnvironmentHelper?: boolean;
  68951. /**
  68952. * flags to configure the removal of the environment helper.
  68953. * If not set, the entire background will be removed. If set, flags should be set as well.
  68954. */
  68955. environmentHelperRemovalFlags?: {
  68956. /**
  68957. * Should the skybox be removed (default false)
  68958. */
  68959. skyBox?: boolean;
  68960. /**
  68961. * Should the ground be removed (default false)
  68962. */
  68963. ground?: boolean;
  68964. };
  68965. /**
  68966. * Further background meshes to disable when entering AR
  68967. */
  68968. backgroundMeshes?: AbstractMesh[];
  68969. }
  68970. /**
  68971. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  68972. */
  68973. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  68974. /**
  68975. * read-only options to be used in this module
  68976. */
  68977. readonly options: IWebXRBackgroundRemoverOptions;
  68978. /**
  68979. * The module's name
  68980. */
  68981. static readonly Name: string;
  68982. /**
  68983. * The (Babylon) version of this module.
  68984. * This is an integer representing the implementation version.
  68985. * This number does not correspond to the webxr specs version
  68986. */
  68987. static readonly Version: number;
  68988. /**
  68989. * registered observers will be triggered when the background state changes
  68990. */
  68991. onBackgroundStateChangedObservable: Observable<boolean>;
  68992. /**
  68993. * constructs a new background remover module
  68994. * @param _xrSessionManager the session manager for this module
  68995. * @param options read-only options to be used in this module
  68996. */
  68997. constructor(_xrSessionManager: WebXRSessionManager,
  68998. /**
  68999. * read-only options to be used in this module
  69000. */
  69001. options?: IWebXRBackgroundRemoverOptions);
  69002. /**
  69003. * attach this feature
  69004. * Will usually be called by the features manager
  69005. *
  69006. * @returns true if successful.
  69007. */
  69008. attach(): boolean;
  69009. /**
  69010. * detach this feature.
  69011. * Will usually be called by the features manager
  69012. *
  69013. * @returns true if successful.
  69014. */
  69015. detach(): boolean;
  69016. private _setBackgroundState;
  69017. /**
  69018. * Dispose this feature and all of the resources attached
  69019. */
  69020. dispose(): void;
  69021. protected _onXRFrame(_xrFrame: XRFrame): void;
  69022. }
  69023. }
  69024. declare module BABYLON {
  69025. /**
  69026. * Options for the controller physics feature
  69027. */
  69028. export class IWebXRControllerPhysicsOptions {
  69029. /**
  69030. * the xr input to use with this pointer selection
  69031. */
  69032. xrInput: WebXRInput;
  69033. /**
  69034. * The physics properties of the future impostors
  69035. */
  69036. physicsProperties?: {
  69037. /**
  69038. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  69039. * Note that this requires a physics engine that supports mesh impostors!
  69040. */
  69041. useControllerMesh?: boolean;
  69042. /**
  69043. * The type of impostor to create. Default is sphere
  69044. */
  69045. impostorType?: number;
  69046. /**
  69047. * the size of the impostor. Defaults to 10cm
  69048. */
  69049. impostorSize?: number | {
  69050. width: number;
  69051. height: number;
  69052. depth: number;
  69053. };
  69054. /**
  69055. * Friction definitions
  69056. */
  69057. friction?: number;
  69058. /**
  69059. * Restitution
  69060. */
  69061. restitution?: number;
  69062. };
  69063. }
  69064. /**
  69065. * Add physics impostor to your webxr controllers,
  69066. * including naive calculation of their linear and angular velocity
  69067. */
  69068. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  69069. private readonly _options;
  69070. /**
  69071. * The module's name
  69072. */
  69073. static readonly Name: string;
  69074. /**
  69075. * The (Babylon) version of this module.
  69076. * This is an integer representing the implementation version.
  69077. * This number does not correspond to the webxr specs version
  69078. */
  69079. static readonly Version: number;
  69080. private _lastTimestamp;
  69081. private _delta;
  69082. private _controllers;
  69083. private _tmpVector;
  69084. private _tmpQuaternion;
  69085. /**
  69086. * Construct a new Controller Physics Feature
  69087. * @param _xrSessionManager the corresponding xr session manager
  69088. * @param _options options to create this feature with
  69089. */
  69090. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  69091. /**
  69092. * Update the physics properties provided in the constructor
  69093. * @param newProperties the new properties object
  69094. */
  69095. setPhysicsProperties(newProperties: {
  69096. impostorType?: number;
  69097. impostorSize?: number | {
  69098. width: number;
  69099. height: number;
  69100. depth: number;
  69101. };
  69102. friction?: number;
  69103. restitution?: number;
  69104. }): void;
  69105. /**
  69106. * attach this feature
  69107. * Will usually be called by the features manager
  69108. *
  69109. * @returns true if successful.
  69110. */
  69111. attach(): boolean;
  69112. /**
  69113. * detach this feature.
  69114. * Will usually be called by the features manager
  69115. *
  69116. * @returns true if successful.
  69117. */
  69118. detach(): boolean;
  69119. /**
  69120. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  69121. * @param xrController the controller to add
  69122. */
  69123. addController(xrController: WebXRInputSource): void;
  69124. private _debugMode;
  69125. /**
  69126. * @hidden
  69127. * enable debugging - will show console outputs and the impostor mesh
  69128. */
  69129. _enablePhysicsDebug(): void;
  69130. private _attachController;
  69131. private _detachController;
  69132. protected _onXRFrame(_xrFrame: any): void;
  69133. }
  69134. }
  69135. declare module BABYLON {
  69136. /**
  69137. * The motion controller class for all microsoft mixed reality controllers
  69138. */
  69139. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  69140. /**
  69141. * The base url used to load the left and right controller models
  69142. */
  69143. static MODEL_BASE_URL: string;
  69144. /**
  69145. * The name of the left controller model file
  69146. */
  69147. static MODEL_LEFT_FILENAME: string;
  69148. /**
  69149. * The name of the right controller model file
  69150. */
  69151. static MODEL_RIGHT_FILENAME: string;
  69152. profileId: string;
  69153. protected readonly _mapping: {
  69154. defaultButton: {
  69155. "valueNodeName": string;
  69156. "unpressedNodeName": string;
  69157. "pressedNodeName": string;
  69158. };
  69159. defaultAxis: {
  69160. "valueNodeName": string;
  69161. "minNodeName": string;
  69162. "maxNodeName": string;
  69163. };
  69164. buttons: {
  69165. "xr-standard-trigger": {
  69166. "rootNodeName": string;
  69167. "componentProperty": string;
  69168. "states": string[];
  69169. };
  69170. "xr-standard-squeeze": {
  69171. "rootNodeName": string;
  69172. "componentProperty": string;
  69173. "states": string[];
  69174. };
  69175. "xr-standard-touchpad": {
  69176. "rootNodeName": string;
  69177. "labelAnchorNodeName": string;
  69178. "touchPointNodeName": string;
  69179. };
  69180. "xr-standard-thumbstick": {
  69181. "rootNodeName": string;
  69182. "componentProperty": string;
  69183. "states": string[];
  69184. };
  69185. };
  69186. axes: {
  69187. "xr-standard-touchpad": {
  69188. "x-axis": {
  69189. "rootNodeName": string;
  69190. };
  69191. "y-axis": {
  69192. "rootNodeName": string;
  69193. };
  69194. };
  69195. "xr-standard-thumbstick": {
  69196. "x-axis": {
  69197. "rootNodeName": string;
  69198. };
  69199. "y-axis": {
  69200. "rootNodeName": string;
  69201. };
  69202. };
  69203. };
  69204. };
  69205. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  69206. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  69207. protected _getFilenameAndPath(): {
  69208. filename: string;
  69209. path: string;
  69210. };
  69211. protected _updateModel(): void;
  69212. protected _getModelLoadingConstraints(): boolean;
  69213. protected _setRootMesh(meshes: AbstractMesh[]): void;
  69214. }
  69215. }
  69216. declare module BABYLON {
  69217. /**
  69218. * The motion controller class for oculus touch (quest, rift).
  69219. * This class supports legacy mapping as well the standard xr mapping
  69220. */
  69221. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  69222. private _forceLegacyControllers;
  69223. /**
  69224. * The base url used to load the left and right controller models
  69225. */
  69226. static MODEL_BASE_URL: string;
  69227. /**
  69228. * The name of the left controller model file
  69229. */
  69230. static MODEL_LEFT_FILENAME: string;
  69231. /**
  69232. * The name of the right controller model file
  69233. */
  69234. static MODEL_RIGHT_FILENAME: string;
  69235. /**
  69236. * Base Url for the Quest controller model.
  69237. */
  69238. static QUEST_MODEL_BASE_URL: string;
  69239. profileId: string;
  69240. private _modelRootNode;
  69241. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  69242. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  69243. protected _getFilenameAndPath(): {
  69244. filename: string;
  69245. path: string;
  69246. };
  69247. /**
  69248. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  69249. * between the touch and touch 2.
  69250. */
  69251. private _isQuest;
  69252. protected _updateModel(): void;
  69253. protected _getModelLoadingConstraints(): boolean;
  69254. protected _setRootMesh(meshes: AbstractMesh[]): void;
  69255. }
  69256. }
  69257. declare module BABYLON {
  69258. /**
  69259. * The motion controller class for the standard HTC-Vive controllers
  69260. */
  69261. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  69262. /**
  69263. * The base url used to load the left and right controller models
  69264. */
  69265. static MODEL_BASE_URL: string;
  69266. /**
  69267. * File name for the controller model.
  69268. */
  69269. static MODEL_FILENAME: string;
  69270. profileId: string;
  69271. private _modelRootNode;
  69272. /**
  69273. * Create a new Vive motion controller object
  69274. * @param scene the scene to use to create this controller
  69275. * @param gamepadObject the corresponding gamepad object
  69276. * @param handness the handness of the controller
  69277. */
  69278. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  69279. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  69280. protected _getFilenameAndPath(): {
  69281. filename: string;
  69282. path: string;
  69283. };
  69284. protected _updateModel(): void;
  69285. protected _getModelLoadingConstraints(): boolean;
  69286. protected _setRootMesh(meshes: AbstractMesh[]): void;
  69287. }
  69288. }
  69289. declare module BABYLON {
  69290. /**
  69291. * A cursor which tracks a point on a path
  69292. */
  69293. export class PathCursor {
  69294. private path;
  69295. /**
  69296. * Stores path cursor callbacks for when an onchange event is triggered
  69297. */
  69298. private _onchange;
  69299. /**
  69300. * The value of the path cursor
  69301. */
  69302. value: number;
  69303. /**
  69304. * The animation array of the path cursor
  69305. */
  69306. animations: Animation[];
  69307. /**
  69308. * Initializes the path cursor
  69309. * @param path The path to track
  69310. */
  69311. constructor(path: Path2);
  69312. /**
  69313. * Gets the cursor point on the path
  69314. * @returns A point on the path cursor at the cursor location
  69315. */
  69316. getPoint(): Vector3;
  69317. /**
  69318. * Moves the cursor ahead by the step amount
  69319. * @param step The amount to move the cursor forward
  69320. * @returns This path cursor
  69321. */
  69322. moveAhead(step?: number): PathCursor;
  69323. /**
  69324. * Moves the cursor behind by the step amount
  69325. * @param step The amount to move the cursor back
  69326. * @returns This path cursor
  69327. */
  69328. moveBack(step?: number): PathCursor;
  69329. /**
  69330. * Moves the cursor by the step amount
  69331. * If the step amount is greater than one, an exception is thrown
  69332. * @param step The amount to move the cursor
  69333. * @returns This path cursor
  69334. */
  69335. move(step: number): PathCursor;
  69336. /**
  69337. * Ensures that the value is limited between zero and one
  69338. * @returns This path cursor
  69339. */
  69340. private ensureLimits;
  69341. /**
  69342. * Runs onchange callbacks on change (used by the animation engine)
  69343. * @returns This path cursor
  69344. */
  69345. private raiseOnChange;
  69346. /**
  69347. * Executes a function on change
  69348. * @param f A path cursor onchange callback
  69349. * @returns This path cursor
  69350. */
  69351. onchange(f: (cursor: PathCursor) => void): PathCursor;
  69352. }
  69353. }
  69354. declare module BABYLON {
  69355. /** @hidden */
  69356. export var blurPixelShader: {
  69357. name: string;
  69358. shader: string;
  69359. };
  69360. }
  69361. declare module BABYLON {
  69362. /** @hidden */
  69363. export var pointCloudVertexDeclaration: {
  69364. name: string;
  69365. shader: string;
  69366. };
  69367. }
  69368. // Mixins
  69369. interface Window {
  69370. mozIndexedDB: IDBFactory;
  69371. webkitIndexedDB: IDBFactory;
  69372. msIndexedDB: IDBFactory;
  69373. webkitURL: typeof URL;
  69374. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  69375. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  69376. WebGLRenderingContext: WebGLRenderingContext;
  69377. MSGesture: MSGesture;
  69378. CANNON: any;
  69379. AudioContext: AudioContext;
  69380. webkitAudioContext: AudioContext;
  69381. PointerEvent: any;
  69382. Math: Math;
  69383. Uint8Array: Uint8ArrayConstructor;
  69384. Float32Array: Float32ArrayConstructor;
  69385. mozURL: typeof URL;
  69386. msURL: typeof URL;
  69387. VRFrameData: any; // WebVR, from specs 1.1
  69388. DracoDecoderModule: any;
  69389. setImmediate(handler: (...args: any[]) => void): number;
  69390. }
  69391. interface HTMLCanvasElement {
  69392. requestPointerLock(): void;
  69393. msRequestPointerLock?(): void;
  69394. mozRequestPointerLock?(): void;
  69395. webkitRequestPointerLock?(): void;
  69396. /** Track wether a record is in progress */
  69397. isRecording: boolean;
  69398. /** Capture Stream method defined by some browsers */
  69399. captureStream(fps?: number): MediaStream;
  69400. }
  69401. interface CanvasRenderingContext2D {
  69402. msImageSmoothingEnabled: boolean;
  69403. }
  69404. interface MouseEvent {
  69405. mozMovementX: number;
  69406. mozMovementY: number;
  69407. webkitMovementX: number;
  69408. webkitMovementY: number;
  69409. msMovementX: number;
  69410. msMovementY: number;
  69411. }
  69412. interface Navigator {
  69413. mozGetVRDevices: (any: any) => any;
  69414. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  69415. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  69416. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  69417. webkitGetGamepads(): Gamepad[];
  69418. msGetGamepads(): Gamepad[];
  69419. webkitGamepads(): Gamepad[];
  69420. }
  69421. interface HTMLVideoElement {
  69422. mozSrcObject: any;
  69423. }
  69424. interface Math {
  69425. fround(x: number): number;
  69426. imul(a: number, b: number): number;
  69427. }
  69428. interface WebGLRenderingContext {
  69429. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  69430. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  69431. vertexAttribDivisor(index: number, divisor: number): void;
  69432. createVertexArray(): any;
  69433. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  69434. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  69435. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  69436. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  69437. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  69438. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  69439. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  69440. // Queries
  69441. createQuery(): WebGLQuery;
  69442. deleteQuery(query: WebGLQuery): void;
  69443. beginQuery(target: number, query: WebGLQuery): void;
  69444. endQuery(target: number): void;
  69445. getQueryParameter(query: WebGLQuery, pname: number): any;
  69446. getQuery(target: number, pname: number): any;
  69447. MAX_SAMPLES: number;
  69448. RGBA8: number;
  69449. READ_FRAMEBUFFER: number;
  69450. DRAW_FRAMEBUFFER: number;
  69451. UNIFORM_BUFFER: number;
  69452. HALF_FLOAT_OES: number;
  69453. RGBA16F: number;
  69454. RGBA32F: number;
  69455. R32F: number;
  69456. RG32F: number;
  69457. RGB32F: number;
  69458. R16F: number;
  69459. RG16F: number;
  69460. RGB16F: number;
  69461. RED: number;
  69462. RG: number;
  69463. R8: number;
  69464. RG8: number;
  69465. UNSIGNED_INT_24_8: number;
  69466. DEPTH24_STENCIL8: number;
  69467. MIN: number;
  69468. MAX: number;
  69469. /* Multiple Render Targets */
  69470. drawBuffers(buffers: number[]): void;
  69471. readBuffer(src: number): void;
  69472. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  69473. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  69474. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  69475. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  69476. // Occlusion Query
  69477. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  69478. ANY_SAMPLES_PASSED: number;
  69479. QUERY_RESULT_AVAILABLE: number;
  69480. QUERY_RESULT: number;
  69481. }
  69482. interface WebGLProgram {
  69483. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  69484. }
  69485. interface EXT_disjoint_timer_query {
  69486. QUERY_COUNTER_BITS_EXT: number;
  69487. TIME_ELAPSED_EXT: number;
  69488. TIMESTAMP_EXT: number;
  69489. GPU_DISJOINT_EXT: number;
  69490. QUERY_RESULT_EXT: number;
  69491. QUERY_RESULT_AVAILABLE_EXT: number;
  69492. queryCounterEXT(query: WebGLQuery, target: number): void;
  69493. createQueryEXT(): WebGLQuery;
  69494. beginQueryEXT(target: number, query: WebGLQuery): void;
  69495. endQueryEXT(target: number): void;
  69496. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  69497. deleteQueryEXT(query: WebGLQuery): void;
  69498. }
  69499. interface WebGLUniformLocation {
  69500. _currentState: any;
  69501. }
  69502. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  69503. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  69504. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  69505. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  69506. interface WebGLRenderingContext {
  69507. readonly RASTERIZER_DISCARD: number;
  69508. readonly DEPTH_COMPONENT24: number;
  69509. readonly TEXTURE_3D: number;
  69510. readonly TEXTURE_2D_ARRAY: number;
  69511. readonly TEXTURE_COMPARE_FUNC: number;
  69512. readonly TEXTURE_COMPARE_MODE: number;
  69513. readonly COMPARE_REF_TO_TEXTURE: number;
  69514. readonly TEXTURE_WRAP_R: number;
  69515. readonly HALF_FLOAT: number;
  69516. readonly RGB8: number;
  69517. readonly RED_INTEGER: number;
  69518. readonly RG_INTEGER: number;
  69519. readonly RGB_INTEGER: number;
  69520. readonly RGBA_INTEGER: number;
  69521. readonly R8_SNORM: number;
  69522. readonly RG8_SNORM: number;
  69523. readonly RGB8_SNORM: number;
  69524. readonly RGBA8_SNORM: number;
  69525. readonly R8I: number;
  69526. readonly RG8I: number;
  69527. readonly RGB8I: number;
  69528. readonly RGBA8I: number;
  69529. readonly R8UI: number;
  69530. readonly RG8UI: number;
  69531. readonly RGB8UI: number;
  69532. readonly RGBA8UI: number;
  69533. readonly R16I: number;
  69534. readonly RG16I: number;
  69535. readonly RGB16I: number;
  69536. readonly RGBA16I: number;
  69537. readonly R16UI: number;
  69538. readonly RG16UI: number;
  69539. readonly RGB16UI: number;
  69540. readonly RGBA16UI: number;
  69541. readonly R32I: number;
  69542. readonly RG32I: number;
  69543. readonly RGB32I: number;
  69544. readonly RGBA32I: number;
  69545. readonly R32UI: number;
  69546. readonly RG32UI: number;
  69547. readonly RGB32UI: number;
  69548. readonly RGBA32UI: number;
  69549. readonly RGB10_A2UI: number;
  69550. readonly R11F_G11F_B10F: number;
  69551. readonly RGB9_E5: number;
  69552. readonly RGB10_A2: number;
  69553. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  69554. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  69555. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  69556. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  69557. readonly DEPTH_COMPONENT32F: number;
  69558. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  69559. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  69560. 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;
  69561. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  69562. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  69563. readonly TRANSFORM_FEEDBACK: number;
  69564. readonly INTERLEAVED_ATTRIBS: number;
  69565. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  69566. createTransformFeedback(): WebGLTransformFeedback;
  69567. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  69568. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  69569. beginTransformFeedback(primitiveMode: number): void;
  69570. endTransformFeedback(): void;
  69571. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  69572. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  69573. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  69574. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  69575. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  69576. }
  69577. interface ImageBitmap {
  69578. readonly width: number;
  69579. readonly height: number;
  69580. close(): void;
  69581. }
  69582. interface WebGLQuery extends WebGLObject {
  69583. }
  69584. declare var WebGLQuery: {
  69585. prototype: WebGLQuery;
  69586. new(): WebGLQuery;
  69587. };
  69588. interface WebGLSampler extends WebGLObject {
  69589. }
  69590. declare var WebGLSampler: {
  69591. prototype: WebGLSampler;
  69592. new(): WebGLSampler;
  69593. };
  69594. interface WebGLSync extends WebGLObject {
  69595. }
  69596. declare var WebGLSync: {
  69597. prototype: WebGLSync;
  69598. new(): WebGLSync;
  69599. };
  69600. interface WebGLTransformFeedback extends WebGLObject {
  69601. }
  69602. declare var WebGLTransformFeedback: {
  69603. prototype: WebGLTransformFeedback;
  69604. new(): WebGLTransformFeedback;
  69605. };
  69606. interface WebGLVertexArrayObject extends WebGLObject {
  69607. }
  69608. declare var WebGLVertexArrayObject: {
  69609. prototype: WebGLVertexArrayObject;
  69610. new(): WebGLVertexArrayObject;
  69611. };
  69612. // Type definitions for WebVR API
  69613. // Project: https://w3c.github.io/webvr/
  69614. // Definitions by: six a <https://github.com/lostfictions>
  69615. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  69616. interface VRDisplay extends EventTarget {
  69617. /**
  69618. * Dictionary of capabilities describing the VRDisplay.
  69619. */
  69620. readonly capabilities: VRDisplayCapabilities;
  69621. /**
  69622. * z-depth defining the far plane of the eye view frustum
  69623. * enables mapping of values in the render target depth
  69624. * attachment to scene coordinates. Initially set to 10000.0.
  69625. */
  69626. depthFar: number;
  69627. /**
  69628. * z-depth defining the near plane of the eye view frustum
  69629. * enables mapping of values in the render target depth
  69630. * attachment to scene coordinates. Initially set to 0.01.
  69631. */
  69632. depthNear: number;
  69633. /**
  69634. * An identifier for this distinct VRDisplay. Used as an
  69635. * association point in the Gamepad API.
  69636. */
  69637. readonly displayId: number;
  69638. /**
  69639. * A display name, a user-readable name identifying it.
  69640. */
  69641. readonly displayName: string;
  69642. readonly isConnected: boolean;
  69643. readonly isPresenting: boolean;
  69644. /**
  69645. * If this VRDisplay supports room-scale experiences, the optional
  69646. * stage attribute contains details on the room-scale parameters.
  69647. */
  69648. readonly stageParameters: VRStageParameters | null;
  69649. /**
  69650. * Passing the value returned by `requestAnimationFrame` to
  69651. * `cancelAnimationFrame` will unregister the callback.
  69652. * @param handle Define the hanle of the request to cancel
  69653. */
  69654. cancelAnimationFrame(handle: number): void;
  69655. /**
  69656. * Stops presenting to the VRDisplay.
  69657. * @returns a promise to know when it stopped
  69658. */
  69659. exitPresent(): Promise<void>;
  69660. /**
  69661. * Return the current VREyeParameters for the given eye.
  69662. * @param whichEye Define the eye we want the parameter for
  69663. * @returns the eye parameters
  69664. */
  69665. getEyeParameters(whichEye: string): VREyeParameters;
  69666. /**
  69667. * Populates the passed VRFrameData with the information required to render
  69668. * the current frame.
  69669. * @param frameData Define the data structure to populate
  69670. * @returns true if ok otherwise false
  69671. */
  69672. getFrameData(frameData: VRFrameData): boolean;
  69673. /**
  69674. * Get the layers currently being presented.
  69675. * @returns the list of VR layers
  69676. */
  69677. getLayers(): VRLayer[];
  69678. /**
  69679. * Return a VRPose containing the future predicted pose of the VRDisplay
  69680. * when the current frame will be presented. The value returned will not
  69681. * change until JavaScript has returned control to the browser.
  69682. *
  69683. * The VRPose will contain the position, orientation, velocity,
  69684. * and acceleration of each of these properties.
  69685. * @returns the pose object
  69686. */
  69687. getPose(): VRPose;
  69688. /**
  69689. * Return the current instantaneous pose of the VRDisplay, with no
  69690. * prediction applied.
  69691. * @returns the current instantaneous pose
  69692. */
  69693. getImmediatePose(): VRPose;
  69694. /**
  69695. * The callback passed to `requestAnimationFrame` will be called
  69696. * any time a new frame should be rendered. When the VRDisplay is
  69697. * presenting the callback will be called at the native refresh
  69698. * rate of the HMD. When not presenting this function acts
  69699. * identically to how window.requestAnimationFrame acts. Content should
  69700. * make no assumptions of frame rate or vsync behavior as the HMD runs
  69701. * asynchronously from other displays and at differing refresh rates.
  69702. * @param callback Define the eaction to run next frame
  69703. * @returns the request handle it
  69704. */
  69705. requestAnimationFrame(callback: FrameRequestCallback): number;
  69706. /**
  69707. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  69708. * Repeat calls while already presenting will update the VRLayers being displayed.
  69709. * @param layers Define the list of layer to present
  69710. * @returns a promise to know when the request has been fulfilled
  69711. */
  69712. requestPresent(layers: VRLayer[]): Promise<void>;
  69713. /**
  69714. * Reset the pose for this display, treating its current position and
  69715. * orientation as the "origin/zero" values. VRPose.position,
  69716. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  69717. * updated when calling resetPose(). This should be called in only
  69718. * sitting-space experiences.
  69719. */
  69720. resetPose(): void;
  69721. /**
  69722. * The VRLayer provided to the VRDisplay will be captured and presented
  69723. * in the HMD. Calling this function has the same effect on the source
  69724. * canvas as any other operation that uses its source image, and canvases
  69725. * created without preserveDrawingBuffer set to true will be cleared.
  69726. * @param pose Define the pose to submit
  69727. */
  69728. submitFrame(pose?: VRPose): void;
  69729. }
  69730. declare var VRDisplay: {
  69731. prototype: VRDisplay;
  69732. new(): VRDisplay;
  69733. };
  69734. interface VRLayer {
  69735. leftBounds?: number[] | Float32Array | null;
  69736. rightBounds?: number[] | Float32Array | null;
  69737. source?: HTMLCanvasElement | null;
  69738. }
  69739. interface VRDisplayCapabilities {
  69740. readonly canPresent: boolean;
  69741. readonly hasExternalDisplay: boolean;
  69742. readonly hasOrientation: boolean;
  69743. readonly hasPosition: boolean;
  69744. readonly maxLayers: number;
  69745. }
  69746. interface VREyeParameters {
  69747. /** @deprecated */
  69748. readonly fieldOfView: VRFieldOfView;
  69749. readonly offset: Float32Array;
  69750. readonly renderHeight: number;
  69751. readonly renderWidth: number;
  69752. }
  69753. interface VRFieldOfView {
  69754. readonly downDegrees: number;
  69755. readonly leftDegrees: number;
  69756. readonly rightDegrees: number;
  69757. readonly upDegrees: number;
  69758. }
  69759. interface VRFrameData {
  69760. readonly leftProjectionMatrix: Float32Array;
  69761. readonly leftViewMatrix: Float32Array;
  69762. readonly pose: VRPose;
  69763. readonly rightProjectionMatrix: Float32Array;
  69764. readonly rightViewMatrix: Float32Array;
  69765. readonly timestamp: number;
  69766. }
  69767. interface VRPose {
  69768. readonly angularAcceleration: Float32Array | null;
  69769. readonly angularVelocity: Float32Array | null;
  69770. readonly linearAcceleration: Float32Array | null;
  69771. readonly linearVelocity: Float32Array | null;
  69772. readonly orientation: Float32Array | null;
  69773. readonly position: Float32Array | null;
  69774. readonly timestamp: number;
  69775. }
  69776. interface VRStageParameters {
  69777. sittingToStandingTransform?: Float32Array;
  69778. sizeX?: number;
  69779. sizeY?: number;
  69780. }
  69781. interface Navigator {
  69782. getVRDisplays(): Promise<VRDisplay[]>;
  69783. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  69784. }
  69785. interface Window {
  69786. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  69787. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  69788. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  69789. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  69790. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  69791. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  69792. }
  69793. interface Gamepad {
  69794. readonly displayId: number;
  69795. }
  69796. type XRSessionMode =
  69797. | "inline"
  69798. | "immersive-vr"
  69799. | "immersive-ar";
  69800. type XRReferenceSpaceType =
  69801. | "viewer"
  69802. | "local"
  69803. | "local-floor"
  69804. | "bounded-floor"
  69805. | "unbounded";
  69806. type XREnvironmentBlendMode =
  69807. | "opaque"
  69808. | "additive"
  69809. | "alpha-blend";
  69810. type XRVisibilityState =
  69811. | "visible"
  69812. | "visible-blurred"
  69813. | "hidden";
  69814. type XRHandedness =
  69815. | "none"
  69816. | "left"
  69817. | "right";
  69818. type XRTargetRayMode =
  69819. | "gaze"
  69820. | "tracked-pointer"
  69821. | "screen";
  69822. type XREye =
  69823. | "none"
  69824. | "left"
  69825. | "right";
  69826. interface XRSpace extends EventTarget {
  69827. }
  69828. interface XRRenderState {
  69829. depthNear?: number;
  69830. depthFar?: number;
  69831. inlineVerticalFieldOfView?: number;
  69832. baseLayer?: XRWebGLLayer;
  69833. }
  69834. interface XRInputSource {
  69835. handedness: XRHandedness;
  69836. targetRayMode: XRTargetRayMode;
  69837. targetRaySpace: XRSpace;
  69838. gripSpace: XRSpace | undefined;
  69839. gamepad: Gamepad | undefined;
  69840. profiles: Array<string>;
  69841. }
  69842. interface XRSessionInit {
  69843. optionalFeatures?: XRReferenceSpaceType[];
  69844. requiredFeatures?: XRReferenceSpaceType[];
  69845. }
  69846. interface XRSession extends XRAnchorCreator {
  69847. addEventListener: Function;
  69848. removeEventListener: Function;
  69849. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  69850. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  69851. requestAnimationFrame: Function;
  69852. end(): Promise<void>;
  69853. renderState: XRRenderState;
  69854. inputSources: Array<XRInputSource>;
  69855. // AR hit test
  69856. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  69857. updateWorldTrackingState(options: {
  69858. planeDetectionState?: { enabled: boolean; }
  69859. }): void;
  69860. }
  69861. interface XRReferenceSpace extends XRSpace {
  69862. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  69863. onreset: any;
  69864. }
  69865. type XRPlaneSet = Set<XRPlane>;
  69866. type XRAnchorSet = Set<XRAnchor>;
  69867. interface XRFrame {
  69868. session: XRSession;
  69869. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  69870. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  69871. // Anchors
  69872. trackedAnchors?: XRAnchorSet;
  69873. // Planes
  69874. worldInformation: {
  69875. detectedPlanes?: XRPlaneSet;
  69876. };
  69877. }
  69878. interface XRViewerPose extends XRPose {
  69879. views: Array<XRView>;
  69880. }
  69881. interface XRPose {
  69882. transform: XRRigidTransform;
  69883. emulatedPosition: boolean;
  69884. }
  69885. interface XRWebGLLayerOptions {
  69886. antialias?: boolean;
  69887. depth?: boolean;
  69888. stencil?: boolean;
  69889. alpha?: boolean;
  69890. multiview?: boolean;
  69891. framebufferScaleFactor?: number;
  69892. }
  69893. declare var XRWebGLLayer: {
  69894. prototype: XRWebGLLayer;
  69895. new(session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  69896. };
  69897. interface XRWebGLLayer {
  69898. framebuffer: WebGLFramebuffer;
  69899. framebufferWidth: number;
  69900. framebufferHeight: number;
  69901. getViewport: Function;
  69902. }
  69903. declare class XRRigidTransform {
  69904. constructor(matrix: Float32Array | DOMPointInit, direction?: DOMPointInit);
  69905. position: DOMPointReadOnly;
  69906. orientation: DOMPointReadOnly;
  69907. matrix: Float32Array;
  69908. inverse: XRRigidTransform;
  69909. }
  69910. interface XRView {
  69911. eye: XREye;
  69912. projectionMatrix: Float32Array;
  69913. transform: XRRigidTransform;
  69914. }
  69915. interface XRInputSourceChangeEvent {
  69916. session: XRSession;
  69917. removed: Array<XRInputSource>;
  69918. added: Array<XRInputSource>;
  69919. }
  69920. interface XRInputSourceEvent extends Event {
  69921. readonly frame: XRFrame;
  69922. readonly inputSource: XRInputSource;
  69923. }
  69924. // Experimental(er) features
  69925. declare class XRRay {
  69926. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  69927. origin: DOMPointReadOnly;
  69928. direction: DOMPointReadOnly;
  69929. matrix: Float32Array;
  69930. }
  69931. interface XRHitResult {
  69932. hitMatrix: Float32Array;
  69933. }
  69934. interface XRAnchor {
  69935. // remove?
  69936. id?: string;
  69937. anchorSpace: XRSpace;
  69938. lastChangedTime: number;
  69939. detach(): void;
  69940. }
  69941. interface XRPlane extends XRAnchorCreator {
  69942. orientation: "Horizontal" | "Vertical";
  69943. planeSpace: XRSpace;
  69944. polygon: Array<DOMPointReadOnly>;
  69945. lastChangedTime: number;
  69946. }
  69947. interface XRAnchorCreator {
  69948. // AR Anchors
  69949. createAnchor(pose: XRPose | XRRigidTransform, referenceSpace: XRReferenceSpace): Promise<XRAnchor>;
  69950. }
  69951. /**
  69952. * @ignore
  69953. */
  69954. declare module BABYLON.GLTF2.Exporter {
  69955. }
  69956. /**
  69957. * @ignore
  69958. */
  69959. declare module BABYLON.GLTF1 {
  69960. }
  69961. declare module BABYLON.GUI {
  69962. /**
  69963. * Class used to specific a value and its associated unit
  69964. */
  69965. export class ValueAndUnit {
  69966. /** defines the unit to store */
  69967. unit: number;
  69968. /** defines a boolean indicating if the value can be negative */
  69969. negativeValueAllowed: boolean;
  69970. private _value;
  69971. private _originalUnit;
  69972. /**
  69973. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  69974. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  69975. */
  69976. ignoreAdaptiveScaling: boolean;
  69977. /**
  69978. * Creates a new ValueAndUnit
  69979. * @param value defines the value to store
  69980. * @param unit defines the unit to store
  69981. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  69982. */
  69983. constructor(value: number,
  69984. /** defines the unit to store */
  69985. unit?: number,
  69986. /** defines a boolean indicating if the value can be negative */
  69987. negativeValueAllowed?: boolean);
  69988. /** Gets a boolean indicating if the value is a percentage */
  69989. get isPercentage(): boolean;
  69990. /** Gets a boolean indicating if the value is store as pixel */
  69991. get isPixel(): boolean;
  69992. /** Gets direct internal value */
  69993. get internalValue(): number;
  69994. /**
  69995. * Gets value as pixel
  69996. * @param host defines the root host
  69997. * @param refValue defines the reference value for percentages
  69998. * @returns the value as pixel
  69999. */
  70000. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  70001. /**
  70002. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  70003. * @param value defines the value to store
  70004. * @param unit defines the unit to store
  70005. * @returns the current ValueAndUnit
  70006. */
  70007. updateInPlace(value: number, unit?: number): ValueAndUnit;
  70008. /**
  70009. * Gets the value accordingly to its unit
  70010. * @param host defines the root host
  70011. * @returns the value
  70012. */
  70013. getValue(host: AdvancedDynamicTexture): number;
  70014. /**
  70015. * Gets a string representation of the value
  70016. * @param host defines the root host
  70017. * @param decimals defines an optional number of decimals to display
  70018. * @returns a string
  70019. */
  70020. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  70021. /**
  70022. * Store a value parsed from a string
  70023. * @param source defines the source string
  70024. * @returns true if the value was successfully parsed
  70025. */
  70026. fromString(source: string | number): boolean;
  70027. private static _Regex;
  70028. private static _UNITMODE_PERCENTAGE;
  70029. private static _UNITMODE_PIXEL;
  70030. /** UNITMODE_PERCENTAGE */
  70031. static get UNITMODE_PERCENTAGE(): number;
  70032. /** UNITMODE_PIXEL */
  70033. static get UNITMODE_PIXEL(): number;
  70034. }
  70035. }
  70036. declare module BABYLON.GUI {
  70037. /**
  70038. * Define a style used by control to automatically setup properties based on a template.
  70039. * Only support font related properties so far
  70040. */
  70041. export class Style implements BABYLON.IDisposable {
  70042. private _fontFamily;
  70043. private _fontStyle;
  70044. private _fontWeight;
  70045. /** @hidden */
  70046. _host: AdvancedDynamicTexture;
  70047. /** @hidden */
  70048. _fontSize: ValueAndUnit;
  70049. /**
  70050. * BABYLON.Observable raised when the style values are changed
  70051. */
  70052. onChangedObservable: BABYLON.Observable<Style>;
  70053. /**
  70054. * Creates a new style object
  70055. * @param host defines the AdvancedDynamicTexture which hosts this style
  70056. */
  70057. constructor(host: AdvancedDynamicTexture);
  70058. /**
  70059. * Gets or sets the font size
  70060. */
  70061. get fontSize(): string | number;
  70062. set fontSize(value: string | number);
  70063. /**
  70064. * Gets or sets the font family
  70065. */
  70066. get fontFamily(): string;
  70067. set fontFamily(value: string);
  70068. /**
  70069. * Gets or sets the font style
  70070. */
  70071. get fontStyle(): string;
  70072. set fontStyle(value: string);
  70073. /** Gets or sets font weight */
  70074. get fontWeight(): string;
  70075. set fontWeight(value: string);
  70076. /** Dispose all associated resources */
  70077. dispose(): void;
  70078. }
  70079. }
  70080. declare module BABYLON.GUI {
  70081. /**
  70082. * Class used to transport BABYLON.Vector2 information for pointer events
  70083. */
  70084. export class Vector2WithInfo extends BABYLON.Vector2 {
  70085. /** defines the current mouse button index */
  70086. buttonIndex: number;
  70087. /**
  70088. * Creates a new Vector2WithInfo
  70089. * @param source defines the vector2 data to transport
  70090. * @param buttonIndex defines the current mouse button index
  70091. */
  70092. constructor(source: BABYLON.Vector2,
  70093. /** defines the current mouse button index */
  70094. buttonIndex?: number);
  70095. }
  70096. /** Class used to provide 2D matrix features */
  70097. export class Matrix2D {
  70098. /** Gets the internal array of 6 floats used to store matrix data */
  70099. m: Float32Array;
  70100. /**
  70101. * Creates a new matrix
  70102. * @param m00 defines value for (0, 0)
  70103. * @param m01 defines value for (0, 1)
  70104. * @param m10 defines value for (1, 0)
  70105. * @param m11 defines value for (1, 1)
  70106. * @param m20 defines value for (2, 0)
  70107. * @param m21 defines value for (2, 1)
  70108. */
  70109. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  70110. /**
  70111. * Fills the matrix from direct values
  70112. * @param m00 defines value for (0, 0)
  70113. * @param m01 defines value for (0, 1)
  70114. * @param m10 defines value for (1, 0)
  70115. * @param m11 defines value for (1, 1)
  70116. * @param m20 defines value for (2, 0)
  70117. * @param m21 defines value for (2, 1)
  70118. * @returns the current modified matrix
  70119. */
  70120. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  70121. /**
  70122. * Gets matrix determinant
  70123. * @returns the determinant
  70124. */
  70125. determinant(): number;
  70126. /**
  70127. * Inverses the matrix and stores it in a target matrix
  70128. * @param result defines the target matrix
  70129. * @returns the current matrix
  70130. */
  70131. invertToRef(result: Matrix2D): Matrix2D;
  70132. /**
  70133. * Multiplies the current matrix with another one
  70134. * @param other defines the second operand
  70135. * @param result defines the target matrix
  70136. * @returns the current matrix
  70137. */
  70138. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  70139. /**
  70140. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  70141. * @param x defines the x coordinate to transform
  70142. * @param y defines the x coordinate to transform
  70143. * @param result defines the target vector2
  70144. * @returns the current matrix
  70145. */
  70146. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  70147. /**
  70148. * Creates an identity matrix
  70149. * @returns a new matrix
  70150. */
  70151. static Identity(): Matrix2D;
  70152. /**
  70153. * Creates a translation matrix and stores it in a target matrix
  70154. * @param x defines the x coordinate of the translation
  70155. * @param y defines the y coordinate of the translation
  70156. * @param result defines the target matrix
  70157. */
  70158. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  70159. /**
  70160. * Creates a scaling matrix and stores it in a target matrix
  70161. * @param x defines the x coordinate of the scaling
  70162. * @param y defines the y coordinate of the scaling
  70163. * @param result defines the target matrix
  70164. */
  70165. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  70166. /**
  70167. * Creates a rotation matrix and stores it in a target matrix
  70168. * @param angle defines the rotation angle
  70169. * @param result defines the target matrix
  70170. */
  70171. static RotationToRef(angle: number, result: Matrix2D): void;
  70172. private static _TempPreTranslationMatrix;
  70173. private static _TempPostTranslationMatrix;
  70174. private static _TempRotationMatrix;
  70175. private static _TempScalingMatrix;
  70176. private static _TempCompose0;
  70177. private static _TempCompose1;
  70178. private static _TempCompose2;
  70179. /**
  70180. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  70181. * @param tx defines the x coordinate of the translation
  70182. * @param ty defines the y coordinate of the translation
  70183. * @param angle defines the rotation angle
  70184. * @param scaleX defines the x coordinate of the scaling
  70185. * @param scaleY defines the y coordinate of the scaling
  70186. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  70187. * @param result defines the target matrix
  70188. */
  70189. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  70190. }
  70191. }
  70192. declare module BABYLON.GUI {
  70193. /**
  70194. * Class used to store 2D control sizes
  70195. */
  70196. export class Measure {
  70197. /** defines left coordinate */
  70198. left: number;
  70199. /** defines top coordinate */
  70200. top: number;
  70201. /** defines width dimension */
  70202. width: number;
  70203. /** defines height dimension */
  70204. height: number;
  70205. /**
  70206. * Creates a new measure
  70207. * @param left defines left coordinate
  70208. * @param top defines top coordinate
  70209. * @param width defines width dimension
  70210. * @param height defines height dimension
  70211. */
  70212. constructor(
  70213. /** defines left coordinate */
  70214. left: number,
  70215. /** defines top coordinate */
  70216. top: number,
  70217. /** defines width dimension */
  70218. width: number,
  70219. /** defines height dimension */
  70220. height: number);
  70221. /**
  70222. * Copy from another measure
  70223. * @param other defines the other measure to copy from
  70224. */
  70225. copyFrom(other: Measure): void;
  70226. /**
  70227. * Copy from a group of 4 floats
  70228. * @param left defines left coordinate
  70229. * @param top defines top coordinate
  70230. * @param width defines width dimension
  70231. * @param height defines height dimension
  70232. */
  70233. copyFromFloats(left: number, top: number, width: number, height: number): void;
  70234. /**
  70235. * Computes the axis aligned bounding box measure for two given measures
  70236. * @param a Input measure
  70237. * @param b Input measure
  70238. * @param result the resulting bounding measure
  70239. */
  70240. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  70241. /**
  70242. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  70243. * @param transform the matrix to transform the measure before computing the AABB
  70244. * @param result the resulting AABB
  70245. */
  70246. transformToRef(transform: Matrix2D, result: Measure): void;
  70247. /**
  70248. * Check equality between this measure and another one
  70249. * @param other defines the other measures
  70250. * @returns true if both measures are equals
  70251. */
  70252. isEqualsTo(other: Measure): boolean;
  70253. /**
  70254. * Creates an empty measure
  70255. * @returns a new measure
  70256. */
  70257. static Empty(): Measure;
  70258. }
  70259. }
  70260. declare module BABYLON.GUI {
  70261. /**
  70262. * Interface used to define a control that can receive focus
  70263. */
  70264. export interface IFocusableControl {
  70265. /**
  70266. * Function called when the control receives the focus
  70267. */
  70268. onFocus(): void;
  70269. /**
  70270. * Function called when the control loses the focus
  70271. */
  70272. onBlur(): void;
  70273. /**
  70274. * Function called to let the control handle keyboard events
  70275. * @param evt defines the current keyboard event
  70276. */
  70277. processKeyboard(evt: KeyboardEvent): void;
  70278. /**
  70279. * Function called to get the list of controls that should not steal the focus from this control
  70280. * @returns an array of controls
  70281. */
  70282. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  70283. }
  70284. /**
  70285. * Class used to create texture to support 2D GUI elements
  70286. * @see http://doc.babylonjs.com/how_to/gui
  70287. */
  70288. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  70289. private _isDirty;
  70290. private _renderObserver;
  70291. private _resizeObserver;
  70292. private _preKeyboardObserver;
  70293. private _pointerMoveObserver;
  70294. private _pointerObserver;
  70295. private _canvasPointerOutObserver;
  70296. private _background;
  70297. /** @hidden */
  70298. _rootContainer: Container;
  70299. /** @hidden */
  70300. _lastPickedControl: Control;
  70301. /** @hidden */
  70302. _lastControlOver: {
  70303. [pointerId: number]: Control;
  70304. };
  70305. /** @hidden */
  70306. _lastControlDown: {
  70307. [pointerId: number]: Control;
  70308. };
  70309. /** @hidden */
  70310. _capturingControl: {
  70311. [pointerId: number]: Control;
  70312. };
  70313. /** @hidden */
  70314. _shouldBlockPointer: boolean;
  70315. /** @hidden */
  70316. _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  70317. /** @hidden */
  70318. _linkedControls: Control[];
  70319. private _isFullscreen;
  70320. private _fullscreenViewport;
  70321. private _idealWidth;
  70322. private _idealHeight;
  70323. private _useSmallestIdeal;
  70324. private _renderAtIdealSize;
  70325. private _focusedControl;
  70326. private _blockNextFocusCheck;
  70327. private _renderScale;
  70328. private _rootElement;
  70329. private _cursorChanged;
  70330. /** @hidden */
  70331. _numLayoutCalls: number;
  70332. /** Gets the number of layout calls made the last time the ADT has been rendered */
  70333. get numLayoutCalls(): number;
  70334. /** @hidden */
  70335. _numRenderCalls: number;
  70336. /** Gets the number of render calls made the last time the ADT has been rendered */
  70337. get numRenderCalls(): number;
  70338. /**
  70339. * Define type to string to ensure compatibility across browsers
  70340. * Safari doesn't support DataTransfer constructor
  70341. */
  70342. private _clipboardData;
  70343. /**
  70344. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  70345. */
  70346. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  70347. /**
  70348. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  70349. */
  70350. onControlPickedObservable: BABYLON.Observable<Control>;
  70351. /**
  70352. * BABYLON.Observable event triggered before layout is evaluated
  70353. */
  70354. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  70355. /**
  70356. * BABYLON.Observable event triggered after the layout was evaluated
  70357. */
  70358. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  70359. /**
  70360. * BABYLON.Observable event triggered before the texture is rendered
  70361. */
  70362. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  70363. /**
  70364. * BABYLON.Observable event triggered after the texture was rendered
  70365. */
  70366. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  70367. /**
  70368. * Gets or sets a boolean defining if alpha is stored as premultiplied
  70369. */
  70370. premulAlpha: boolean;
  70371. /**
  70372. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  70373. * Useful when you want more antialiasing
  70374. */
  70375. get renderScale(): number;
  70376. set renderScale(value: number);
  70377. /** Gets or sets the background color */
  70378. get background(): string;
  70379. set background(value: string);
  70380. /**
  70381. * Gets or sets the ideal width used to design controls.
  70382. * The GUI will then rescale everything accordingly
  70383. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  70384. */
  70385. get idealWidth(): number;
  70386. set idealWidth(value: number);
  70387. /**
  70388. * Gets or sets the ideal height used to design controls.
  70389. * The GUI will then rescale everything accordingly
  70390. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  70391. */
  70392. get idealHeight(): number;
  70393. set idealHeight(value: number);
  70394. /**
  70395. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  70396. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  70397. */
  70398. get useSmallestIdeal(): boolean;
  70399. set useSmallestIdeal(value: boolean);
  70400. /**
  70401. * Gets or sets a boolean indicating if adaptive scaling must be used
  70402. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  70403. */
  70404. get renderAtIdealSize(): boolean;
  70405. set renderAtIdealSize(value: boolean);
  70406. /**
  70407. * Gets the ratio used when in "ideal mode"
  70408. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  70409. * */
  70410. get idealRatio(): number;
  70411. /**
  70412. * Gets the underlying layer used to render the texture when in fullscreen mode
  70413. */
  70414. get layer(): BABYLON.Nullable<BABYLON.Layer>;
  70415. /**
  70416. * Gets the root container control
  70417. */
  70418. get rootContainer(): Container;
  70419. /**
  70420. * Returns an array containing the root container.
  70421. * This is mostly used to let the Inspector introspects the ADT
  70422. * @returns an array containing the rootContainer
  70423. */
  70424. getChildren(): Array<Container>;
  70425. /**
  70426. * Will return all controls that are inside this texture
  70427. * @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
  70428. * @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
  70429. * @return all child controls
  70430. */
  70431. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  70432. /**
  70433. * Gets or sets the current focused control
  70434. */
  70435. get focusedControl(): BABYLON.Nullable<IFocusableControl>;
  70436. set focusedControl(control: BABYLON.Nullable<IFocusableControl>);
  70437. /**
  70438. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  70439. */
  70440. get isForeground(): boolean;
  70441. set isForeground(value: boolean);
  70442. /**
  70443. * Gets or set information about clipboardData
  70444. */
  70445. get clipboardData(): string;
  70446. set clipboardData(value: string);
  70447. /**
  70448. * Creates a new AdvancedDynamicTexture
  70449. * @param name defines the name of the texture
  70450. * @param width defines the width of the texture
  70451. * @param height defines the height of the texture
  70452. * @param scene defines the hosting scene
  70453. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  70454. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  70455. */
  70456. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number);
  70457. /**
  70458. * Get the current class name of the texture useful for serialization or dynamic coding.
  70459. * @returns "AdvancedDynamicTexture"
  70460. */
  70461. getClassName(): string;
  70462. /**
  70463. * Function used to execute a function on all controls
  70464. * @param func defines the function to execute
  70465. * @param container defines the container where controls belong. If null the root container will be used
  70466. */
  70467. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  70468. private _useInvalidateRectOptimization;
  70469. /**
  70470. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  70471. */
  70472. get useInvalidateRectOptimization(): boolean;
  70473. set useInvalidateRectOptimization(value: boolean);
  70474. private _invalidatedRectangle;
  70475. /**
  70476. * Invalidates a rectangle area on the gui texture
  70477. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  70478. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  70479. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  70480. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  70481. */
  70482. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  70483. /**
  70484. * Marks the texture as dirty forcing a complete update
  70485. */
  70486. markAsDirty(): void;
  70487. /**
  70488. * Helper function used to create a new style
  70489. * @returns a new style
  70490. * @see http://doc.babylonjs.com/how_to/gui#styles
  70491. */
  70492. createStyle(): Style;
  70493. /**
  70494. * Adds a new control to the root container
  70495. * @param control defines the control to add
  70496. * @returns the current texture
  70497. */
  70498. addControl(control: Control): AdvancedDynamicTexture;
  70499. /**
  70500. * Removes a control from the root container
  70501. * @param control defines the control to remove
  70502. * @returns the current texture
  70503. */
  70504. removeControl(control: Control): AdvancedDynamicTexture;
  70505. /**
  70506. * Release all resources
  70507. */
  70508. dispose(): void;
  70509. private _onResize;
  70510. /** @hidden */
  70511. _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  70512. /**
  70513. * Get screen coordinates for a vector3
  70514. * @param position defines the position to project
  70515. * @param worldMatrix defines the world matrix to use
  70516. * @returns the projected position
  70517. */
  70518. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  70519. private _checkUpdate;
  70520. private _clearMeasure;
  70521. private _render;
  70522. /** @hidden */
  70523. _changeCursor(cursor: string): void;
  70524. /** @hidden */
  70525. _registerLastControlDown(control: Control, pointerId: number): void;
  70526. private _doPicking;
  70527. /** @hidden */
  70528. _cleanControlAfterRemovalFromList(list: {
  70529. [pointerId: number]: Control;
  70530. }, control: Control): void;
  70531. /** @hidden */
  70532. _cleanControlAfterRemoval(control: Control): void;
  70533. /** Attach to all scene events required to support pointer events */
  70534. attach(): void;
  70535. /** @hidden */
  70536. private onClipboardCopy;
  70537. /** @hidden */
  70538. private onClipboardCut;
  70539. /** @hidden */
  70540. private onClipboardPaste;
  70541. /**
  70542. * Register the clipboard Events onto the canvas
  70543. */
  70544. registerClipboardEvents(): void;
  70545. /**
  70546. * Unregister the clipboard Events from the canvas
  70547. */
  70548. unRegisterClipboardEvents(): void;
  70549. /**
  70550. * Connect the texture to a hosting mesh to enable interactions
  70551. * @param mesh defines the mesh to attach to
  70552. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  70553. */
  70554. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  70555. /**
  70556. * Move the focus to a specific control
  70557. * @param control defines the control which will receive the focus
  70558. */
  70559. moveFocusToControl(control: IFocusableControl): void;
  70560. private _manageFocus;
  70561. private _attachToOnPointerOut;
  70562. /**
  70563. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  70564. * @param mesh defines the mesh which will receive the texture
  70565. * @param width defines the texture width (1024 by default)
  70566. * @param height defines the texture height (1024 by default)
  70567. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  70568. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  70569. * @returns a new AdvancedDynamicTexture
  70570. */
  70571. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean): AdvancedDynamicTexture;
  70572. /**
  70573. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  70574. * In this mode the texture will rely on a layer for its rendering.
  70575. * This allows it to be treated like any other layer.
  70576. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  70577. * LayerMask is set through advancedTexture.layer.layerMask
  70578. * @param name defines name for the texture
  70579. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  70580. * @param scene defines the hsoting scene
  70581. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  70582. * @returns a new AdvancedDynamicTexture
  70583. */
  70584. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  70585. }
  70586. }
  70587. declare module BABYLON.GUI {
  70588. /**
  70589. * Root class used for all 2D controls
  70590. * @see http://doc.babylonjs.com/how_to/gui#controls
  70591. */
  70592. export class Control {
  70593. /** defines the name of the control */
  70594. name?: string | undefined;
  70595. /**
  70596. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  70597. */
  70598. static AllowAlphaInheritance: boolean;
  70599. private _alpha;
  70600. private _alphaSet;
  70601. private _zIndex;
  70602. /** @hidden */
  70603. _host: AdvancedDynamicTexture;
  70604. /** Gets or sets the control parent */
  70605. parent: BABYLON.Nullable<Container>;
  70606. /** @hidden */
  70607. _currentMeasure: Measure;
  70608. private _fontFamily;
  70609. private _fontStyle;
  70610. private _fontWeight;
  70611. private _fontSize;
  70612. private _font;
  70613. /** @hidden */
  70614. _width: ValueAndUnit;
  70615. /** @hidden */
  70616. _height: ValueAndUnit;
  70617. /** @hidden */
  70618. protected _fontOffset: {
  70619. ascent: number;
  70620. height: number;
  70621. descent: number;
  70622. };
  70623. private _color;
  70624. private _style;
  70625. private _styleObserver;
  70626. /** @hidden */
  70627. protected _horizontalAlignment: number;
  70628. /** @hidden */
  70629. protected _verticalAlignment: number;
  70630. /** @hidden */
  70631. protected _isDirty: boolean;
  70632. /** @hidden */
  70633. protected _wasDirty: boolean;
  70634. /** @hidden */
  70635. _tempParentMeasure: Measure;
  70636. /** @hidden */
  70637. _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  70638. /** @hidden */
  70639. protected _cachedParentMeasure: Measure;
  70640. private _paddingLeft;
  70641. private _paddingRight;
  70642. private _paddingTop;
  70643. private _paddingBottom;
  70644. /** @hidden */
  70645. _left: ValueAndUnit;
  70646. /** @hidden */
  70647. _top: ValueAndUnit;
  70648. private _scaleX;
  70649. private _scaleY;
  70650. private _rotation;
  70651. private _transformCenterX;
  70652. private _transformCenterY;
  70653. /** @hidden */
  70654. _transformMatrix: Matrix2D;
  70655. /** @hidden */
  70656. protected _invertTransformMatrix: Matrix2D;
  70657. /** @hidden */
  70658. protected _transformedPosition: BABYLON.Vector2;
  70659. private _isMatrixDirty;
  70660. private _cachedOffsetX;
  70661. private _cachedOffsetY;
  70662. private _isVisible;
  70663. private _isHighlighted;
  70664. /** @hidden */
  70665. _linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  70666. private _fontSet;
  70667. private _dummyVector2;
  70668. private _downCount;
  70669. private _enterCount;
  70670. private _doNotRender;
  70671. private _downPointerIds;
  70672. protected _isEnabled: boolean;
  70673. protected _disabledColor: string;
  70674. /** @hidden */
  70675. protected _rebuildLayout: boolean;
  70676. /** @hidden */
  70677. _customData: any;
  70678. /** @hidden */
  70679. _isClipped: boolean;
  70680. /** @hidden */
  70681. _automaticSize: boolean;
  70682. /** @hidden */
  70683. _tag: any;
  70684. /**
  70685. * 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
  70686. */
  70687. uniqueId: number;
  70688. /**
  70689. * Gets or sets an object used to store user defined information for the node
  70690. */
  70691. metadata: any;
  70692. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  70693. isHitTestVisible: boolean;
  70694. /** Gets or sets a boolean indicating if the control can block pointer events */
  70695. isPointerBlocker: boolean;
  70696. /** Gets or sets a boolean indicating if the control can be focusable */
  70697. isFocusInvisible: boolean;
  70698. /**
  70699. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  70700. * 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
  70701. */
  70702. clipChildren: boolean;
  70703. /**
  70704. * Gets or sets a boolean indicating that control content must be clipped
  70705. * 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
  70706. */
  70707. clipContent: boolean;
  70708. /**
  70709. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  70710. */
  70711. useBitmapCache: boolean;
  70712. private _cacheData;
  70713. private _shadowOffsetX;
  70714. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  70715. get shadowOffsetX(): number;
  70716. set shadowOffsetX(value: number);
  70717. private _shadowOffsetY;
  70718. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  70719. get shadowOffsetY(): number;
  70720. set shadowOffsetY(value: number);
  70721. private _shadowBlur;
  70722. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  70723. get shadowBlur(): number;
  70724. set shadowBlur(value: number);
  70725. private _shadowColor;
  70726. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  70727. get shadowColor(): string;
  70728. set shadowColor(value: string);
  70729. /** Gets or sets the cursor to use when the control is hovered */
  70730. hoverCursor: string;
  70731. /** @hidden */
  70732. protected _linkOffsetX: ValueAndUnit;
  70733. /** @hidden */
  70734. protected _linkOffsetY: ValueAndUnit;
  70735. /** Gets the control type name */
  70736. get typeName(): string;
  70737. /**
  70738. * Get the current class name of the control.
  70739. * @returns current class name
  70740. */
  70741. getClassName(): string;
  70742. /**
  70743. * An event triggered when the pointer move over the control.
  70744. */
  70745. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  70746. /**
  70747. * An event triggered when the pointer move out of the control.
  70748. */
  70749. onPointerOutObservable: BABYLON.Observable<Control>;
  70750. /**
  70751. * An event triggered when the pointer taps the control
  70752. */
  70753. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  70754. /**
  70755. * An event triggered when pointer up
  70756. */
  70757. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  70758. /**
  70759. * An event triggered when a control is clicked on
  70760. */
  70761. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  70762. /**
  70763. * An event triggered when pointer enters the control
  70764. */
  70765. onPointerEnterObservable: BABYLON.Observable<Control>;
  70766. /**
  70767. * An event triggered when the control is marked as dirty
  70768. */
  70769. onDirtyObservable: BABYLON.Observable<Control>;
  70770. /**
  70771. * An event triggered before drawing the control
  70772. */
  70773. onBeforeDrawObservable: BABYLON.Observable<Control>;
  70774. /**
  70775. * An event triggered after the control was drawn
  70776. */
  70777. onAfterDrawObservable: BABYLON.Observable<Control>;
  70778. /**
  70779. * Get the hosting AdvancedDynamicTexture
  70780. */
  70781. get host(): AdvancedDynamicTexture;
  70782. /** Gets or set information about font offsets (used to render and align text) */
  70783. get fontOffset(): {
  70784. ascent: number;
  70785. height: number;
  70786. descent: number;
  70787. };
  70788. set fontOffset(offset: {
  70789. ascent: number;
  70790. height: number;
  70791. descent: number;
  70792. });
  70793. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  70794. get alpha(): number;
  70795. set alpha(value: number);
  70796. /**
  70797. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  70798. */
  70799. get isHighlighted(): boolean;
  70800. set isHighlighted(value: boolean);
  70801. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  70802. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  70803. */
  70804. get scaleX(): number;
  70805. set scaleX(value: number);
  70806. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  70807. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  70808. */
  70809. get scaleY(): number;
  70810. set scaleY(value: number);
  70811. /** Gets or sets the rotation angle (0 by default)
  70812. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  70813. */
  70814. get rotation(): number;
  70815. set rotation(value: number);
  70816. /** Gets or sets the transformation center on Y axis (0 by default)
  70817. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  70818. */
  70819. get transformCenterY(): number;
  70820. set transformCenterY(value: number);
  70821. /** Gets or sets the transformation center on X axis (0 by default)
  70822. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  70823. */
  70824. get transformCenterX(): number;
  70825. set transformCenterX(value: number);
  70826. /**
  70827. * Gets or sets the horizontal alignment
  70828. * @see http://doc.babylonjs.com/how_to/gui#alignments
  70829. */
  70830. get horizontalAlignment(): number;
  70831. set horizontalAlignment(value: number);
  70832. /**
  70833. * Gets or sets the vertical alignment
  70834. * @see http://doc.babylonjs.com/how_to/gui#alignments
  70835. */
  70836. get verticalAlignment(): number;
  70837. set verticalAlignment(value: number);
  70838. /**
  70839. * Gets or sets control width
  70840. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  70841. */
  70842. get width(): string | number;
  70843. set width(value: string | number);
  70844. /**
  70845. * Gets or sets the control width in pixel
  70846. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  70847. */
  70848. get widthInPixels(): number;
  70849. set widthInPixels(value: number);
  70850. /**
  70851. * Gets or sets control height
  70852. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  70853. */
  70854. get height(): string | number;
  70855. set height(value: string | number);
  70856. /**
  70857. * Gets or sets control height in pixel
  70858. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  70859. */
  70860. get heightInPixels(): number;
  70861. set heightInPixels(value: number);
  70862. /** Gets or set font family */
  70863. get fontFamily(): string;
  70864. set fontFamily(value: string);
  70865. /** Gets or sets font style */
  70866. get fontStyle(): string;
  70867. set fontStyle(value: string);
  70868. /** Gets or sets font weight */
  70869. get fontWeight(): string;
  70870. set fontWeight(value: string);
  70871. /**
  70872. * Gets or sets style
  70873. * @see http://doc.babylonjs.com/how_to/gui#styles
  70874. */
  70875. get style(): BABYLON.Nullable<Style>;
  70876. set style(value: BABYLON.Nullable<Style>);
  70877. /** @hidden */
  70878. get _isFontSizeInPercentage(): boolean;
  70879. /** Gets or sets font size in pixels */
  70880. get fontSizeInPixels(): number;
  70881. set fontSizeInPixels(value: number);
  70882. /** Gets or sets font size */
  70883. get fontSize(): string | number;
  70884. set fontSize(value: string | number);
  70885. /** Gets or sets foreground color */
  70886. get color(): string;
  70887. set color(value: string);
  70888. /** Gets or sets z index which is used to reorder controls on the z axis */
  70889. get zIndex(): number;
  70890. set zIndex(value: number);
  70891. /** Gets or sets a boolean indicating if the control can be rendered */
  70892. get notRenderable(): boolean;
  70893. set notRenderable(value: boolean);
  70894. /** Gets or sets a boolean indicating if the control is visible */
  70895. get isVisible(): boolean;
  70896. set isVisible(value: boolean);
  70897. /** Gets a boolean indicating that the control needs to update its rendering */
  70898. get isDirty(): boolean;
  70899. /**
  70900. * Gets the current linked mesh (or null if none)
  70901. */
  70902. get linkedMesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  70903. /**
  70904. * Gets or sets a value indicating the padding to use on the left of the control
  70905. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  70906. */
  70907. get paddingLeft(): string | number;
  70908. set paddingLeft(value: string | number);
  70909. /**
  70910. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  70911. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  70912. */
  70913. get paddingLeftInPixels(): number;
  70914. set paddingLeftInPixels(value: number);
  70915. /**
  70916. * Gets or sets a value indicating the padding to use on the right of the control
  70917. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  70918. */
  70919. get paddingRight(): string | number;
  70920. set paddingRight(value: string | number);
  70921. /**
  70922. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  70923. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  70924. */
  70925. get paddingRightInPixels(): number;
  70926. set paddingRightInPixels(value: number);
  70927. /**
  70928. * Gets or sets a value indicating the padding to use on the top of the control
  70929. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  70930. */
  70931. get paddingTop(): string | number;
  70932. set paddingTop(value: string | number);
  70933. /**
  70934. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  70935. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  70936. */
  70937. get paddingTopInPixels(): number;
  70938. set paddingTopInPixels(value: number);
  70939. /**
  70940. * Gets or sets a value indicating the padding to use on the bottom of the control
  70941. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  70942. */
  70943. get paddingBottom(): string | number;
  70944. set paddingBottom(value: string | number);
  70945. /**
  70946. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  70947. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  70948. */
  70949. get paddingBottomInPixels(): number;
  70950. set paddingBottomInPixels(value: number);
  70951. /**
  70952. * Gets or sets a value indicating the left coordinate of the control
  70953. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  70954. */
  70955. get left(): string | number;
  70956. set left(value: string | number);
  70957. /**
  70958. * Gets or sets a value indicating the left coordinate in pixels of the control
  70959. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  70960. */
  70961. get leftInPixels(): number;
  70962. set leftInPixels(value: number);
  70963. /**
  70964. * Gets or sets a value indicating the top coordinate of the control
  70965. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  70966. */
  70967. get top(): string | number;
  70968. set top(value: string | number);
  70969. /**
  70970. * Gets or sets a value indicating the top coordinate in pixels of the control
  70971. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  70972. */
  70973. get topInPixels(): number;
  70974. set topInPixels(value: number);
  70975. /**
  70976. * Gets or sets a value indicating the offset on X axis to the linked mesh
  70977. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  70978. */
  70979. get linkOffsetX(): string | number;
  70980. set linkOffsetX(value: string | number);
  70981. /**
  70982. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  70983. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  70984. */
  70985. get linkOffsetXInPixels(): number;
  70986. set linkOffsetXInPixels(value: number);
  70987. /**
  70988. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  70989. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  70990. */
  70991. get linkOffsetY(): string | number;
  70992. set linkOffsetY(value: string | number);
  70993. /**
  70994. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  70995. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  70996. */
  70997. get linkOffsetYInPixels(): number;
  70998. set linkOffsetYInPixels(value: number);
  70999. /** Gets the center coordinate on X axis */
  71000. get centerX(): number;
  71001. /** Gets the center coordinate on Y axis */
  71002. get centerY(): number;
  71003. /** Gets or sets if control is Enabled*/
  71004. get isEnabled(): boolean;
  71005. set isEnabled(value: boolean);
  71006. /** Gets or sets background color of control if it's disabled*/
  71007. get disabledColor(): string;
  71008. set disabledColor(value: string);
  71009. /**
  71010. * Creates a new control
  71011. * @param name defines the name of the control
  71012. */
  71013. constructor(
  71014. /** defines the name of the control */
  71015. name?: string | undefined);
  71016. /** @hidden */
  71017. protected _getTypeName(): string;
  71018. /**
  71019. * Gets the first ascendant in the hierarchy of the given type
  71020. * @param className defines the required type
  71021. * @returns the ascendant or null if not found
  71022. */
  71023. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  71024. /** @hidden */
  71025. _resetFontCache(): void;
  71026. /**
  71027. * Determines if a container is an ascendant of the current control
  71028. * @param container defines the container to look for
  71029. * @returns true if the container is one of the ascendant of the control
  71030. */
  71031. isAscendant(container: Control): boolean;
  71032. /**
  71033. * Gets coordinates in local control space
  71034. * @param globalCoordinates defines the coordinates to transform
  71035. * @returns the new coordinates in local space
  71036. */
  71037. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  71038. /**
  71039. * Gets coordinates in local control space
  71040. * @param globalCoordinates defines the coordinates to transform
  71041. * @param result defines the target vector2 where to store the result
  71042. * @returns the current control
  71043. */
  71044. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  71045. /**
  71046. * Gets coordinates in parent local control space
  71047. * @param globalCoordinates defines the coordinates to transform
  71048. * @returns the new coordinates in parent local space
  71049. */
  71050. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  71051. /**
  71052. * Move the current control to a vector3 position projected onto the screen.
  71053. * @param position defines the target position
  71054. * @param scene defines the hosting scene
  71055. */
  71056. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  71057. /**
  71058. * Will store all controls that have this control as ascendant in a given array
  71059. * @param results defines the array where to store the descendants
  71060. * @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
  71061. * @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
  71062. */
  71063. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  71064. /**
  71065. * Will return all controls that have this control as ascendant
  71066. * @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
  71067. * @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
  71068. * @return all child controls
  71069. */
  71070. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  71071. /**
  71072. * Link current control with a target mesh
  71073. * @param mesh defines the mesh to link with
  71074. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  71075. */
  71076. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.AbstractMesh>): void;
  71077. /** @hidden */
  71078. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  71079. /** @hidden */
  71080. _offsetLeft(offset: number): void;
  71081. /** @hidden */
  71082. _offsetTop(offset: number): void;
  71083. /** @hidden */
  71084. _markMatrixAsDirty(): void;
  71085. /** @hidden */
  71086. _flagDescendantsAsMatrixDirty(): void;
  71087. /** @hidden */
  71088. _intersectsRect(rect: Measure): boolean;
  71089. /** @hidden */
  71090. protected invalidateRect(): void;
  71091. /** @hidden */
  71092. _markAsDirty(force?: boolean): void;
  71093. /** @hidden */
  71094. _markAllAsDirty(): void;
  71095. /** @hidden */
  71096. _link(host: AdvancedDynamicTexture): void;
  71097. /** @hidden */
  71098. protected _transform(context?: CanvasRenderingContext2D): void;
  71099. /** @hidden */
  71100. _renderHighlight(context: CanvasRenderingContext2D): void;
  71101. /** @hidden */
  71102. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  71103. /** @hidden */
  71104. protected _applyStates(context: CanvasRenderingContext2D): void;
  71105. /** @hidden */
  71106. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  71107. /** @hidden */
  71108. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  71109. protected _evaluateClippingState(parentMeasure: Measure): void;
  71110. /** @hidden */
  71111. _measure(): void;
  71112. /** @hidden */
  71113. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  71114. /** @hidden */
  71115. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  71116. /** @hidden */
  71117. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  71118. /** @hidden */
  71119. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  71120. private static _ClipMeasure;
  71121. private _tmpMeasureA;
  71122. private _clip;
  71123. /** @hidden */
  71124. _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  71125. /** @hidden */
  71126. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  71127. /**
  71128. * Tests if a given coordinates belong to the current control
  71129. * @param x defines x coordinate to test
  71130. * @param y defines y coordinate to test
  71131. * @returns true if the coordinates are inside the control
  71132. */
  71133. contains(x: number, y: number): boolean;
  71134. /** @hidden */
  71135. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  71136. /** @hidden */
  71137. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  71138. /** @hidden */
  71139. _onPointerEnter(target: Control): boolean;
  71140. /** @hidden */
  71141. _onPointerOut(target: Control, force?: boolean): void;
  71142. /** @hidden */
  71143. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  71144. /** @hidden */
  71145. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  71146. /** @hidden */
  71147. _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  71148. /** @hidden */
  71149. _processObservables(type: number, x: number, y: number, pointerId: number, buttonIndex: number): boolean;
  71150. private _prepareFont;
  71151. /** Releases associated resources */
  71152. dispose(): void;
  71153. private static _HORIZONTAL_ALIGNMENT_LEFT;
  71154. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  71155. private static _HORIZONTAL_ALIGNMENT_CENTER;
  71156. private static _VERTICAL_ALIGNMENT_TOP;
  71157. private static _VERTICAL_ALIGNMENT_BOTTOM;
  71158. private static _VERTICAL_ALIGNMENT_CENTER;
  71159. /** HORIZONTAL_ALIGNMENT_LEFT */
  71160. static get HORIZONTAL_ALIGNMENT_LEFT(): number;
  71161. /** HORIZONTAL_ALIGNMENT_RIGHT */
  71162. static get HORIZONTAL_ALIGNMENT_RIGHT(): number;
  71163. /** HORIZONTAL_ALIGNMENT_CENTER */
  71164. static get HORIZONTAL_ALIGNMENT_CENTER(): number;
  71165. /** VERTICAL_ALIGNMENT_TOP */
  71166. static get VERTICAL_ALIGNMENT_TOP(): number;
  71167. /** VERTICAL_ALIGNMENT_BOTTOM */
  71168. static get VERTICAL_ALIGNMENT_BOTTOM(): number;
  71169. /** VERTICAL_ALIGNMENT_CENTER */
  71170. static get VERTICAL_ALIGNMENT_CENTER(): number;
  71171. private static _FontHeightSizes;
  71172. /** @hidden */
  71173. static _GetFontOffset(font: string): {
  71174. ascent: number;
  71175. height: number;
  71176. descent: number;
  71177. };
  71178. /**
  71179. * Creates a stack panel that can be used to render headers
  71180. * @param control defines the control to associate with the header
  71181. * @param text defines the text of the header
  71182. * @param size defines the size of the header
  71183. * @param options defines options used to configure the header
  71184. * @returns a new StackPanel
  71185. * @ignore
  71186. * @hidden
  71187. */
  71188. static AddHeader: (control: Control, text: string, size: string | number, options: {
  71189. isHorizontal: boolean;
  71190. controlFirst: boolean;
  71191. }) => any;
  71192. /** @hidden */
  71193. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  71194. }
  71195. }
  71196. declare module BABYLON.GUI {
  71197. /**
  71198. * Root class for 2D containers
  71199. * @see http://doc.babylonjs.com/how_to/gui#containers
  71200. */
  71201. export class Container extends Control {
  71202. name?: string | undefined;
  71203. /** @hidden */
  71204. _children: Control[];
  71205. /** @hidden */
  71206. protected _measureForChildren: Measure;
  71207. /** @hidden */
  71208. protected _background: string;
  71209. /** @hidden */
  71210. protected _adaptWidthToChildren: boolean;
  71211. /** @hidden */
  71212. protected _adaptHeightToChildren: boolean;
  71213. /**
  71214. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  71215. */
  71216. logLayoutCycleErrors: boolean;
  71217. /**
  71218. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  71219. */
  71220. maxLayoutCycle: number;
  71221. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  71222. get adaptHeightToChildren(): boolean;
  71223. set adaptHeightToChildren(value: boolean);
  71224. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  71225. get adaptWidthToChildren(): boolean;
  71226. set adaptWidthToChildren(value: boolean);
  71227. /** Gets or sets background color */
  71228. get background(): string;
  71229. set background(value: string);
  71230. /** Gets the list of children */
  71231. get children(): Control[];
  71232. /**
  71233. * Creates a new Container
  71234. * @param name defines the name of the container
  71235. */
  71236. constructor(name?: string | undefined);
  71237. protected _getTypeName(): string;
  71238. _flagDescendantsAsMatrixDirty(): void;
  71239. /**
  71240. * Gets a child using its name
  71241. * @param name defines the child name to look for
  71242. * @returns the child control if found
  71243. */
  71244. getChildByName(name: string): BABYLON.Nullable<Control>;
  71245. /**
  71246. * Gets a child using its type and its name
  71247. * @param name defines the child name to look for
  71248. * @param type defines the child type to look for
  71249. * @returns the child control if found
  71250. */
  71251. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  71252. /**
  71253. * Search for a specific control in children
  71254. * @param control defines the control to look for
  71255. * @returns true if the control is in child list
  71256. */
  71257. containsControl(control: Control): boolean;
  71258. /**
  71259. * Adds a new control to the current container
  71260. * @param control defines the control to add
  71261. * @returns the current container
  71262. */
  71263. addControl(control: BABYLON.Nullable<Control>): Container;
  71264. /**
  71265. * Removes all controls from the current container
  71266. * @returns the current container
  71267. */
  71268. clearControls(): Container;
  71269. /**
  71270. * Removes a control from the current container
  71271. * @param control defines the control to remove
  71272. * @returns the current container
  71273. */
  71274. removeControl(control: Control): Container;
  71275. /** @hidden */
  71276. _reOrderControl(control: Control): void;
  71277. /** @hidden */
  71278. _offsetLeft(offset: number): void;
  71279. /** @hidden */
  71280. _offsetTop(offset: number): void;
  71281. /** @hidden */
  71282. _markAllAsDirty(): void;
  71283. /** @hidden */
  71284. protected _localDraw(context: CanvasRenderingContext2D): void;
  71285. /** @hidden */
  71286. _link(host: AdvancedDynamicTexture): void;
  71287. /** @hidden */
  71288. protected _beforeLayout(): void;
  71289. /** @hidden */
  71290. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  71291. /** @hidden */
  71292. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  71293. protected _postMeasure(): void;
  71294. /** @hidden */
  71295. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  71296. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  71297. /** @hidden */
  71298. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  71299. /** @hidden */
  71300. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  71301. /** Releases associated resources */
  71302. dispose(): void;
  71303. }
  71304. }
  71305. declare module BABYLON.GUI {
  71306. /** Class used to create rectangle container */
  71307. export class Rectangle extends Container {
  71308. name?: string | undefined;
  71309. private _thickness;
  71310. private _cornerRadius;
  71311. /** Gets or sets border thickness */
  71312. get thickness(): number;
  71313. set thickness(value: number);
  71314. /** Gets or sets the corner radius angle */
  71315. get cornerRadius(): number;
  71316. set cornerRadius(value: number);
  71317. /**
  71318. * Creates a new Rectangle
  71319. * @param name defines the control name
  71320. */
  71321. constructor(name?: string | undefined);
  71322. protected _getTypeName(): string;
  71323. protected _localDraw(context: CanvasRenderingContext2D): void;
  71324. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  71325. private _drawRoundedRect;
  71326. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  71327. }
  71328. }
  71329. declare module BABYLON.GUI {
  71330. /**
  71331. * Enum that determines the text-wrapping mode to use.
  71332. */
  71333. export enum TextWrapping {
  71334. /**
  71335. * Clip the text when it's larger than Control.width; this is the default mode.
  71336. */
  71337. Clip = 0,
  71338. /**
  71339. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  71340. */
  71341. WordWrap = 1,
  71342. /**
  71343. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  71344. */
  71345. Ellipsis = 2
  71346. }
  71347. /**
  71348. * Class used to create text block control
  71349. */
  71350. export class TextBlock extends Control {
  71351. /**
  71352. * Defines the name of the control
  71353. */
  71354. name?: string | undefined;
  71355. private _text;
  71356. private _textWrapping;
  71357. private _textHorizontalAlignment;
  71358. private _textVerticalAlignment;
  71359. private _lines;
  71360. private _resizeToFit;
  71361. private _lineSpacing;
  71362. private _outlineWidth;
  71363. private _outlineColor;
  71364. /**
  71365. * An event triggered after the text is changed
  71366. */
  71367. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  71368. /**
  71369. * An event triggered after the text was broken up into lines
  71370. */
  71371. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  71372. /**
  71373. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  71374. */
  71375. get lines(): any[];
  71376. /**
  71377. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  71378. */
  71379. get resizeToFit(): boolean;
  71380. /**
  71381. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  71382. */
  71383. set resizeToFit(value: boolean);
  71384. /**
  71385. * Gets or sets a boolean indicating if text must be wrapped
  71386. */
  71387. get textWrapping(): TextWrapping | boolean;
  71388. /**
  71389. * Gets or sets a boolean indicating if text must be wrapped
  71390. */
  71391. set textWrapping(value: TextWrapping | boolean);
  71392. /**
  71393. * Gets or sets text to display
  71394. */
  71395. get text(): string;
  71396. /**
  71397. * Gets or sets text to display
  71398. */
  71399. set text(value: string);
  71400. /**
  71401. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  71402. */
  71403. get textHorizontalAlignment(): number;
  71404. /**
  71405. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  71406. */
  71407. set textHorizontalAlignment(value: number);
  71408. /**
  71409. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  71410. */
  71411. get textVerticalAlignment(): number;
  71412. /**
  71413. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  71414. */
  71415. set textVerticalAlignment(value: number);
  71416. /**
  71417. * Gets or sets line spacing value
  71418. */
  71419. set lineSpacing(value: string | number);
  71420. /**
  71421. * Gets or sets line spacing value
  71422. */
  71423. get lineSpacing(): string | number;
  71424. /**
  71425. * Gets or sets outlineWidth of the text to display
  71426. */
  71427. get outlineWidth(): number;
  71428. /**
  71429. * Gets or sets outlineWidth of the text to display
  71430. */
  71431. set outlineWidth(value: number);
  71432. /**
  71433. * Gets or sets outlineColor of the text to display
  71434. */
  71435. get outlineColor(): string;
  71436. /**
  71437. * Gets or sets outlineColor of the text to display
  71438. */
  71439. set outlineColor(value: string);
  71440. /**
  71441. * Creates a new TextBlock object
  71442. * @param name defines the name of the control
  71443. * @param text defines the text to display (emptry string by default)
  71444. */
  71445. constructor(
  71446. /**
  71447. * Defines the name of the control
  71448. */
  71449. name?: string | undefined, text?: string);
  71450. protected _getTypeName(): string;
  71451. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  71452. private _drawText;
  71453. /** @hidden */
  71454. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  71455. protected _applyStates(context: CanvasRenderingContext2D): void;
  71456. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  71457. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  71458. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  71459. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  71460. protected _renderLines(context: CanvasRenderingContext2D): void;
  71461. /**
  71462. * Given a width constraint applied on the text block, find the expected height
  71463. * @returns expected height
  71464. */
  71465. computeExpectedHeight(): number;
  71466. dispose(): void;
  71467. }
  71468. }
  71469. declare module BABYLON.GUI {
  71470. /**
  71471. * Class used to create 2D images
  71472. */
  71473. export class Image extends Control {
  71474. name?: string | undefined;
  71475. private _workingCanvas;
  71476. private _domImage;
  71477. private _imageWidth;
  71478. private _imageHeight;
  71479. private _loaded;
  71480. private _stretch;
  71481. private _source;
  71482. private _autoScale;
  71483. private _sourceLeft;
  71484. private _sourceTop;
  71485. private _sourceWidth;
  71486. private _sourceHeight;
  71487. private _svgAttributesComputationCompleted;
  71488. private _isSVG;
  71489. private _cellWidth;
  71490. private _cellHeight;
  71491. private _cellId;
  71492. private _populateNinePatchSlicesFromImage;
  71493. private _sliceLeft;
  71494. private _sliceRight;
  71495. private _sliceTop;
  71496. private _sliceBottom;
  71497. private _detectPointerOnOpaqueOnly;
  71498. /**
  71499. * BABYLON.Observable notified when the content is loaded
  71500. */
  71501. onImageLoadedObservable: BABYLON.Observable<Image>;
  71502. /**
  71503. * BABYLON.Observable notified when _sourceLeft, _sourceTop, _sourceWidth and _sourceHeight are computed
  71504. */
  71505. onSVGAttributesComputedObservable: BABYLON.Observable<Image>;
  71506. /**
  71507. * Gets a boolean indicating that the content is loaded
  71508. */
  71509. get isLoaded(): boolean;
  71510. /**
  71511. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  71512. */
  71513. get populateNinePatchSlicesFromImage(): boolean;
  71514. set populateNinePatchSlicesFromImage(value: boolean);
  71515. /**
  71516. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  71517. * Beware using this as this will comsume more memory as the image has to be stored twice
  71518. */
  71519. get detectPointerOnOpaqueOnly(): boolean;
  71520. set detectPointerOnOpaqueOnly(value: boolean);
  71521. /**
  71522. * Gets or sets the left value for slicing (9-patch)
  71523. */
  71524. get sliceLeft(): number;
  71525. set sliceLeft(value: number);
  71526. /**
  71527. * Gets or sets the right value for slicing (9-patch)
  71528. */
  71529. get sliceRight(): number;
  71530. set sliceRight(value: number);
  71531. /**
  71532. * Gets or sets the top value for slicing (9-patch)
  71533. */
  71534. get sliceTop(): number;
  71535. set sliceTop(value: number);
  71536. /**
  71537. * Gets or sets the bottom value for slicing (9-patch)
  71538. */
  71539. get sliceBottom(): number;
  71540. set sliceBottom(value: number);
  71541. /**
  71542. * Gets or sets the left coordinate in the source image
  71543. */
  71544. get sourceLeft(): number;
  71545. set sourceLeft(value: number);
  71546. /**
  71547. * Gets or sets the top coordinate in the source image
  71548. */
  71549. get sourceTop(): number;
  71550. set sourceTop(value: number);
  71551. /**
  71552. * Gets or sets the width to capture in the source image
  71553. */
  71554. get sourceWidth(): number;
  71555. set sourceWidth(value: number);
  71556. /**
  71557. * Gets or sets the height to capture in the source image
  71558. */
  71559. get sourceHeight(): number;
  71560. set sourceHeight(value: number);
  71561. /** Indicates if the format of the image is SVG */
  71562. get isSVG(): boolean;
  71563. /** Gets the status of the SVG attributes computation (sourceLeft, sourceTop, sourceWidth, sourceHeight) */
  71564. get svgAttributesComputationCompleted(): boolean;
  71565. /**
  71566. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  71567. * @see http://doc.babylonjs.com/how_to/gui#image
  71568. */
  71569. get autoScale(): boolean;
  71570. set autoScale(value: boolean);
  71571. /** Gets or sets the streching mode used by the image */
  71572. get stretch(): number;
  71573. set stretch(value: number);
  71574. /** @hidden */
  71575. _rotate90(n: number, preserveProperties?: boolean): Image;
  71576. private _handleRotationForSVGImage;
  71577. private _rotate90SourceProperties;
  71578. /**
  71579. * Gets or sets the internal DOM image used to render the control
  71580. */
  71581. set domImage(value: HTMLImageElement);
  71582. get domImage(): HTMLImageElement;
  71583. private _onImageLoaded;
  71584. private _extractNinePatchSliceDataFromImage;
  71585. /**
  71586. * Gets or sets image source url
  71587. */
  71588. set source(value: BABYLON.Nullable<string>);
  71589. /**
  71590. * Checks for svg document with icon id present
  71591. */
  71592. private _svgCheck;
  71593. /**
  71594. * Sets sourceLeft, sourceTop, sourceWidth, sourceHeight automatically
  71595. * given external svg file and icon id
  71596. */
  71597. private _getSVGAttribs;
  71598. /**
  71599. * Gets or sets the cell width to use when animation sheet is enabled
  71600. * @see http://doc.babylonjs.com/how_to/gui#image
  71601. */
  71602. get cellWidth(): number;
  71603. set cellWidth(value: number);
  71604. /**
  71605. * Gets or sets the cell height to use when animation sheet is enabled
  71606. * @see http://doc.babylonjs.com/how_to/gui#image
  71607. */
  71608. get cellHeight(): number;
  71609. set cellHeight(value: number);
  71610. /**
  71611. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  71612. * @see http://doc.babylonjs.com/how_to/gui#image
  71613. */
  71614. get cellId(): number;
  71615. set cellId(value: number);
  71616. /**
  71617. * Creates a new Image
  71618. * @param name defines the control name
  71619. * @param url defines the image url
  71620. */
  71621. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  71622. /**
  71623. * Tests if a given coordinates belong to the current control
  71624. * @param x defines x coordinate to test
  71625. * @param y defines y coordinate to test
  71626. * @returns true if the coordinates are inside the control
  71627. */
  71628. contains(x: number, y: number): boolean;
  71629. protected _getTypeName(): string;
  71630. /** Force the control to synchronize with its content */
  71631. synchronizeSizeWithContent(): void;
  71632. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  71633. private _prepareWorkingCanvasForOpaqueDetection;
  71634. private _drawImage;
  71635. _draw(context: CanvasRenderingContext2D): void;
  71636. private _renderCornerPatch;
  71637. private _renderNinePatch;
  71638. dispose(): void;
  71639. /** STRETCH_NONE */
  71640. static readonly STRETCH_NONE: number;
  71641. /** STRETCH_FILL */
  71642. static readonly STRETCH_FILL: number;
  71643. /** STRETCH_UNIFORM */
  71644. static readonly STRETCH_UNIFORM: number;
  71645. /** STRETCH_EXTEND */
  71646. static readonly STRETCH_EXTEND: number;
  71647. /** NINE_PATCH */
  71648. static readonly STRETCH_NINE_PATCH: number;
  71649. }
  71650. }
  71651. declare module BABYLON.GUI {
  71652. /**
  71653. * Class used to create 2D buttons
  71654. */
  71655. export class Button extends Rectangle {
  71656. name?: string | undefined;
  71657. /**
  71658. * Function called to generate a pointer enter animation
  71659. */
  71660. pointerEnterAnimation: () => void;
  71661. /**
  71662. * Function called to generate a pointer out animation
  71663. */
  71664. pointerOutAnimation: () => void;
  71665. /**
  71666. * Function called to generate a pointer down animation
  71667. */
  71668. pointerDownAnimation: () => void;
  71669. /**
  71670. * Function called to generate a pointer up animation
  71671. */
  71672. pointerUpAnimation: () => void;
  71673. /**
  71674. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  71675. */
  71676. delegatePickingToChildren: boolean;
  71677. private _image;
  71678. /**
  71679. * Returns the image part of the button (if any)
  71680. */
  71681. get image(): BABYLON.Nullable<Image>;
  71682. private _textBlock;
  71683. /**
  71684. * Returns the image part of the button (if any)
  71685. */
  71686. get textBlock(): BABYLON.Nullable<TextBlock>;
  71687. /**
  71688. * Creates a new Button
  71689. * @param name defines the name of the button
  71690. */
  71691. constructor(name?: string | undefined);
  71692. protected _getTypeName(): string;
  71693. /** @hidden */
  71694. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  71695. /** @hidden */
  71696. _onPointerEnter(target: Control): boolean;
  71697. /** @hidden */
  71698. _onPointerOut(target: Control, force?: boolean): void;
  71699. /** @hidden */
  71700. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  71701. /** @hidden */
  71702. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  71703. /**
  71704. * Creates a new button made with an image and a text
  71705. * @param name defines the name of the button
  71706. * @param text defines the text of the button
  71707. * @param imageUrl defines the url of the image
  71708. * @returns a new Button
  71709. */
  71710. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  71711. /**
  71712. * Creates a new button made with an image
  71713. * @param name defines the name of the button
  71714. * @param imageUrl defines the url of the image
  71715. * @returns a new Button
  71716. */
  71717. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  71718. /**
  71719. * Creates a new button made with a text
  71720. * @param name defines the name of the button
  71721. * @param text defines the text of the button
  71722. * @returns a new Button
  71723. */
  71724. static CreateSimpleButton(name: string, text: string): Button;
  71725. /**
  71726. * Creates a new button made with an image and a centered text
  71727. * @param name defines the name of the button
  71728. * @param text defines the text of the button
  71729. * @param imageUrl defines the url of the image
  71730. * @returns a new Button
  71731. */
  71732. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  71733. }
  71734. }
  71735. declare module BABYLON.GUI {
  71736. /**
  71737. * Class used to create a 2D stack panel container
  71738. */
  71739. export class StackPanel extends Container {
  71740. name?: string | undefined;
  71741. private _isVertical;
  71742. private _manualWidth;
  71743. private _manualHeight;
  71744. private _doNotTrackManualChanges;
  71745. /**
  71746. * Gets or sets a boolean indicating that layou warnings should be ignored
  71747. */
  71748. ignoreLayoutWarnings: boolean;
  71749. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  71750. get isVertical(): boolean;
  71751. set isVertical(value: boolean);
  71752. /**
  71753. * Gets or sets panel width.
  71754. * This value should not be set when in horizontal mode as it will be computed automatically
  71755. */
  71756. set width(value: string | number);
  71757. get width(): string | number;
  71758. /**
  71759. * Gets or sets panel height.
  71760. * This value should not be set when in vertical mode as it will be computed automatically
  71761. */
  71762. set height(value: string | number);
  71763. get height(): string | number;
  71764. /**
  71765. * Creates a new StackPanel
  71766. * @param name defines control name
  71767. */
  71768. constructor(name?: string | undefined);
  71769. protected _getTypeName(): string;
  71770. /** @hidden */
  71771. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  71772. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  71773. protected _postMeasure(): void;
  71774. }
  71775. }
  71776. declare module BABYLON.GUI {
  71777. /**
  71778. * Class used to represent a 2D checkbox
  71779. */
  71780. export class Checkbox extends Control {
  71781. name?: string | undefined;
  71782. private _isChecked;
  71783. private _background;
  71784. private _checkSizeRatio;
  71785. private _thickness;
  71786. /** Gets or sets border thickness */
  71787. get thickness(): number;
  71788. set thickness(value: number);
  71789. /**
  71790. * BABYLON.Observable raised when isChecked property changes
  71791. */
  71792. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  71793. /** Gets or sets a value indicating the ratio between overall size and check size */
  71794. get checkSizeRatio(): number;
  71795. set checkSizeRatio(value: number);
  71796. /** Gets or sets background color */
  71797. get background(): string;
  71798. set background(value: string);
  71799. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  71800. get isChecked(): boolean;
  71801. set isChecked(value: boolean);
  71802. /**
  71803. * Creates a new CheckBox
  71804. * @param name defines the control name
  71805. */
  71806. constructor(name?: string | undefined);
  71807. protected _getTypeName(): string;
  71808. /** @hidden */
  71809. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  71810. /** @hidden */
  71811. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  71812. /**
  71813. * Utility function to easily create a checkbox with a header
  71814. * @param title defines the label to use for the header
  71815. * @param onValueChanged defines the callback to call when value changes
  71816. * @returns a StackPanel containing the checkbox and a textBlock
  71817. */
  71818. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  71819. }
  71820. }
  71821. declare module BABYLON.GUI {
  71822. /**
  71823. * Class used to store key control properties
  71824. */
  71825. export class KeyPropertySet {
  71826. /** Width */
  71827. width?: string;
  71828. /** Height */
  71829. height?: string;
  71830. /** Left padding */
  71831. paddingLeft?: string;
  71832. /** Right padding */
  71833. paddingRight?: string;
  71834. /** Top padding */
  71835. paddingTop?: string;
  71836. /** Bottom padding */
  71837. paddingBottom?: string;
  71838. /** Foreground color */
  71839. color?: string;
  71840. /** Background color */
  71841. background?: string;
  71842. }
  71843. /**
  71844. * Class used to create virtual keyboard
  71845. */
  71846. export class VirtualKeyboard extends StackPanel {
  71847. /** BABYLON.Observable raised when a key is pressed */
  71848. onKeyPressObservable: BABYLON.Observable<string>;
  71849. /** Gets or sets default key button width */
  71850. defaultButtonWidth: string;
  71851. /** Gets or sets default key button height */
  71852. defaultButtonHeight: string;
  71853. /** Gets or sets default key button left padding */
  71854. defaultButtonPaddingLeft: string;
  71855. /** Gets or sets default key button right padding */
  71856. defaultButtonPaddingRight: string;
  71857. /** Gets or sets default key button top padding */
  71858. defaultButtonPaddingTop: string;
  71859. /** Gets or sets default key button bottom padding */
  71860. defaultButtonPaddingBottom: string;
  71861. /** Gets or sets default key button foreground color */
  71862. defaultButtonColor: string;
  71863. /** Gets or sets default key button background color */
  71864. defaultButtonBackground: string;
  71865. /** Gets or sets shift button foreground color */
  71866. shiftButtonColor: string;
  71867. /** Gets or sets shift button thickness*/
  71868. selectedShiftThickness: number;
  71869. /** Gets shift key state */
  71870. shiftState: number;
  71871. protected _getTypeName(): string;
  71872. private _createKey;
  71873. /**
  71874. * Adds a new row of keys
  71875. * @param keys defines the list of keys to add
  71876. * @param propertySets defines the associated property sets
  71877. */
  71878. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  71879. /**
  71880. * Set the shift key to a specific state
  71881. * @param shiftState defines the new shift state
  71882. */
  71883. applyShiftState(shiftState: number): void;
  71884. private _currentlyConnectedInputText;
  71885. private _connectedInputTexts;
  71886. private _onKeyPressObserver;
  71887. /** Gets the input text control currently attached to the keyboard */
  71888. get connectedInputText(): BABYLON.Nullable<InputText>;
  71889. /**
  71890. * Connects the keyboard with an input text control
  71891. *
  71892. * @param input defines the target control
  71893. */
  71894. connect(input: InputText): void;
  71895. /**
  71896. * Disconnects the keyboard from connected InputText controls
  71897. *
  71898. * @param input optionally defines a target control, otherwise all are disconnected
  71899. */
  71900. disconnect(input?: InputText): void;
  71901. private _removeConnectedInputObservables;
  71902. /**
  71903. * Release all resources
  71904. */
  71905. dispose(): void;
  71906. /**
  71907. * Creates a new keyboard using a default layout
  71908. *
  71909. * @param name defines control name
  71910. * @returns a new VirtualKeyboard
  71911. */
  71912. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  71913. }
  71914. }
  71915. declare module BABYLON.GUI {
  71916. /**
  71917. * Class used to create input text control
  71918. */
  71919. export class InputText extends Control implements IFocusableControl {
  71920. name?: string | undefined;
  71921. private _text;
  71922. private _placeholderText;
  71923. private _background;
  71924. private _focusedBackground;
  71925. private _focusedColor;
  71926. private _placeholderColor;
  71927. private _thickness;
  71928. private _margin;
  71929. private _autoStretchWidth;
  71930. private _maxWidth;
  71931. private _isFocused;
  71932. private _blinkTimeout;
  71933. private _blinkIsEven;
  71934. private _cursorOffset;
  71935. private _scrollLeft;
  71936. private _textWidth;
  71937. private _clickedCoordinate;
  71938. private _deadKey;
  71939. private _addKey;
  71940. private _currentKey;
  71941. private _isTextHighlightOn;
  71942. private _textHighlightColor;
  71943. private _highligherOpacity;
  71944. private _highlightedText;
  71945. private _startHighlightIndex;
  71946. private _endHighlightIndex;
  71947. private _cursorIndex;
  71948. private _onFocusSelectAll;
  71949. private _isPointerDown;
  71950. private _onClipboardObserver;
  71951. private _onPointerDblTapObserver;
  71952. /** @hidden */
  71953. _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  71954. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  71955. promptMessage: string;
  71956. /** Force disable prompt on mobile device */
  71957. disableMobilePrompt: boolean;
  71958. /** BABYLON.Observable raised when the text changes */
  71959. onTextChangedObservable: BABYLON.Observable<InputText>;
  71960. /** BABYLON.Observable raised just before an entered character is to be added */
  71961. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  71962. /** BABYLON.Observable raised when the control gets the focus */
  71963. onFocusObservable: BABYLON.Observable<InputText>;
  71964. /** BABYLON.Observable raised when the control loses the focus */
  71965. onBlurObservable: BABYLON.Observable<InputText>;
  71966. /**Observable raised when the text is highlighted */
  71967. onTextHighlightObservable: BABYLON.Observable<InputText>;
  71968. /**Observable raised when copy event is triggered */
  71969. onTextCopyObservable: BABYLON.Observable<InputText>;
  71970. /** BABYLON.Observable raised when cut event is triggered */
  71971. onTextCutObservable: BABYLON.Observable<InputText>;
  71972. /** BABYLON.Observable raised when paste event is triggered */
  71973. onTextPasteObservable: BABYLON.Observable<InputText>;
  71974. /** BABYLON.Observable raised when a key event was processed */
  71975. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  71976. /** Gets or sets the maximum width allowed by the control */
  71977. get maxWidth(): string | number;
  71978. /** Gets the maximum width allowed by the control in pixels */
  71979. get maxWidthInPixels(): number;
  71980. set maxWidth(value: string | number);
  71981. /** Gets or sets the text highlighter transparency; default: 0.4 */
  71982. get highligherOpacity(): number;
  71983. set highligherOpacity(value: number);
  71984. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  71985. get onFocusSelectAll(): boolean;
  71986. set onFocusSelectAll(value: boolean);
  71987. /** Gets or sets the text hightlight color */
  71988. get textHighlightColor(): string;
  71989. set textHighlightColor(value: string);
  71990. /** Gets or sets control margin */
  71991. get margin(): string;
  71992. /** Gets control margin in pixels */
  71993. get marginInPixels(): number;
  71994. set margin(value: string);
  71995. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  71996. get autoStretchWidth(): boolean;
  71997. set autoStretchWidth(value: boolean);
  71998. /** Gets or sets border thickness */
  71999. get thickness(): number;
  72000. set thickness(value: number);
  72001. /** Gets or sets the background color when focused */
  72002. get focusedBackground(): string;
  72003. set focusedBackground(value: string);
  72004. /** Gets or sets the background color when focused */
  72005. get focusedColor(): string;
  72006. set focusedColor(value: string);
  72007. /** Gets or sets the background color */
  72008. get background(): string;
  72009. set background(value: string);
  72010. /** Gets or sets the placeholder color */
  72011. get placeholderColor(): string;
  72012. set placeholderColor(value: string);
  72013. /** Gets or sets the text displayed when the control is empty */
  72014. get placeholderText(): string;
  72015. set placeholderText(value: string);
  72016. /** Gets or sets the dead key flag */
  72017. get deadKey(): boolean;
  72018. set deadKey(flag: boolean);
  72019. /** Gets or sets the highlight text */
  72020. get highlightedText(): string;
  72021. set highlightedText(text: string);
  72022. /** Gets or sets if the current key should be added */
  72023. get addKey(): boolean;
  72024. set addKey(flag: boolean);
  72025. /** Gets or sets the value of the current key being entered */
  72026. get currentKey(): string;
  72027. set currentKey(key: string);
  72028. /** Gets or sets the text displayed in the control */
  72029. get text(): string;
  72030. set text(value: string);
  72031. /** Gets or sets control width */
  72032. get width(): string | number;
  72033. set width(value: string | number);
  72034. /**
  72035. * Creates a new InputText
  72036. * @param name defines the control name
  72037. * @param text defines the text of the control
  72038. */
  72039. constructor(name?: string | undefined, text?: string);
  72040. /** @hidden */
  72041. onBlur(): void;
  72042. /** @hidden */
  72043. onFocus(): void;
  72044. protected _getTypeName(): string;
  72045. /**
  72046. * Function called to get the list of controls that should not steal the focus from this control
  72047. * @returns an array of controls
  72048. */
  72049. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  72050. /** @hidden */
  72051. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  72052. /** @hidden */
  72053. private _updateValueFromCursorIndex;
  72054. /** @hidden */
  72055. private _processDblClick;
  72056. /** @hidden */
  72057. private _selectAllText;
  72058. /**
  72059. * Handles the keyboard event
  72060. * @param evt Defines the KeyboardEvent
  72061. */
  72062. processKeyboard(evt: KeyboardEvent): void;
  72063. /** @hidden */
  72064. private _onCopyText;
  72065. /** @hidden */
  72066. private _onCutText;
  72067. /** @hidden */
  72068. private _onPasteText;
  72069. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  72070. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  72071. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  72072. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  72073. protected _beforeRenderText(text: string): string;
  72074. dispose(): void;
  72075. }
  72076. }
  72077. declare module BABYLON.GUI {
  72078. /**
  72079. * Class used to create a 2D grid container
  72080. */
  72081. export class Grid extends Container {
  72082. name?: string | undefined;
  72083. private _rowDefinitions;
  72084. private _columnDefinitions;
  72085. private _cells;
  72086. private _childControls;
  72087. /**
  72088. * Gets the number of columns
  72089. */
  72090. get columnCount(): number;
  72091. /**
  72092. * Gets the number of rows
  72093. */
  72094. get rowCount(): number;
  72095. /** Gets the list of children */
  72096. get children(): Control[];
  72097. /** Gets the list of cells (e.g. the containers) */
  72098. get cells(): {
  72099. [key: string]: Container;
  72100. };
  72101. /**
  72102. * Gets the definition of a specific row
  72103. * @param index defines the index of the row
  72104. * @returns the row definition
  72105. */
  72106. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  72107. /**
  72108. * Gets the definition of a specific column
  72109. * @param index defines the index of the column
  72110. * @returns the column definition
  72111. */
  72112. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  72113. /**
  72114. * Adds a new row to the grid
  72115. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  72116. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  72117. * @returns the current grid
  72118. */
  72119. addRowDefinition(height: number, isPixel?: boolean): Grid;
  72120. /**
  72121. * Adds a new column to the grid
  72122. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  72123. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  72124. * @returns the current grid
  72125. */
  72126. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  72127. /**
  72128. * Update a row definition
  72129. * @param index defines the index of the row to update
  72130. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  72131. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  72132. * @returns the current grid
  72133. */
  72134. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  72135. /**
  72136. * Update a column definition
  72137. * @param index defines the index of the column to update
  72138. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  72139. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  72140. * @returns the current grid
  72141. */
  72142. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  72143. /**
  72144. * Gets the list of children stored in a specific cell
  72145. * @param row defines the row to check
  72146. * @param column defines the column to check
  72147. * @returns the list of controls
  72148. */
  72149. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  72150. /**
  72151. * Gets a string representing the child cell info (row x column)
  72152. * @param child defines the control to get info from
  72153. * @returns a string containing the child cell info (row x column)
  72154. */
  72155. getChildCellInfo(child: Control): string;
  72156. private _removeCell;
  72157. private _offsetCell;
  72158. /**
  72159. * Remove a column definition at specified index
  72160. * @param index defines the index of the column to remove
  72161. * @returns the current grid
  72162. */
  72163. removeColumnDefinition(index: number): Grid;
  72164. /**
  72165. * Remove a row definition at specified index
  72166. * @param index defines the index of the row to remove
  72167. * @returns the current grid
  72168. */
  72169. removeRowDefinition(index: number): Grid;
  72170. /**
  72171. * Adds a new control to the current grid
  72172. * @param control defines the control to add
  72173. * @param row defines the row where to add the control (0 by default)
  72174. * @param column defines the column where to add the control (0 by default)
  72175. * @returns the current grid
  72176. */
  72177. addControl(control: Control, row?: number, column?: number): Grid;
  72178. /**
  72179. * Removes a control from the current container
  72180. * @param control defines the control to remove
  72181. * @returns the current container
  72182. */
  72183. removeControl(control: Control): Container;
  72184. /**
  72185. * Creates a new Grid
  72186. * @param name defines control name
  72187. */
  72188. constructor(name?: string | undefined);
  72189. protected _getTypeName(): string;
  72190. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  72191. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72192. _flagDescendantsAsMatrixDirty(): void;
  72193. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  72194. /** Releases associated resources */
  72195. dispose(): void;
  72196. }
  72197. }
  72198. declare module BABYLON.GUI {
  72199. /** Class used to create color pickers */
  72200. export class ColorPicker extends Control {
  72201. name?: string | undefined;
  72202. private static _Epsilon;
  72203. private _colorWheelCanvas;
  72204. private _value;
  72205. private _tmpColor;
  72206. private _pointerStartedOnSquare;
  72207. private _pointerStartedOnWheel;
  72208. private _squareLeft;
  72209. private _squareTop;
  72210. private _squareSize;
  72211. private _h;
  72212. private _s;
  72213. private _v;
  72214. private _lastPointerDownID;
  72215. /**
  72216. * BABYLON.Observable raised when the value changes
  72217. */
  72218. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  72219. /** Gets or sets the color of the color picker */
  72220. get value(): BABYLON.Color3;
  72221. set value(value: BABYLON.Color3);
  72222. /**
  72223. * Gets or sets control width
  72224. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  72225. */
  72226. get width(): string | number;
  72227. set width(value: string | number);
  72228. /**
  72229. * Gets or sets control height
  72230. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  72231. */
  72232. get height(): string | number;
  72233. /** Gets or sets control height */
  72234. set height(value: string | number);
  72235. /** Gets or sets control size */
  72236. get size(): string | number;
  72237. set size(value: string | number);
  72238. /**
  72239. * Creates a new ColorPicker
  72240. * @param name defines the control name
  72241. */
  72242. constructor(name?: string | undefined);
  72243. protected _getTypeName(): string;
  72244. /** @hidden */
  72245. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72246. private _updateSquareProps;
  72247. private _drawGradientSquare;
  72248. private _drawCircle;
  72249. private _createColorWheelCanvas;
  72250. /** @hidden */
  72251. _draw(context: CanvasRenderingContext2D): void;
  72252. private _pointerIsDown;
  72253. private _updateValueFromPointer;
  72254. private _isPointOnSquare;
  72255. private _isPointOnWheel;
  72256. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  72257. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  72258. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  72259. /**
  72260. * This function expands the color picker by creating a color picker dialog with manual
  72261. * color value input and the ability to save colors into an array to be used later in
  72262. * subsequent launches of the dialogue.
  72263. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  72264. * @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.
  72265. * @returns picked color as a hex string and the saved colors array as hex strings.
  72266. */
  72267. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  72268. pickerWidth?: string;
  72269. pickerHeight?: string;
  72270. headerHeight?: string;
  72271. lastColor?: string;
  72272. swatchLimit?: number;
  72273. numSwatchesPerLine?: number;
  72274. savedColors?: Array<string>;
  72275. }): Promise<{
  72276. savedColors?: string[];
  72277. pickedColor: string;
  72278. }>;
  72279. }
  72280. }
  72281. declare module BABYLON.GUI {
  72282. /** Class used to create 2D ellipse containers */
  72283. export class Ellipse extends Container {
  72284. name?: string | undefined;
  72285. private _thickness;
  72286. /** Gets or sets border thickness */
  72287. get thickness(): number;
  72288. set thickness(value: number);
  72289. /**
  72290. * Creates a new Ellipse
  72291. * @param name defines the control name
  72292. */
  72293. constructor(name?: string | undefined);
  72294. protected _getTypeName(): string;
  72295. protected _localDraw(context: CanvasRenderingContext2D): void;
  72296. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72297. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  72298. }
  72299. }
  72300. declare module BABYLON.GUI {
  72301. /**
  72302. * Class used to create a password control
  72303. */
  72304. export class InputPassword extends InputText {
  72305. protected _beforeRenderText(text: string): string;
  72306. }
  72307. }
  72308. declare module BABYLON.GUI {
  72309. /** Class used to render 2D lines */
  72310. export class Line extends Control {
  72311. name?: string | undefined;
  72312. private _lineWidth;
  72313. private _x1;
  72314. private _y1;
  72315. private _x2;
  72316. private _y2;
  72317. private _dash;
  72318. private _connectedControl;
  72319. private _connectedControlDirtyObserver;
  72320. /** Gets or sets the dash pattern */
  72321. get dash(): Array<number>;
  72322. set dash(value: Array<number>);
  72323. /** Gets or sets the control connected with the line end */
  72324. get connectedControl(): Control;
  72325. set connectedControl(value: Control);
  72326. /** Gets or sets start coordinates on X axis */
  72327. get x1(): string | number;
  72328. set x1(value: string | number);
  72329. /** Gets or sets start coordinates on Y axis */
  72330. get y1(): string | number;
  72331. set y1(value: string | number);
  72332. /** Gets or sets end coordinates on X axis */
  72333. get x2(): string | number;
  72334. set x2(value: string | number);
  72335. /** Gets or sets end coordinates on Y axis */
  72336. get y2(): string | number;
  72337. set y2(value: string | number);
  72338. /** Gets or sets line width */
  72339. get lineWidth(): number;
  72340. set lineWidth(value: number);
  72341. /** Gets or sets horizontal alignment */
  72342. set horizontalAlignment(value: number);
  72343. /** Gets or sets vertical alignment */
  72344. set verticalAlignment(value: number);
  72345. private get _effectiveX2();
  72346. private get _effectiveY2();
  72347. /**
  72348. * Creates a new Line
  72349. * @param name defines the control name
  72350. */
  72351. constructor(name?: string | undefined);
  72352. protected _getTypeName(): string;
  72353. _draw(context: CanvasRenderingContext2D): void;
  72354. _measure(): void;
  72355. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72356. /**
  72357. * Move one end of the line given 3D cartesian coordinates.
  72358. * @param position Targeted world position
  72359. * @param scene BABYLON.Scene
  72360. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  72361. */
  72362. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  72363. /**
  72364. * Move one end of the line to a position in screen absolute space.
  72365. * @param projectedPosition Position in screen absolute space (X, Y)
  72366. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  72367. */
  72368. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  72369. }
  72370. }
  72371. declare module BABYLON.GUI {
  72372. /**
  72373. * Class used to store a point for a MultiLine object.
  72374. * The point can be pure 2D coordinates, a mesh or a control
  72375. */
  72376. export class MultiLinePoint {
  72377. private _multiLine;
  72378. private _x;
  72379. private _y;
  72380. private _control;
  72381. private _mesh;
  72382. private _controlObserver;
  72383. private _meshObserver;
  72384. /** @hidden */
  72385. _point: BABYLON.Vector2;
  72386. /**
  72387. * Creates a new MultiLinePoint
  72388. * @param multiLine defines the source MultiLine object
  72389. */
  72390. constructor(multiLine: MultiLine);
  72391. /** Gets or sets x coordinate */
  72392. get x(): string | number;
  72393. set x(value: string | number);
  72394. /** Gets or sets y coordinate */
  72395. get y(): string | number;
  72396. set y(value: string | number);
  72397. /** Gets or sets the control associated with this point */
  72398. get control(): BABYLON.Nullable<Control>;
  72399. set control(value: BABYLON.Nullable<Control>);
  72400. /** Gets or sets the mesh associated with this point */
  72401. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  72402. set mesh(value: BABYLON.Nullable<BABYLON.AbstractMesh>);
  72403. /** Resets links */
  72404. resetLinks(): void;
  72405. /**
  72406. * Gets a translation vector
  72407. * @returns the translation vector
  72408. */
  72409. translate(): BABYLON.Vector2;
  72410. private _translatePoint;
  72411. /** Release associated resources */
  72412. dispose(): void;
  72413. }
  72414. }
  72415. declare module BABYLON.GUI {
  72416. /**
  72417. * Class used to create multi line control
  72418. */
  72419. export class MultiLine extends Control {
  72420. name?: string | undefined;
  72421. private _lineWidth;
  72422. private _dash;
  72423. private _points;
  72424. private _minX;
  72425. private _minY;
  72426. private _maxX;
  72427. private _maxY;
  72428. /**
  72429. * Creates a new MultiLine
  72430. * @param name defines the control name
  72431. */
  72432. constructor(name?: string | undefined);
  72433. /** Gets or sets dash pattern */
  72434. get dash(): Array<number>;
  72435. set dash(value: Array<number>);
  72436. /**
  72437. * Gets point stored at specified index
  72438. * @param index defines the index to look for
  72439. * @returns the requested point if found
  72440. */
  72441. getAt(index: number): MultiLinePoint;
  72442. /** Function called when a point is updated */
  72443. onPointUpdate: () => void;
  72444. /**
  72445. * Adds new points to the point collection
  72446. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  72447. * @returns the list of created MultiLinePoint
  72448. */
  72449. add(...items: (AbstractMesh | Control | {
  72450. x: string | number;
  72451. y: string | number;
  72452. })[]): MultiLinePoint[];
  72453. /**
  72454. * Adds a new point to the point collection
  72455. * @param item defines the item (mesh, control or 2d coordiantes) to add
  72456. * @returns the created MultiLinePoint
  72457. */
  72458. push(item?: (AbstractMesh | Control | {
  72459. x: string | number;
  72460. y: string | number;
  72461. })): MultiLinePoint;
  72462. /**
  72463. * Remove a specific value or point from the active point collection
  72464. * @param value defines the value or point to remove
  72465. */
  72466. remove(value: number | MultiLinePoint): void;
  72467. /**
  72468. * Resets this object to initial state (no point)
  72469. */
  72470. reset(): void;
  72471. /**
  72472. * Resets all links
  72473. */
  72474. resetLinks(): void;
  72475. /** Gets or sets line width */
  72476. get lineWidth(): number;
  72477. set lineWidth(value: number);
  72478. set horizontalAlignment(value: number);
  72479. set verticalAlignment(value: number);
  72480. protected _getTypeName(): string;
  72481. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  72482. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72483. _measure(): void;
  72484. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72485. dispose(): void;
  72486. }
  72487. }
  72488. declare module BABYLON.GUI {
  72489. /**
  72490. * Class used to create radio button controls
  72491. */
  72492. export class RadioButton extends Control {
  72493. name?: string | undefined;
  72494. private _isChecked;
  72495. private _background;
  72496. private _checkSizeRatio;
  72497. private _thickness;
  72498. /** Gets or sets border thickness */
  72499. get thickness(): number;
  72500. set thickness(value: number);
  72501. /** Gets or sets group name */
  72502. group: string;
  72503. /** BABYLON.Observable raised when isChecked is changed */
  72504. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  72505. /** Gets or sets a value indicating the ratio between overall size and check size */
  72506. get checkSizeRatio(): number;
  72507. set checkSizeRatio(value: number);
  72508. /** Gets or sets background color */
  72509. get background(): string;
  72510. set background(value: string);
  72511. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  72512. get isChecked(): boolean;
  72513. set isChecked(value: boolean);
  72514. /**
  72515. * Creates a new RadioButton
  72516. * @param name defines the control name
  72517. */
  72518. constructor(name?: string | undefined);
  72519. protected _getTypeName(): string;
  72520. _draw(context: CanvasRenderingContext2D): void;
  72521. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  72522. /**
  72523. * Utility function to easily create a radio button with a header
  72524. * @param title defines the label to use for the header
  72525. * @param group defines the group to use for the radio button
  72526. * @param isChecked defines the initial state of the radio button
  72527. * @param onValueChanged defines the callback to call when value changes
  72528. * @returns a StackPanel containing the radio button and a textBlock
  72529. */
  72530. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  72531. }
  72532. }
  72533. declare module BABYLON.GUI {
  72534. /**
  72535. * Class used to create slider controls
  72536. */
  72537. export class BaseSlider extends Control {
  72538. name?: string | undefined;
  72539. protected _thumbWidth: ValueAndUnit;
  72540. private _minimum;
  72541. private _maximum;
  72542. private _value;
  72543. private _isVertical;
  72544. protected _barOffset: ValueAndUnit;
  72545. private _isThumbClamped;
  72546. protected _displayThumb: boolean;
  72547. private _step;
  72548. private _lastPointerDownID;
  72549. protected _effectiveBarOffset: number;
  72550. protected _renderLeft: number;
  72551. protected _renderTop: number;
  72552. protected _renderWidth: number;
  72553. protected _renderHeight: number;
  72554. protected _backgroundBoxLength: number;
  72555. protected _backgroundBoxThickness: number;
  72556. protected _effectiveThumbThickness: number;
  72557. /** BABYLON.Observable raised when the sldier value changes */
  72558. onValueChangedObservable: BABYLON.Observable<number>;
  72559. /** Gets or sets a boolean indicating if the thumb must be rendered */
  72560. get displayThumb(): boolean;
  72561. set displayThumb(value: boolean);
  72562. /** Gets or sets a step to apply to values (0 by default) */
  72563. get step(): number;
  72564. set step(value: number);
  72565. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  72566. get barOffset(): string | number;
  72567. /** Gets main bar offset in pixels*/
  72568. get barOffsetInPixels(): number;
  72569. set barOffset(value: string | number);
  72570. /** Gets or sets thumb width */
  72571. get thumbWidth(): string | number;
  72572. /** Gets thumb width in pixels */
  72573. get thumbWidthInPixels(): number;
  72574. set thumbWidth(value: string | number);
  72575. /** Gets or sets minimum value */
  72576. get minimum(): number;
  72577. set minimum(value: number);
  72578. /** Gets or sets maximum value */
  72579. get maximum(): number;
  72580. set maximum(value: number);
  72581. /** Gets or sets current value */
  72582. get value(): number;
  72583. set value(value: number);
  72584. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  72585. get isVertical(): boolean;
  72586. set isVertical(value: boolean);
  72587. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  72588. get isThumbClamped(): boolean;
  72589. set isThumbClamped(value: boolean);
  72590. /**
  72591. * Creates a new BaseSlider
  72592. * @param name defines the control name
  72593. */
  72594. constructor(name?: string | undefined);
  72595. protected _getTypeName(): string;
  72596. protected _getThumbPosition(): number;
  72597. protected _getThumbThickness(type: string): number;
  72598. protected _prepareRenderingData(type: string): void;
  72599. private _pointerIsDown;
  72600. /** @hidden */
  72601. protected _updateValueFromPointer(x: number, y: number): void;
  72602. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  72603. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  72604. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  72605. }
  72606. }
  72607. declare module BABYLON.GUI {
  72608. /**
  72609. * Class used to create slider controls
  72610. */
  72611. export class Slider extends BaseSlider {
  72612. name?: string | undefined;
  72613. private _background;
  72614. private _borderColor;
  72615. private _isThumbCircle;
  72616. protected _displayValueBar: boolean;
  72617. /** Gets or sets a boolean indicating if the value bar must be rendered */
  72618. get displayValueBar(): boolean;
  72619. set displayValueBar(value: boolean);
  72620. /** Gets or sets border color */
  72621. get borderColor(): string;
  72622. set borderColor(value: string);
  72623. /** Gets or sets background color */
  72624. get background(): string;
  72625. set background(value: string);
  72626. /** Gets or sets a boolean indicating if the thumb should be round or square */
  72627. get isThumbCircle(): boolean;
  72628. set isThumbCircle(value: boolean);
  72629. /**
  72630. * Creates a new Slider
  72631. * @param name defines the control name
  72632. */
  72633. constructor(name?: string | undefined);
  72634. protected _getTypeName(): string;
  72635. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  72636. }
  72637. }
  72638. declare module BABYLON.GUI {
  72639. /** Class used to create a RadioGroup
  72640. * which contains groups of radio buttons
  72641. */
  72642. export class SelectorGroup {
  72643. /** name of SelectorGroup */
  72644. name: string;
  72645. private _groupPanel;
  72646. private _selectors;
  72647. private _groupHeader;
  72648. /**
  72649. * Creates a new SelectorGroup
  72650. * @param name of group, used as a group heading
  72651. */
  72652. constructor(
  72653. /** name of SelectorGroup */
  72654. name: string);
  72655. /** Gets the groupPanel of the SelectorGroup */
  72656. get groupPanel(): StackPanel;
  72657. /** Gets the selectors array */
  72658. get selectors(): StackPanel[];
  72659. /** Gets and sets the group header */
  72660. get header(): string;
  72661. set header(label: string);
  72662. /** @hidden */
  72663. private _addGroupHeader;
  72664. /** @hidden*/
  72665. _getSelector(selectorNb: number): StackPanel | undefined;
  72666. /** Removes the selector at the given position
  72667. * @param selectorNb the position of the selector within the group
  72668. */
  72669. removeSelector(selectorNb: number): void;
  72670. }
  72671. /** Class used to create a CheckboxGroup
  72672. * which contains groups of checkbox buttons
  72673. */
  72674. export class CheckboxGroup extends SelectorGroup {
  72675. /** Adds a checkbox as a control
  72676. * @param text is the label for the selector
  72677. * @param func is the function called when the Selector is checked
  72678. * @param checked is true when Selector is checked
  72679. */
  72680. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  72681. /** @hidden */
  72682. _setSelectorLabel(selectorNb: number, label: string): void;
  72683. /** @hidden */
  72684. _setSelectorLabelColor(selectorNb: number, color: string): void;
  72685. /** @hidden */
  72686. _setSelectorButtonColor(selectorNb: number, color: string): void;
  72687. /** @hidden */
  72688. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  72689. }
  72690. /** Class used to create a RadioGroup
  72691. * which contains groups of radio buttons
  72692. */
  72693. export class RadioGroup extends SelectorGroup {
  72694. private _selectNb;
  72695. /** Adds a radio button as a control
  72696. * @param label is the label for the selector
  72697. * @param func is the function called when the Selector is checked
  72698. * @param checked is true when Selector is checked
  72699. */
  72700. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  72701. /** @hidden */
  72702. _setSelectorLabel(selectorNb: number, label: string): void;
  72703. /** @hidden */
  72704. _setSelectorLabelColor(selectorNb: number, color: string): void;
  72705. /** @hidden */
  72706. _setSelectorButtonColor(selectorNb: number, color: string): void;
  72707. /** @hidden */
  72708. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  72709. }
  72710. /** Class used to create a SliderGroup
  72711. * which contains groups of slider buttons
  72712. */
  72713. export class SliderGroup extends SelectorGroup {
  72714. /**
  72715. * Adds a slider to the SelectorGroup
  72716. * @param label is the label for the SliderBar
  72717. * @param func is the function called when the Slider moves
  72718. * @param unit is a string describing the units used, eg degrees or metres
  72719. * @param min is the minimum value for the Slider
  72720. * @param max is the maximum value for the Slider
  72721. * @param value is the start value for the Slider between min and max
  72722. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  72723. */
  72724. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  72725. /** @hidden */
  72726. _setSelectorLabel(selectorNb: number, label: string): void;
  72727. /** @hidden */
  72728. _setSelectorLabelColor(selectorNb: number, color: string): void;
  72729. /** @hidden */
  72730. _setSelectorButtonColor(selectorNb: number, color: string): void;
  72731. /** @hidden */
  72732. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  72733. }
  72734. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  72735. * @see http://doc.babylonjs.com/how_to/selector
  72736. */
  72737. export class SelectionPanel extends Rectangle {
  72738. /** name of SelectionPanel */
  72739. name: string;
  72740. /** an array of SelectionGroups */
  72741. groups: SelectorGroup[];
  72742. private _panel;
  72743. private _buttonColor;
  72744. private _buttonBackground;
  72745. private _headerColor;
  72746. private _barColor;
  72747. private _barHeight;
  72748. private _spacerHeight;
  72749. private _labelColor;
  72750. private _groups;
  72751. private _bars;
  72752. /**
  72753. * Creates a new SelectionPanel
  72754. * @param name of SelectionPanel
  72755. * @param groups is an array of SelectionGroups
  72756. */
  72757. constructor(
  72758. /** name of SelectionPanel */
  72759. name: string,
  72760. /** an array of SelectionGroups */
  72761. groups?: SelectorGroup[]);
  72762. protected _getTypeName(): string;
  72763. /** Gets or sets the headerColor */
  72764. get headerColor(): string;
  72765. set headerColor(color: string);
  72766. private _setHeaderColor;
  72767. /** Gets or sets the button color */
  72768. get buttonColor(): string;
  72769. set buttonColor(color: string);
  72770. private _setbuttonColor;
  72771. /** Gets or sets the label color */
  72772. get labelColor(): string;
  72773. set labelColor(color: string);
  72774. private _setLabelColor;
  72775. /** Gets or sets the button background */
  72776. get buttonBackground(): string;
  72777. set buttonBackground(color: string);
  72778. private _setButtonBackground;
  72779. /** Gets or sets the color of separator bar */
  72780. get barColor(): string;
  72781. set barColor(color: string);
  72782. private _setBarColor;
  72783. /** Gets or sets the height of separator bar */
  72784. get barHeight(): string;
  72785. set barHeight(value: string);
  72786. private _setBarHeight;
  72787. /** Gets or sets the height of spacers*/
  72788. get spacerHeight(): string;
  72789. set spacerHeight(value: string);
  72790. private _setSpacerHeight;
  72791. /** Adds a bar between groups */
  72792. private _addSpacer;
  72793. /** Add a group to the selection panel
  72794. * @param group is the selector group to add
  72795. */
  72796. addGroup(group: SelectorGroup): void;
  72797. /** Remove the group from the given position
  72798. * @param groupNb is the position of the group in the list
  72799. */
  72800. removeGroup(groupNb: number): void;
  72801. /** Change a group header label
  72802. * @param label is the new group header label
  72803. * @param groupNb is the number of the group to relabel
  72804. * */
  72805. setHeaderName(label: string, groupNb: number): void;
  72806. /** Change selector label to the one given
  72807. * @param label is the new selector label
  72808. * @param groupNb is the number of the groupcontaining the selector
  72809. * @param selectorNb is the number of the selector within a group to relabel
  72810. * */
  72811. relabel(label: string, groupNb: number, selectorNb: number): void;
  72812. /** For a given group position remove the selector at the given position
  72813. * @param groupNb is the number of the group to remove the selector from
  72814. * @param selectorNb is the number of the selector within the group
  72815. */
  72816. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  72817. /** For a given group position of correct type add a checkbox button
  72818. * @param groupNb is the number of the group to remove the selector from
  72819. * @param label is the label for the selector
  72820. * @param func is the function called when the Selector is checked
  72821. * @param checked is true when Selector is checked
  72822. */
  72823. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  72824. /** For a given group position of correct type add a radio button
  72825. * @param groupNb is the number of the group to remove the selector from
  72826. * @param label is the label for the selector
  72827. * @param func is the function called when the Selector is checked
  72828. * @param checked is true when Selector is checked
  72829. */
  72830. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  72831. /**
  72832. * For a given slider group add a slider
  72833. * @param groupNb is the number of the group to add the slider to
  72834. * @param label is the label for the Slider
  72835. * @param func is the function called when the Slider moves
  72836. * @param unit is a string describing the units used, eg degrees or metres
  72837. * @param min is the minimum value for the Slider
  72838. * @param max is the maximum value for the Slider
  72839. * @param value is the start value for the Slider between min and max
  72840. * @param onVal is the function used to format the value displayed, eg radians to degrees
  72841. */
  72842. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  72843. }
  72844. }
  72845. declare module BABYLON.GUI {
  72846. /**
  72847. * Class used to hold a the container for ScrollViewer
  72848. * @hidden
  72849. */
  72850. export class _ScrollViewerWindow extends Container {
  72851. parentClientWidth: number;
  72852. parentClientHeight: number;
  72853. private _freezeControls;
  72854. private _parentMeasure;
  72855. private _oldLeft;
  72856. private _oldTop;
  72857. get freezeControls(): boolean;
  72858. set freezeControls(value: boolean);
  72859. private _bucketWidth;
  72860. private _bucketHeight;
  72861. private _buckets;
  72862. private _bucketLen;
  72863. get bucketWidth(): number;
  72864. get bucketHeight(): number;
  72865. setBucketSizes(width: number, height: number): void;
  72866. private _useBuckets;
  72867. private _makeBuckets;
  72868. private _dispatchInBuckets;
  72869. private _updateMeasures;
  72870. private _updateChildrenMeasures;
  72871. /**
  72872. * Creates a new ScrollViewerWindow
  72873. * @param name of ScrollViewerWindow
  72874. */
  72875. constructor(name?: string);
  72876. protected _getTypeName(): string;
  72877. /** @hidden */
  72878. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72879. /** @hidden */
  72880. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  72881. private _scrollChildren;
  72882. private _scrollChildrenWithBuckets;
  72883. /** @hidden */
  72884. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  72885. protected _postMeasure(): void;
  72886. }
  72887. }
  72888. declare module BABYLON.GUI {
  72889. /**
  72890. * Class used to create slider controls
  72891. */
  72892. export class ScrollBar extends BaseSlider {
  72893. name?: string | undefined;
  72894. private _background;
  72895. private _borderColor;
  72896. private _tempMeasure;
  72897. /** Gets or sets border color */
  72898. get borderColor(): string;
  72899. set borderColor(value: string);
  72900. /** Gets or sets background color */
  72901. get background(): string;
  72902. set background(value: string);
  72903. /**
  72904. * Creates a new Slider
  72905. * @param name defines the control name
  72906. */
  72907. constructor(name?: string | undefined);
  72908. protected _getTypeName(): string;
  72909. protected _getThumbThickness(): number;
  72910. _draw(context: CanvasRenderingContext2D): void;
  72911. private _first;
  72912. private _originX;
  72913. private _originY;
  72914. /** @hidden */
  72915. protected _updateValueFromPointer(x: number, y: number): void;
  72916. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  72917. }
  72918. }
  72919. declare module BABYLON.GUI {
  72920. /**
  72921. * Class used to create slider controls
  72922. */
  72923. export class ImageScrollBar extends BaseSlider {
  72924. name?: string | undefined;
  72925. private _backgroundBaseImage;
  72926. private _backgroundImage;
  72927. private _thumbImage;
  72928. private _thumbBaseImage;
  72929. private _thumbLength;
  72930. private _thumbHeight;
  72931. private _barImageHeight;
  72932. private _tempMeasure;
  72933. /** Number of 90° rotation to apply on the images when in vertical mode */
  72934. num90RotationInVerticalMode: number;
  72935. /**
  72936. * Gets or sets the image used to render the background for horizontal bar
  72937. */
  72938. get backgroundImage(): Image;
  72939. set backgroundImage(value: Image);
  72940. /**
  72941. * Gets or sets the image used to render the thumb
  72942. */
  72943. get thumbImage(): Image;
  72944. set thumbImage(value: Image);
  72945. /**
  72946. * Gets or sets the length of the thumb
  72947. */
  72948. get thumbLength(): number;
  72949. set thumbLength(value: number);
  72950. /**
  72951. * Gets or sets the height of the thumb
  72952. */
  72953. get thumbHeight(): number;
  72954. set thumbHeight(value: number);
  72955. /**
  72956. * Gets or sets the height of the bar image
  72957. */
  72958. get barImageHeight(): number;
  72959. set barImageHeight(value: number);
  72960. /**
  72961. * Creates a new ImageScrollBar
  72962. * @param name defines the control name
  72963. */
  72964. constructor(name?: string | undefined);
  72965. protected _getTypeName(): string;
  72966. protected _getThumbThickness(): number;
  72967. _draw(context: CanvasRenderingContext2D): void;
  72968. private _first;
  72969. private _originX;
  72970. private _originY;
  72971. /** @hidden */
  72972. protected _updateValueFromPointer(x: number, y: number): void;
  72973. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  72974. }
  72975. }
  72976. declare module BABYLON.GUI {
  72977. /**
  72978. * Class used to hold a viewer window and sliders in a grid
  72979. */
  72980. export class ScrollViewer extends Rectangle {
  72981. private _grid;
  72982. private _horizontalBarSpace;
  72983. private _verticalBarSpace;
  72984. private _dragSpace;
  72985. private _horizontalBar;
  72986. private _verticalBar;
  72987. private _barColor;
  72988. private _barBackground;
  72989. private _barImage;
  72990. private _horizontalBarImage;
  72991. private _verticalBarImage;
  72992. private _barBackgroundImage;
  72993. private _horizontalBarBackgroundImage;
  72994. private _verticalBarBackgroundImage;
  72995. private _barSize;
  72996. private _window;
  72997. private _pointerIsOver;
  72998. private _wheelPrecision;
  72999. private _onPointerObserver;
  73000. private _clientWidth;
  73001. private _clientHeight;
  73002. private _useImageBar;
  73003. private _thumbLength;
  73004. private _thumbHeight;
  73005. private _barImageHeight;
  73006. private _horizontalBarImageHeight;
  73007. private _verticalBarImageHeight;
  73008. /**
  73009. * Gets the horizontal scrollbar
  73010. */
  73011. get horizontalBar(): ScrollBar | ImageScrollBar;
  73012. /**
  73013. * Gets the vertical scrollbar
  73014. */
  73015. get verticalBar(): ScrollBar | ImageScrollBar;
  73016. /**
  73017. * Adds a new control to the current container
  73018. * @param control defines the control to add
  73019. * @returns the current container
  73020. */
  73021. addControl(control: BABYLON.Nullable<Control>): Container;
  73022. /**
  73023. * Removes a control from the current container
  73024. * @param control defines the control to remove
  73025. * @returns the current container
  73026. */
  73027. removeControl(control: Control): Container;
  73028. /** Gets the list of children */
  73029. get children(): Control[];
  73030. _flagDescendantsAsMatrixDirty(): void;
  73031. /**
  73032. * Freezes or unfreezes the controls in the window.
  73033. * When controls are frozen, the scroll viewer can render a lot more quickly but updates to positions/sizes of controls
  73034. * are not taken into account. If you want to change positions/sizes, unfreeze, perform the changes then freeze again
  73035. */
  73036. get freezeControls(): boolean;
  73037. set freezeControls(value: boolean);
  73038. /** Gets the bucket width */
  73039. get bucketWidth(): number;
  73040. /** Gets the bucket height */
  73041. get bucketHeight(): number;
  73042. /**
  73043. * Sets the bucket sizes.
  73044. * When freezeControls is true, setting a non-zero bucket size will improve performances by updating only
  73045. * controls that are visible. The bucket sizes is used to subdivide (internally) the window area to smaller areas into which
  73046. * controls are dispatched. So, the size should be roughly equals to the mean size of all the controls of
  73047. * the window. To disable the usage of buckets, sets either width or height (or both) to 0.
  73048. * Please note that using this option will raise the memory usage (the higher the bucket sizes, the less memory
  73049. * used), that's why it is not enabled by default.
  73050. * @param width width of the bucket
  73051. * @param height height of the bucket
  73052. */
  73053. setBucketSizes(width: number, height: number): void;
  73054. private _forceHorizontalBar;
  73055. private _forceVerticalBar;
  73056. /**
  73057. * Forces the horizontal scroll bar to be displayed
  73058. */
  73059. get forceHorizontalBar(): boolean;
  73060. set forceHorizontalBar(value: boolean);
  73061. /**
  73062. * Forces the vertical scroll bar to be displayed
  73063. */
  73064. get forceVerticalBar(): boolean;
  73065. set forceVerticalBar(value: boolean);
  73066. /**
  73067. * Creates a new ScrollViewer
  73068. * @param name of ScrollViewer
  73069. */
  73070. constructor(name?: string, isImageBased?: boolean);
  73071. /** Reset the scroll viewer window to initial size */
  73072. resetWindow(): void;
  73073. protected _getTypeName(): string;
  73074. private _buildClientSizes;
  73075. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  73076. protected _postMeasure(): void;
  73077. /**
  73078. * Gets or sets the mouse wheel precision
  73079. * from 0 to 1 with a default value of 0.05
  73080. * */
  73081. get wheelPrecision(): number;
  73082. set wheelPrecision(value: number);
  73083. /** Gets or sets the scroll bar container background color */
  73084. get scrollBackground(): string;
  73085. set scrollBackground(color: string);
  73086. /** Gets or sets the bar color */
  73087. get barColor(): string;
  73088. set barColor(color: string);
  73089. /** Gets or sets the bar image */
  73090. get thumbImage(): Image;
  73091. set thumbImage(value: Image);
  73092. /** Gets or sets the horizontal bar image */
  73093. get horizontalThumbImage(): Image;
  73094. set horizontalThumbImage(value: Image);
  73095. /** Gets or sets the vertical bar image */
  73096. get verticalThumbImage(): Image;
  73097. set verticalThumbImage(value: Image);
  73098. /** Gets or sets the size of the bar */
  73099. get barSize(): number;
  73100. set barSize(value: number);
  73101. /** Gets or sets the length of the thumb */
  73102. get thumbLength(): number;
  73103. set thumbLength(value: number);
  73104. /** Gets or sets the height of the thumb */
  73105. get thumbHeight(): number;
  73106. set thumbHeight(value: number);
  73107. /** Gets or sets the height of the bar image */
  73108. get barImageHeight(): number;
  73109. set barImageHeight(value: number);
  73110. /** Gets or sets the height of the horizontal bar image */
  73111. get horizontalBarImageHeight(): number;
  73112. set horizontalBarImageHeight(value: number);
  73113. /** Gets or sets the height of the vertical bar image */
  73114. get verticalBarImageHeight(): number;
  73115. set verticalBarImageHeight(value: number);
  73116. /** Gets or sets the bar background */
  73117. get barBackground(): string;
  73118. set barBackground(color: string);
  73119. /** Gets or sets the bar background image */
  73120. get barImage(): Image;
  73121. set barImage(value: Image);
  73122. /** Gets or sets the horizontal bar background image */
  73123. get horizontalBarImage(): Image;
  73124. set horizontalBarImage(value: Image);
  73125. /** Gets or sets the vertical bar background image */
  73126. get verticalBarImage(): Image;
  73127. set verticalBarImage(value: Image);
  73128. private _setWindowPosition;
  73129. /** @hidden */
  73130. private _updateScroller;
  73131. _link(host: AdvancedDynamicTexture): void;
  73132. /** @hidden */
  73133. private _addBar;
  73134. /** @hidden */
  73135. private _attachWheel;
  73136. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  73137. /** Releases associated resources */
  73138. dispose(): void;
  73139. }
  73140. }
  73141. declare module BABYLON.GUI {
  73142. /** Class used to render a grid */
  73143. export class DisplayGrid extends Control {
  73144. name?: string | undefined;
  73145. private _cellWidth;
  73146. private _cellHeight;
  73147. private _minorLineTickness;
  73148. private _minorLineColor;
  73149. private _majorLineTickness;
  73150. private _majorLineColor;
  73151. private _majorLineFrequency;
  73152. private _background;
  73153. private _displayMajorLines;
  73154. private _displayMinorLines;
  73155. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  73156. get displayMinorLines(): boolean;
  73157. set displayMinorLines(value: boolean);
  73158. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  73159. get displayMajorLines(): boolean;
  73160. set displayMajorLines(value: boolean);
  73161. /** Gets or sets background color (Black by default) */
  73162. get background(): string;
  73163. set background(value: string);
  73164. /** Gets or sets the width of each cell (20 by default) */
  73165. get cellWidth(): number;
  73166. set cellWidth(value: number);
  73167. /** Gets or sets the height of each cell (20 by default) */
  73168. get cellHeight(): number;
  73169. set cellHeight(value: number);
  73170. /** Gets or sets the tickness of minor lines (1 by default) */
  73171. get minorLineTickness(): number;
  73172. set minorLineTickness(value: number);
  73173. /** Gets or sets the color of minor lines (DarkGray by default) */
  73174. get minorLineColor(): string;
  73175. set minorLineColor(value: string);
  73176. /** Gets or sets the tickness of major lines (2 by default) */
  73177. get majorLineTickness(): number;
  73178. set majorLineTickness(value: number);
  73179. /** Gets or sets the color of major lines (White by default) */
  73180. get majorLineColor(): string;
  73181. set majorLineColor(value: string);
  73182. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  73183. get majorLineFrequency(): number;
  73184. set majorLineFrequency(value: number);
  73185. /**
  73186. * Creates a new GridDisplayRectangle
  73187. * @param name defines the control name
  73188. */
  73189. constructor(name?: string | undefined);
  73190. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  73191. protected _getTypeName(): string;
  73192. }
  73193. }
  73194. declare module BABYLON.GUI {
  73195. /**
  73196. * Class used to create slider controls based on images
  73197. */
  73198. export class ImageBasedSlider extends BaseSlider {
  73199. name?: string | undefined;
  73200. private _backgroundImage;
  73201. private _thumbImage;
  73202. private _valueBarImage;
  73203. private _tempMeasure;
  73204. get displayThumb(): boolean;
  73205. set displayThumb(value: boolean);
  73206. /**
  73207. * Gets or sets the image used to render the background
  73208. */
  73209. get backgroundImage(): Image;
  73210. set backgroundImage(value: Image);
  73211. /**
  73212. * Gets or sets the image used to render the value bar
  73213. */
  73214. get valueBarImage(): Image;
  73215. set valueBarImage(value: Image);
  73216. /**
  73217. * Gets or sets the image used to render the thumb
  73218. */
  73219. get thumbImage(): Image;
  73220. set thumbImage(value: Image);
  73221. /**
  73222. * Creates a new ImageBasedSlider
  73223. * @param name defines the control name
  73224. */
  73225. constructor(name?: string | undefined);
  73226. protected _getTypeName(): string;
  73227. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  73228. }
  73229. }
  73230. declare module BABYLON.GUI {
  73231. /**
  73232. * Forcing an export so that this code will execute
  73233. * @hidden
  73234. */
  73235. const name = "Statics";
  73236. }
  73237. declare module BABYLON.GUI {
  73238. /**
  73239. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  73240. */
  73241. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  73242. /**
  73243. * Define the instrumented AdvancedDynamicTexture.
  73244. */
  73245. texture: AdvancedDynamicTexture;
  73246. private _captureRenderTime;
  73247. private _renderTime;
  73248. private _captureLayoutTime;
  73249. private _layoutTime;
  73250. private _onBeginRenderObserver;
  73251. private _onEndRenderObserver;
  73252. private _onBeginLayoutObserver;
  73253. private _onEndLayoutObserver;
  73254. /**
  73255. * Gets the perf counter used to capture render time
  73256. */
  73257. get renderTimeCounter(): BABYLON.PerfCounter;
  73258. /**
  73259. * Gets the perf counter used to capture layout time
  73260. */
  73261. get layoutTimeCounter(): BABYLON.PerfCounter;
  73262. /**
  73263. * Enable or disable the render time capture
  73264. */
  73265. get captureRenderTime(): boolean;
  73266. set captureRenderTime(value: boolean);
  73267. /**
  73268. * Enable or disable the layout time capture
  73269. */
  73270. get captureLayoutTime(): boolean;
  73271. set captureLayoutTime(value: boolean);
  73272. /**
  73273. * Instantiates a new advanced dynamic texture instrumentation.
  73274. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  73275. * @param texture Defines the AdvancedDynamicTexture to instrument
  73276. */
  73277. constructor(
  73278. /**
  73279. * Define the instrumented AdvancedDynamicTexture.
  73280. */
  73281. texture: AdvancedDynamicTexture);
  73282. /**
  73283. * Dispose and release associated resources.
  73284. */
  73285. dispose(): void;
  73286. }
  73287. }
  73288. declare module BABYLON.GUI {
  73289. /**
  73290. * Class used to load GUI via XML.
  73291. */
  73292. export class XmlLoader {
  73293. private _nodes;
  73294. private _nodeTypes;
  73295. private _isLoaded;
  73296. private _objectAttributes;
  73297. private _parentClass;
  73298. /**
  73299. * Create a new xml loader
  73300. * @param parentClass Sets the class context. Used when the loader is instanced inside a class and not in a global context
  73301. */
  73302. constructor(parentClass?: null);
  73303. private _getChainElement;
  73304. private _getClassAttribute;
  73305. private _createGuiElement;
  73306. private _parseGrid;
  73307. private _parseElement;
  73308. private _prepareSourceElement;
  73309. private _parseElementsFromSource;
  73310. private _parseXml;
  73311. /**
  73312. * Gets if the loading has finished.
  73313. * @returns whether the loading has finished or not
  73314. */
  73315. isLoaded(): boolean;
  73316. /**
  73317. * Gets a loaded node / control by id.
  73318. * @param id the Controls id set in the xml
  73319. * @returns element of type Control
  73320. */
  73321. getNodeById(id: string): any;
  73322. /**
  73323. * Gets all loaded nodes / controls
  73324. * @returns Array of controls
  73325. */
  73326. getNodes(): any;
  73327. /**
  73328. * Initiates the xml layout loading
  73329. * @param xmlFile defines the xml layout to load
  73330. * @param rootNode defines the node / control to use as a parent for the loaded layout controls.
  73331. * @param callback defines the callback called on layout load.
  73332. */
  73333. loadLayout(xmlFile: any, rootNode: any, callback: any): void;
  73334. }
  73335. }
  73336. declare module BABYLON.GUI {
  73337. /**
  73338. * Class used to create containers for controls
  73339. */
  73340. export class Container3D extends Control3D {
  73341. private _blockLayout;
  73342. /**
  73343. * Gets the list of child controls
  73344. */
  73345. protected _children: Control3D[];
  73346. /**
  73347. * Gets the list of child controls
  73348. */
  73349. get children(): Array<Control3D>;
  73350. /**
  73351. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  73352. * This is helpful to optimize layout operation when adding multiple children in a row
  73353. */
  73354. get blockLayout(): boolean;
  73355. set blockLayout(value: boolean);
  73356. /**
  73357. * Creates a new container
  73358. * @param name defines the container name
  73359. */
  73360. constructor(name?: string);
  73361. /**
  73362. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  73363. * @returns the current container
  73364. */
  73365. updateLayout(): Container3D;
  73366. /**
  73367. * Gets a boolean indicating if the given control is in the children of this control
  73368. * @param control defines the control to check
  73369. * @returns true if the control is in the child list
  73370. */
  73371. containsControl(control: Control3D): boolean;
  73372. /**
  73373. * Adds a control to the children of this control
  73374. * @param control defines the control to add
  73375. * @returns the current container
  73376. */
  73377. addControl(control: Control3D): Container3D;
  73378. /**
  73379. * This function will be called everytime a new control is added
  73380. */
  73381. protected _arrangeChildren(): void;
  73382. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  73383. /**
  73384. * Removes a control from the children of this control
  73385. * @param control defines the control to remove
  73386. * @returns the current container
  73387. */
  73388. removeControl(control: Control3D): Container3D;
  73389. protected _getTypeName(): string;
  73390. /**
  73391. * Releases all associated resources
  73392. */
  73393. dispose(): void;
  73394. /** Control rotation will remain unchanged */
  73395. static readonly UNSET_ORIENTATION: number;
  73396. /** Control will rotate to make it look at sphere central axis */
  73397. static readonly FACEORIGIN_ORIENTATION: number;
  73398. /** Control will rotate to make it look back at sphere central axis */
  73399. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  73400. /** Control will rotate to look at z axis (0, 0, 1) */
  73401. static readonly FACEFORWARD_ORIENTATION: number;
  73402. /** Control will rotate to look at negative z axis (0, 0, -1) */
  73403. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  73404. }
  73405. }
  73406. declare module BABYLON.GUI {
  73407. /**
  73408. * Class used to manage 3D user interface
  73409. * @see http://doc.babylonjs.com/how_to/gui3d
  73410. */
  73411. export class GUI3DManager implements BABYLON.IDisposable {
  73412. private _scene;
  73413. private _sceneDisposeObserver;
  73414. private _utilityLayer;
  73415. private _rootContainer;
  73416. private _pointerObserver;
  73417. private _pointerOutObserver;
  73418. /** @hidden */
  73419. _lastPickedControl: Control3D;
  73420. /** @hidden */
  73421. _lastControlOver: {
  73422. [pointerId: number]: Control3D;
  73423. };
  73424. /** @hidden */
  73425. _lastControlDown: {
  73426. [pointerId: number]: Control3D;
  73427. };
  73428. /**
  73429. * BABYLON.Observable raised when the point picked by the pointer events changed
  73430. */
  73431. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  73432. /** @hidden */
  73433. _sharedMaterials: {
  73434. [key: string]: BABYLON.Material;
  73435. };
  73436. /** Gets the hosting scene */
  73437. get scene(): BABYLON.Scene;
  73438. /** Gets associated utility layer */
  73439. get utilityLayer(): BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  73440. /**
  73441. * Creates a new GUI3DManager
  73442. * @param scene
  73443. */
  73444. constructor(scene?: BABYLON.Scene);
  73445. private _handlePointerOut;
  73446. private _doPicking;
  73447. /**
  73448. * Gets the root container
  73449. */
  73450. get rootContainer(): Container3D;
  73451. /**
  73452. * Gets a boolean indicating if the given control is in the root child list
  73453. * @param control defines the control to check
  73454. * @returns true if the control is in the root child list
  73455. */
  73456. containsControl(control: Control3D): boolean;
  73457. /**
  73458. * Adds a control to the root child list
  73459. * @param control defines the control to add
  73460. * @returns the current manager
  73461. */
  73462. addControl(control: Control3D): GUI3DManager;
  73463. /**
  73464. * Removes a control from the root child list
  73465. * @param control defines the control to remove
  73466. * @returns the current container
  73467. */
  73468. removeControl(control: Control3D): GUI3DManager;
  73469. /**
  73470. * Releases all associated resources
  73471. */
  73472. dispose(): void;
  73473. }
  73474. }
  73475. declare module BABYLON.GUI {
  73476. /**
  73477. * Class used to transport BABYLON.Vector3 information for pointer events
  73478. */
  73479. export class Vector3WithInfo extends BABYLON.Vector3 {
  73480. /** defines the current mouse button index */
  73481. buttonIndex: number;
  73482. /**
  73483. * Creates a new Vector3WithInfo
  73484. * @param source defines the vector3 data to transport
  73485. * @param buttonIndex defines the current mouse button index
  73486. */
  73487. constructor(source: BABYLON.Vector3,
  73488. /** defines the current mouse button index */
  73489. buttonIndex?: number);
  73490. }
  73491. }
  73492. declare module BABYLON.GUI {
  73493. /**
  73494. * Class used as base class for controls
  73495. */
  73496. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  73497. /** Defines the control name */
  73498. name?: string | undefined;
  73499. /** @hidden */
  73500. _host: GUI3DManager;
  73501. private _node;
  73502. private _downCount;
  73503. private _enterCount;
  73504. private _downPointerIds;
  73505. private _isVisible;
  73506. /** Gets or sets the control position in world space */
  73507. get position(): BABYLON.Vector3;
  73508. set position(value: BABYLON.Vector3);
  73509. /** Gets or sets the control scaling in world space */
  73510. get scaling(): BABYLON.Vector3;
  73511. set scaling(value: BABYLON.Vector3);
  73512. /** Callback used to start pointer enter animation */
  73513. pointerEnterAnimation: () => void;
  73514. /** Callback used to start pointer out animation */
  73515. pointerOutAnimation: () => void;
  73516. /** Callback used to start pointer down animation */
  73517. pointerDownAnimation: () => void;
  73518. /** Callback used to start pointer up animation */
  73519. pointerUpAnimation: () => void;
  73520. /**
  73521. * An event triggered when the pointer move over the control
  73522. */
  73523. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  73524. /**
  73525. * An event triggered when the pointer move out of the control
  73526. */
  73527. onPointerOutObservable: BABYLON.Observable<Control3D>;
  73528. /**
  73529. * An event triggered when the pointer taps the control
  73530. */
  73531. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  73532. /**
  73533. * An event triggered when pointer is up
  73534. */
  73535. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  73536. /**
  73537. * An event triggered when a control is clicked on (with a mouse)
  73538. */
  73539. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  73540. /**
  73541. * An event triggered when pointer enters the control
  73542. */
  73543. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  73544. /**
  73545. * Gets or sets the parent container
  73546. */
  73547. parent: BABYLON.Nullable<Container3D>;
  73548. private _behaviors;
  73549. /**
  73550. * Gets the list of attached behaviors
  73551. * @see http://doc.babylonjs.com/features/behaviour
  73552. */
  73553. get behaviors(): BABYLON.Behavior<Control3D>[];
  73554. /**
  73555. * Attach a behavior to the control
  73556. * @see http://doc.babylonjs.com/features/behaviour
  73557. * @param behavior defines the behavior to attach
  73558. * @returns the current control
  73559. */
  73560. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  73561. /**
  73562. * Remove an attached behavior
  73563. * @see http://doc.babylonjs.com/features/behaviour
  73564. * @param behavior defines the behavior to attach
  73565. * @returns the current control
  73566. */
  73567. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  73568. /**
  73569. * Gets an attached behavior by name
  73570. * @param name defines the name of the behavior to look for
  73571. * @see http://doc.babylonjs.com/features/behaviour
  73572. * @returns null if behavior was not found else the requested behavior
  73573. */
  73574. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  73575. /** Gets or sets a boolean indicating if the control is visible */
  73576. get isVisible(): boolean;
  73577. set isVisible(value: boolean);
  73578. /**
  73579. * Creates a new control
  73580. * @param name defines the control name
  73581. */
  73582. constructor(
  73583. /** Defines the control name */
  73584. name?: string | undefined);
  73585. /**
  73586. * Gets a string representing the class name
  73587. */
  73588. get typeName(): string;
  73589. /**
  73590. * Get the current class name of the control.
  73591. * @returns current class name
  73592. */
  73593. getClassName(): string;
  73594. protected _getTypeName(): string;
  73595. /**
  73596. * Gets the transform node used by this control
  73597. */
  73598. get node(): BABYLON.Nullable<BABYLON.TransformNode>;
  73599. /**
  73600. * Gets the mesh used to render this control
  73601. */
  73602. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  73603. /**
  73604. * Link the control as child of the given node
  73605. * @param node defines the node to link to. Use null to unlink the control
  73606. * @returns the current control
  73607. */
  73608. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  73609. /** @hidden **/
  73610. _prepareNode(scene: BABYLON.Scene): void;
  73611. /**
  73612. * Node creation.
  73613. * Can be overriden by children
  73614. * @param scene defines the scene where the node must be attached
  73615. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  73616. */
  73617. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  73618. /**
  73619. * Affect a material to the given mesh
  73620. * @param mesh defines the mesh which will represent the control
  73621. */
  73622. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  73623. /** @hidden */
  73624. _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  73625. /** @hidden */
  73626. _onPointerEnter(target: Control3D): boolean;
  73627. /** @hidden */
  73628. _onPointerOut(target: Control3D): void;
  73629. /** @hidden */
  73630. _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  73631. /** @hidden */
  73632. _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  73633. /** @hidden */
  73634. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  73635. /** @hidden */
  73636. _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  73637. /** @hidden */
  73638. _disposeNode(): void;
  73639. /**
  73640. * Releases all associated resources
  73641. */
  73642. dispose(): void;
  73643. }
  73644. }
  73645. declare module BABYLON.GUI {
  73646. /**
  73647. * Class used as a root to all buttons
  73648. */
  73649. export class AbstractButton3D extends Control3D {
  73650. /**
  73651. * Creates a new button
  73652. * @param name defines the control name
  73653. */
  73654. constructor(name?: string);
  73655. protected _getTypeName(): string;
  73656. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  73657. }
  73658. }
  73659. declare module BABYLON.GUI {
  73660. /**
  73661. * Class used to create a button in 3D
  73662. */
  73663. export class Button3D extends AbstractButton3D {
  73664. /** @hidden */
  73665. protected _currentMaterial: BABYLON.Material;
  73666. private _facadeTexture;
  73667. private _content;
  73668. private _contentResolution;
  73669. private _contentScaleRatio;
  73670. /**
  73671. * Gets or sets the texture resolution used to render content (512 by default)
  73672. */
  73673. get contentResolution(): BABYLON.int;
  73674. set contentResolution(value: BABYLON.int);
  73675. /**
  73676. * Gets or sets the texture scale ratio used to render content (2 by default)
  73677. */
  73678. get contentScaleRatio(): number;
  73679. set contentScaleRatio(value: number);
  73680. protected _disposeFacadeTexture(): void;
  73681. protected _resetContent(): void;
  73682. /**
  73683. * Creates a new button
  73684. * @param name defines the control name
  73685. */
  73686. constructor(name?: string);
  73687. /**
  73688. * Gets or sets the GUI 2D content used to display the button's facade
  73689. */
  73690. get content(): Control;
  73691. set content(value: Control);
  73692. /**
  73693. * Apply the facade texture (created from the content property).
  73694. * This function can be overloaded by child classes
  73695. * @param facadeTexture defines the AdvancedDynamicTexture to use
  73696. */
  73697. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  73698. protected _getTypeName(): string;
  73699. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  73700. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  73701. /**
  73702. * Releases all associated resources
  73703. */
  73704. dispose(): void;
  73705. }
  73706. }
  73707. declare module BABYLON.GUI {
  73708. /**
  73709. * Abstract class used to create a container panel deployed on the surface of a volume
  73710. */
  73711. export abstract class VolumeBasedPanel extends Container3D {
  73712. private _columns;
  73713. private _rows;
  73714. private _rowThenColum;
  73715. private _orientation;
  73716. protected _cellWidth: number;
  73717. protected _cellHeight: number;
  73718. /**
  73719. * Gets or sets the distance between elements
  73720. */
  73721. margin: number;
  73722. /**
  73723. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  73724. * | Value | Type | Description |
  73725. * | ----- | ----------------------------------- | ----------- |
  73726. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  73727. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  73728. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  73729. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  73730. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  73731. */
  73732. get orientation(): number;
  73733. set orientation(value: number);
  73734. /**
  73735. * Gets or sets the number of columns requested (10 by default).
  73736. * The panel will automatically compute the number of rows based on number of child controls.
  73737. */
  73738. get columns(): BABYLON.int;
  73739. set columns(value: BABYLON.int);
  73740. /**
  73741. * Gets or sets a the number of rows requested.
  73742. * The panel will automatically compute the number of columns based on number of child controls.
  73743. */
  73744. get rows(): BABYLON.int;
  73745. set rows(value: BABYLON.int);
  73746. /**
  73747. * Creates new VolumeBasedPanel
  73748. */
  73749. constructor();
  73750. protected _arrangeChildren(): void;
  73751. /** Child classes must implement this function to provide correct control positioning */
  73752. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  73753. /** Child classes can implement this function to provide additional processing */
  73754. protected _finalProcessing(): void;
  73755. }
  73756. }
  73757. declare module BABYLON.GUI {
  73758. /**
  73759. * Class used to create a container panel deployed on the surface of a cylinder
  73760. */
  73761. export class CylinderPanel extends VolumeBasedPanel {
  73762. private _radius;
  73763. /**
  73764. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  73765. */
  73766. get radius(): BABYLON.float;
  73767. set radius(value: BABYLON.float);
  73768. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  73769. private _cylindricalMapping;
  73770. }
  73771. }
  73772. declare module BABYLON.GUI {
  73773. /** @hidden */
  73774. export var fluentVertexShader: {
  73775. name: string;
  73776. shader: string;
  73777. };
  73778. }
  73779. declare module BABYLON.GUI {
  73780. /** @hidden */
  73781. export var fluentPixelShader: {
  73782. name: string;
  73783. shader: string;
  73784. };
  73785. }
  73786. declare module BABYLON.GUI {
  73787. /** @hidden */
  73788. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  73789. INNERGLOW: boolean;
  73790. BORDER: boolean;
  73791. HOVERLIGHT: boolean;
  73792. TEXTURE: boolean;
  73793. constructor();
  73794. }
  73795. /**
  73796. * Class used to render controls with fluent desgin
  73797. */
  73798. export class FluentMaterial extends BABYLON.PushMaterial {
  73799. /**
  73800. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  73801. */
  73802. innerGlowColorIntensity: number;
  73803. /**
  73804. * Gets or sets the inner glow color (white by default)
  73805. */
  73806. innerGlowColor: BABYLON.Color3;
  73807. /**
  73808. * Gets or sets alpha value (default is 1.0)
  73809. */
  73810. alpha: number;
  73811. /**
  73812. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  73813. */
  73814. albedoColor: BABYLON.Color3;
  73815. /**
  73816. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  73817. */
  73818. renderBorders: boolean;
  73819. /**
  73820. * Gets or sets border width (default is 0.5)
  73821. */
  73822. borderWidth: number;
  73823. /**
  73824. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  73825. */
  73826. edgeSmoothingValue: number;
  73827. /**
  73828. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  73829. */
  73830. borderMinValue: number;
  73831. /**
  73832. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  73833. */
  73834. renderHoverLight: boolean;
  73835. /**
  73836. * Gets or sets the radius used to render the hover light (default is 1.0)
  73837. */
  73838. hoverRadius: number;
  73839. /**
  73840. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  73841. */
  73842. hoverColor: BABYLON.Color4;
  73843. /**
  73844. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  73845. */
  73846. hoverPosition: BABYLON.Vector3;
  73847. private _albedoTexture;
  73848. /** Gets or sets the texture to use for albedo color */
  73849. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  73850. /**
  73851. * Creates a new Fluent material
  73852. * @param name defines the name of the material
  73853. * @param scene defines the hosting scene
  73854. */
  73855. constructor(name: string, scene: BABYLON.Scene);
  73856. needAlphaBlending(): boolean;
  73857. needAlphaTesting(): boolean;
  73858. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  73859. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  73860. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  73861. getActiveTextures(): BABYLON.BaseTexture[];
  73862. hasTexture(texture: BABYLON.BaseTexture): boolean;
  73863. dispose(forceDisposeEffect?: boolean): void;
  73864. clone(name: string): FluentMaterial;
  73865. serialize(): any;
  73866. getClassName(): string;
  73867. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  73868. }
  73869. }
  73870. declare module BABYLON.GUI {
  73871. /**
  73872. * Class used to create a holographic button in 3D
  73873. */
  73874. export class HolographicButton extends Button3D {
  73875. private _backPlate;
  73876. private _textPlate;
  73877. private _frontPlate;
  73878. private _text;
  73879. private _imageUrl;
  73880. private _shareMaterials;
  73881. private _frontMaterial;
  73882. private _backMaterial;
  73883. private _plateMaterial;
  73884. private _pickedPointObserver;
  73885. private _tooltipFade;
  73886. private _tooltipTextBlock;
  73887. private _tooltipTexture;
  73888. private _tooltipMesh;
  73889. private _tooltipHoverObserver;
  73890. private _tooltipOutObserver;
  73891. private _disposeTooltip;
  73892. /**
  73893. * Rendering ground id of all the mesh in the button
  73894. */
  73895. set renderingGroupId(id: number);
  73896. get renderingGroupId(): number;
  73897. /**
  73898. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  73899. */
  73900. set tooltipText(text: BABYLON.Nullable<string>);
  73901. get tooltipText(): BABYLON.Nullable<string>;
  73902. /**
  73903. * Gets or sets text for the button
  73904. */
  73905. get text(): string;
  73906. set text(value: string);
  73907. /**
  73908. * Gets or sets the image url for the button
  73909. */
  73910. get imageUrl(): string;
  73911. set imageUrl(value: string);
  73912. /**
  73913. * Gets the back material used by this button
  73914. */
  73915. get backMaterial(): FluentMaterial;
  73916. /**
  73917. * Gets the front material used by this button
  73918. */
  73919. get frontMaterial(): FluentMaterial;
  73920. /**
  73921. * Gets the plate material used by this button
  73922. */
  73923. get plateMaterial(): BABYLON.StandardMaterial;
  73924. /**
  73925. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  73926. */
  73927. get shareMaterials(): boolean;
  73928. /**
  73929. * Creates a new button
  73930. * @param name defines the control name
  73931. */
  73932. constructor(name?: string, shareMaterials?: boolean);
  73933. protected _getTypeName(): string;
  73934. private _rebuildContent;
  73935. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  73936. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  73937. private _createBackMaterial;
  73938. private _createFrontMaterial;
  73939. private _createPlateMaterial;
  73940. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  73941. /**
  73942. * Releases all associated resources
  73943. */
  73944. dispose(): void;
  73945. }
  73946. }
  73947. declare module BABYLON.GUI {
  73948. /**
  73949. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  73950. */
  73951. export class MeshButton3D extends Button3D {
  73952. /** @hidden */
  73953. protected _currentMesh: BABYLON.Mesh;
  73954. /**
  73955. * Creates a new 3D button based on a mesh
  73956. * @param mesh mesh to become a 3D button
  73957. * @param name defines the control name
  73958. */
  73959. constructor(mesh: BABYLON.Mesh, name?: string);
  73960. protected _getTypeName(): string;
  73961. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  73962. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  73963. }
  73964. }
  73965. declare module BABYLON.GUI {
  73966. /**
  73967. * Class used to create a container panel deployed on the surface of a plane
  73968. */
  73969. export class PlanePanel extends VolumeBasedPanel {
  73970. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  73971. }
  73972. }
  73973. declare module BABYLON.GUI {
  73974. /**
  73975. * Class used to create a container panel where items get randomized planar mapping
  73976. */
  73977. export class ScatterPanel extends VolumeBasedPanel {
  73978. private _iteration;
  73979. /**
  73980. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  73981. */
  73982. get iteration(): BABYLON.float;
  73983. set iteration(value: BABYLON.float);
  73984. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  73985. private _scatterMapping;
  73986. protected _finalProcessing(): void;
  73987. }
  73988. }
  73989. declare module BABYLON.GUI {
  73990. /**
  73991. * Class used to create a container panel deployed on the surface of a sphere
  73992. */
  73993. export class SpherePanel extends VolumeBasedPanel {
  73994. private _radius;
  73995. /**
  73996. * Gets or sets the radius of the sphere where to project controls (5 by default)
  73997. */
  73998. get radius(): BABYLON.float;
  73999. set radius(value: BABYLON.float);
  74000. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  74001. private _sphericalMapping;
  74002. }
  74003. }
  74004. declare module BABYLON.GUI {
  74005. /**
  74006. * Class used to create a stack panel in 3D on XY plane
  74007. */
  74008. export class StackPanel3D extends Container3D {
  74009. private _isVertical;
  74010. /**
  74011. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  74012. */
  74013. get isVertical(): boolean;
  74014. set isVertical(value: boolean);
  74015. /**
  74016. * Gets or sets the distance between elements
  74017. */
  74018. margin: number;
  74019. /**
  74020. * Creates new StackPanel
  74021. * @param isVertical
  74022. */
  74023. constructor(isVertical?: boolean);
  74024. protected _arrangeChildren(): void;
  74025. }
  74026. }
  74027. declare module BABYLON {
  74028. /**
  74029. * Configuration for glTF validation
  74030. */
  74031. export interface IGLTFValidationConfiguration {
  74032. /**
  74033. * The url of the glTF validator.
  74034. */
  74035. url: string;
  74036. }
  74037. /**
  74038. * glTF validation
  74039. */
  74040. export class GLTFValidation {
  74041. /**
  74042. * The configuration. Defaults to `{ url: "https://preview.babylonjs.com/gltf_validator.js" }`.
  74043. */
  74044. static Configuration: IGLTFValidationConfiguration;
  74045. private static _LoadScriptPromise;
  74046. /**
  74047. * Validate a glTF asset using the glTF-Validator.
  74048. * @param data The JSON of a glTF or the array buffer of a binary glTF
  74049. * @param rootUrl The root url for the glTF
  74050. * @param fileName The file name for the glTF
  74051. * @param getExternalResource The callback to get external resources for the glTF validator
  74052. * @returns A promise that resolves with the glTF validation results once complete
  74053. */
  74054. static ValidateAsync(data: string | ArrayBuffer, rootUrl: string, fileName: string, getExternalResource: (uri: string) => Promise<ArrayBuffer>): Promise<BABYLON.GLTF2.IGLTFValidationResults>;
  74055. }
  74056. }
  74057. declare module BABYLON {
  74058. /**
  74059. * Mode that determines the coordinate system to use.
  74060. */
  74061. export enum GLTFLoaderCoordinateSystemMode {
  74062. /**
  74063. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  74064. */
  74065. AUTO = 0,
  74066. /**
  74067. * Sets the useRightHandedSystem flag on the scene.
  74068. */
  74069. FORCE_RIGHT_HANDED = 1
  74070. }
  74071. /**
  74072. * Mode that determines what animations will start.
  74073. */
  74074. export enum GLTFLoaderAnimationStartMode {
  74075. /**
  74076. * No animation will start.
  74077. */
  74078. NONE = 0,
  74079. /**
  74080. * The first animation will start.
  74081. */
  74082. FIRST = 1,
  74083. /**
  74084. * All animations will start.
  74085. */
  74086. ALL = 2
  74087. }
  74088. /**
  74089. * Interface that contains the data for the glTF asset.
  74090. */
  74091. export interface IGLTFLoaderData {
  74092. /**
  74093. * The object that represents the glTF JSON.
  74094. */
  74095. json: Object;
  74096. /**
  74097. * The BIN chunk of a binary glTF.
  74098. */
  74099. bin: Nullable<IDataBuffer>;
  74100. }
  74101. /**
  74102. * Interface for extending the loader.
  74103. */
  74104. export interface IGLTFLoaderExtension {
  74105. /**
  74106. * The name of this extension.
  74107. */
  74108. readonly name: string;
  74109. /**
  74110. * Defines whether this extension is enabled.
  74111. */
  74112. enabled: boolean;
  74113. /**
  74114. * Defines the order of this extension.
  74115. * The loader sorts the extensions using these values when loading.
  74116. */
  74117. order?: number;
  74118. }
  74119. /**
  74120. * Loader state.
  74121. */
  74122. export enum GLTFLoaderState {
  74123. /**
  74124. * The asset is loading.
  74125. */
  74126. LOADING = 0,
  74127. /**
  74128. * The asset is ready for rendering.
  74129. */
  74130. READY = 1,
  74131. /**
  74132. * The asset is completely loaded.
  74133. */
  74134. COMPLETE = 2
  74135. }
  74136. /** @hidden */
  74137. export interface IGLTFLoader extends IDisposable {
  74138. readonly state: Nullable<GLTFLoaderState>;
  74139. importMeshAsync: (meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<{
  74140. meshes: AbstractMesh[];
  74141. particleSystems: IParticleSystem[];
  74142. skeletons: Skeleton[];
  74143. animationGroups: AnimationGroup[];
  74144. }>;
  74145. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  74146. }
  74147. /**
  74148. * File loader for loading glTF files into a scene.
  74149. */
  74150. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  74151. /** @hidden */
  74152. static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  74153. /** @hidden */
  74154. static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  74155. /**
  74156. * Raised when the asset has been parsed
  74157. */
  74158. onParsedObservable: Observable<IGLTFLoaderData>;
  74159. private _onParsedObserver;
  74160. /**
  74161. * Raised when the asset has been parsed
  74162. */
  74163. set onParsed(callback: (loaderData: IGLTFLoaderData) => void);
  74164. /**
  74165. * 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.
  74166. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  74167. * Defaults to true.
  74168. * @hidden
  74169. */
  74170. static IncrementalLoading: boolean;
  74171. /**
  74172. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  74173. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  74174. * @hidden
  74175. */
  74176. static HomogeneousCoordinates: boolean;
  74177. /**
  74178. * The coordinate system mode. Defaults to AUTO.
  74179. */
  74180. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  74181. /**
  74182. * The animation start mode. Defaults to FIRST.
  74183. */
  74184. animationStartMode: GLTFLoaderAnimationStartMode;
  74185. /**
  74186. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  74187. */
  74188. compileMaterials: boolean;
  74189. /**
  74190. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  74191. */
  74192. useClipPlane: boolean;
  74193. /**
  74194. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  74195. */
  74196. compileShadowGenerators: boolean;
  74197. /**
  74198. * Defines if the Alpha blended materials are only applied as coverage.
  74199. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  74200. * If true, no extra effects are applied to transparent pixels.
  74201. */
  74202. transparencyAsCoverage: boolean;
  74203. /**
  74204. * Defines if the loader should use range requests when load binary glTF files from HTTP.
  74205. * Enabling will disable offline support and glTF validator.
  74206. * Defaults to false.
  74207. */
  74208. useRangeRequests: boolean;
  74209. /**
  74210. * Defines if the loader should create instances when multiple glTF nodes point to the same glTF mesh. Defaults to true.
  74211. */
  74212. createInstances: boolean;
  74213. /**
  74214. * Function called before loading a url referenced by the asset.
  74215. */
  74216. preprocessUrlAsync: (url: string) => Promise<string>;
  74217. /**
  74218. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  74219. */
  74220. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  74221. private _onMeshLoadedObserver;
  74222. /**
  74223. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  74224. */
  74225. set onMeshLoaded(callback: (mesh: AbstractMesh) => void);
  74226. /**
  74227. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  74228. */
  74229. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  74230. private _onTextureLoadedObserver;
  74231. /**
  74232. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  74233. */
  74234. set onTextureLoaded(callback: (texture: BaseTexture) => void);
  74235. /**
  74236. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  74237. */
  74238. readonly onMaterialLoadedObservable: Observable<Material>;
  74239. private _onMaterialLoadedObserver;
  74240. /**
  74241. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  74242. */
  74243. set onMaterialLoaded(callback: (material: Material) => void);
  74244. /**
  74245. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  74246. */
  74247. readonly onCameraLoadedObservable: Observable<Camera>;
  74248. private _onCameraLoadedObserver;
  74249. /**
  74250. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  74251. */
  74252. set onCameraLoaded(callback: (camera: Camera) => void);
  74253. /**
  74254. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  74255. * For assets with LODs, raised when all of the LODs are complete.
  74256. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  74257. */
  74258. readonly onCompleteObservable: Observable<void>;
  74259. private _onCompleteObserver;
  74260. /**
  74261. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  74262. * For assets with LODs, raised when all of the LODs are complete.
  74263. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  74264. */
  74265. set onComplete(callback: () => void);
  74266. /**
  74267. * Observable raised when an error occurs.
  74268. */
  74269. readonly onErrorObservable: Observable<any>;
  74270. private _onErrorObserver;
  74271. /**
  74272. * Callback raised when an error occurs.
  74273. */
  74274. set onError(callback: (reason: any) => void);
  74275. /**
  74276. * Observable raised after the loader is disposed.
  74277. */
  74278. readonly onDisposeObservable: Observable<void>;
  74279. private _onDisposeObserver;
  74280. /**
  74281. * Callback raised after the loader is disposed.
  74282. */
  74283. set onDispose(callback: () => void);
  74284. /**
  74285. * Observable raised after a loader extension is created.
  74286. * Set additional options for a loader extension in this event.
  74287. */
  74288. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  74289. private _onExtensionLoadedObserver;
  74290. /**
  74291. * Callback raised after a loader extension is created.
  74292. */
  74293. set onExtensionLoaded(callback: (extension: IGLTFLoaderExtension) => void);
  74294. /**
  74295. * Defines if the loader logging is enabled.
  74296. */
  74297. get loggingEnabled(): boolean;
  74298. set loggingEnabled(value: boolean);
  74299. /**
  74300. * Defines if the loader should capture performance counters.
  74301. */
  74302. get capturePerformanceCounters(): boolean;
  74303. set capturePerformanceCounters(value: boolean);
  74304. /**
  74305. * Defines if the loader should validate the asset.
  74306. */
  74307. validate: boolean;
  74308. /**
  74309. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  74310. */
  74311. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  74312. private _onValidatedObserver;
  74313. /**
  74314. * Callback raised after a loader extension is created.
  74315. */
  74316. set onValidated(callback: (results: BABYLON.GLTF2.IGLTFValidationResults) => void);
  74317. private _loader;
  74318. /**
  74319. * Name of the loader ("gltf")
  74320. */
  74321. name: string;
  74322. /** @hidden */
  74323. extensions: ISceneLoaderPluginExtensions;
  74324. /**
  74325. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  74326. */
  74327. dispose(): void;
  74328. /** @hidden */
  74329. _clear(): void;
  74330. /** @hidden */
  74331. requestFile(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  74332. /** @hidden */
  74333. readFile(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  74334. /** @hidden */
  74335. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  74336. meshes: AbstractMesh[];
  74337. particleSystems: IParticleSystem[];
  74338. skeletons: Skeleton[];
  74339. animationGroups: AnimationGroup[];
  74340. }>;
  74341. /** @hidden */
  74342. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  74343. /** @hidden */
  74344. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  74345. /** @hidden */
  74346. canDirectLoad(data: string): boolean;
  74347. /** @hidden */
  74348. directLoad(scene: Scene, data: string): any;
  74349. /**
  74350. * The callback that allows custom handling of the root url based on the response url.
  74351. * @param rootUrl the original root url
  74352. * @param responseURL the response url if available
  74353. * @returns the new root url
  74354. */
  74355. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  74356. /** @hidden */
  74357. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  74358. /**
  74359. * The loader state or null if the loader is not active.
  74360. */
  74361. get loaderState(): Nullable<GLTFLoaderState>;
  74362. /**
  74363. * Returns a promise that resolves when the asset is completely loaded.
  74364. * @returns a promise that resolves when the asset is completely loaded.
  74365. */
  74366. whenCompleteAsync(): Promise<void>;
  74367. private _validate;
  74368. private _getLoader;
  74369. private _parseJson;
  74370. private _unpackBinaryAsync;
  74371. private _unpackBinaryV1Async;
  74372. private _unpackBinaryV2Async;
  74373. private static _parseVersion;
  74374. private static _compareVersion;
  74375. private static readonly _logSpaces;
  74376. private _logIndentLevel;
  74377. private _loggingEnabled;
  74378. /** @hidden */
  74379. _log: (message: string) => void;
  74380. /** @hidden */
  74381. _logOpen(message: string): void;
  74382. /** @hidden */
  74383. _logClose(): void;
  74384. private _logEnabled;
  74385. private _logDisabled;
  74386. private _capturePerformanceCounters;
  74387. /** @hidden */
  74388. _startPerformanceCounter: (counterName: string) => void;
  74389. /** @hidden */
  74390. _endPerformanceCounter: (counterName: string) => void;
  74391. private _startPerformanceCounterEnabled;
  74392. private _startPerformanceCounterDisabled;
  74393. private _endPerformanceCounterEnabled;
  74394. private _endPerformanceCounterDisabled;
  74395. }
  74396. }
  74397. declare module BABYLON.GLTF1 {
  74398. /**
  74399. * Enums
  74400. * @hidden
  74401. */
  74402. export enum EComponentType {
  74403. BYTE = 5120,
  74404. UNSIGNED_BYTE = 5121,
  74405. SHORT = 5122,
  74406. UNSIGNED_SHORT = 5123,
  74407. FLOAT = 5126
  74408. }
  74409. /** @hidden */
  74410. export enum EShaderType {
  74411. FRAGMENT = 35632,
  74412. VERTEX = 35633
  74413. }
  74414. /** @hidden */
  74415. export enum EParameterType {
  74416. BYTE = 5120,
  74417. UNSIGNED_BYTE = 5121,
  74418. SHORT = 5122,
  74419. UNSIGNED_SHORT = 5123,
  74420. INT = 5124,
  74421. UNSIGNED_INT = 5125,
  74422. FLOAT = 5126,
  74423. FLOAT_VEC2 = 35664,
  74424. FLOAT_VEC3 = 35665,
  74425. FLOAT_VEC4 = 35666,
  74426. INT_VEC2 = 35667,
  74427. INT_VEC3 = 35668,
  74428. INT_VEC4 = 35669,
  74429. BOOL = 35670,
  74430. BOOL_VEC2 = 35671,
  74431. BOOL_VEC3 = 35672,
  74432. BOOL_VEC4 = 35673,
  74433. FLOAT_MAT2 = 35674,
  74434. FLOAT_MAT3 = 35675,
  74435. FLOAT_MAT4 = 35676,
  74436. SAMPLER_2D = 35678
  74437. }
  74438. /** @hidden */
  74439. export enum ETextureWrapMode {
  74440. CLAMP_TO_EDGE = 33071,
  74441. MIRRORED_REPEAT = 33648,
  74442. REPEAT = 10497
  74443. }
  74444. /** @hidden */
  74445. export enum ETextureFilterType {
  74446. NEAREST = 9728,
  74447. LINEAR = 9728,
  74448. NEAREST_MIPMAP_NEAREST = 9984,
  74449. LINEAR_MIPMAP_NEAREST = 9985,
  74450. NEAREST_MIPMAP_LINEAR = 9986,
  74451. LINEAR_MIPMAP_LINEAR = 9987
  74452. }
  74453. /** @hidden */
  74454. export enum ETextureFormat {
  74455. ALPHA = 6406,
  74456. RGB = 6407,
  74457. RGBA = 6408,
  74458. LUMINANCE = 6409,
  74459. LUMINANCE_ALPHA = 6410
  74460. }
  74461. /** @hidden */
  74462. export enum ECullingType {
  74463. FRONT = 1028,
  74464. BACK = 1029,
  74465. FRONT_AND_BACK = 1032
  74466. }
  74467. /** @hidden */
  74468. export enum EBlendingFunction {
  74469. ZERO = 0,
  74470. ONE = 1,
  74471. SRC_COLOR = 768,
  74472. ONE_MINUS_SRC_COLOR = 769,
  74473. DST_COLOR = 774,
  74474. ONE_MINUS_DST_COLOR = 775,
  74475. SRC_ALPHA = 770,
  74476. ONE_MINUS_SRC_ALPHA = 771,
  74477. DST_ALPHA = 772,
  74478. ONE_MINUS_DST_ALPHA = 773,
  74479. CONSTANT_COLOR = 32769,
  74480. ONE_MINUS_CONSTANT_COLOR = 32770,
  74481. CONSTANT_ALPHA = 32771,
  74482. ONE_MINUS_CONSTANT_ALPHA = 32772,
  74483. SRC_ALPHA_SATURATE = 776
  74484. }
  74485. /** @hidden */
  74486. export interface IGLTFProperty {
  74487. extensions?: {
  74488. [key: string]: any;
  74489. };
  74490. extras?: Object;
  74491. }
  74492. /** @hidden */
  74493. export interface IGLTFChildRootProperty extends IGLTFProperty {
  74494. name?: string;
  74495. }
  74496. /** @hidden */
  74497. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  74498. bufferView: string;
  74499. byteOffset: number;
  74500. byteStride: number;
  74501. count: number;
  74502. type: string;
  74503. componentType: EComponentType;
  74504. max?: number[];
  74505. min?: number[];
  74506. name?: string;
  74507. }
  74508. /** @hidden */
  74509. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  74510. buffer: string;
  74511. byteOffset: number;
  74512. byteLength: number;
  74513. byteStride: number;
  74514. target?: number;
  74515. }
  74516. /** @hidden */
  74517. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  74518. uri: string;
  74519. byteLength?: number;
  74520. type?: string;
  74521. }
  74522. /** @hidden */
  74523. export interface IGLTFShader extends IGLTFChildRootProperty {
  74524. uri: string;
  74525. type: EShaderType;
  74526. }
  74527. /** @hidden */
  74528. export interface IGLTFProgram extends IGLTFChildRootProperty {
  74529. attributes: string[];
  74530. fragmentShader: string;
  74531. vertexShader: string;
  74532. }
  74533. /** @hidden */
  74534. export interface IGLTFTechniqueParameter {
  74535. type: number;
  74536. count?: number;
  74537. semantic?: string;
  74538. node?: string;
  74539. value?: number | boolean | string | Array<any>;
  74540. source?: string;
  74541. babylonValue?: any;
  74542. }
  74543. /** @hidden */
  74544. export interface IGLTFTechniqueCommonProfile {
  74545. lightingModel: string;
  74546. texcoordBindings: Object;
  74547. parameters?: Array<any>;
  74548. }
  74549. /** @hidden */
  74550. export interface IGLTFTechniqueStatesFunctions {
  74551. blendColor?: number[];
  74552. blendEquationSeparate?: number[];
  74553. blendFuncSeparate?: number[];
  74554. colorMask: boolean[];
  74555. cullFace: number[];
  74556. }
  74557. /** @hidden */
  74558. export interface IGLTFTechniqueStates {
  74559. enable: number[];
  74560. functions: IGLTFTechniqueStatesFunctions;
  74561. }
  74562. /** @hidden */
  74563. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  74564. parameters: {
  74565. [key: string]: IGLTFTechniqueParameter;
  74566. };
  74567. program: string;
  74568. attributes: {
  74569. [key: string]: string;
  74570. };
  74571. uniforms: {
  74572. [key: string]: string;
  74573. };
  74574. states: IGLTFTechniqueStates;
  74575. }
  74576. /** @hidden */
  74577. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  74578. technique?: string;
  74579. values: string[];
  74580. }
  74581. /** @hidden */
  74582. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  74583. attributes: {
  74584. [key: string]: string;
  74585. };
  74586. indices: string;
  74587. material: string;
  74588. mode?: number;
  74589. }
  74590. /** @hidden */
  74591. export interface IGLTFMesh extends IGLTFChildRootProperty {
  74592. primitives: IGLTFMeshPrimitive[];
  74593. }
  74594. /** @hidden */
  74595. export interface IGLTFImage extends IGLTFChildRootProperty {
  74596. uri: string;
  74597. }
  74598. /** @hidden */
  74599. export interface IGLTFSampler extends IGLTFChildRootProperty {
  74600. magFilter?: number;
  74601. minFilter?: number;
  74602. wrapS?: number;
  74603. wrapT?: number;
  74604. }
  74605. /** @hidden */
  74606. export interface IGLTFTexture extends IGLTFChildRootProperty {
  74607. sampler: string;
  74608. source: string;
  74609. format?: ETextureFormat;
  74610. internalFormat?: ETextureFormat;
  74611. target?: number;
  74612. type?: number;
  74613. babylonTexture?: Texture;
  74614. }
  74615. /** @hidden */
  74616. export interface IGLTFAmbienLight {
  74617. color?: number[];
  74618. }
  74619. /** @hidden */
  74620. export interface IGLTFDirectionalLight {
  74621. color?: number[];
  74622. }
  74623. /** @hidden */
  74624. export interface IGLTFPointLight {
  74625. color?: number[];
  74626. constantAttenuation?: number;
  74627. linearAttenuation?: number;
  74628. quadraticAttenuation?: number;
  74629. }
  74630. /** @hidden */
  74631. export interface IGLTFSpotLight {
  74632. color?: number[];
  74633. constantAttenuation?: number;
  74634. fallOfAngle?: number;
  74635. fallOffExponent?: number;
  74636. linearAttenuation?: number;
  74637. quadraticAttenuation?: number;
  74638. }
  74639. /** @hidden */
  74640. export interface IGLTFLight extends IGLTFChildRootProperty {
  74641. type: string;
  74642. }
  74643. /** @hidden */
  74644. export interface IGLTFCameraOrthographic {
  74645. xmag: number;
  74646. ymag: number;
  74647. zfar: number;
  74648. znear: number;
  74649. }
  74650. /** @hidden */
  74651. export interface IGLTFCameraPerspective {
  74652. aspectRatio: number;
  74653. yfov: number;
  74654. zfar: number;
  74655. znear: number;
  74656. }
  74657. /** @hidden */
  74658. export interface IGLTFCamera extends IGLTFChildRootProperty {
  74659. type: string;
  74660. }
  74661. /** @hidden */
  74662. export interface IGLTFAnimationChannelTarget {
  74663. id: string;
  74664. path: string;
  74665. }
  74666. /** @hidden */
  74667. export interface IGLTFAnimationChannel {
  74668. sampler: string;
  74669. target: IGLTFAnimationChannelTarget;
  74670. }
  74671. /** @hidden */
  74672. export interface IGLTFAnimationSampler {
  74673. input: string;
  74674. output: string;
  74675. interpolation?: string;
  74676. }
  74677. /** @hidden */
  74678. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  74679. channels?: IGLTFAnimationChannel[];
  74680. parameters?: {
  74681. [key: string]: string;
  74682. };
  74683. samplers?: {
  74684. [key: string]: IGLTFAnimationSampler;
  74685. };
  74686. }
  74687. /** @hidden */
  74688. export interface IGLTFNodeInstanceSkin {
  74689. skeletons: string[];
  74690. skin: string;
  74691. meshes: string[];
  74692. }
  74693. /** @hidden */
  74694. export interface IGLTFSkins extends IGLTFChildRootProperty {
  74695. bindShapeMatrix: number[];
  74696. inverseBindMatrices: string;
  74697. jointNames: string[];
  74698. babylonSkeleton?: Skeleton;
  74699. }
  74700. /** @hidden */
  74701. export interface IGLTFNode extends IGLTFChildRootProperty {
  74702. camera?: string;
  74703. children: string[];
  74704. skin?: string;
  74705. jointName?: string;
  74706. light?: string;
  74707. matrix: number[];
  74708. mesh?: string;
  74709. meshes?: string[];
  74710. rotation?: number[];
  74711. scale?: number[];
  74712. translation?: number[];
  74713. babylonNode?: Node;
  74714. }
  74715. /** @hidden */
  74716. export interface IGLTFScene extends IGLTFChildRootProperty {
  74717. nodes: string[];
  74718. }
  74719. /** @hidden */
  74720. export interface IGLTFRuntime {
  74721. extensions: {
  74722. [key: string]: any;
  74723. };
  74724. accessors: {
  74725. [key: string]: IGLTFAccessor;
  74726. };
  74727. buffers: {
  74728. [key: string]: IGLTFBuffer;
  74729. };
  74730. bufferViews: {
  74731. [key: string]: IGLTFBufferView;
  74732. };
  74733. meshes: {
  74734. [key: string]: IGLTFMesh;
  74735. };
  74736. lights: {
  74737. [key: string]: IGLTFLight;
  74738. };
  74739. cameras: {
  74740. [key: string]: IGLTFCamera;
  74741. };
  74742. nodes: {
  74743. [key: string]: IGLTFNode;
  74744. };
  74745. images: {
  74746. [key: string]: IGLTFImage;
  74747. };
  74748. textures: {
  74749. [key: string]: IGLTFTexture;
  74750. };
  74751. shaders: {
  74752. [key: string]: IGLTFShader;
  74753. };
  74754. programs: {
  74755. [key: string]: IGLTFProgram;
  74756. };
  74757. samplers: {
  74758. [key: string]: IGLTFSampler;
  74759. };
  74760. techniques: {
  74761. [key: string]: IGLTFTechnique;
  74762. };
  74763. materials: {
  74764. [key: string]: IGLTFMaterial;
  74765. };
  74766. animations: {
  74767. [key: string]: IGLTFAnimation;
  74768. };
  74769. skins: {
  74770. [key: string]: IGLTFSkins;
  74771. };
  74772. currentScene?: Object;
  74773. scenes: {
  74774. [key: string]: IGLTFScene;
  74775. };
  74776. extensionsUsed: string[];
  74777. extensionsRequired?: string[];
  74778. buffersCount: number;
  74779. shaderscount: number;
  74780. scene: Scene;
  74781. rootUrl: string;
  74782. loadedBufferCount: number;
  74783. loadedBufferViews: {
  74784. [name: string]: ArrayBufferView;
  74785. };
  74786. loadedShaderCount: number;
  74787. importOnlyMeshes: boolean;
  74788. importMeshesNames?: string[];
  74789. dummyNodes: Node[];
  74790. }
  74791. /** @hidden */
  74792. export interface INodeToRoot {
  74793. bone: Bone;
  74794. node: IGLTFNode;
  74795. id: string;
  74796. }
  74797. /** @hidden */
  74798. export interface IJointNode {
  74799. node: IGLTFNode;
  74800. id: string;
  74801. }
  74802. }
  74803. declare module BABYLON.GLTF1 {
  74804. /**
  74805. * Utils functions for GLTF
  74806. * @hidden
  74807. */
  74808. export class GLTFUtils {
  74809. /**
  74810. * Sets the given "parameter" matrix
  74811. * @param scene: the Scene object
  74812. * @param source: the source node where to pick the matrix
  74813. * @param parameter: the GLTF technique parameter
  74814. * @param uniformName: the name of the shader's uniform
  74815. * @param shaderMaterial: the shader material
  74816. */
  74817. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  74818. /**
  74819. * Sets the given "parameter" matrix
  74820. * @param shaderMaterial: the shader material
  74821. * @param uniform: the name of the shader's uniform
  74822. * @param value: the value of the uniform
  74823. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  74824. */
  74825. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  74826. /**
  74827. * Returns the wrap mode of the texture
  74828. * @param mode: the mode value
  74829. */
  74830. static GetWrapMode(mode: number): number;
  74831. /**
  74832. * Returns the byte stride giving an accessor
  74833. * @param accessor: the GLTF accessor objet
  74834. */
  74835. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  74836. /**
  74837. * Returns the texture filter mode giving a mode value
  74838. * @param mode: the filter mode value
  74839. */
  74840. static GetTextureFilterMode(mode: number): ETextureFilterType;
  74841. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  74842. /**
  74843. * Returns a buffer from its accessor
  74844. * @param gltfRuntime: the GLTF runtime
  74845. * @param accessor: the GLTF accessor
  74846. */
  74847. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  74848. /**
  74849. * Decodes a buffer view into a string
  74850. * @param view: the buffer view
  74851. */
  74852. static DecodeBufferToText(view: ArrayBufferView): string;
  74853. /**
  74854. * Returns the default material of gltf. Related to
  74855. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  74856. * @param scene: the Babylon.js scene
  74857. */
  74858. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  74859. private static _DefaultMaterial;
  74860. }
  74861. }
  74862. declare module BABYLON.GLTF1 {
  74863. /**
  74864. * Implementation of the base glTF spec
  74865. * @hidden
  74866. */
  74867. export class GLTFLoaderBase {
  74868. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  74869. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  74870. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  74871. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  74872. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  74873. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  74874. }
  74875. /**
  74876. * glTF V1 Loader
  74877. * @hidden
  74878. */
  74879. export class GLTFLoader implements IGLTFLoader {
  74880. static Extensions: {
  74881. [name: string]: GLTFLoaderExtension;
  74882. };
  74883. static RegisterExtension(extension: GLTFLoaderExtension): void;
  74884. state: Nullable<GLTFLoaderState>;
  74885. dispose(): void;
  74886. private _importMeshAsync;
  74887. /**
  74888. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  74889. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  74890. * @param scene the scene the meshes should be added to
  74891. * @param data gltf data containing information of the meshes in a loaded file
  74892. * @param rootUrl root url to load from
  74893. * @param onProgress event that fires when loading progress has occured
  74894. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  74895. */
  74896. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<{
  74897. meshes: AbstractMesh[];
  74898. particleSystems: IParticleSystem[];
  74899. skeletons: Skeleton[];
  74900. animationGroups: AnimationGroup[];
  74901. }>;
  74902. private _loadAsync;
  74903. /**
  74904. * Imports all objects from a loaded gltf file and adds them to the scene
  74905. * @param scene the scene the objects should be added to
  74906. * @param data gltf data containing information of the meshes in a loaded file
  74907. * @param rootUrl root url to load from
  74908. * @param onProgress event that fires when loading progress has occured
  74909. * @returns a promise which completes when objects have been loaded to the scene
  74910. */
  74911. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
  74912. private _loadShadersAsync;
  74913. private _loadBuffersAsync;
  74914. private _createNodes;
  74915. }
  74916. /** @hidden */
  74917. export abstract class GLTFLoaderExtension {
  74918. private _name;
  74919. constructor(name: string);
  74920. get name(): string;
  74921. /**
  74922. * Defines an override for loading the runtime
  74923. * Return true to stop further extensions from loading the runtime
  74924. */
  74925. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  74926. /**
  74927. * Defines an onverride for creating gltf runtime
  74928. * Return true to stop further extensions from creating the runtime
  74929. */
  74930. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  74931. /**
  74932. * Defines an override for loading buffers
  74933. * Return true to stop further extensions from loading this buffer
  74934. */
  74935. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  74936. /**
  74937. * Defines an override for loading texture buffers
  74938. * Return true to stop further extensions from loading this texture data
  74939. */
  74940. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  74941. /**
  74942. * Defines an override for creating textures
  74943. * Return true to stop further extensions from loading this texture
  74944. */
  74945. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  74946. /**
  74947. * Defines an override for loading shader strings
  74948. * Return true to stop further extensions from loading this shader data
  74949. */
  74950. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  74951. /**
  74952. * Defines an override for loading materials
  74953. * Return true to stop further extensions from loading this material
  74954. */
  74955. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  74956. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  74957. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  74958. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  74959. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  74960. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  74961. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  74962. private static LoadTextureBufferAsync;
  74963. private static CreateTextureAsync;
  74964. private static ApplyExtensions;
  74965. }
  74966. }
  74967. declare module BABYLON.GLTF1 {
  74968. /** @hidden */
  74969. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  74970. private _bin;
  74971. constructor();
  74972. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  74973. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  74974. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  74975. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  74976. }
  74977. }
  74978. declare module BABYLON.GLTF1 {
  74979. /** @hidden */
  74980. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  74981. constructor();
  74982. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  74983. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  74984. private _loadTexture;
  74985. }
  74986. }
  74987. declare module BABYLON.GLTF2.Loader {
  74988. /**
  74989. * Loader interface with an index field.
  74990. */
  74991. export interface IArrayItem {
  74992. /**
  74993. * The index of this item in the array.
  74994. */
  74995. index: number;
  74996. }
  74997. /**
  74998. * Loader interface with additional members.
  74999. */
  75000. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  75001. /** @hidden */
  75002. _data?: Promise<ArrayBufferView>;
  75003. /** @hidden */
  75004. _babylonVertexBuffer?: Promise<VertexBuffer>;
  75005. }
  75006. /**
  75007. * Loader interface with additional members.
  75008. */
  75009. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  75010. }
  75011. /** @hidden */
  75012. export interface _IAnimationSamplerData {
  75013. input: Float32Array;
  75014. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  75015. output: Float32Array;
  75016. }
  75017. /**
  75018. * Loader interface with additional members.
  75019. */
  75020. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  75021. /** @hidden */
  75022. _data?: Promise<_IAnimationSamplerData>;
  75023. }
  75024. /**
  75025. * Loader interface with additional members.
  75026. */
  75027. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  75028. channels: IAnimationChannel[];
  75029. samplers: IAnimationSampler[];
  75030. /** @hidden */
  75031. _babylonAnimationGroup?: AnimationGroup;
  75032. }
  75033. /**
  75034. * Loader interface with additional members.
  75035. */
  75036. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  75037. /** @hidden */
  75038. _data?: Promise<ArrayBufferView>;
  75039. }
  75040. /**
  75041. * Loader interface with additional members.
  75042. */
  75043. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  75044. /** @hidden */
  75045. _data?: Promise<ArrayBufferView>;
  75046. /** @hidden */
  75047. _babylonBuffer?: Promise<Buffer>;
  75048. }
  75049. /**
  75050. * Loader interface with additional members.
  75051. */
  75052. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  75053. }
  75054. /**
  75055. * Loader interface with additional members.
  75056. */
  75057. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  75058. /** @hidden */
  75059. _data?: Promise<ArrayBufferView>;
  75060. }
  75061. /**
  75062. * Loader interface with additional members.
  75063. */
  75064. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  75065. }
  75066. /**
  75067. * Loader interface with additional members.
  75068. */
  75069. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  75070. }
  75071. /**
  75072. * Loader interface with additional members.
  75073. */
  75074. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  75075. baseColorTexture?: ITextureInfo;
  75076. metallicRoughnessTexture?: ITextureInfo;
  75077. }
  75078. /**
  75079. * Loader interface with additional members.
  75080. */
  75081. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  75082. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  75083. normalTexture?: IMaterialNormalTextureInfo;
  75084. occlusionTexture?: IMaterialOcclusionTextureInfo;
  75085. emissiveTexture?: ITextureInfo;
  75086. /** @hidden */
  75087. _data?: {
  75088. [babylonDrawMode: number]: {
  75089. babylonMaterial: Material;
  75090. babylonMeshes: AbstractMesh[];
  75091. promise: Promise<void>;
  75092. };
  75093. };
  75094. }
  75095. /**
  75096. * Loader interface with additional members.
  75097. */
  75098. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  75099. primitives: IMeshPrimitive[];
  75100. }
  75101. /**
  75102. * Loader interface with additional members.
  75103. */
  75104. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  75105. /** @hidden */
  75106. _instanceData?: {
  75107. babylonSourceMesh: Mesh;
  75108. promise: Promise<any>;
  75109. };
  75110. }
  75111. /**
  75112. * Loader interface with additional members.
  75113. */
  75114. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  75115. /**
  75116. * The parent glTF node.
  75117. */
  75118. parent?: INode;
  75119. /** @hidden */
  75120. _babylonTransformNode?: TransformNode;
  75121. /** @hidden */
  75122. _primitiveBabylonMeshes?: AbstractMesh[];
  75123. /** @hidden */
  75124. _babylonBones?: Bone[];
  75125. /** @hidden */
  75126. _numMorphTargets?: number;
  75127. }
  75128. /** @hidden */
  75129. export interface _ISamplerData {
  75130. noMipMaps: boolean;
  75131. samplingMode: number;
  75132. wrapU: number;
  75133. wrapV: number;
  75134. }
  75135. /**
  75136. * Loader interface with additional members.
  75137. */
  75138. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  75139. /** @hidden */
  75140. _data?: _ISamplerData;
  75141. }
  75142. /**
  75143. * Loader interface with additional members.
  75144. */
  75145. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  75146. }
  75147. /**
  75148. * Loader interface with additional members.
  75149. */
  75150. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  75151. /** @hidden */
  75152. _data?: {
  75153. babylonSkeleton: Skeleton;
  75154. promise: Promise<void>;
  75155. };
  75156. }
  75157. /**
  75158. * Loader interface with additional members.
  75159. */
  75160. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  75161. }
  75162. /**
  75163. * Loader interface with additional members.
  75164. */
  75165. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  75166. }
  75167. /**
  75168. * Loader interface with additional members.
  75169. */
  75170. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  75171. accessors?: IAccessor[];
  75172. animations?: IAnimation[];
  75173. buffers?: IBuffer[];
  75174. bufferViews?: IBufferView[];
  75175. cameras?: ICamera[];
  75176. images?: IImage[];
  75177. materials?: IMaterial[];
  75178. meshes?: IMesh[];
  75179. nodes?: INode[];
  75180. samplers?: ISampler[];
  75181. scenes?: IScene[];
  75182. skins?: ISkin[];
  75183. textures?: ITexture[];
  75184. }
  75185. }
  75186. declare module BABYLON.GLTF2 {
  75187. /**
  75188. * Interface for a glTF loader extension.
  75189. */
  75190. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  75191. /**
  75192. * Called after the loader state changes to LOADING.
  75193. */
  75194. onLoading?(): void;
  75195. /**
  75196. * Called after the loader state changes to READY.
  75197. */
  75198. onReady?(): void;
  75199. /**
  75200. * Define this method to modify the default behavior when loading scenes.
  75201. * @param context The context when loading the asset
  75202. * @param scene The glTF scene property
  75203. * @returns A promise that resolves when the load is complete or null if not handled
  75204. */
  75205. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  75206. /**
  75207. * Define this method to modify the default behavior when loading nodes.
  75208. * @param context The context when loading the asset
  75209. * @param node The glTF node property
  75210. * @param assign A function called synchronously after parsing the glTF properties
  75211. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  75212. */
  75213. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  75214. /**
  75215. * Define this method to modify the default behavior when loading cameras.
  75216. * @param context The context when loading the asset
  75217. * @param camera The glTF camera property
  75218. * @param assign A function called synchronously after parsing the glTF properties
  75219. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  75220. */
  75221. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  75222. /**
  75223. * @hidden Define this method to modify the default behavior when loading vertex data for mesh primitives.
  75224. * @param context The context when loading the asset
  75225. * @param primitive The glTF mesh primitive property
  75226. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  75227. */
  75228. _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  75229. /**
  75230. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  75231. * @param context The context when loading the asset
  75232. * @param name The mesh name when loading the asset
  75233. * @param node The glTF node when loading the asset
  75234. * @param mesh The glTF mesh when loading the asset
  75235. * @param primitive The glTF mesh primitive property
  75236. * @param assign A function called synchronously after parsing the glTF properties
  75237. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  75238. */
  75239. _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  75240. /**
  75241. * @hidden Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  75242. * @param context The context when loading the asset
  75243. * @param material The glTF material property
  75244. * @param assign A function called synchronously after parsing the glTF properties
  75245. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  75246. */
  75247. _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  75248. /**
  75249. * Define this method to modify the default behavior when creating materials.
  75250. * @param context The context when loading the asset
  75251. * @param material The glTF material property
  75252. * @param babylonDrawMode The draw mode for the Babylon material
  75253. * @returns The Babylon material or null if not handled
  75254. */
  75255. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  75256. /**
  75257. * Define this method to modify the default behavior when loading material properties.
  75258. * @param context The context when loading the asset
  75259. * @param material The glTF material property
  75260. * @param babylonMaterial The Babylon material
  75261. * @returns A promise that resolves when the load is complete or null if not handled
  75262. */
  75263. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  75264. /**
  75265. * Define this method to modify the default behavior when loading texture infos.
  75266. * @param context The context when loading the asset
  75267. * @param textureInfo The glTF texture info property
  75268. * @param assign A function called synchronously after parsing the glTF properties
  75269. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  75270. */
  75271. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  75272. /**
  75273. * Define this method to modify the default behavior when loading animations.
  75274. * @param context The context when loading the asset
  75275. * @param animation The glTF animation property
  75276. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  75277. */
  75278. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  75279. /**
  75280. * @hidden Define this method to modify the default behavior when loading skins.
  75281. * @param context The context when loading the asset
  75282. * @param node The glTF node property
  75283. * @param skin The glTF skin property
  75284. * @returns A promise that resolves when the load is complete or null if not handled
  75285. */
  75286. _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  75287. /**
  75288. * @hidden Define this method to modify the default behavior when loading uris.
  75289. * @param context The context when loading the asset
  75290. * @param property The glTF property associated with the uri
  75291. * @param uri The uri to load
  75292. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  75293. */
  75294. _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  75295. /**
  75296. * Define this method to modify the default behavior when loading buffer views.
  75297. * @param context The context when loading the asset
  75298. * @param bufferView The glTF buffer view property
  75299. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  75300. */
  75301. loadBufferViewAsync?(context: string, bufferView: IBufferView): Nullable<Promise<ArrayBufferView>>;
  75302. /**
  75303. * Define this method to modify the default behavior when loading buffers.
  75304. * @param context The context when loading the asset
  75305. * @param buffer The glTF buffer property
  75306. * @param byteOffset The byte offset to load
  75307. * @param byteLength The byte length to load
  75308. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  75309. */
  75310. loadBufferAsync?(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  75311. }
  75312. }
  75313. declare module BABYLON.GLTF2 {
  75314. /**
  75315. * Helper class for working with arrays when loading the glTF asset
  75316. */
  75317. export class ArrayItem {
  75318. /**
  75319. * Gets an item from the given array.
  75320. * @param context The context when loading the asset
  75321. * @param array The array to get the item from
  75322. * @param index The index to the array
  75323. * @returns The array item
  75324. */
  75325. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  75326. /**
  75327. * Assign an `index` field to each item of the given array.
  75328. * @param array The array of items
  75329. */
  75330. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  75331. }
  75332. /**
  75333. * The glTF 2.0 loader
  75334. */
  75335. export class GLTFLoader implements IGLTFLoader {
  75336. /** @hidden */
  75337. _completePromises: Promise<any>[];
  75338. private _disposed;
  75339. private _parent;
  75340. private _state;
  75341. private _extensions;
  75342. private _rootUrl;
  75343. private _fileName;
  75344. private _uniqueRootUrl;
  75345. private _gltf;
  75346. private _bin;
  75347. private _babylonScene;
  75348. private _rootBabylonMesh;
  75349. private _defaultBabylonMaterialData;
  75350. private _progressCallback?;
  75351. private _requests;
  75352. private static readonly _DefaultSampler;
  75353. private static _RegisteredExtensions;
  75354. /**
  75355. * Registers a loader extension.
  75356. * @param name The name of the loader extension.
  75357. * @param factory The factory function that creates the loader extension.
  75358. */
  75359. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  75360. /**
  75361. * Unregisters a loader extension.
  75362. * @param name The name of the loader extension.
  75363. * @returns A boolean indicating whether the extension has been unregistered
  75364. */
  75365. static UnregisterExtension(name: string): boolean;
  75366. /**
  75367. * Gets the loader state.
  75368. */
  75369. get state(): Nullable<GLTFLoaderState>;
  75370. /**
  75371. * The object that represents the glTF JSON.
  75372. */
  75373. get gltf(): IGLTF;
  75374. /**
  75375. * The BIN chunk of a binary glTF.
  75376. */
  75377. get bin(): Nullable<IDataBuffer>;
  75378. /**
  75379. * The parent file loader.
  75380. */
  75381. get parent(): GLTFFileLoader;
  75382. /**
  75383. * The Babylon scene when loading the asset.
  75384. */
  75385. get babylonScene(): Scene;
  75386. /**
  75387. * The root Babylon mesh when loading the asset.
  75388. */
  75389. get rootBabylonMesh(): Mesh;
  75390. /** @hidden */
  75391. constructor(parent: GLTFFileLoader);
  75392. /** @hidden */
  75393. dispose(): void;
  75394. /** @hidden */
  75395. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  75396. meshes: AbstractMesh[];
  75397. particleSystems: IParticleSystem[];
  75398. skeletons: Skeleton[];
  75399. animationGroups: AnimationGroup[];
  75400. }>;
  75401. /** @hidden */
  75402. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  75403. private _loadAsync;
  75404. private _loadData;
  75405. private _setupData;
  75406. private _loadExtensions;
  75407. private _checkExtensions;
  75408. private _setState;
  75409. private _createRootNode;
  75410. /**
  75411. * Loads a glTF scene.
  75412. * @param context The context when loading the asset
  75413. * @param scene The glTF scene property
  75414. * @returns A promise that resolves when the load is complete
  75415. */
  75416. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  75417. private _forEachPrimitive;
  75418. private _getMeshes;
  75419. private _getSkeletons;
  75420. private _getAnimationGroups;
  75421. private _startAnimations;
  75422. /**
  75423. * Loads a glTF node.
  75424. * @param context The context when loading the asset
  75425. * @param node The glTF node property
  75426. * @param assign A function called synchronously after parsing the glTF properties
  75427. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  75428. */
  75429. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  75430. private _loadMeshAsync;
  75431. /**
  75432. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  75433. * @param context The context when loading the asset
  75434. * @param name The mesh name when loading the asset
  75435. * @param node The glTF node when loading the asset
  75436. * @param mesh The glTF mesh when loading the asset
  75437. * @param primitive The glTF mesh primitive property
  75438. * @param assign A function called synchronously after parsing the glTF properties
  75439. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  75440. */
  75441. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  75442. private _loadVertexDataAsync;
  75443. private _createMorphTargets;
  75444. private _loadMorphTargetsAsync;
  75445. private _loadMorphTargetVertexDataAsync;
  75446. private static _LoadTransform;
  75447. private _loadSkinAsync;
  75448. private _loadBones;
  75449. private _loadBone;
  75450. private _loadSkinInverseBindMatricesDataAsync;
  75451. private _updateBoneMatrices;
  75452. private _getNodeMatrix;
  75453. /**
  75454. * Loads a glTF camera.
  75455. * @param context The context when loading the asset
  75456. * @param camera The glTF camera property
  75457. * @param assign A function called synchronously after parsing the glTF properties
  75458. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  75459. */
  75460. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  75461. private _loadAnimationsAsync;
  75462. /**
  75463. * Loads a glTF animation.
  75464. * @param context The context when loading the asset
  75465. * @param animation The glTF animation property
  75466. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  75467. */
  75468. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  75469. /**
  75470. * @hidden Loads a glTF animation channel.
  75471. * @param context The context when loading the asset
  75472. * @param animationContext The context of the animation when loading the asset
  75473. * @param animation The glTF animation property
  75474. * @param channel The glTF animation channel property
  75475. * @param babylonAnimationGroup The babylon animation group property
  75476. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  75477. * @returns A void promise when the channel load is complete
  75478. */
  75479. _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  75480. private _loadAnimationSamplerAsync;
  75481. private _loadBufferAsync;
  75482. /**
  75483. * Loads a glTF buffer view.
  75484. * @param context The context when loading the asset
  75485. * @param bufferView The glTF buffer view property
  75486. * @returns A promise that resolves with the loaded data when the load is complete
  75487. */
  75488. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  75489. private _loadAccessorAsync;
  75490. private _loadFloatAccessorAsync;
  75491. private _loadIndicesAccessorAsync;
  75492. private _loadVertexBufferViewAsync;
  75493. private _loadVertexAccessorAsync;
  75494. private _loadMaterialMetallicRoughnessPropertiesAsync;
  75495. /** @hidden */
  75496. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  75497. private _createDefaultMaterial;
  75498. /**
  75499. * Creates a Babylon material from a glTF material.
  75500. * @param context The context when loading the asset
  75501. * @param material The glTF material property
  75502. * @param babylonDrawMode The draw mode for the Babylon material
  75503. * @returns The Babylon material
  75504. */
  75505. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  75506. /**
  75507. * Loads properties from a glTF material into a Babylon material.
  75508. * @param context The context when loading the asset
  75509. * @param material The glTF material property
  75510. * @param babylonMaterial The Babylon material
  75511. * @returns A promise that resolves when the load is complete
  75512. */
  75513. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  75514. /**
  75515. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  75516. * @param context The context when loading the asset
  75517. * @param material The glTF material property
  75518. * @param babylonMaterial The Babylon material
  75519. * @returns A promise that resolves when the load is complete
  75520. */
  75521. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  75522. /**
  75523. * Loads the alpha properties from a glTF material into a Babylon material.
  75524. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  75525. * @param context The context when loading the asset
  75526. * @param material The glTF material property
  75527. * @param babylonMaterial The Babylon material
  75528. */
  75529. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  75530. /**
  75531. * Loads a glTF texture info.
  75532. * @param context The context when loading the asset
  75533. * @param textureInfo The glTF texture info property
  75534. * @param assign A function called synchronously after parsing the glTF properties
  75535. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  75536. */
  75537. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  75538. private _loadTextureAsync;
  75539. private _loadSampler;
  75540. /**
  75541. * Loads a glTF image.
  75542. * @param context The context when loading the asset
  75543. * @param image The glTF image property
  75544. * @returns A promise that resolves with the loaded data when the load is complete
  75545. */
  75546. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  75547. /**
  75548. * Loads a glTF uri.
  75549. * @param context The context when loading the asset
  75550. * @param property The glTF property associated with the uri
  75551. * @param uri The base64 or relative uri
  75552. * @returns A promise that resolves with the loaded data when the load is complete
  75553. */
  75554. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  75555. private _onProgress;
  75556. /**
  75557. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  75558. * @param babylonObject the Babylon object with metadata
  75559. * @param pointer the JSON pointer
  75560. */
  75561. static AddPointerMetadata(babylonObject: {
  75562. metadata: any;
  75563. }, pointer: string): void;
  75564. private static _GetTextureWrapMode;
  75565. private static _GetTextureSamplingMode;
  75566. private static _GetTypedArrayConstructor;
  75567. private static _GetTypedArray;
  75568. private static _GetNumComponents;
  75569. private static _ValidateUri;
  75570. private static _GetDrawMode;
  75571. private _compileMaterialsAsync;
  75572. private _compileShadowGeneratorsAsync;
  75573. private _forEachExtensions;
  75574. private _applyExtensions;
  75575. private _extensionsOnLoading;
  75576. private _extensionsOnReady;
  75577. private _extensionsLoadSceneAsync;
  75578. private _extensionsLoadNodeAsync;
  75579. private _extensionsLoadCameraAsync;
  75580. private _extensionsLoadVertexDataAsync;
  75581. private _extensionsLoadMeshPrimitiveAsync;
  75582. private _extensionsLoadMaterialAsync;
  75583. private _extensionsCreateMaterial;
  75584. private _extensionsLoadMaterialPropertiesAsync;
  75585. private _extensionsLoadTextureInfoAsync;
  75586. private _extensionsLoadAnimationAsync;
  75587. private _extensionsLoadSkinAsync;
  75588. private _extensionsLoadUriAsync;
  75589. private _extensionsLoadBufferViewAsync;
  75590. private _extensionsLoadBufferAsync;
  75591. /**
  75592. * Helper method called by a loader extension to load an glTF extension.
  75593. * @param context The context when loading the asset
  75594. * @param property The glTF property to load the extension from
  75595. * @param extensionName The name of the extension to load
  75596. * @param actionAsync The action to run
  75597. * @returns The promise returned by actionAsync or null if the extension does not exist
  75598. */
  75599. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  75600. /**
  75601. * Helper method called by a loader extension to load a glTF extra.
  75602. * @param context The context when loading the asset
  75603. * @param property The glTF property to load the extra from
  75604. * @param extensionName The name of the extension to load
  75605. * @param actionAsync The action to run
  75606. * @returns The promise returned by actionAsync or null if the extra does not exist
  75607. */
  75608. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  75609. /**
  75610. * Checks for presence of an extension.
  75611. * @param name The name of the extension to check
  75612. * @returns A boolean indicating the presence of the given extension name in `extensionsUsed`
  75613. */
  75614. isExtensionUsed(name: string): boolean;
  75615. /**
  75616. * Increments the indentation level and logs a message.
  75617. * @param message The message to log
  75618. */
  75619. logOpen(message: string): void;
  75620. /**
  75621. * Decrements the indentation level.
  75622. */
  75623. logClose(): void;
  75624. /**
  75625. * Logs a message
  75626. * @param message The message to log
  75627. */
  75628. log(message: string): void;
  75629. /**
  75630. * Starts a performance counter.
  75631. * @param counterName The name of the performance counter
  75632. */
  75633. startPerformanceCounter(counterName: string): void;
  75634. /**
  75635. * Ends a performance counter.
  75636. * @param counterName The name of the performance counter
  75637. */
  75638. endPerformanceCounter(counterName: string): void;
  75639. }
  75640. }
  75641. declare module BABYLON.GLTF2.Loader.Extensions {
  75642. /**
  75643. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_lights_image_based/README.md)
  75644. */
  75645. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  75646. /**
  75647. * The name of this extension.
  75648. */
  75649. readonly name: string;
  75650. /**
  75651. * Defines whether this extension is enabled.
  75652. */
  75653. enabled: boolean;
  75654. private _loader;
  75655. private _lights?;
  75656. /** @hidden */
  75657. constructor(loader: GLTFLoader);
  75658. /** @hidden */
  75659. dispose(): void;
  75660. /** @hidden */
  75661. onLoading(): void;
  75662. /** @hidden */
  75663. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  75664. private _loadLightAsync;
  75665. }
  75666. }
  75667. declare module BABYLON.GLTF2.Loader.Extensions {
  75668. /**
  75669. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  75670. */
  75671. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  75672. /**
  75673. * The name of this extension.
  75674. */
  75675. readonly name: string;
  75676. /**
  75677. * The draco compression used to decode vertex data or DracoCompression.Default if not defined
  75678. */
  75679. dracoCompression?: DracoCompression;
  75680. /**
  75681. * Defines whether this extension is enabled.
  75682. */
  75683. enabled: boolean;
  75684. private _loader;
  75685. /** @hidden */
  75686. constructor(loader: GLTFLoader);
  75687. /** @hidden */
  75688. dispose(): void;
  75689. /** @hidden */
  75690. _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  75691. }
  75692. }
  75693. declare module BABYLON.GLTF2.Loader.Extensions {
  75694. /**
  75695. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  75696. */
  75697. export class KHR_lights implements IGLTFLoaderExtension {
  75698. /**
  75699. * The name of this extension.
  75700. */
  75701. readonly name: string;
  75702. /**
  75703. * Defines whether this extension is enabled.
  75704. */
  75705. enabled: boolean;
  75706. private _loader;
  75707. private _lights?;
  75708. /** @hidden */
  75709. constructor(loader: GLTFLoader);
  75710. /** @hidden */
  75711. dispose(): void;
  75712. /** @hidden */
  75713. onLoading(): void;
  75714. /** @hidden */
  75715. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  75716. }
  75717. }
  75718. declare module BABYLON.GLTF2.Loader.Extensions {
  75719. /**
  75720. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  75721. */
  75722. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  75723. /**
  75724. * The name of this extension.
  75725. */
  75726. readonly name: string;
  75727. /**
  75728. * Defines whether this extension is enabled.
  75729. */
  75730. enabled: boolean;
  75731. /**
  75732. * Defines a number that determines the order the extensions are applied.
  75733. */
  75734. order: number;
  75735. private _loader;
  75736. /** @hidden */
  75737. constructor(loader: GLTFLoader);
  75738. /** @hidden */
  75739. dispose(): void;
  75740. /** @hidden */
  75741. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  75742. private _loadSpecularGlossinessPropertiesAsync;
  75743. }
  75744. }
  75745. declare module BABYLON.GLTF2.Loader.Extensions {
  75746. /**
  75747. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  75748. */
  75749. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  75750. /**
  75751. * The name of this extension.
  75752. */
  75753. readonly name: string;
  75754. /**
  75755. * Defines whether this extension is enabled.
  75756. */
  75757. enabled: boolean;
  75758. /**
  75759. * Defines a number that determines the order the extensions are applied.
  75760. */
  75761. order: number;
  75762. private _loader;
  75763. /** @hidden */
  75764. constructor(loader: GLTFLoader);
  75765. /** @hidden */
  75766. dispose(): void;
  75767. /** @hidden */
  75768. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  75769. private _loadUnlitPropertiesAsync;
  75770. }
  75771. }
  75772. declare module BABYLON.GLTF2.Loader.Extensions {
  75773. /**
  75774. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1677)
  75775. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#7F7PN6#8)
  75776. * !!! Experimental Extension Subject to Changes !!!
  75777. */
  75778. export class KHR_materials_clearcoat implements IGLTFLoaderExtension {
  75779. /**
  75780. * The name of this extension.
  75781. */
  75782. readonly name: string;
  75783. /**
  75784. * Defines whether this extension is enabled.
  75785. */
  75786. enabled: boolean;
  75787. /**
  75788. * Defines a number that determines the order the extensions are applied.
  75789. */
  75790. order: number;
  75791. private _loader;
  75792. /** @hidden */
  75793. constructor(loader: GLTFLoader);
  75794. /** @hidden */
  75795. dispose(): void;
  75796. /** @hidden */
  75797. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  75798. private _loadClearCoatPropertiesAsync;
  75799. }
  75800. }
  75801. declare module BABYLON.GLTF2.Loader.Extensions {
  75802. /**
  75803. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1688)
  75804. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  75805. * !!! Experimental Extension Subject to Changes !!!
  75806. */
  75807. export class KHR_materials_sheen implements IGLTFLoaderExtension {
  75808. /**
  75809. * The name of this extension.
  75810. */
  75811. readonly name: string;
  75812. /**
  75813. * Defines whether this extension is enabled.
  75814. */
  75815. enabled: boolean;
  75816. /**
  75817. * Defines a number that determines the order the extensions are applied.
  75818. */
  75819. order: number;
  75820. private _loader;
  75821. /** @hidden */
  75822. constructor(loader: GLTFLoader);
  75823. /** @hidden */
  75824. dispose(): void;
  75825. /** @hidden */
  75826. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  75827. private _loadSheenPropertiesAsync;
  75828. }
  75829. }
  75830. declare module BABYLON.GLTF2.Loader.Extensions {
  75831. /**
  75832. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1677)
  75833. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  75834. * !!! Experimental Extension Subject to Changes !!!
  75835. */
  75836. export class KHR_materials_specular implements IGLTFLoaderExtension {
  75837. /**
  75838. * The name of this extension.
  75839. */
  75840. readonly name: string;
  75841. /**
  75842. * Defines whether this extension is enabled.
  75843. */
  75844. enabled: boolean;
  75845. /**
  75846. * Defines a number that determines the order the extensions are applied.
  75847. */
  75848. order: number;
  75849. private _loader;
  75850. /** @hidden */
  75851. constructor(loader: GLTFLoader);
  75852. /** @hidden */
  75853. dispose(): void;
  75854. /** @hidden */
  75855. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  75856. private _loadSpecularPropertiesAsync;
  75857. }
  75858. }
  75859. declare module BABYLON.GLTF2.Loader.Extensions {
  75860. /**
  75861. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_mesh_quantization)
  75862. */
  75863. export class KHR_mesh_quantization implements IGLTFLoaderExtension {
  75864. /**
  75865. * The name of this extension.
  75866. */
  75867. readonly name: string;
  75868. /**
  75869. * Defines whether this extension is enabled.
  75870. */
  75871. enabled: boolean;
  75872. /** @hidden */
  75873. constructor(loader: GLTFLoader);
  75874. /** @hidden */
  75875. dispose(): void;
  75876. }
  75877. }
  75878. declare module BABYLON.GLTF2.Loader.Extensions {
  75879. /**
  75880. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform/README.md)
  75881. */
  75882. export class KHR_texture_transform implements IGLTFLoaderExtension {
  75883. /**
  75884. * The name of this extension.
  75885. */
  75886. readonly name: string;
  75887. /**
  75888. * Defines whether this extension is enabled.
  75889. */
  75890. enabled: boolean;
  75891. private _loader;
  75892. /** @hidden */
  75893. constructor(loader: GLTFLoader);
  75894. /** @hidden */
  75895. dispose(): void;
  75896. /** @hidden */
  75897. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  75898. }
  75899. }
  75900. declare module BABYLON.GLTF2.Loader.Extensions {
  75901. /**
  75902. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  75903. */
  75904. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  75905. /**
  75906. * The name of this extension.
  75907. */
  75908. readonly name: string;
  75909. /**
  75910. * Defines whether this extension is enabled.
  75911. */
  75912. enabled: boolean;
  75913. private _loader;
  75914. private _clips;
  75915. private _emitters;
  75916. /** @hidden */
  75917. constructor(loader: GLTFLoader);
  75918. /** @hidden */
  75919. dispose(): void;
  75920. /** @hidden */
  75921. onLoading(): void;
  75922. /** @hidden */
  75923. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  75924. /** @hidden */
  75925. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  75926. /** @hidden */
  75927. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  75928. private _loadClipAsync;
  75929. private _loadEmitterAsync;
  75930. private _getEventAction;
  75931. private _loadAnimationEventAsync;
  75932. }
  75933. }
  75934. declare module BABYLON.GLTF2.Loader.Extensions {
  75935. /**
  75936. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  75937. */
  75938. export class MSFT_lod implements IGLTFLoaderExtension {
  75939. /**
  75940. * The name of this extension.
  75941. */
  75942. readonly name: string;
  75943. /**
  75944. * Defines whether this extension is enabled.
  75945. */
  75946. enabled: boolean;
  75947. /**
  75948. * Defines a number that determines the order the extensions are applied.
  75949. */
  75950. order: number;
  75951. /**
  75952. * Maximum number of LODs to load, starting from the lowest LOD.
  75953. */
  75954. maxLODsToLoad: number;
  75955. /**
  75956. * Observable raised when all node LODs of one level are loaded.
  75957. * The event data is the index of the loaded LOD starting from zero.
  75958. * Dispose the loader to cancel the loading of the next level of LODs.
  75959. */
  75960. onNodeLODsLoadedObservable: Observable<number>;
  75961. /**
  75962. * Observable raised when all material LODs of one level are loaded.
  75963. * The event data is the index of the loaded LOD starting from zero.
  75964. * Dispose the loader to cancel the loading of the next level of LODs.
  75965. */
  75966. onMaterialLODsLoadedObservable: Observable<number>;
  75967. private _loader;
  75968. private _nodeIndexLOD;
  75969. private _nodeSignalLODs;
  75970. private _nodePromiseLODs;
  75971. private _materialIndexLOD;
  75972. private _materialSignalLODs;
  75973. private _materialPromiseLODs;
  75974. private _indexLOD;
  75975. private _bufferLODs;
  75976. /** @hidden */
  75977. constructor(loader: GLTFLoader);
  75978. /** @hidden */
  75979. dispose(): void;
  75980. /** @hidden */
  75981. onReady(): void;
  75982. /** @hidden */
  75983. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  75984. /** @hidden */
  75985. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  75986. /** @hidden */
  75987. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  75988. /** @hidden */
  75989. _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  75990. /** @hidden */
  75991. loadBufferAsync(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  75992. private _loadBufferLOD;
  75993. /**
  75994. * Gets an array of LOD properties from lowest to highest.
  75995. */
  75996. private _getLODs;
  75997. private _disposeUnusedMaterials;
  75998. }
  75999. }
  76000. declare module BABYLON.GLTF2.Loader.Extensions {
  76001. /** @hidden */
  76002. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  76003. readonly name: string;
  76004. enabled: boolean;
  76005. private _loader;
  76006. constructor(loader: GLTFLoader);
  76007. dispose(): void;
  76008. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  76009. }
  76010. }
  76011. declare module BABYLON.GLTF2.Loader.Extensions {
  76012. /** @hidden */
  76013. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  76014. readonly name: string;
  76015. enabled: boolean;
  76016. private _loader;
  76017. constructor(loader: GLTFLoader);
  76018. dispose(): void;
  76019. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  76020. }
  76021. }
  76022. declare module BABYLON.GLTF2.Loader.Extensions {
  76023. /**
  76024. * Store glTF extras (if present) in BJS objects' metadata
  76025. */
  76026. export class ExtrasAsMetadata implements IGLTFLoaderExtension {
  76027. /**
  76028. * The name of this extension.
  76029. */
  76030. readonly name: string;
  76031. /**
  76032. * Defines whether this extension is enabled.
  76033. */
  76034. enabled: boolean;
  76035. private _loader;
  76036. private _assignExtras;
  76037. /** @hidden */
  76038. constructor(loader: GLTFLoader);
  76039. /** @hidden */
  76040. dispose(): void;
  76041. /** @hidden */
  76042. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  76043. /** @hidden */
  76044. loadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  76045. /** @hidden */
  76046. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  76047. }
  76048. }
  76049. declare module BABYLON {
  76050. /**
  76051. * Class reading and parsing the MTL file bundled with the obj file.
  76052. */
  76053. export class MTLFileLoader {
  76054. /**
  76055. * Invert Y-Axis of referenced textures on load
  76056. */
  76057. static INVERT_TEXTURE_Y: boolean;
  76058. /**
  76059. * All material loaded from the mtl will be set here
  76060. */
  76061. materials: StandardMaterial[];
  76062. /**
  76063. * This function will read the mtl file and create each material described inside
  76064. * This function could be improve by adding :
  76065. * -some component missing (Ni, Tf...)
  76066. * -including the specific options available
  76067. *
  76068. * @param scene defines the scene the material will be created in
  76069. * @param data defines the mtl data to parse
  76070. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  76071. */
  76072. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string): void;
  76073. /**
  76074. * Gets the texture for the material.
  76075. *
  76076. * If the material is imported from input file,
  76077. * We sanitize the url to ensure it takes the textre from aside the material.
  76078. *
  76079. * @param rootUrl The root url to load from
  76080. * @param value The value stored in the mtl
  76081. * @return The Texture
  76082. */
  76083. private static _getTexture;
  76084. }
  76085. }
  76086. declare module BABYLON {
  76087. /**
  76088. * Options for loading OBJ/MTL files
  76089. */
  76090. type MeshLoadOptions = {
  76091. /**
  76092. * Defines if UVs are optimized by default during load.
  76093. */
  76094. OptimizeWithUV: boolean;
  76095. /**
  76096. * Defines custom scaling of UV coordinates of loaded meshes.
  76097. */
  76098. UVScaling: Vector2;
  76099. /**
  76100. * Invert model on y-axis (does a model scaling inversion)
  76101. */
  76102. InvertY: boolean;
  76103. /**
  76104. * Invert Y-Axis of referenced textures on load
  76105. */
  76106. InvertTextureY: boolean;
  76107. /**
  76108. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  76109. */
  76110. ImportVertexColors: boolean;
  76111. /**
  76112. * Compute the normals for the model, even if normals are present in the file.
  76113. */
  76114. ComputeNormals: boolean;
  76115. /**
  76116. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  76117. */
  76118. SkipMaterials: boolean;
  76119. /**
  76120. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  76121. */
  76122. MaterialLoadingFailsSilently: boolean;
  76123. };
  76124. /**
  76125. * OBJ file type loader.
  76126. * This is a babylon scene loader plugin.
  76127. */
  76128. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  76129. /**
  76130. * Defines if UVs are optimized by default during load.
  76131. */
  76132. static OPTIMIZE_WITH_UV: boolean;
  76133. /**
  76134. * Invert model on y-axis (does a model scaling inversion)
  76135. */
  76136. static INVERT_Y: boolean;
  76137. /**
  76138. * Invert Y-Axis of referenced textures on load
  76139. */
  76140. static get INVERT_TEXTURE_Y(): boolean;
  76141. static set INVERT_TEXTURE_Y(value: boolean);
  76142. /**
  76143. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  76144. */
  76145. static IMPORT_VERTEX_COLORS: boolean;
  76146. /**
  76147. * Compute the normals for the model, even if normals are present in the file.
  76148. */
  76149. static COMPUTE_NORMALS: boolean;
  76150. /**
  76151. * Defines custom scaling of UV coordinates of loaded meshes.
  76152. */
  76153. static UV_SCALING: Vector2;
  76154. /**
  76155. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  76156. */
  76157. static SKIP_MATERIALS: boolean;
  76158. /**
  76159. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  76160. *
  76161. * Defaults to true for backwards compatibility.
  76162. */
  76163. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  76164. /**
  76165. * Defines the name of the plugin.
  76166. */
  76167. name: string;
  76168. /**
  76169. * Defines the extension the plugin is able to load.
  76170. */
  76171. extensions: string;
  76172. /** @hidden */
  76173. obj: RegExp;
  76174. /** @hidden */
  76175. group: RegExp;
  76176. /** @hidden */
  76177. mtllib: RegExp;
  76178. /** @hidden */
  76179. usemtl: RegExp;
  76180. /** @hidden */
  76181. smooth: RegExp;
  76182. /** @hidden */
  76183. vertexPattern: RegExp;
  76184. /** @hidden */
  76185. normalPattern: RegExp;
  76186. /** @hidden */
  76187. uvPattern: RegExp;
  76188. /** @hidden */
  76189. facePattern1: RegExp;
  76190. /** @hidden */
  76191. facePattern2: RegExp;
  76192. /** @hidden */
  76193. facePattern3: RegExp;
  76194. /** @hidden */
  76195. facePattern4: RegExp;
  76196. /** @hidden */
  76197. facePattern5: RegExp;
  76198. private _meshLoadOptions;
  76199. /**
  76200. * Creates loader for .OBJ files
  76201. *
  76202. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  76203. */
  76204. constructor(meshLoadOptions?: MeshLoadOptions);
  76205. private static get currentMeshLoadOptions();
  76206. /**
  76207. * Calls synchronously the MTL file attached to this obj.
  76208. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  76209. * Without this function materials are not displayed in the first frame (but displayed after).
  76210. * In consequence it is impossible to get material information in your HTML file
  76211. *
  76212. * @param url The URL of the MTL file
  76213. * @param rootUrl
  76214. * @param onSuccess Callback function to be called when the MTL file is loaded
  76215. * @private
  76216. */
  76217. private _loadMTL;
  76218. /**
  76219. * Instantiates a OBJ file loader plugin.
  76220. * @returns the created plugin
  76221. */
  76222. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  76223. /**
  76224. * If the data string can be loaded directly.
  76225. *
  76226. * @param data string containing the file data
  76227. * @returns if the data can be loaded directly
  76228. */
  76229. canDirectLoad(data: string): boolean;
  76230. /**
  76231. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  76232. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  76233. * @param scene the scene the meshes should be added to
  76234. * @param data the OBJ data to load
  76235. * @param rootUrl root url to load from
  76236. * @param onProgress event that fires when loading progress has occured
  76237. * @param fileName Defines the name of the file to load
  76238. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  76239. */
  76240. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  76241. meshes: AbstractMesh[];
  76242. particleSystems: IParticleSystem[];
  76243. skeletons: Skeleton[];
  76244. animationGroups: AnimationGroup[];
  76245. }>;
  76246. /**
  76247. * Imports all objects from the loaded OBJ data and adds them to the scene
  76248. * @param scene the scene the objects should be added to
  76249. * @param data the OBJ data to load
  76250. * @param rootUrl root url to load from
  76251. * @param onProgress event that fires when loading progress has occured
  76252. * @param fileName Defines the name of the file to load
  76253. * @returns a promise which completes when objects have been loaded to the scene
  76254. */
  76255. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  76256. /**
  76257. * Load into an asset container.
  76258. * @param scene The scene to load into
  76259. * @param data The data to import
  76260. * @param rootUrl The root url for scene and resources
  76261. * @param onProgress The callback when the load progresses
  76262. * @param fileName Defines the name of the file to load
  76263. * @returns The loaded asset container
  76264. */
  76265. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  76266. /**
  76267. * Read the OBJ file and create an Array of meshes.
  76268. * Each mesh contains all information given by the OBJ and the MTL file.
  76269. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  76270. *
  76271. * @param meshesNames
  76272. * @param scene Scene The scene where are displayed the data
  76273. * @param data String The content of the obj file
  76274. * @param rootUrl String The path to the folder
  76275. * @returns Array<AbstractMesh>
  76276. * @private
  76277. */
  76278. private _parseSolid;
  76279. }
  76280. }
  76281. declare module BABYLON {
  76282. /**
  76283. * STL file type loader.
  76284. * This is a babylon scene loader plugin.
  76285. */
  76286. export class STLFileLoader implements ISceneLoaderPlugin {
  76287. /** @hidden */
  76288. solidPattern: RegExp;
  76289. /** @hidden */
  76290. facetsPattern: RegExp;
  76291. /** @hidden */
  76292. normalPattern: RegExp;
  76293. /** @hidden */
  76294. vertexPattern: RegExp;
  76295. /**
  76296. * Defines the name of the plugin.
  76297. */
  76298. name: string;
  76299. /**
  76300. * Defines the extensions the stl loader is able to load.
  76301. * force data to come in as an ArrayBuffer
  76302. * we'll convert to string if it looks like it's an ASCII .stl
  76303. */
  76304. extensions: ISceneLoaderPluginExtensions;
  76305. /**
  76306. * Import meshes into a scene.
  76307. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  76308. * @param scene The scene to import into
  76309. * @param data The data to import
  76310. * @param rootUrl The root url for scene and resources
  76311. * @param meshes The meshes array to import into
  76312. * @param particleSystems The particle systems array to import into
  76313. * @param skeletons The skeletons array to import into
  76314. * @param onError The callback when import fails
  76315. * @returns True if successful or false otherwise
  76316. */
  76317. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  76318. /**
  76319. * Load into a scene.
  76320. * @param scene The scene to load into
  76321. * @param data The data to import
  76322. * @param rootUrl The root url for scene and resources
  76323. * @param onError The callback when import fails
  76324. * @returns true if successful or false otherwise
  76325. */
  76326. load(scene: Scene, data: any, rootUrl: string): boolean;
  76327. /**
  76328. * Load into an asset container.
  76329. * @param scene The scene to load into
  76330. * @param data The data to import
  76331. * @param rootUrl The root url for scene and resources
  76332. * @param onError The callback when import fails
  76333. * @returns The loaded asset container
  76334. */
  76335. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  76336. private _isBinary;
  76337. private _parseBinary;
  76338. private _parseASCII;
  76339. }
  76340. }
  76341. declare module BABYLON {
  76342. /**
  76343. * Class for generating OBJ data from a Babylon scene.
  76344. */
  76345. export class OBJExport {
  76346. /**
  76347. * Exports the geometry of a Mesh array in .OBJ file format (text)
  76348. * @param mesh defines the list of meshes to serialize
  76349. * @param materials defines if materials should be exported
  76350. * @param matlibname defines the name of the associated mtl file
  76351. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  76352. * @returns the OBJ content
  76353. */
  76354. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  76355. /**
  76356. * Exports the material(s) of a mesh in .MTL file format (text)
  76357. * @param mesh defines the mesh to extract the material from
  76358. * @returns the mtl content
  76359. */
  76360. static MTL(mesh: Mesh): string;
  76361. }
  76362. }
  76363. declare module BABYLON {
  76364. /** @hidden */
  76365. export var __IGLTFExporterExtension: number;
  76366. /**
  76367. * Interface for extending the exporter
  76368. * @hidden
  76369. */
  76370. export interface IGLTFExporterExtension {
  76371. /**
  76372. * The name of this extension
  76373. */
  76374. readonly name: string;
  76375. /**
  76376. * Defines whether this extension is enabled
  76377. */
  76378. enabled: boolean;
  76379. /**
  76380. * Defines whether this extension is required
  76381. */
  76382. required: boolean;
  76383. }
  76384. }
  76385. declare module BABYLON.GLTF2.Exporter {
  76386. /** @hidden */
  76387. export var __IGLTFExporterExtensionV2: number;
  76388. /**
  76389. * Interface for a glTF exporter extension
  76390. * @hidden
  76391. */
  76392. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  76393. /**
  76394. * Define this method to modify the default behavior before exporting a texture
  76395. * @param context The context when loading the asset
  76396. * @param babylonTexture The Babylon.js texture
  76397. * @param mimeType The mime-type of the generated image
  76398. * @returns A promise that resolves with the exported texture
  76399. */
  76400. preExportTextureAsync?(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Promise<Texture>;
  76401. /**
  76402. * Define this method to get notified when a texture info is created
  76403. * @param context The context when loading the asset
  76404. * @param textureInfo The glTF texture info
  76405. * @param babylonTexture The Babylon.js texture
  76406. */
  76407. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  76408. /**
  76409. * Define this method to modify the default behavior when exporting texture info
  76410. * @param context The context when loading the asset
  76411. * @param meshPrimitive glTF mesh primitive
  76412. * @param babylonSubMesh Babylon submesh
  76413. * @param binaryWriter glTF serializer binary writer instance
  76414. * @returns nullable IMeshPrimitive promise
  76415. */
  76416. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<IMeshPrimitive>;
  76417. /**
  76418. * Define this method to modify the default behavior when exporting a node
  76419. * @param context The context when exporting the node
  76420. * @param node glTF node
  76421. * @param babylonNode BabylonJS node
  76422. * @returns nullable INode promise
  76423. */
  76424. postExportNodeAsync?(context: string, node: INode, babylonNode: Node): Promise<INode>;
  76425. /**
  76426. * Define this method to modify the default behavior when exporting a material
  76427. * @param material glTF material
  76428. * @param babylonMaterial BabylonJS material
  76429. * @returns nullable IMaterial promise
  76430. */
  76431. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  76432. /**
  76433. * Define this method to return additional textures to export from a material
  76434. * @param material glTF material
  76435. * @param babylonMaterial BabylonJS material
  76436. * @returns List of textures
  76437. */
  76438. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  76439. /** Gets a boolean indicating that this extension was used */
  76440. wasUsed: boolean;
  76441. /** Gets a boolean indicating that this extension is required for the file to work */
  76442. required: boolean;
  76443. /**
  76444. * Called after the exporter state changes to EXPORTING
  76445. */
  76446. onExporting?(): void;
  76447. }
  76448. }
  76449. declare module BABYLON.GLTF2.Exporter {
  76450. /**
  76451. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  76452. * @hidden
  76453. */
  76454. export class _GLTFMaterialExporter {
  76455. /**
  76456. * Represents the dielectric specular values for R, G and B
  76457. */
  76458. private static readonly _DielectricSpecular;
  76459. /**
  76460. * Allows the maximum specular power to be defined for material calculations
  76461. */
  76462. private static readonly _MaxSpecularPower;
  76463. /**
  76464. * Mapping to store textures
  76465. */
  76466. private _textureMap;
  76467. /**
  76468. * Numeric tolerance value
  76469. */
  76470. private static readonly _Epsilon;
  76471. /**
  76472. * Reference to the glTF Exporter
  76473. */
  76474. private _exporter;
  76475. constructor(exporter: _Exporter);
  76476. /**
  76477. * Specifies if two colors are approximately equal in value
  76478. * @param color1 first color to compare to
  76479. * @param color2 second color to compare to
  76480. * @param epsilon threshold value
  76481. */
  76482. private static FuzzyEquals;
  76483. /**
  76484. * Gets the materials from a Babylon scene and converts them to glTF materials
  76485. * @param scene babylonjs scene
  76486. * @param mimeType texture mime type
  76487. * @param images array of images
  76488. * @param textures array of textures
  76489. * @param materials array of materials
  76490. * @param imageData mapping of texture names to base64 textures
  76491. * @param hasTextureCoords specifies if texture coordinates are present on the material
  76492. */
  76493. _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  76494. /**
  76495. * Makes a copy of the glTF material without the texture parameters
  76496. * @param originalMaterial original glTF material
  76497. * @returns glTF material without texture parameters
  76498. */
  76499. _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  76500. /**
  76501. * Specifies if the material has any texture parameters present
  76502. * @param material glTF Material
  76503. * @returns boolean specifying if texture parameters are present
  76504. */
  76505. _hasTexturesPresent(material: IMaterial): boolean;
  76506. /**
  76507. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  76508. * @param babylonStandardMaterial
  76509. * @returns glTF Metallic Roughness Material representation
  76510. */
  76511. _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  76512. /**
  76513. * Computes the metallic factor
  76514. * @param diffuse diffused value
  76515. * @param specular specular value
  76516. * @param oneMinusSpecularStrength one minus the specular strength
  76517. * @returns metallic value
  76518. */
  76519. static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  76520. /**
  76521. * Sets the glTF alpha mode to a glTF material from the Babylon Material
  76522. * @param glTFMaterial glTF material
  76523. * @param babylonMaterial Babylon material
  76524. */
  76525. private static _SetAlphaMode;
  76526. /**
  76527. * Converts a Babylon Standard Material to a glTF Material
  76528. * @param babylonStandardMaterial BJS Standard Material
  76529. * @param mimeType mime type to use for the textures
  76530. * @param images array of glTF image interfaces
  76531. * @param textures array of glTF texture interfaces
  76532. * @param materials array of glTF material interfaces
  76533. * @param imageData map of image file name to data
  76534. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  76535. */
  76536. _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  76537. private _finishMaterial;
  76538. /**
  76539. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  76540. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  76541. * @param mimeType mime type to use for the textures
  76542. * @param images array of glTF image interfaces
  76543. * @param textures array of glTF texture interfaces
  76544. * @param materials array of glTF material interfaces
  76545. * @param imageData map of image file name to data
  76546. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  76547. */
  76548. _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  76549. /**
  76550. * Converts an image typed array buffer to a base64 image
  76551. * @param buffer typed array buffer
  76552. * @param width width of the image
  76553. * @param height height of the image
  76554. * @param mimeType mimetype of the image
  76555. * @returns base64 image string
  76556. */
  76557. private _createBase64FromCanvasAsync;
  76558. /**
  76559. * Generates a white texture based on the specified width and height
  76560. * @param width width of the texture in pixels
  76561. * @param height height of the texture in pixels
  76562. * @param scene babylonjs scene
  76563. * @returns white texture
  76564. */
  76565. private _createWhiteTexture;
  76566. /**
  76567. * 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
  76568. * @param texture1 first texture to resize
  76569. * @param texture2 second texture to resize
  76570. * @param scene babylonjs scene
  76571. * @returns resized textures or null
  76572. */
  76573. private _resizeTexturesToSameDimensions;
  76574. /**
  76575. * Converts an array of pixels to a Float32Array
  76576. * Throws an error if the pixel format is not supported
  76577. * @param pixels - array buffer containing pixel values
  76578. * @returns Float32 of pixels
  76579. */
  76580. private _convertPixelArrayToFloat32;
  76581. /**
  76582. * Convert Specular Glossiness Textures to Metallic Roughness
  76583. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  76584. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  76585. * @param diffuseTexture texture used to store diffuse information
  76586. * @param specularGlossinessTexture texture used to store specular and glossiness information
  76587. * @param factors specular glossiness material factors
  76588. * @param mimeType the mime type to use for the texture
  76589. * @returns pbr metallic roughness interface or null
  76590. */
  76591. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  76592. /**
  76593. * Converts specular glossiness material properties to metallic roughness
  76594. * @param specularGlossiness interface with specular glossiness material properties
  76595. * @returns interface with metallic roughness material properties
  76596. */
  76597. private _convertSpecularGlossinessToMetallicRoughness;
  76598. /**
  76599. * Calculates the surface reflectance, independent of lighting conditions
  76600. * @param color Color source to calculate brightness from
  76601. * @returns number representing the perceived brightness, or zero if color is undefined
  76602. */
  76603. private _getPerceivedBrightness;
  76604. /**
  76605. * Returns the maximum color component value
  76606. * @param color
  76607. * @returns maximum color component value, or zero if color is null or undefined
  76608. */
  76609. private _getMaxComponent;
  76610. /**
  76611. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  76612. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  76613. * @param mimeType mime type to use for the textures
  76614. * @param images array of glTF image interfaces
  76615. * @param textures array of glTF texture interfaces
  76616. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  76617. * @param imageData map of image file name to data
  76618. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  76619. * @returns glTF PBR Metallic Roughness factors
  76620. */
  76621. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  76622. private _getGLTFTextureSampler;
  76623. private _getGLTFTextureWrapMode;
  76624. private _getGLTFTextureWrapModesSampler;
  76625. /**
  76626. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  76627. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  76628. * @param mimeType mime type to use for the textures
  76629. * @param images array of glTF image interfaces
  76630. * @param textures array of glTF texture interfaces
  76631. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  76632. * @param imageData map of image file name to data
  76633. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  76634. * @returns glTF PBR Metallic Roughness factors
  76635. */
  76636. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  76637. /**
  76638. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  76639. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  76640. * @param mimeType mime type to use for the textures
  76641. * @param images array of glTF image interfaces
  76642. * @param textures array of glTF texture interfaces
  76643. * @param materials array of glTF material interfaces
  76644. * @param imageData map of image file name to data
  76645. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  76646. */
  76647. _convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  76648. private setMetallicRoughnessPbrMaterial;
  76649. private getPixelsFromTexture;
  76650. /**
  76651. * Extracts a texture from a Babylon texture into file data and glTF data
  76652. * @param babylonTexture Babylon texture to extract
  76653. * @param mimeType Mime Type of the babylonTexture
  76654. * @return glTF texture info, or null if the texture format is not supported
  76655. */
  76656. _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  76657. _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  76658. /**
  76659. * Builds a texture from base64 string
  76660. * @param base64Texture base64 texture string
  76661. * @param baseTextureName Name to use for the texture
  76662. * @param mimeType image mime type for the texture
  76663. * @param images array of images
  76664. * @param textures array of textures
  76665. * @param imageData map of image data
  76666. * @returns glTF texture info, or null if the texture format is not supported
  76667. */
  76668. private _getTextureInfoFromBase64;
  76669. }
  76670. }
  76671. declare module BABYLON {
  76672. /**
  76673. * Class for holding and downloading glTF file data
  76674. */
  76675. export class GLTFData {
  76676. /**
  76677. * Object which contains the file name as the key and its data as the value
  76678. */
  76679. glTFFiles: {
  76680. [fileName: string]: string | Blob;
  76681. };
  76682. /**
  76683. * Initializes the glTF file object
  76684. */
  76685. constructor();
  76686. /**
  76687. * Downloads the glTF data as files based on their names and data
  76688. */
  76689. downloadFiles(): void;
  76690. }
  76691. }
  76692. declare module BABYLON {
  76693. /**
  76694. * Holds a collection of exporter options and parameters
  76695. */
  76696. export interface IExportOptions {
  76697. /**
  76698. * Function which indicates whether a babylon node should be exported or not
  76699. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  76700. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  76701. */
  76702. shouldExportNode?(node: Node): boolean;
  76703. /**
  76704. * Function used to extract the part of node's metadata that will be exported into glTF node extras
  76705. * @param metadata source metadata to read from
  76706. * @returns the data to store to glTF node extras
  76707. */
  76708. metadataSelector?(metadata: any): any;
  76709. /**
  76710. * The sample rate to bake animation curves
  76711. */
  76712. animationSampleRate?: number;
  76713. /**
  76714. * Begin serialization without waiting for the scene to be ready
  76715. */
  76716. exportWithoutWaitingForScene?: boolean;
  76717. }
  76718. /**
  76719. * Class for generating glTF data from a Babylon scene.
  76720. */
  76721. export class GLTF2Export {
  76722. /**
  76723. * Exports the geometry of the scene to .gltf file format asynchronously
  76724. * @param scene Babylon scene with scene hierarchy information
  76725. * @param filePrefix File prefix to use when generating the glTF file
  76726. * @param options Exporter options
  76727. * @returns Returns an object with a .gltf file and associates texture names
  76728. * as keys and their data and paths as values
  76729. */
  76730. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  76731. private static _PreExportAsync;
  76732. private static _PostExportAsync;
  76733. /**
  76734. * Exports the geometry of the scene to .glb file format asychronously
  76735. * @param scene Babylon scene with scene hierarchy information
  76736. * @param filePrefix File prefix to use when generating glb file
  76737. * @param options Exporter options
  76738. * @returns Returns an object with a .glb filename as key and data as value
  76739. */
  76740. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  76741. }
  76742. }
  76743. declare module BABYLON.GLTF2.Exporter {
  76744. /**
  76745. * @hidden
  76746. */
  76747. export class _GLTFUtilities {
  76748. /**
  76749. * Creates a buffer view based on the supplied arguments
  76750. * @param bufferIndex index value of the specified buffer
  76751. * @param byteOffset byte offset value
  76752. * @param byteLength byte length of the bufferView
  76753. * @param byteStride byte distance between conequential elements
  76754. * @param name name of the buffer view
  76755. * @returns bufferView for glTF
  76756. */
  76757. static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  76758. /**
  76759. * Creates an accessor based on the supplied arguments
  76760. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  76761. * @param name The name of the accessor
  76762. * @param type The type of the accessor
  76763. * @param componentType The datatype of components in the attribute
  76764. * @param count The number of attributes referenced by this accessor
  76765. * @param byteOffset The offset relative to the start of the bufferView in bytes
  76766. * @param min Minimum value of each component in this attribute
  76767. * @param max Maximum value of each component in this attribute
  76768. * @returns accessor for glTF
  76769. */
  76770. static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  76771. /**
  76772. * Calculates the minimum and maximum values of an array of position floats
  76773. * @param positions Positions array of a mesh
  76774. * @param vertexStart Starting vertex offset to calculate min and max values
  76775. * @param vertexCount Number of vertices to check for min and max values
  76776. * @returns min number array and max number array
  76777. */
  76778. static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  76779. min: number[];
  76780. max: number[];
  76781. };
  76782. /**
  76783. * Converts a new right-handed Vector3
  76784. * @param vector vector3 array
  76785. * @returns right-handed Vector3
  76786. */
  76787. static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  76788. /**
  76789. * Converts a Vector3 to right-handed
  76790. * @param vector Vector3 to convert to right-handed
  76791. */
  76792. static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  76793. /**
  76794. * Converts a three element number array to right-handed
  76795. * @param vector number array to convert to right-handed
  76796. */
  76797. static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  76798. /**
  76799. * Converts a new right-handed Vector3
  76800. * @param vector vector3 array
  76801. * @returns right-handed Vector3
  76802. */
  76803. static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  76804. /**
  76805. * Converts a Vector3 to right-handed
  76806. * @param vector Vector3 to convert to right-handed
  76807. */
  76808. static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  76809. /**
  76810. * Converts a three element number array to right-handed
  76811. * @param vector number array to convert to right-handed
  76812. */
  76813. static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  76814. /**
  76815. * Converts a Vector4 to right-handed
  76816. * @param vector Vector4 to convert to right-handed
  76817. */
  76818. static _GetRightHandedVector4FromRef(vector: Vector4): void;
  76819. /**
  76820. * Converts a Vector4 to right-handed
  76821. * @param vector Vector4 to convert to right-handed
  76822. */
  76823. static _GetRightHandedArray4FromRef(vector: number[]): void;
  76824. /**
  76825. * Converts a Quaternion to right-handed
  76826. * @param quaternion Source quaternion to convert to right-handed
  76827. */
  76828. static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  76829. /**
  76830. * Converts a Quaternion to right-handed
  76831. * @param quaternion Source quaternion to convert to right-handed
  76832. */
  76833. static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void;
  76834. static _NormalizeTangentFromRef(tangent: Vector4): void;
  76835. }
  76836. }
  76837. declare module BABYLON.GLTF2.Exporter {
  76838. /**
  76839. * Converts Babylon Scene into glTF 2.0.
  76840. * @hidden
  76841. */
  76842. export class _Exporter {
  76843. /**
  76844. * Stores the glTF to export
  76845. */
  76846. _glTF: IGLTF;
  76847. /**
  76848. * Stores all generated buffer views, which represents views into the main glTF buffer data
  76849. */
  76850. _bufferViews: IBufferView[];
  76851. /**
  76852. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  76853. */
  76854. _accessors: IAccessor[];
  76855. /**
  76856. * Stores all the generated nodes, which contains transform and/or mesh information per node
  76857. */
  76858. private _nodes;
  76859. /**
  76860. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  76861. */
  76862. private _scenes;
  76863. /**
  76864. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  76865. */
  76866. private _meshes;
  76867. /**
  76868. * Stores all the generated material information, which represents the appearance of each primitive
  76869. */
  76870. _materials: IMaterial[];
  76871. _materialMap: {
  76872. [materialID: number]: number;
  76873. };
  76874. /**
  76875. * Stores all the generated texture information, which is referenced by glTF materials
  76876. */
  76877. _textures: ITexture[];
  76878. /**
  76879. * Stores all the generated image information, which is referenced by glTF textures
  76880. */
  76881. _images: IImage[];
  76882. /**
  76883. * Stores all the texture samplers
  76884. */
  76885. _samplers: ISampler[];
  76886. /**
  76887. * Stores all the generated animation samplers, which is referenced by glTF animations
  76888. */
  76889. /**
  76890. * Stores the animations for glTF models
  76891. */
  76892. private _animations;
  76893. /**
  76894. * Stores the total amount of bytes stored in the glTF buffer
  76895. */
  76896. private _totalByteLength;
  76897. /**
  76898. * Stores a reference to the Babylon scene containing the source geometry and material information
  76899. */
  76900. _babylonScene: Scene;
  76901. /**
  76902. * Stores a map of the image data, where the key is the file name and the value
  76903. * is the image data
  76904. */
  76905. _imageData: {
  76906. [fileName: string]: {
  76907. data: Uint8Array;
  76908. mimeType: ImageMimeType;
  76909. };
  76910. };
  76911. /**
  76912. * Stores a map of the unique id of a node to its index in the node array
  76913. */
  76914. private _nodeMap;
  76915. /**
  76916. * Specifies if the Babylon scene should be converted to right-handed on export
  76917. */
  76918. _convertToRightHandedSystem: boolean;
  76919. /**
  76920. * Baked animation sample rate
  76921. */
  76922. private _animationSampleRate;
  76923. private _options;
  76924. private _localEngine;
  76925. _glTFMaterialExporter: _GLTFMaterialExporter;
  76926. private _extensions;
  76927. private static _ExtensionNames;
  76928. private static _ExtensionFactories;
  76929. private _applyExtension;
  76930. private _applyExtensions;
  76931. _extensionsPreExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Promise<Nullable<BaseTexture>>;
  76932. _extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<Nullable<IMeshPrimitive>>;
  76933. _extensionsPostExportNodeAsync(context: string, node: INode, babylonNode: Node): Promise<Nullable<INode>>;
  76934. _extensionsPostExportMaterialAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<Nullable<IMaterial>>;
  76935. _extensionsPostExportMaterialAdditionalTextures(context: string, material: IMaterial, babylonMaterial: Material): BaseTexture[];
  76936. _extensionsPostExportTextures(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  76937. private _forEachExtensions;
  76938. private _extensionsOnExporting;
  76939. /**
  76940. * Load glTF serializer extensions
  76941. */
  76942. private _loadExtensions;
  76943. /**
  76944. * Creates a glTF Exporter instance, which can accept optional exporter options
  76945. * @param babylonScene Babylon scene object
  76946. * @param options Options to modify the behavior of the exporter
  76947. */
  76948. constructor(babylonScene: Scene, options?: IExportOptions);
  76949. dispose(): void;
  76950. /**
  76951. * Registers a glTF exporter extension
  76952. * @param name Name of the extension to export
  76953. * @param factory The factory function that creates the exporter extension
  76954. */
  76955. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  76956. /**
  76957. * Un-registers an exporter extension
  76958. * @param name The name fo the exporter extension
  76959. * @returns A boolean indicating whether the extension has been un-registered
  76960. */
  76961. static UnregisterExtension(name: string): boolean;
  76962. /**
  76963. * Lazy load a local engine
  76964. */
  76965. _getLocalEngine(): Engine;
  76966. private reorderIndicesBasedOnPrimitiveMode;
  76967. /**
  76968. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  76969. * clock-wise during export to glTF
  76970. * @param submesh BabylonJS submesh
  76971. * @param primitiveMode Primitive mode of the mesh
  76972. * @param sideOrientation the winding order of the submesh
  76973. * @param vertexBufferKind The type of vertex attribute
  76974. * @param meshAttributeArray The vertex attribute data
  76975. * @param byteOffset The offset to the binary data
  76976. * @param binaryWriter The binary data for the glTF file
  76977. */
  76978. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  76979. /**
  76980. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  76981. * clock-wise during export to glTF
  76982. * @param submesh BabylonJS submesh
  76983. * @param primitiveMode Primitive mode of the mesh
  76984. * @param sideOrientation the winding order of the submesh
  76985. * @param vertexBufferKind The type of vertex attribute
  76986. * @param meshAttributeArray The vertex attribute data
  76987. * @param byteOffset The offset to the binary data
  76988. * @param binaryWriter The binary data for the glTF file
  76989. */
  76990. private reorderTriangleFillMode;
  76991. /**
  76992. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  76993. * clock-wise during export to glTF
  76994. * @param submesh BabylonJS submesh
  76995. * @param primitiveMode Primitive mode of the mesh
  76996. * @param sideOrientation the winding order of the submesh
  76997. * @param vertexBufferKind The type of vertex attribute
  76998. * @param meshAttributeArray The vertex attribute data
  76999. * @param byteOffset The offset to the binary data
  77000. * @param binaryWriter The binary data for the glTF file
  77001. */
  77002. private reorderTriangleStripDrawMode;
  77003. /**
  77004. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  77005. * clock-wise during export to glTF
  77006. * @param submesh BabylonJS submesh
  77007. * @param primitiveMode Primitive mode of the mesh
  77008. * @param sideOrientation the winding order of the submesh
  77009. * @param vertexBufferKind The type of vertex attribute
  77010. * @param meshAttributeArray The vertex attribute data
  77011. * @param byteOffset The offset to the binary data
  77012. * @param binaryWriter The binary data for the glTF file
  77013. */
  77014. private reorderTriangleFanMode;
  77015. /**
  77016. * Writes the vertex attribute data to binary
  77017. * @param vertices The vertices to write to the binary writer
  77018. * @param byteOffset The offset into the binary writer to overwrite binary data
  77019. * @param vertexAttributeKind The vertex attribute type
  77020. * @param meshAttributeArray The vertex attribute data
  77021. * @param binaryWriter The writer containing the binary data
  77022. */
  77023. private writeVertexAttributeData;
  77024. /**
  77025. * Writes mesh attribute data to a data buffer
  77026. * Returns the bytelength of the data
  77027. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  77028. * @param meshAttributeArray Array containing the attribute data
  77029. * @param binaryWriter The buffer to write the binary data to
  77030. * @param indices Used to specify the order of the vertex data
  77031. */
  77032. writeAttributeData(vertexBufferKind: string, meshAttributeArray: FloatArray, byteStride: number, binaryWriter: _BinaryWriter): void;
  77033. /**
  77034. * Generates glTF json data
  77035. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  77036. * @param glTFPrefix Text to use when prefixing a glTF file
  77037. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  77038. * @returns json data as string
  77039. */
  77040. private generateJSON;
  77041. /**
  77042. * Generates data for .gltf and .bin files based on the glTF prefix string
  77043. * @param glTFPrefix Text to use when prefixing a glTF file
  77044. * @param dispose Dispose the exporter
  77045. * @returns GLTFData with glTF file data
  77046. */
  77047. _generateGLTFAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  77048. /**
  77049. * Creates a binary buffer for glTF
  77050. * @returns array buffer for binary data
  77051. */
  77052. private _generateBinaryAsync;
  77053. /**
  77054. * Pads the number to a multiple of 4
  77055. * @param num number to pad
  77056. * @returns padded number
  77057. */
  77058. private _getPadding;
  77059. /**
  77060. * @hidden
  77061. */
  77062. _generateGLBAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  77063. /**
  77064. * Sets the TRS for each node
  77065. * @param node glTF Node for storing the transformation data
  77066. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  77067. */
  77068. private setNodeTransformation;
  77069. private getVertexBufferFromMesh;
  77070. /**
  77071. * Creates a bufferview based on the vertices type for the Babylon mesh
  77072. * @param kind Indicates the type of vertices data
  77073. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  77074. * @param binaryWriter The buffer to write the bufferview data to
  77075. */
  77076. private createBufferViewKind;
  77077. /**
  77078. * The primitive mode of the Babylon mesh
  77079. * @param babylonMesh The BabylonJS mesh
  77080. */
  77081. private getMeshPrimitiveMode;
  77082. /**
  77083. * Sets the primitive mode of the glTF mesh primitive
  77084. * @param meshPrimitive glTF mesh primitive
  77085. * @param primitiveMode The primitive mode
  77086. */
  77087. private setPrimitiveMode;
  77088. /**
  77089. * Sets the vertex attribute accessor based of the glTF mesh primitive
  77090. * @param meshPrimitive glTF mesh primitive
  77091. * @param attributeKind vertex attribute
  77092. * @returns boolean specifying if uv coordinates are present
  77093. */
  77094. private setAttributeKind;
  77095. /**
  77096. * Sets data for the primitive attributes of each submesh
  77097. * @param mesh glTF Mesh object to store the primitive attribute information
  77098. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  77099. * @param binaryWriter Buffer to write the attribute data to
  77100. */
  77101. private setPrimitiveAttributesAsync;
  77102. /**
  77103. * Creates a glTF scene based on the array of meshes
  77104. * Returns the the total byte offset
  77105. * @param babylonScene Babylon scene to get the mesh data from
  77106. * @param binaryWriter Buffer to write binary data to
  77107. */
  77108. private createSceneAsync;
  77109. /**
  77110. * Creates a mapping of Node unique id to node index and handles animations
  77111. * @param babylonScene Babylon Scene
  77112. * @param nodes Babylon transform nodes
  77113. * @param binaryWriter Buffer to write binary data to
  77114. * @returns Node mapping of unique id to index
  77115. */
  77116. private createNodeMapAndAnimationsAsync;
  77117. /**
  77118. * Creates a glTF node from a Babylon mesh
  77119. * @param babylonMesh Source Babylon mesh
  77120. * @param binaryWriter Buffer for storing geometry data
  77121. * @returns glTF node
  77122. */
  77123. private createNodeAsync;
  77124. }
  77125. /**
  77126. * @hidden
  77127. *
  77128. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  77129. */
  77130. export class _BinaryWriter {
  77131. /**
  77132. * Array buffer which stores all binary data
  77133. */
  77134. private _arrayBuffer;
  77135. /**
  77136. * View of the array buffer
  77137. */
  77138. private _dataView;
  77139. /**
  77140. * byte offset of data in array buffer
  77141. */
  77142. private _byteOffset;
  77143. /**
  77144. * Initialize binary writer with an initial byte length
  77145. * @param byteLength Initial byte length of the array buffer
  77146. */
  77147. constructor(byteLength: number);
  77148. /**
  77149. * Resize the array buffer to the specified byte length
  77150. * @param byteLength
  77151. */
  77152. private resizeBuffer;
  77153. /**
  77154. * Get an array buffer with the length of the byte offset
  77155. * @returns ArrayBuffer resized to the byte offset
  77156. */
  77157. getArrayBuffer(): ArrayBuffer;
  77158. /**
  77159. * Get the byte offset of the array buffer
  77160. * @returns byte offset
  77161. */
  77162. getByteOffset(): number;
  77163. /**
  77164. * Stores an UInt8 in the array buffer
  77165. * @param entry
  77166. * @param byteOffset If defined, specifies where to set the value as an offset.
  77167. */
  77168. setUInt8(entry: number, byteOffset?: number): void;
  77169. /**
  77170. * Gets an UInt32 in the array buffer
  77171. * @param entry
  77172. * @param byteOffset If defined, specifies where to set the value as an offset.
  77173. */
  77174. getUInt32(byteOffset: number): number;
  77175. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  77176. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  77177. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  77178. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  77179. /**
  77180. * Stores a Float32 in the array buffer
  77181. * @param entry
  77182. */
  77183. setFloat32(entry: number, byteOffset?: number): void;
  77184. /**
  77185. * Stores an UInt32 in the array buffer
  77186. * @param entry
  77187. * @param byteOffset If defined, specifies where to set the value as an offset.
  77188. */
  77189. setUInt32(entry: number, byteOffset?: number): void;
  77190. }
  77191. }
  77192. declare module BABYLON.GLTF2.Exporter {
  77193. /**
  77194. * @hidden
  77195. * Interface to store animation data.
  77196. */
  77197. export interface _IAnimationData {
  77198. /**
  77199. * Keyframe data.
  77200. */
  77201. inputs: number[];
  77202. /**
  77203. * Value data.
  77204. */
  77205. outputs: number[][];
  77206. /**
  77207. * Animation interpolation data.
  77208. */
  77209. samplerInterpolation: AnimationSamplerInterpolation;
  77210. /**
  77211. * Minimum keyframe value.
  77212. */
  77213. inputsMin: number;
  77214. /**
  77215. * Maximum keyframe value.
  77216. */
  77217. inputsMax: number;
  77218. }
  77219. /**
  77220. * @hidden
  77221. */
  77222. export interface _IAnimationInfo {
  77223. /**
  77224. * The target channel for the animation
  77225. */
  77226. animationChannelTargetPath: AnimationChannelTargetPath;
  77227. /**
  77228. * The glTF accessor type for the data.
  77229. */
  77230. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4;
  77231. /**
  77232. * Specifies if quaternions should be used.
  77233. */
  77234. useQuaternion: boolean;
  77235. }
  77236. /**
  77237. * @hidden
  77238. * Utility class for generating glTF animation data from BabylonJS.
  77239. */
  77240. export class _GLTFAnimation {
  77241. /**
  77242. * @ignore
  77243. *
  77244. * Creates glTF channel animation from BabylonJS animation.
  77245. * @param babylonTransformNode - BabylonJS mesh.
  77246. * @param animation - animation.
  77247. * @param animationChannelTargetPath - The target animation channel.
  77248. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  77249. * @param useQuaternion - Specifies if quaternions are used.
  77250. * @returns nullable IAnimationData
  77251. */
  77252. static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  77253. private static _DeduceAnimationInfo;
  77254. /**
  77255. * @ignore
  77256. * Create node animations from the transform node animations
  77257. * @param babylonNode
  77258. * @param runtimeGLTFAnimation
  77259. * @param idleGLTFAnimations
  77260. * @param nodeMap
  77261. * @param nodes
  77262. * @param binaryWriter
  77263. * @param bufferViews
  77264. * @param accessors
  77265. * @param convertToRightHandedSystem
  77266. */
  77267. static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  77268. [key: number]: number;
  77269. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  77270. /**
  77271. * @ignore
  77272. * Create node animations from the animation groups
  77273. * @param babylonScene
  77274. * @param glTFAnimations
  77275. * @param nodeMap
  77276. * @param nodes
  77277. * @param binaryWriter
  77278. * @param bufferViews
  77279. * @param accessors
  77280. * @param convertToRightHandedSystem
  77281. */
  77282. static _CreateNodeAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  77283. [key: number]: number;
  77284. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  77285. private static AddAnimation;
  77286. /**
  77287. * Create a baked animation
  77288. * @param babylonTransformNode BabylonJS mesh
  77289. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  77290. * @param animationChannelTargetPath animation target channel
  77291. * @param minFrame minimum animation frame
  77292. * @param maxFrame maximum animation frame
  77293. * @param fps frames per second of the animation
  77294. * @param inputs input key frames of the animation
  77295. * @param outputs output key frame data of the animation
  77296. * @param convertToRightHandedSystem converts the values to right-handed
  77297. * @param useQuaternion specifies if quaternions should be used
  77298. */
  77299. private static _CreateBakedAnimation;
  77300. private static _ConvertFactorToVector3OrQuaternion;
  77301. private static _SetInterpolatedValue;
  77302. /**
  77303. * Creates linear animation from the animation key frames
  77304. * @param babylonTransformNode BabylonJS mesh
  77305. * @param animation BabylonJS animation
  77306. * @param animationChannelTargetPath The target animation channel
  77307. * @param frameDelta The difference between the last and first frame of the animation
  77308. * @param inputs Array to store the key frame times
  77309. * @param outputs Array to store the key frame data
  77310. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  77311. * @param useQuaternion Specifies if quaternions are used in the animation
  77312. */
  77313. private static _CreateLinearOrStepAnimation;
  77314. /**
  77315. * Creates cubic spline animation from the animation key frames
  77316. * @param babylonTransformNode BabylonJS mesh
  77317. * @param animation BabylonJS animation
  77318. * @param animationChannelTargetPath The target animation channel
  77319. * @param frameDelta The difference between the last and first frame of the animation
  77320. * @param inputs Array to store the key frame times
  77321. * @param outputs Array to store the key frame data
  77322. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  77323. * @param useQuaternion Specifies if quaternions are used in the animation
  77324. */
  77325. private static _CreateCubicSplineAnimation;
  77326. private static _GetBasePositionRotationOrScale;
  77327. /**
  77328. * Adds a key frame value
  77329. * @param keyFrame
  77330. * @param animation
  77331. * @param outputs
  77332. * @param animationChannelTargetPath
  77333. * @param basePositionRotationOrScale
  77334. * @param convertToRightHandedSystem
  77335. * @param useQuaternion
  77336. */
  77337. private static _AddKeyframeValue;
  77338. /**
  77339. * Determine the interpolation based on the key frames
  77340. * @param keyFrames
  77341. * @param animationChannelTargetPath
  77342. * @param useQuaternion
  77343. */
  77344. private static _DeduceInterpolation;
  77345. /**
  77346. * Adds an input tangent or output tangent to the output data
  77347. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  77348. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  77349. * @param outputs The animation data by keyframe
  77350. * @param animationChannelTargetPath The target animation channel
  77351. * @param interpolation The interpolation type
  77352. * @param keyFrame The key frame with the animation data
  77353. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  77354. * @param useQuaternion Specifies if quaternions are used
  77355. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  77356. */
  77357. private static AddSplineTangent;
  77358. /**
  77359. * Get the minimum and maximum key frames' frame values
  77360. * @param keyFrames animation key frames
  77361. * @returns the minimum and maximum key frame value
  77362. */
  77363. private static calculateMinMaxKeyFrames;
  77364. }
  77365. }
  77366. declare module BABYLON.GLTF2.Exporter {
  77367. /** @hidden */
  77368. export var textureTransformPixelShader: {
  77369. name: string;
  77370. shader: string;
  77371. };
  77372. }
  77373. declare module BABYLON.GLTF2.Exporter.Extensions {
  77374. /**
  77375. * @hidden
  77376. */
  77377. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  77378. private _recordedTextures;
  77379. /** Name of this extension */
  77380. readonly name: string;
  77381. /** Defines whether this extension is enabled */
  77382. enabled: boolean;
  77383. /** Defines whether this extension is required */
  77384. required: boolean;
  77385. /** Reference to the glTF exporter */
  77386. private _wasUsed;
  77387. constructor(exporter: _Exporter);
  77388. dispose(): void;
  77389. /** @hidden */
  77390. get wasUsed(): boolean;
  77391. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  77392. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Promise<Texture>;
  77393. /**
  77394. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  77395. * @param babylonTexture
  77396. * @param offset
  77397. * @param rotation
  77398. * @param scale
  77399. * @param scene
  77400. */
  77401. private _textureTransformTextureAsync;
  77402. }
  77403. }
  77404. declare module BABYLON.GLTF2.Exporter.Extensions {
  77405. /**
  77406. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  77407. */
  77408. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  77409. /** The name of this extension. */
  77410. readonly name: string;
  77411. /** Defines whether this extension is enabled. */
  77412. enabled: boolean;
  77413. /** Defines whether this extension is required */
  77414. required: boolean;
  77415. /** Reference to the glTF exporter */
  77416. private _exporter;
  77417. private _lights;
  77418. /** @hidden */
  77419. constructor(exporter: _Exporter);
  77420. /** @hidden */
  77421. dispose(): void;
  77422. /** @hidden */
  77423. get wasUsed(): boolean;
  77424. /** @hidden */
  77425. onExporting(): void;
  77426. /**
  77427. * Define this method to modify the default behavior when exporting a node
  77428. * @param context The context when exporting the node
  77429. * @param node glTF node
  77430. * @param babylonNode BabylonJS node
  77431. * @returns nullable INode promise
  77432. */
  77433. postExportNodeAsync(context: string, node: INode, babylonNode: Node): Promise<INode>;
  77434. }
  77435. }
  77436. declare module BABYLON.GLTF2.Exporter.Extensions {
  77437. /**
  77438. * @hidden
  77439. */
  77440. export class KHR_materials_sheen implements IGLTFExporterExtensionV2 {
  77441. /** Name of this extension */
  77442. readonly name: string;
  77443. /** Defines whether this extension is enabled */
  77444. enabled: boolean;
  77445. /** Defines whether this extension is required */
  77446. required: boolean;
  77447. /** Reference to the glTF exporter */
  77448. private _textureInfos;
  77449. private _exportedTextures;
  77450. private _wasUsed;
  77451. constructor(exporter: _Exporter);
  77452. dispose(): void;
  77453. /** @hidden */
  77454. get wasUsed(): boolean;
  77455. private _getTextureIndex;
  77456. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  77457. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  77458. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  77459. }
  77460. }
  77461. declare module BABYLON {
  77462. /**
  77463. * Class for generating STL data from a Babylon scene.
  77464. */
  77465. export class STLExport {
  77466. /**
  77467. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  77468. * @param meshes list defines the mesh to serialize
  77469. * @param download triggers the automatic download of the file.
  77470. * @param fileName changes the downloads fileName.
  77471. * @param binary changes the STL to a binary type.
  77472. * @param isLittleEndian toggle for binary type exporter.
  77473. * @returns the STL as UTF8 string
  77474. */
  77475. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean): any;
  77476. }
  77477. }
  77478. declare module "babylonjs-gltf2interface" {
  77479. export = BABYLON.GLTF2;
  77480. }
  77481. /**
  77482. * Module for glTF 2.0 Interface
  77483. */
  77484. declare module BABYLON.GLTF2 {
  77485. /**
  77486. * The datatype of the components in the attribute
  77487. */
  77488. const enum AccessorComponentType {
  77489. /**
  77490. * Byte
  77491. */
  77492. BYTE = 5120,
  77493. /**
  77494. * Unsigned Byte
  77495. */
  77496. UNSIGNED_BYTE = 5121,
  77497. /**
  77498. * Short
  77499. */
  77500. SHORT = 5122,
  77501. /**
  77502. * Unsigned Short
  77503. */
  77504. UNSIGNED_SHORT = 5123,
  77505. /**
  77506. * Unsigned Int
  77507. */
  77508. UNSIGNED_INT = 5125,
  77509. /**
  77510. * Float
  77511. */
  77512. FLOAT = 5126,
  77513. }
  77514. /**
  77515. * Specifies if the attirbute is a scalar, vector, or matrix
  77516. */
  77517. const enum AccessorType {
  77518. /**
  77519. * Scalar
  77520. */
  77521. SCALAR = "SCALAR",
  77522. /**
  77523. * Vector2
  77524. */
  77525. VEC2 = "VEC2",
  77526. /**
  77527. * Vector3
  77528. */
  77529. VEC3 = "VEC3",
  77530. /**
  77531. * Vector4
  77532. */
  77533. VEC4 = "VEC4",
  77534. /**
  77535. * Matrix2x2
  77536. */
  77537. MAT2 = "MAT2",
  77538. /**
  77539. * Matrix3x3
  77540. */
  77541. MAT3 = "MAT3",
  77542. /**
  77543. * Matrix4x4
  77544. */
  77545. MAT4 = "MAT4",
  77546. }
  77547. /**
  77548. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  77549. */
  77550. const enum AnimationChannelTargetPath {
  77551. /**
  77552. * Translation
  77553. */
  77554. TRANSLATION = "translation",
  77555. /**
  77556. * Rotation
  77557. */
  77558. ROTATION = "rotation",
  77559. /**
  77560. * Scale
  77561. */
  77562. SCALE = "scale",
  77563. /**
  77564. * Weights
  77565. */
  77566. WEIGHTS = "weights",
  77567. }
  77568. /**
  77569. * Interpolation algorithm
  77570. */
  77571. const enum AnimationSamplerInterpolation {
  77572. /**
  77573. * The animated values are linearly interpolated between keyframes
  77574. */
  77575. LINEAR = "LINEAR",
  77576. /**
  77577. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  77578. */
  77579. STEP = "STEP",
  77580. /**
  77581. * The animation's interpolation is computed using a cubic spline with specified tangents
  77582. */
  77583. CUBICSPLINE = "CUBICSPLINE",
  77584. }
  77585. /**
  77586. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  77587. */
  77588. const enum CameraType {
  77589. /**
  77590. * A perspective camera containing properties to create a perspective projection matrix
  77591. */
  77592. PERSPECTIVE = "perspective",
  77593. /**
  77594. * An orthographic camera containing properties to create an orthographic projection matrix
  77595. */
  77596. ORTHOGRAPHIC = "orthographic",
  77597. }
  77598. /**
  77599. * The mime-type of the image
  77600. */
  77601. const enum ImageMimeType {
  77602. /**
  77603. * JPEG Mime-type
  77604. */
  77605. JPEG = "image/jpeg",
  77606. /**
  77607. * PNG Mime-type
  77608. */
  77609. PNG = "image/png",
  77610. }
  77611. /**
  77612. * The alpha rendering mode of the material
  77613. */
  77614. const enum MaterialAlphaMode {
  77615. /**
  77616. * The alpha value is ignored and the rendered output is fully opaque
  77617. */
  77618. OPAQUE = "OPAQUE",
  77619. /**
  77620. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  77621. */
  77622. MASK = "MASK",
  77623. /**
  77624. * 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)
  77625. */
  77626. BLEND = "BLEND",
  77627. }
  77628. /**
  77629. * The type of the primitives to render
  77630. */
  77631. const enum MeshPrimitiveMode {
  77632. /**
  77633. * Points
  77634. */
  77635. POINTS = 0,
  77636. /**
  77637. * Lines
  77638. */
  77639. LINES = 1,
  77640. /**
  77641. * Line Loop
  77642. */
  77643. LINE_LOOP = 2,
  77644. /**
  77645. * Line Strip
  77646. */
  77647. LINE_STRIP = 3,
  77648. /**
  77649. * Triangles
  77650. */
  77651. TRIANGLES = 4,
  77652. /**
  77653. * Triangle Strip
  77654. */
  77655. TRIANGLE_STRIP = 5,
  77656. /**
  77657. * Triangle Fan
  77658. */
  77659. TRIANGLE_FAN = 6,
  77660. }
  77661. /**
  77662. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  77663. */
  77664. const enum TextureMagFilter {
  77665. /**
  77666. * Nearest
  77667. */
  77668. NEAREST = 9728,
  77669. /**
  77670. * Linear
  77671. */
  77672. LINEAR = 9729,
  77673. }
  77674. /**
  77675. * Minification filter. All valid values correspond to WebGL enums
  77676. */
  77677. const enum TextureMinFilter {
  77678. /**
  77679. * Nearest
  77680. */
  77681. NEAREST = 9728,
  77682. /**
  77683. * Linear
  77684. */
  77685. LINEAR = 9729,
  77686. /**
  77687. * Nearest Mip-Map Nearest
  77688. */
  77689. NEAREST_MIPMAP_NEAREST = 9984,
  77690. /**
  77691. * Linear Mipmap Nearest
  77692. */
  77693. LINEAR_MIPMAP_NEAREST = 9985,
  77694. /**
  77695. * Nearest Mipmap Linear
  77696. */
  77697. NEAREST_MIPMAP_LINEAR = 9986,
  77698. /**
  77699. * Linear Mipmap Linear
  77700. */
  77701. LINEAR_MIPMAP_LINEAR = 9987,
  77702. }
  77703. /**
  77704. * S (U) wrapping mode. All valid values correspond to WebGL enums
  77705. */
  77706. const enum TextureWrapMode {
  77707. /**
  77708. * Clamp to Edge
  77709. */
  77710. CLAMP_TO_EDGE = 33071,
  77711. /**
  77712. * Mirrored Repeat
  77713. */
  77714. MIRRORED_REPEAT = 33648,
  77715. /**
  77716. * Repeat
  77717. */
  77718. REPEAT = 10497,
  77719. }
  77720. /**
  77721. * glTF Property
  77722. */
  77723. interface IProperty {
  77724. /**
  77725. * Dictionary object with extension-specific objects
  77726. */
  77727. extensions?: {
  77728. [key: string]: any;
  77729. };
  77730. /**
  77731. * Application-Specific data
  77732. */
  77733. extras?: any;
  77734. }
  77735. /**
  77736. * glTF Child of Root Property
  77737. */
  77738. interface IChildRootProperty extends IProperty {
  77739. /**
  77740. * The user-defined name of this object
  77741. */
  77742. name?: string;
  77743. }
  77744. /**
  77745. * Indices of those attributes that deviate from their initialization value
  77746. */
  77747. interface IAccessorSparseIndices extends IProperty {
  77748. /**
  77749. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  77750. */
  77751. bufferView: number;
  77752. /**
  77753. * The offset relative to the start of the bufferView in bytes. Must be aligned
  77754. */
  77755. byteOffset?: number;
  77756. /**
  77757. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  77758. */
  77759. componentType: AccessorComponentType;
  77760. }
  77761. /**
  77762. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  77763. */
  77764. interface IAccessorSparseValues extends IProperty {
  77765. /**
  77766. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  77767. */
  77768. bufferView: number;
  77769. /**
  77770. * The offset relative to the start of the bufferView in bytes. Must be aligned
  77771. */
  77772. byteOffset?: number;
  77773. }
  77774. /**
  77775. * Sparse storage of attributes that deviate from their initialization value
  77776. */
  77777. interface IAccessorSparse extends IProperty {
  77778. /**
  77779. * The number of attributes encoded in this sparse accessor
  77780. */
  77781. count: number;
  77782. /**
  77783. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  77784. */
  77785. indices: IAccessorSparseIndices;
  77786. /**
  77787. * 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
  77788. */
  77789. values: IAccessorSparseValues;
  77790. }
  77791. /**
  77792. * 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
  77793. */
  77794. interface IAccessor extends IChildRootProperty {
  77795. /**
  77796. * The index of the bufferview
  77797. */
  77798. bufferView?: number;
  77799. /**
  77800. * The offset relative to the start of the bufferView in bytes
  77801. */
  77802. byteOffset?: number;
  77803. /**
  77804. * The datatype of components in the attribute
  77805. */
  77806. componentType: AccessorComponentType;
  77807. /**
  77808. * Specifies whether integer data values should be normalized
  77809. */
  77810. normalized?: boolean;
  77811. /**
  77812. * The number of attributes referenced by this accessor
  77813. */
  77814. count: number;
  77815. /**
  77816. * Specifies if the attribute is a scalar, vector, or matrix
  77817. */
  77818. type: AccessorType;
  77819. /**
  77820. * Maximum value of each component in this attribute
  77821. */
  77822. max?: number[];
  77823. /**
  77824. * Minimum value of each component in this attribute
  77825. */
  77826. min?: number[];
  77827. /**
  77828. * Sparse storage of attributes that deviate from their initialization value
  77829. */
  77830. sparse?: IAccessorSparse;
  77831. }
  77832. /**
  77833. * Targets an animation's sampler at a node's property
  77834. */
  77835. interface IAnimationChannel extends IProperty {
  77836. /**
  77837. * The index of a sampler in this animation used to compute the value for the target
  77838. */
  77839. sampler: number;
  77840. /**
  77841. * The index of the node and TRS property to target
  77842. */
  77843. target: IAnimationChannelTarget;
  77844. }
  77845. /**
  77846. * The index of the node and TRS property that an animation channel targets
  77847. */
  77848. interface IAnimationChannelTarget extends IProperty {
  77849. /**
  77850. * The index of the node to target
  77851. */
  77852. node: number;
  77853. /**
  77854. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  77855. */
  77856. path: AnimationChannelTargetPath;
  77857. }
  77858. /**
  77859. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  77860. */
  77861. interface IAnimationSampler extends IProperty {
  77862. /**
  77863. * The index of an accessor containing keyframe input values, e.g., time
  77864. */
  77865. input: number;
  77866. /**
  77867. * Interpolation algorithm
  77868. */
  77869. interpolation?: AnimationSamplerInterpolation;
  77870. /**
  77871. * The index of an accessor, containing keyframe output values
  77872. */
  77873. output: number;
  77874. }
  77875. /**
  77876. * A keyframe animation
  77877. */
  77878. interface IAnimation extends IChildRootProperty {
  77879. /**
  77880. * An array of channels, each of which targets an animation's sampler at a node's property
  77881. */
  77882. channels: IAnimationChannel[];
  77883. /**
  77884. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  77885. */
  77886. samplers: IAnimationSampler[];
  77887. }
  77888. /**
  77889. * Metadata about the glTF asset
  77890. */
  77891. interface IAsset extends IChildRootProperty {
  77892. /**
  77893. * A copyright message suitable for display to credit the content creator
  77894. */
  77895. copyright?: string;
  77896. /**
  77897. * Tool that generated this glTF model. Useful for debugging
  77898. */
  77899. generator?: string;
  77900. /**
  77901. * The glTF version that this asset targets
  77902. */
  77903. version: string;
  77904. /**
  77905. * The minimum glTF version that this asset targets
  77906. */
  77907. minVersion?: string;
  77908. }
  77909. /**
  77910. * A buffer points to binary geometry, animation, or skins
  77911. */
  77912. interface IBuffer extends IChildRootProperty {
  77913. /**
  77914. * 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
  77915. */
  77916. uri?: string;
  77917. /**
  77918. * The length of the buffer in bytes
  77919. */
  77920. byteLength: number;
  77921. }
  77922. /**
  77923. * A view into a buffer generally representing a subset of the buffer
  77924. */
  77925. interface IBufferView extends IChildRootProperty {
  77926. /**
  77927. * The index of the buffer
  77928. */
  77929. buffer: number;
  77930. /**
  77931. * The offset into the buffer in bytes
  77932. */
  77933. byteOffset?: number;
  77934. /**
  77935. * The lenth of the bufferView in bytes
  77936. */
  77937. byteLength: number;
  77938. /**
  77939. * The stride, in bytes
  77940. */
  77941. byteStride?: number;
  77942. }
  77943. /**
  77944. * An orthographic camera containing properties to create an orthographic projection matrix
  77945. */
  77946. interface ICameraOrthographic extends IProperty {
  77947. /**
  77948. * The floating-point horizontal magnification of the view. Must not be zero
  77949. */
  77950. xmag: number;
  77951. /**
  77952. * The floating-point vertical magnification of the view. Must not be zero
  77953. */
  77954. ymag: number;
  77955. /**
  77956. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  77957. */
  77958. zfar: number;
  77959. /**
  77960. * The floating-point distance to the near clipping plane
  77961. */
  77962. znear: number;
  77963. }
  77964. /**
  77965. * A perspective camera containing properties to create a perspective projection matrix
  77966. */
  77967. interface ICameraPerspective extends IProperty {
  77968. /**
  77969. * The floating-point aspect ratio of the field of view
  77970. */
  77971. aspectRatio?: number;
  77972. /**
  77973. * The floating-point vertical field of view in radians
  77974. */
  77975. yfov: number;
  77976. /**
  77977. * The floating-point distance to the far clipping plane
  77978. */
  77979. zfar?: number;
  77980. /**
  77981. * The floating-point distance to the near clipping plane
  77982. */
  77983. znear: number;
  77984. }
  77985. /**
  77986. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  77987. */
  77988. interface ICamera extends IChildRootProperty {
  77989. /**
  77990. * An orthographic camera containing properties to create an orthographic projection matrix
  77991. */
  77992. orthographic?: ICameraOrthographic;
  77993. /**
  77994. * A perspective camera containing properties to create a perspective projection matrix
  77995. */
  77996. perspective?: ICameraPerspective;
  77997. /**
  77998. * Specifies if the camera uses a perspective or orthographic projection
  77999. */
  78000. type: CameraType;
  78001. }
  78002. /**
  78003. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  78004. */
  78005. interface IImage extends IChildRootProperty {
  78006. /**
  78007. * 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
  78008. */
  78009. uri?: string;
  78010. /**
  78011. * The image's MIME type
  78012. */
  78013. mimeType?: ImageMimeType;
  78014. /**
  78015. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  78016. */
  78017. bufferView?: number;
  78018. }
  78019. /**
  78020. * Material Normal Texture Info
  78021. */
  78022. interface IMaterialNormalTextureInfo extends ITextureInfo {
  78023. /**
  78024. * The scalar multiplier applied to each normal vector of the normal texture
  78025. */
  78026. scale?: number;
  78027. }
  78028. /**
  78029. * Material Occlusion Texture Info
  78030. */
  78031. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  78032. /**
  78033. * A scalar multiplier controlling the amount of occlusion applied
  78034. */
  78035. strength?: number;
  78036. }
  78037. /**
  78038. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  78039. */
  78040. interface IMaterialPbrMetallicRoughness {
  78041. /**
  78042. * The material's base color factor
  78043. */
  78044. baseColorFactor?: number[];
  78045. /**
  78046. * The base color texture
  78047. */
  78048. baseColorTexture?: ITextureInfo;
  78049. /**
  78050. * The metalness of the material
  78051. */
  78052. metallicFactor?: number;
  78053. /**
  78054. * The roughness of the material
  78055. */
  78056. roughnessFactor?: number;
  78057. /**
  78058. * The metallic-roughness texture
  78059. */
  78060. metallicRoughnessTexture?: ITextureInfo;
  78061. }
  78062. /**
  78063. * The material appearance of a primitive
  78064. */
  78065. interface IMaterial extends IChildRootProperty {
  78066. /**
  78067. * 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
  78068. */
  78069. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  78070. /**
  78071. * The normal map texture
  78072. */
  78073. normalTexture?: IMaterialNormalTextureInfo;
  78074. /**
  78075. * The occlusion map texture
  78076. */
  78077. occlusionTexture?: IMaterialOcclusionTextureInfo;
  78078. /**
  78079. * The emissive map texture
  78080. */
  78081. emissiveTexture?: ITextureInfo;
  78082. /**
  78083. * 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
  78084. */
  78085. emissiveFactor?: number[];
  78086. /**
  78087. * The alpha rendering mode of the material
  78088. */
  78089. alphaMode?: MaterialAlphaMode;
  78090. /**
  78091. * The alpha cutoff value of the material
  78092. */
  78093. alphaCutoff?: number;
  78094. /**
  78095. * Specifies whether the material is double sided
  78096. */
  78097. doubleSided?: boolean;
  78098. }
  78099. /**
  78100. * Geometry to be rendered with the given material
  78101. */
  78102. interface IMeshPrimitive extends IProperty {
  78103. /**
  78104. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  78105. */
  78106. attributes: {
  78107. [name: string]: number;
  78108. };
  78109. /**
  78110. * The index of the accessor that contains the indices
  78111. */
  78112. indices?: number;
  78113. /**
  78114. * The index of the material to apply to this primitive when rendering
  78115. */
  78116. material?: number;
  78117. /**
  78118. * The type of primitives to render. All valid values correspond to WebGL enums
  78119. */
  78120. mode?: MeshPrimitiveMode;
  78121. /**
  78122. * 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
  78123. */
  78124. targets?: {
  78125. [name: string]: number;
  78126. }[];
  78127. }
  78128. /**
  78129. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  78130. */
  78131. interface IMesh extends IChildRootProperty {
  78132. /**
  78133. * An array of primitives, each defining geometry to be rendered with a material
  78134. */
  78135. primitives: IMeshPrimitive[];
  78136. /**
  78137. * Array of weights to be applied to the Morph Targets
  78138. */
  78139. weights?: number[];
  78140. }
  78141. /**
  78142. * A node in the node hierarchy
  78143. */
  78144. interface INode extends IChildRootProperty {
  78145. /**
  78146. * The index of the camera referenced by this node
  78147. */
  78148. camera?: number;
  78149. /**
  78150. * The indices of this node's children
  78151. */
  78152. children?: number[];
  78153. /**
  78154. * The index of the skin referenced by this node
  78155. */
  78156. skin?: number;
  78157. /**
  78158. * A floating-point 4x4 transformation matrix stored in column-major order
  78159. */
  78160. matrix?: number[];
  78161. /**
  78162. * The index of the mesh in this node
  78163. */
  78164. mesh?: number;
  78165. /**
  78166. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  78167. */
  78168. rotation?: number[];
  78169. /**
  78170. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  78171. */
  78172. scale?: number[];
  78173. /**
  78174. * The node's translation along the x, y, and z axes
  78175. */
  78176. translation?: number[];
  78177. /**
  78178. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  78179. */
  78180. weights?: number[];
  78181. }
  78182. /**
  78183. * Texture sampler properties for filtering and wrapping modes
  78184. */
  78185. interface ISampler extends IChildRootProperty {
  78186. /**
  78187. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  78188. */
  78189. magFilter?: TextureMagFilter;
  78190. /**
  78191. * Minification filter. All valid values correspond to WebGL enums
  78192. */
  78193. minFilter?: TextureMinFilter;
  78194. /**
  78195. * S (U) wrapping mode. All valid values correspond to WebGL enums
  78196. */
  78197. wrapS?: TextureWrapMode;
  78198. /**
  78199. * T (V) wrapping mode. All valid values correspond to WebGL enums
  78200. */
  78201. wrapT?: TextureWrapMode;
  78202. }
  78203. /**
  78204. * The root nodes of a scene
  78205. */
  78206. interface IScene extends IChildRootProperty {
  78207. /**
  78208. * The indices of each root node
  78209. */
  78210. nodes: number[];
  78211. }
  78212. /**
  78213. * Joints and matrices defining a skin
  78214. */
  78215. interface ISkin extends IChildRootProperty {
  78216. /**
  78217. * 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
  78218. */
  78219. inverseBindMatrices?: number;
  78220. /**
  78221. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  78222. */
  78223. skeleton?: number;
  78224. /**
  78225. * 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)
  78226. */
  78227. joints: number[];
  78228. }
  78229. /**
  78230. * A texture and its sampler
  78231. */
  78232. interface ITexture extends IChildRootProperty {
  78233. /**
  78234. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  78235. */
  78236. sampler?: number;
  78237. /**
  78238. * The index of the image used by this texture
  78239. */
  78240. source: number;
  78241. }
  78242. /**
  78243. * Reference to a texture
  78244. */
  78245. interface ITextureInfo extends IProperty {
  78246. /**
  78247. * The index of the texture
  78248. */
  78249. index: number;
  78250. /**
  78251. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  78252. */
  78253. texCoord?: number;
  78254. }
  78255. /**
  78256. * The root object for a glTF asset
  78257. */
  78258. interface IGLTF extends IProperty {
  78259. /**
  78260. * An array of accessors. An accessor is a typed view into a bufferView
  78261. */
  78262. accessors?: IAccessor[];
  78263. /**
  78264. * An array of keyframe animations
  78265. */
  78266. animations?: IAnimation[];
  78267. /**
  78268. * Metadata about the glTF asset
  78269. */
  78270. asset: IAsset;
  78271. /**
  78272. * An array of buffers. A buffer points to binary geometry, animation, or skins
  78273. */
  78274. buffers?: IBuffer[];
  78275. /**
  78276. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  78277. */
  78278. bufferViews?: IBufferView[];
  78279. /**
  78280. * An array of cameras
  78281. */
  78282. cameras?: ICamera[];
  78283. /**
  78284. * Names of glTF extensions used somewhere in this asset
  78285. */
  78286. extensionsUsed?: string[];
  78287. /**
  78288. * Names of glTF extensions required to properly load this asset
  78289. */
  78290. extensionsRequired?: string[];
  78291. /**
  78292. * An array of images. An image defines data used to create a texture
  78293. */
  78294. images?: IImage[];
  78295. /**
  78296. * An array of materials. A material defines the appearance of a primitive
  78297. */
  78298. materials?: IMaterial[];
  78299. /**
  78300. * An array of meshes. A mesh is a set of primitives to be rendered
  78301. */
  78302. meshes?: IMesh[];
  78303. /**
  78304. * An array of nodes
  78305. */
  78306. nodes?: INode[];
  78307. /**
  78308. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  78309. */
  78310. samplers?: ISampler[];
  78311. /**
  78312. * The index of the default scene
  78313. */
  78314. scene?: number;
  78315. /**
  78316. * An array of scenes
  78317. */
  78318. scenes?: IScene[];
  78319. /**
  78320. * An array of skins. A skin is defined by joints and matrices
  78321. */
  78322. skins?: ISkin[];
  78323. /**
  78324. * An array of textures
  78325. */
  78326. textures?: ITexture[];
  78327. }
  78328. /**
  78329. * The glTF validation results
  78330. * @ignore
  78331. */
  78332. interface IGLTFValidationResults {
  78333. info: {
  78334. generator: string;
  78335. hasAnimations: boolean;
  78336. hasDefaultScene: boolean;
  78337. hasMaterials: boolean;
  78338. hasMorphTargets: boolean;
  78339. hasSkins: boolean;
  78340. hasTextures: boolean;
  78341. maxAttributesUsed: number;
  78342. primitivesCount: number
  78343. };
  78344. issues: {
  78345. messages: Array<string>;
  78346. numErrors: number;
  78347. numHints: number;
  78348. numInfos: number;
  78349. numWarnings: number;
  78350. truncated: boolean
  78351. };
  78352. mimeType: string;
  78353. uri: string;
  78354. validatedAt: string;
  78355. validatorVersion: string;
  78356. }
  78357. /**
  78358. * The glTF validation options
  78359. */
  78360. interface IGLTFValidationOptions {
  78361. /** Uri to use */
  78362. uri?: string;
  78363. /** Function used to load external resources */
  78364. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  78365. /** Boolean indicating that we need to validate accessor data */
  78366. validateAccessorData?: boolean;
  78367. /** max number of issues allowed */
  78368. maxIssues?: number;
  78369. /** Ignored issues */
  78370. ignoredIssues?: Array<string>;
  78371. /** Value to override severy settings */
  78372. severityOverrides?: Object;
  78373. }
  78374. /**
  78375. * The glTF validator object
  78376. * @ignore
  78377. */
  78378. interface IGLTFValidator {
  78379. validateBytes: (data: Uint8Array, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  78380. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  78381. }
  78382. }
  78383. declare module BABYLON {
  78384. /** @hidden */
  78385. export var cellPixelShader: {
  78386. name: string;
  78387. shader: string;
  78388. };
  78389. }
  78390. declare module BABYLON {
  78391. /** @hidden */
  78392. export var cellVertexShader: {
  78393. name: string;
  78394. shader: string;
  78395. };
  78396. }
  78397. declare module BABYLON {
  78398. export class CellMaterial extends BABYLON.PushMaterial {
  78399. private _diffuseTexture;
  78400. diffuseTexture: BABYLON.BaseTexture;
  78401. diffuseColor: BABYLON.Color3;
  78402. _computeHighLevel: boolean;
  78403. computeHighLevel: boolean;
  78404. private _disableLighting;
  78405. disableLighting: boolean;
  78406. private _maxSimultaneousLights;
  78407. maxSimultaneousLights: number;
  78408. private _renderId;
  78409. constructor(name: string, scene: BABYLON.Scene);
  78410. needAlphaBlending(): boolean;
  78411. needAlphaTesting(): boolean;
  78412. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  78413. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  78414. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  78415. getAnimatables(): BABYLON.IAnimatable[];
  78416. getActiveTextures(): BABYLON.BaseTexture[];
  78417. hasTexture(texture: BABYLON.BaseTexture): boolean;
  78418. dispose(forceDisposeEffect?: boolean): void;
  78419. getClassName(): string;
  78420. clone(name: string): CellMaterial;
  78421. serialize(): any;
  78422. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  78423. }
  78424. }
  78425. declare module BABYLON {
  78426. export class CustomShaderStructure {
  78427. FragmentStore: string;
  78428. VertexStore: string;
  78429. constructor();
  78430. }
  78431. export class ShaderSpecialParts {
  78432. constructor();
  78433. Fragment_Begin: string;
  78434. Fragment_Definitions: string;
  78435. Fragment_MainBegin: string;
  78436. Fragment_Custom_Diffuse: string;
  78437. Fragment_Before_Lights: string;
  78438. Fragment_Before_Fog: string;
  78439. Fragment_Custom_Alpha: string;
  78440. Fragment_Before_FragColor: string;
  78441. Vertex_Begin: string;
  78442. Vertex_Definitions: string;
  78443. Vertex_MainBegin: string;
  78444. Vertex_Before_PositionUpdated: string;
  78445. Vertex_Before_NormalUpdated: string;
  78446. Vertex_MainEnd: string;
  78447. }
  78448. export class CustomMaterial extends BABYLON.StandardMaterial {
  78449. static ShaderIndexer: number;
  78450. CustomParts: ShaderSpecialParts;
  78451. _isCreatedShader: boolean;
  78452. _createdShaderName: string;
  78453. _customUniform: string[];
  78454. _newUniforms: string[];
  78455. _newUniformInstances: any[];
  78456. _newSamplerInstances: BABYLON.Texture[];
  78457. FragmentShader: string;
  78458. VertexShader: string;
  78459. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  78460. ReviewUniform(name: string, arr: string[]): string[];
  78461. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.StandardMaterialDefines): string;
  78462. constructor(name: string, scene: BABYLON.Scene);
  78463. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  78464. Fragment_Begin(shaderPart: string): CustomMaterial;
  78465. Fragment_Definitions(shaderPart: string): CustomMaterial;
  78466. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  78467. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  78468. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  78469. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  78470. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  78471. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  78472. Vertex_Begin(shaderPart: string): CustomMaterial;
  78473. Vertex_Definitions(shaderPart: string): CustomMaterial;
  78474. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  78475. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  78476. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  78477. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  78478. }
  78479. }
  78480. declare module BABYLON {
  78481. export class ShaderAlebdoParts {
  78482. constructor();
  78483. Fragment_Begin: string;
  78484. Fragment_Definitions: string;
  78485. Fragment_MainBegin: string;
  78486. Fragment_Custom_Albedo: string;
  78487. Fragment_Before_Lights: string;
  78488. Fragment_Custom_MetallicRoughness: string;
  78489. Fragment_Custom_MicroSurface: string;
  78490. Fragment_Before_Fog: string;
  78491. Fragment_Custom_Alpha: string;
  78492. Fragment_Before_FragColor: string;
  78493. Vertex_Begin: string;
  78494. Vertex_Definitions: string;
  78495. Vertex_MainBegin: string;
  78496. Vertex_Before_PositionUpdated: string;
  78497. Vertex_Before_NormalUpdated: string;
  78498. Vertex_MainEnd: string;
  78499. }
  78500. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  78501. static ShaderIndexer: number;
  78502. CustomParts: ShaderAlebdoParts;
  78503. _isCreatedShader: boolean;
  78504. _createdShaderName: string;
  78505. _customUniform: string[];
  78506. _newUniforms: string[];
  78507. _newUniformInstances: any[];
  78508. _newSamplerInstances: BABYLON.Texture[];
  78509. FragmentShader: string;
  78510. VertexShader: string;
  78511. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  78512. ReviewUniform(name: string, arr: string[]): string[];
  78513. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.PBRMaterialDefines): string;
  78514. constructor(name: string, scene: BABYLON.Scene);
  78515. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  78516. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  78517. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  78518. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  78519. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  78520. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  78521. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  78522. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  78523. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  78524. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  78525. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  78526. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  78527. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  78528. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  78529. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  78530. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  78531. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  78532. }
  78533. }
  78534. declare module BABYLON {
  78535. /** @hidden */
  78536. export var firePixelShader: {
  78537. name: string;
  78538. shader: string;
  78539. };
  78540. }
  78541. declare module BABYLON {
  78542. /** @hidden */
  78543. export var fireVertexShader: {
  78544. name: string;
  78545. shader: string;
  78546. };
  78547. }
  78548. declare module BABYLON {
  78549. export class FireMaterial extends BABYLON.PushMaterial {
  78550. private _diffuseTexture;
  78551. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  78552. private _distortionTexture;
  78553. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  78554. private _opacityTexture;
  78555. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  78556. diffuseColor: BABYLON.Color3;
  78557. speed: number;
  78558. private _scaledDiffuse;
  78559. private _renderId;
  78560. private _lastTime;
  78561. constructor(name: string, scene: BABYLON.Scene);
  78562. needAlphaBlending(): boolean;
  78563. needAlphaTesting(): boolean;
  78564. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  78565. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  78566. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  78567. getAnimatables(): BABYLON.IAnimatable[];
  78568. getActiveTextures(): BABYLON.BaseTexture[];
  78569. hasTexture(texture: BABYLON.BaseTexture): boolean;
  78570. getClassName(): string;
  78571. dispose(forceDisposeEffect?: boolean): void;
  78572. clone(name: string): FireMaterial;
  78573. serialize(): any;
  78574. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  78575. }
  78576. }
  78577. declare module BABYLON {
  78578. /** @hidden */
  78579. export var furPixelShader: {
  78580. name: string;
  78581. shader: string;
  78582. };
  78583. }
  78584. declare module BABYLON {
  78585. /** @hidden */
  78586. export var furVertexShader: {
  78587. name: string;
  78588. shader: string;
  78589. };
  78590. }
  78591. declare module BABYLON {
  78592. export class FurMaterial extends BABYLON.PushMaterial {
  78593. private _diffuseTexture;
  78594. diffuseTexture: BABYLON.BaseTexture;
  78595. private _heightTexture;
  78596. heightTexture: BABYLON.BaseTexture;
  78597. diffuseColor: BABYLON.Color3;
  78598. furLength: number;
  78599. furAngle: number;
  78600. furColor: BABYLON.Color3;
  78601. furOffset: number;
  78602. furSpacing: number;
  78603. furGravity: BABYLON.Vector3;
  78604. furSpeed: number;
  78605. furDensity: number;
  78606. furOcclusion: number;
  78607. furTexture: BABYLON.DynamicTexture;
  78608. private _disableLighting;
  78609. disableLighting: boolean;
  78610. private _maxSimultaneousLights;
  78611. maxSimultaneousLights: number;
  78612. highLevelFur: boolean;
  78613. _meshes: BABYLON.AbstractMesh[];
  78614. private _renderId;
  78615. private _furTime;
  78616. constructor(name: string, scene: BABYLON.Scene);
  78617. get furTime(): number;
  78618. set furTime(furTime: number);
  78619. needAlphaBlending(): boolean;
  78620. needAlphaTesting(): boolean;
  78621. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  78622. updateFur(): void;
  78623. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  78624. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  78625. getAnimatables(): BABYLON.IAnimatable[];
  78626. getActiveTextures(): BABYLON.BaseTexture[];
  78627. hasTexture(texture: BABYLON.BaseTexture): boolean;
  78628. dispose(forceDisposeEffect?: boolean): void;
  78629. clone(name: string): FurMaterial;
  78630. serialize(): any;
  78631. getClassName(): string;
  78632. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  78633. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  78634. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  78635. }
  78636. }
  78637. declare module BABYLON {
  78638. /** @hidden */
  78639. export var gradientPixelShader: {
  78640. name: string;
  78641. shader: string;
  78642. };
  78643. }
  78644. declare module BABYLON {
  78645. /** @hidden */
  78646. export var gradientVertexShader: {
  78647. name: string;
  78648. shader: string;
  78649. };
  78650. }
  78651. declare module BABYLON {
  78652. export class GradientMaterial extends BABYLON.PushMaterial {
  78653. private _maxSimultaneousLights;
  78654. maxSimultaneousLights: number;
  78655. topColor: BABYLON.Color3;
  78656. topColorAlpha: number;
  78657. bottomColor: BABYLON.Color3;
  78658. bottomColorAlpha: number;
  78659. offset: number;
  78660. scale: number;
  78661. smoothness: number;
  78662. private _disableLighting;
  78663. disableLighting: boolean;
  78664. private _renderId;
  78665. constructor(name: string, scene: BABYLON.Scene);
  78666. needAlphaBlending(): boolean;
  78667. needAlphaTesting(): boolean;
  78668. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  78669. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  78670. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  78671. getAnimatables(): BABYLON.IAnimatable[];
  78672. dispose(forceDisposeEffect?: boolean): void;
  78673. clone(name: string): GradientMaterial;
  78674. serialize(): any;
  78675. getClassName(): string;
  78676. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  78677. }
  78678. }
  78679. declare module BABYLON {
  78680. /** @hidden */
  78681. export var gridPixelShader: {
  78682. name: string;
  78683. shader: string;
  78684. };
  78685. }
  78686. declare module BABYLON {
  78687. /** @hidden */
  78688. export var gridVertexShader: {
  78689. name: string;
  78690. shader: string;
  78691. };
  78692. }
  78693. declare module BABYLON {
  78694. /**
  78695. * The grid materials allows you to wrap any shape with a grid.
  78696. * Colors are customizable.
  78697. */
  78698. export class GridMaterial extends BABYLON.PushMaterial {
  78699. /**
  78700. * Main color of the grid (e.g. between lines)
  78701. */
  78702. mainColor: BABYLON.Color3;
  78703. /**
  78704. * Color of the grid lines.
  78705. */
  78706. lineColor: BABYLON.Color3;
  78707. /**
  78708. * The scale of the grid compared to unit.
  78709. */
  78710. gridRatio: number;
  78711. /**
  78712. * Allows setting an offset for the grid lines.
  78713. */
  78714. gridOffset: BABYLON.Vector3;
  78715. /**
  78716. * The frequency of thicker lines.
  78717. */
  78718. majorUnitFrequency: number;
  78719. /**
  78720. * The visibility of minor units in the grid.
  78721. */
  78722. minorUnitVisibility: number;
  78723. /**
  78724. * The grid opacity outside of the lines.
  78725. */
  78726. opacity: number;
  78727. /**
  78728. * Determine RBG output is premultiplied by alpha value.
  78729. */
  78730. preMultiplyAlpha: boolean;
  78731. private _opacityTexture;
  78732. opacityTexture: BABYLON.BaseTexture;
  78733. private _gridControl;
  78734. private _renderId;
  78735. /**
  78736. * constructor
  78737. * @param name The name given to the material in order to identify it afterwards.
  78738. * @param scene The scene the material is used in.
  78739. */
  78740. constructor(name: string, scene: BABYLON.Scene);
  78741. /**
  78742. * Returns wehter or not the grid requires alpha blending.
  78743. */
  78744. needAlphaBlending(): boolean;
  78745. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  78746. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  78747. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  78748. /**
  78749. * Dispose the material and its associated resources.
  78750. * @param forceDisposeEffect will also dispose the used effect when true
  78751. */
  78752. dispose(forceDisposeEffect?: boolean): void;
  78753. clone(name: string): GridMaterial;
  78754. serialize(): any;
  78755. getClassName(): string;
  78756. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  78757. }
  78758. }
  78759. declare module BABYLON {
  78760. /** @hidden */
  78761. export var lavaPixelShader: {
  78762. name: string;
  78763. shader: string;
  78764. };
  78765. }
  78766. declare module BABYLON {
  78767. /** @hidden */
  78768. export var lavaVertexShader: {
  78769. name: string;
  78770. shader: string;
  78771. };
  78772. }
  78773. declare module BABYLON {
  78774. export class LavaMaterial extends BABYLON.PushMaterial {
  78775. private _diffuseTexture;
  78776. diffuseTexture: BABYLON.BaseTexture;
  78777. noiseTexture: BABYLON.BaseTexture;
  78778. fogColor: BABYLON.Color3;
  78779. speed: number;
  78780. movingSpeed: number;
  78781. lowFrequencySpeed: number;
  78782. fogDensity: number;
  78783. private _lastTime;
  78784. diffuseColor: BABYLON.Color3;
  78785. private _disableLighting;
  78786. disableLighting: boolean;
  78787. private _unlit;
  78788. unlit: boolean;
  78789. private _maxSimultaneousLights;
  78790. maxSimultaneousLights: number;
  78791. private _scaledDiffuse;
  78792. private _renderId;
  78793. constructor(name: string, scene: BABYLON.Scene);
  78794. needAlphaBlending(): boolean;
  78795. needAlphaTesting(): boolean;
  78796. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  78797. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  78798. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  78799. getAnimatables(): BABYLON.IAnimatable[];
  78800. getActiveTextures(): BABYLON.BaseTexture[];
  78801. hasTexture(texture: BABYLON.BaseTexture): boolean;
  78802. dispose(forceDisposeEffect?: boolean): void;
  78803. clone(name: string): LavaMaterial;
  78804. serialize(): any;
  78805. getClassName(): string;
  78806. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  78807. }
  78808. }
  78809. declare module BABYLON {
  78810. /** @hidden */
  78811. export var mixPixelShader: {
  78812. name: string;
  78813. shader: string;
  78814. };
  78815. }
  78816. declare module BABYLON {
  78817. /** @hidden */
  78818. export var mixVertexShader: {
  78819. name: string;
  78820. shader: string;
  78821. };
  78822. }
  78823. declare module BABYLON {
  78824. export class MixMaterial extends BABYLON.PushMaterial {
  78825. /**
  78826. * Mix textures
  78827. */
  78828. private _mixTexture1;
  78829. mixTexture1: BABYLON.BaseTexture;
  78830. private _mixTexture2;
  78831. mixTexture2: BABYLON.BaseTexture;
  78832. /**
  78833. * Diffuse textures
  78834. */
  78835. private _diffuseTexture1;
  78836. diffuseTexture1: BABYLON.Texture;
  78837. private _diffuseTexture2;
  78838. diffuseTexture2: BABYLON.Texture;
  78839. private _diffuseTexture3;
  78840. diffuseTexture3: BABYLON.Texture;
  78841. private _diffuseTexture4;
  78842. diffuseTexture4: BABYLON.Texture;
  78843. private _diffuseTexture5;
  78844. diffuseTexture5: BABYLON.Texture;
  78845. private _diffuseTexture6;
  78846. diffuseTexture6: BABYLON.Texture;
  78847. private _diffuseTexture7;
  78848. diffuseTexture7: BABYLON.Texture;
  78849. private _diffuseTexture8;
  78850. diffuseTexture8: BABYLON.Texture;
  78851. /**
  78852. * Uniforms
  78853. */
  78854. diffuseColor: BABYLON.Color3;
  78855. specularColor: BABYLON.Color3;
  78856. specularPower: number;
  78857. private _disableLighting;
  78858. disableLighting: boolean;
  78859. private _maxSimultaneousLights;
  78860. maxSimultaneousLights: number;
  78861. private _renderId;
  78862. constructor(name: string, scene: BABYLON.Scene);
  78863. needAlphaBlending(): boolean;
  78864. needAlphaTesting(): boolean;
  78865. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  78866. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  78867. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  78868. getAnimatables(): BABYLON.IAnimatable[];
  78869. getActiveTextures(): BABYLON.BaseTexture[];
  78870. hasTexture(texture: BABYLON.BaseTexture): boolean;
  78871. dispose(forceDisposeEffect?: boolean): void;
  78872. clone(name: string): MixMaterial;
  78873. serialize(): any;
  78874. getClassName(): string;
  78875. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  78876. }
  78877. }
  78878. declare module BABYLON {
  78879. /** @hidden */
  78880. export var normalPixelShader: {
  78881. name: string;
  78882. shader: string;
  78883. };
  78884. }
  78885. declare module BABYLON {
  78886. /** @hidden */
  78887. export var normalVertexShader: {
  78888. name: string;
  78889. shader: string;
  78890. };
  78891. }
  78892. declare module BABYLON {
  78893. export class NormalMaterial extends BABYLON.PushMaterial {
  78894. private _diffuseTexture;
  78895. diffuseTexture: BABYLON.BaseTexture;
  78896. diffuseColor: BABYLON.Color3;
  78897. private _disableLighting;
  78898. disableLighting: boolean;
  78899. private _maxSimultaneousLights;
  78900. maxSimultaneousLights: number;
  78901. private _renderId;
  78902. constructor(name: string, scene: BABYLON.Scene);
  78903. needAlphaBlending(): boolean;
  78904. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  78905. needAlphaTesting(): boolean;
  78906. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  78907. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  78908. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  78909. getAnimatables(): BABYLON.IAnimatable[];
  78910. getActiveTextures(): BABYLON.BaseTexture[];
  78911. hasTexture(texture: BABYLON.BaseTexture): boolean;
  78912. dispose(forceDisposeEffect?: boolean): void;
  78913. clone(name: string): NormalMaterial;
  78914. serialize(): any;
  78915. getClassName(): string;
  78916. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  78917. }
  78918. }
  78919. declare module BABYLON {
  78920. /** @hidden */
  78921. export var shadowOnlyPixelShader: {
  78922. name: string;
  78923. shader: string;
  78924. };
  78925. }
  78926. declare module BABYLON {
  78927. /** @hidden */
  78928. export var shadowOnlyVertexShader: {
  78929. name: string;
  78930. shader: string;
  78931. };
  78932. }
  78933. declare module BABYLON {
  78934. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  78935. private _renderId;
  78936. private _activeLight;
  78937. constructor(name: string, scene: BABYLON.Scene);
  78938. shadowColor: BABYLON.Color3;
  78939. needAlphaBlending(): boolean;
  78940. needAlphaTesting(): boolean;
  78941. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  78942. get activeLight(): BABYLON.IShadowLight;
  78943. set activeLight(light: BABYLON.IShadowLight);
  78944. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  78945. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  78946. clone(name: string): ShadowOnlyMaterial;
  78947. serialize(): any;
  78948. getClassName(): string;
  78949. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  78950. }
  78951. }
  78952. declare module BABYLON {
  78953. /** @hidden */
  78954. export var simplePixelShader: {
  78955. name: string;
  78956. shader: string;
  78957. };
  78958. }
  78959. declare module BABYLON {
  78960. /** @hidden */
  78961. export var simpleVertexShader: {
  78962. name: string;
  78963. shader: string;
  78964. };
  78965. }
  78966. declare module BABYLON {
  78967. export class SimpleMaterial extends BABYLON.PushMaterial {
  78968. private _diffuseTexture;
  78969. diffuseTexture: BABYLON.BaseTexture;
  78970. diffuseColor: BABYLON.Color3;
  78971. private _disableLighting;
  78972. disableLighting: boolean;
  78973. private _maxSimultaneousLights;
  78974. maxSimultaneousLights: number;
  78975. private _renderId;
  78976. constructor(name: string, scene: BABYLON.Scene);
  78977. needAlphaBlending(): boolean;
  78978. needAlphaTesting(): boolean;
  78979. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  78980. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  78981. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  78982. getAnimatables(): BABYLON.IAnimatable[];
  78983. getActiveTextures(): BABYLON.BaseTexture[];
  78984. hasTexture(texture: BABYLON.BaseTexture): boolean;
  78985. dispose(forceDisposeEffect?: boolean): void;
  78986. clone(name: string): SimpleMaterial;
  78987. serialize(): any;
  78988. getClassName(): string;
  78989. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  78990. }
  78991. }
  78992. declare module BABYLON {
  78993. /** @hidden */
  78994. export var skyPixelShader: {
  78995. name: string;
  78996. shader: string;
  78997. };
  78998. }
  78999. declare module BABYLON {
  79000. /** @hidden */
  79001. export var skyVertexShader: {
  79002. name: string;
  79003. shader: string;
  79004. };
  79005. }
  79006. declare module BABYLON {
  79007. /**
  79008. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  79009. * @see https://doc.babylonjs.com/extensions/sky
  79010. */
  79011. export class SkyMaterial extends BABYLON.PushMaterial {
  79012. /**
  79013. * Defines the overall luminance of sky in interval ]0, 1[.
  79014. */
  79015. luminance: number;
  79016. /**
  79017. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  79018. */
  79019. turbidity: number;
  79020. /**
  79021. * Defines the sky appearance (light intensity).
  79022. */
  79023. rayleigh: number;
  79024. /**
  79025. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  79026. */
  79027. mieCoefficient: number;
  79028. /**
  79029. * Defines the amount of haze particles following the Mie scattering theory.
  79030. */
  79031. mieDirectionalG: number;
  79032. /**
  79033. * Defines the distance of the sun according to the active scene camera.
  79034. */
  79035. distance: number;
  79036. /**
  79037. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  79038. * "inclined".
  79039. */
  79040. inclination: number;
  79041. /**
  79042. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  79043. * an object direction and a reference direction.
  79044. */
  79045. azimuth: number;
  79046. /**
  79047. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  79048. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  79049. */
  79050. sunPosition: BABYLON.Vector3;
  79051. /**
  79052. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  79053. * .sunPosition property.
  79054. */
  79055. useSunPosition: boolean;
  79056. /**
  79057. * Defines an offset vector used to get a horizon offset.
  79058. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  79059. */
  79060. cameraOffset: BABYLON.Vector3;
  79061. private _cameraPosition;
  79062. private _renderId;
  79063. /**
  79064. * Instantiates a new sky material.
  79065. * This material allows to create dynamic and texture free
  79066. * effects for skyboxes by taking care of the atmosphere state.
  79067. * @see https://doc.babylonjs.com/extensions/sky
  79068. * @param name Define the name of the material in the scene
  79069. * @param scene Define the scene the material belong to
  79070. */
  79071. constructor(name: string, scene: BABYLON.Scene);
  79072. /**
  79073. * Specifies if the material will require alpha blending
  79074. * @returns a boolean specifying if alpha blending is needed
  79075. */
  79076. needAlphaBlending(): boolean;
  79077. /**
  79078. * Specifies if this material should be rendered in alpha test mode
  79079. * @returns false as the sky material doesn't need alpha testing.
  79080. */
  79081. needAlphaTesting(): boolean;
  79082. /**
  79083. * Get the texture used for alpha test purpose.
  79084. * @returns null as the sky material has no texture.
  79085. */
  79086. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  79087. /**
  79088. * Get if the submesh is ready to be used and all its information available.
  79089. * Child classes can use it to update shaders
  79090. * @param mesh defines the mesh to check
  79091. * @param subMesh defines which submesh to check
  79092. * @param useInstances specifies that instances should be used
  79093. * @returns a boolean indicating that the submesh is ready or not
  79094. */
  79095. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  79096. /**
  79097. * Binds the submesh to this material by preparing the effect and shader to draw
  79098. * @param world defines the world transformation matrix
  79099. * @param mesh defines the mesh containing the submesh
  79100. * @param subMesh defines the submesh to bind the material to
  79101. */
  79102. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  79103. /**
  79104. * Get the list of animatables in the material.
  79105. * @returns the list of animatables object used in the material
  79106. */
  79107. getAnimatables(): BABYLON.IAnimatable[];
  79108. /**
  79109. * Disposes the material
  79110. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  79111. */
  79112. dispose(forceDisposeEffect?: boolean): void;
  79113. /**
  79114. * Makes a duplicate of the material, and gives it a new name
  79115. * @param name defines the new name for the duplicated material
  79116. * @returns the cloned material
  79117. */
  79118. clone(name: string): SkyMaterial;
  79119. /**
  79120. * Serializes this material in a JSON representation
  79121. * @returns the serialized material object
  79122. */
  79123. serialize(): any;
  79124. /**
  79125. * Gets the current class name of the material e.g. "SkyMaterial"
  79126. * Mainly use in serialization.
  79127. * @returns the class name
  79128. */
  79129. getClassName(): string;
  79130. /**
  79131. * Creates a sky material from parsed material data
  79132. * @param source defines the JSON representation of the material
  79133. * @param scene defines the hosting scene
  79134. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  79135. * @returns a new sky material
  79136. */
  79137. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  79138. }
  79139. }
  79140. declare module BABYLON {
  79141. /** @hidden */
  79142. export var terrainPixelShader: {
  79143. name: string;
  79144. shader: string;
  79145. };
  79146. }
  79147. declare module BABYLON {
  79148. /** @hidden */
  79149. export var terrainVertexShader: {
  79150. name: string;
  79151. shader: string;
  79152. };
  79153. }
  79154. declare module BABYLON {
  79155. export class TerrainMaterial extends BABYLON.PushMaterial {
  79156. private _mixTexture;
  79157. mixTexture: BABYLON.BaseTexture;
  79158. private _diffuseTexture1;
  79159. diffuseTexture1: BABYLON.Texture;
  79160. private _diffuseTexture2;
  79161. diffuseTexture2: BABYLON.Texture;
  79162. private _diffuseTexture3;
  79163. diffuseTexture3: BABYLON.Texture;
  79164. private _bumpTexture1;
  79165. bumpTexture1: BABYLON.Texture;
  79166. private _bumpTexture2;
  79167. bumpTexture2: BABYLON.Texture;
  79168. private _bumpTexture3;
  79169. bumpTexture3: BABYLON.Texture;
  79170. diffuseColor: BABYLON.Color3;
  79171. specularColor: BABYLON.Color3;
  79172. specularPower: number;
  79173. private _disableLighting;
  79174. disableLighting: boolean;
  79175. private _maxSimultaneousLights;
  79176. maxSimultaneousLights: number;
  79177. private _renderId;
  79178. constructor(name: string, scene: BABYLON.Scene);
  79179. needAlphaBlending(): boolean;
  79180. needAlphaTesting(): boolean;
  79181. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  79182. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  79183. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  79184. getAnimatables(): BABYLON.IAnimatable[];
  79185. getActiveTextures(): BABYLON.BaseTexture[];
  79186. hasTexture(texture: BABYLON.BaseTexture): boolean;
  79187. dispose(forceDisposeEffect?: boolean): void;
  79188. clone(name: string): TerrainMaterial;
  79189. serialize(): any;
  79190. getClassName(): string;
  79191. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  79192. }
  79193. }
  79194. declare module BABYLON {
  79195. /** @hidden */
  79196. export var triplanarPixelShader: {
  79197. name: string;
  79198. shader: string;
  79199. };
  79200. }
  79201. declare module BABYLON {
  79202. /** @hidden */
  79203. export var triplanarVertexShader: {
  79204. name: string;
  79205. shader: string;
  79206. };
  79207. }
  79208. declare module BABYLON {
  79209. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  79210. mixTexture: BABYLON.BaseTexture;
  79211. private _diffuseTextureX;
  79212. diffuseTextureX: BABYLON.BaseTexture;
  79213. private _diffuseTextureY;
  79214. diffuseTextureY: BABYLON.BaseTexture;
  79215. private _diffuseTextureZ;
  79216. diffuseTextureZ: BABYLON.BaseTexture;
  79217. private _normalTextureX;
  79218. normalTextureX: BABYLON.BaseTexture;
  79219. private _normalTextureY;
  79220. normalTextureY: BABYLON.BaseTexture;
  79221. private _normalTextureZ;
  79222. normalTextureZ: BABYLON.BaseTexture;
  79223. tileSize: number;
  79224. diffuseColor: BABYLON.Color3;
  79225. specularColor: BABYLON.Color3;
  79226. specularPower: number;
  79227. private _disableLighting;
  79228. disableLighting: boolean;
  79229. private _maxSimultaneousLights;
  79230. maxSimultaneousLights: number;
  79231. private _renderId;
  79232. constructor(name: string, scene: BABYLON.Scene);
  79233. needAlphaBlending(): boolean;
  79234. needAlphaTesting(): boolean;
  79235. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  79236. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  79237. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  79238. getAnimatables(): BABYLON.IAnimatable[];
  79239. getActiveTextures(): BABYLON.BaseTexture[];
  79240. hasTexture(texture: BABYLON.BaseTexture): boolean;
  79241. dispose(forceDisposeEffect?: boolean): void;
  79242. clone(name: string): TriPlanarMaterial;
  79243. serialize(): any;
  79244. getClassName(): string;
  79245. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  79246. }
  79247. }
  79248. declare module BABYLON {
  79249. /** @hidden */
  79250. export var waterPixelShader: {
  79251. name: string;
  79252. shader: string;
  79253. };
  79254. }
  79255. declare module BABYLON {
  79256. /** @hidden */
  79257. export var waterVertexShader: {
  79258. name: string;
  79259. shader: string;
  79260. };
  79261. }
  79262. declare module BABYLON {
  79263. export class WaterMaterial extends BABYLON.PushMaterial {
  79264. renderTargetSize: BABYLON.Vector2;
  79265. private _bumpTexture;
  79266. bumpTexture: BABYLON.BaseTexture;
  79267. diffuseColor: BABYLON.Color3;
  79268. specularColor: BABYLON.Color3;
  79269. specularPower: number;
  79270. private _disableLighting;
  79271. disableLighting: boolean;
  79272. private _maxSimultaneousLights;
  79273. maxSimultaneousLights: number;
  79274. /**
  79275. * @param {number}: Represents the wind force
  79276. */
  79277. windForce: number;
  79278. /**
  79279. * @param {Vector2}: The direction of the wind in the plane (X, Z)
  79280. */
  79281. windDirection: BABYLON.Vector2;
  79282. /**
  79283. * @param {number}: Wave height, represents the height of the waves
  79284. */
  79285. waveHeight: number;
  79286. /**
  79287. * @param {number}: Bump height, represents the bump height related to the bump map
  79288. */
  79289. bumpHeight: number;
  79290. /**
  79291. * @param {boolean}: Add a smaller moving bump to less steady waves.
  79292. */
  79293. private _bumpSuperimpose;
  79294. bumpSuperimpose: boolean;
  79295. /**
  79296. * @param {boolean}: Color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  79297. */
  79298. private _fresnelSeparate;
  79299. fresnelSeparate: boolean;
  79300. /**
  79301. * @param {boolean}: bump Waves modify the reflection.
  79302. */
  79303. private _bumpAffectsReflection;
  79304. bumpAffectsReflection: boolean;
  79305. /**
  79306. * @param {number}: The water color blended with the refraction (near)
  79307. */
  79308. waterColor: BABYLON.Color3;
  79309. /**
  79310. * @param {number}: The blend factor related to the water color
  79311. */
  79312. colorBlendFactor: number;
  79313. /**
  79314. * @param {number}: The water color blended with the reflection (far)
  79315. */
  79316. waterColor2: BABYLON.Color3;
  79317. /**
  79318. * @param {number}: The blend factor related to the water color (reflection, far)
  79319. */
  79320. colorBlendFactor2: number;
  79321. /**
  79322. * @param {number}: Represents the maximum length of a wave
  79323. */
  79324. waveLength: number;
  79325. /**
  79326. * @param {number}: Defines the waves speed
  79327. */
  79328. waveSpeed: number;
  79329. /**
  79330. * Sets or gets whether or not automatic clipping should be enabled or not. Setting to true will save performances and
  79331. * will avoid calculating useless pixels in the pixel shader of the water material.
  79332. */
  79333. disableClipPlane: boolean;
  79334. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  79335. private _mesh;
  79336. private _refractionRTT;
  79337. private _reflectionRTT;
  79338. private _reflectionTransform;
  79339. private _lastTime;
  79340. private _lastDeltaTime;
  79341. private _renderId;
  79342. private _useLogarithmicDepth;
  79343. private _waitingRenderList;
  79344. private _imageProcessingConfiguration;
  79345. private _imageProcessingObserver;
  79346. /**
  79347. * Gets a boolean indicating that current material needs to register RTT
  79348. */
  79349. get hasRenderTargetTextures(): boolean;
  79350. /**
  79351. * Constructor
  79352. */
  79353. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  79354. get useLogarithmicDepth(): boolean;
  79355. set useLogarithmicDepth(value: boolean);
  79356. get refractionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  79357. get reflectionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  79358. addToRenderList(node: any): void;
  79359. enableRenderTargets(enable: boolean): void;
  79360. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  79361. get renderTargetsEnabled(): boolean;
  79362. needAlphaBlending(): boolean;
  79363. needAlphaTesting(): boolean;
  79364. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  79365. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  79366. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  79367. private _createRenderTargets;
  79368. getAnimatables(): BABYLON.IAnimatable[];
  79369. getActiveTextures(): BABYLON.BaseTexture[];
  79370. hasTexture(texture: BABYLON.BaseTexture): boolean;
  79371. dispose(forceDisposeEffect?: boolean): void;
  79372. clone(name: string): WaterMaterial;
  79373. serialize(): any;
  79374. getClassName(): string;
  79375. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  79376. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  79377. }
  79378. }
  79379. declare module BABYLON {
  79380. /** @hidden */
  79381. export var asciiartPixelShader: {
  79382. name: string;
  79383. shader: string;
  79384. };
  79385. }
  79386. declare module BABYLON {
  79387. /**
  79388. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  79389. *
  79390. * It basically takes care rendering the font front the given font size to a texture.
  79391. * This is used later on in the postprocess.
  79392. */
  79393. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  79394. private _font;
  79395. private _text;
  79396. private _charSize;
  79397. /**
  79398. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  79399. */
  79400. get charSize(): number;
  79401. /**
  79402. * Create a new instance of the Ascii Art FontTexture class
  79403. * @param name the name of the texture
  79404. * @param font the font to use, use the W3C CSS notation
  79405. * @param text the caracter set to use in the rendering.
  79406. * @param scene the scene that owns the texture
  79407. */
  79408. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  79409. /**
  79410. * Gets the max char width of a font.
  79411. * @param font the font to use, use the W3C CSS notation
  79412. * @return the max char width
  79413. */
  79414. private getFontWidth;
  79415. /**
  79416. * Gets the max char height of a font.
  79417. * @param font the font to use, use the W3C CSS notation
  79418. * @return the max char height
  79419. */
  79420. private getFontHeight;
  79421. /**
  79422. * Clones the current AsciiArtTexture.
  79423. * @return the clone of the texture.
  79424. */
  79425. clone(): AsciiArtFontTexture;
  79426. /**
  79427. * Parses a json object representing the texture and returns an instance of it.
  79428. * @param source the source JSON representation
  79429. * @param scene the scene to create the texture for
  79430. * @return the parsed texture
  79431. */
  79432. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  79433. }
  79434. /**
  79435. * Option available in the Ascii Art Post Process.
  79436. */
  79437. export interface IAsciiArtPostProcessOptions {
  79438. /**
  79439. * The font to use following the w3c font definition.
  79440. */
  79441. font?: string;
  79442. /**
  79443. * The character set to use in the postprocess.
  79444. */
  79445. characterSet?: string;
  79446. /**
  79447. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  79448. * This number is defined between 0 and 1;
  79449. */
  79450. mixToTile?: number;
  79451. /**
  79452. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  79453. * This number is defined between 0 and 1;
  79454. */
  79455. mixToNormal?: number;
  79456. }
  79457. /**
  79458. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  79459. *
  79460. * Simmply add it to your scene and let the nerd that lives in you have fun.
  79461. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  79462. */
  79463. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  79464. /**
  79465. * The font texture used to render the char in the post process.
  79466. */
  79467. private _asciiArtFontTexture;
  79468. /**
  79469. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  79470. * This number is defined between 0 and 1;
  79471. */
  79472. mixToTile: number;
  79473. /**
  79474. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  79475. * This number is defined between 0 and 1;
  79476. */
  79477. mixToNormal: number;
  79478. /**
  79479. * Instantiates a new Ascii Art Post Process.
  79480. * @param name the name to give to the postprocess
  79481. * @camera the camera to apply the post process to.
  79482. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  79483. */
  79484. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  79485. }
  79486. }
  79487. declare module BABYLON {
  79488. /** @hidden */
  79489. export var digitalrainPixelShader: {
  79490. name: string;
  79491. shader: string;
  79492. };
  79493. }
  79494. declare module BABYLON {
  79495. /**
  79496. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  79497. *
  79498. * It basically takes care rendering the font front the given font size to a texture.
  79499. * This is used later on in the postprocess.
  79500. */
  79501. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  79502. private _font;
  79503. private _text;
  79504. private _charSize;
  79505. /**
  79506. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  79507. */
  79508. get charSize(): number;
  79509. /**
  79510. * Create a new instance of the Digital Rain FontTexture class
  79511. * @param name the name of the texture
  79512. * @param font the font to use, use the W3C CSS notation
  79513. * @param text the caracter set to use in the rendering.
  79514. * @param scene the scene that owns the texture
  79515. */
  79516. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  79517. /**
  79518. * Gets the max char width of a font.
  79519. * @param font the font to use, use the W3C CSS notation
  79520. * @return the max char width
  79521. */
  79522. private getFontWidth;
  79523. /**
  79524. * Gets the max char height of a font.
  79525. * @param font the font to use, use the W3C CSS notation
  79526. * @return the max char height
  79527. */
  79528. private getFontHeight;
  79529. /**
  79530. * Clones the current DigitalRainFontTexture.
  79531. * @return the clone of the texture.
  79532. */
  79533. clone(): DigitalRainFontTexture;
  79534. /**
  79535. * Parses a json object representing the texture and returns an instance of it.
  79536. * @param source the source JSON representation
  79537. * @param scene the scene to create the texture for
  79538. * @return the parsed texture
  79539. */
  79540. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  79541. }
  79542. /**
  79543. * Option available in the Digital Rain Post Process.
  79544. */
  79545. export interface IDigitalRainPostProcessOptions {
  79546. /**
  79547. * The font to use following the w3c font definition.
  79548. */
  79549. font?: string;
  79550. /**
  79551. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  79552. * This number is defined between 0 and 1;
  79553. */
  79554. mixToTile?: number;
  79555. /**
  79556. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  79557. * This number is defined between 0 and 1;
  79558. */
  79559. mixToNormal?: number;
  79560. }
  79561. /**
  79562. * DigitalRainPostProcess helps rendering everithing in digital rain.
  79563. *
  79564. * Simmply add it to your scene and let the nerd that lives in you have fun.
  79565. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  79566. */
  79567. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  79568. /**
  79569. * The font texture used to render the char in the post process.
  79570. */
  79571. private _digitalRainFontTexture;
  79572. /**
  79573. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  79574. * This number is defined between 0 and 1;
  79575. */
  79576. mixToTile: number;
  79577. /**
  79578. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  79579. * This number is defined between 0 and 1;
  79580. */
  79581. mixToNormal: number;
  79582. /**
  79583. * Instantiates a new Digital Rain Post Process.
  79584. * @param name the name to give to the postprocess
  79585. * @camera the camera to apply the post process to.
  79586. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  79587. */
  79588. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  79589. }
  79590. }
  79591. declare module BABYLON {
  79592. /** @hidden */
  79593. export var brickProceduralTexturePixelShader: {
  79594. name: string;
  79595. shader: string;
  79596. };
  79597. }
  79598. declare module BABYLON {
  79599. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  79600. private _numberOfBricksHeight;
  79601. private _numberOfBricksWidth;
  79602. private _jointColor;
  79603. private _brickColor;
  79604. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  79605. updateShaderUniforms(): void;
  79606. get numberOfBricksHeight(): number;
  79607. set numberOfBricksHeight(value: number);
  79608. get numberOfBricksWidth(): number;
  79609. set numberOfBricksWidth(value: number);
  79610. get jointColor(): BABYLON.Color3;
  79611. set jointColor(value: BABYLON.Color3);
  79612. get brickColor(): BABYLON.Color3;
  79613. set brickColor(value: BABYLON.Color3);
  79614. /**
  79615. * Serializes this brick procedural texture
  79616. * @returns a serialized brick procedural texture object
  79617. */
  79618. serialize(): any;
  79619. /**
  79620. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  79621. * @param parsedTexture defines parsed texture data
  79622. * @param scene defines the current scene
  79623. * @param rootUrl defines the root URL containing brick procedural texture information
  79624. * @returns a parsed Brick Procedural BABYLON.Texture
  79625. */
  79626. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  79627. }
  79628. }
  79629. declare module BABYLON {
  79630. /** @hidden */
  79631. export var cloudProceduralTexturePixelShader: {
  79632. name: string;
  79633. shader: string;
  79634. };
  79635. }
  79636. declare module BABYLON {
  79637. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  79638. private _skyColor;
  79639. private _cloudColor;
  79640. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  79641. updateShaderUniforms(): void;
  79642. get skyColor(): BABYLON.Color4;
  79643. set skyColor(value: BABYLON.Color4);
  79644. get cloudColor(): BABYLON.Color4;
  79645. set cloudColor(value: BABYLON.Color4);
  79646. /**
  79647. * Serializes this cloud procedural texture
  79648. * @returns a serialized cloud procedural texture object
  79649. */
  79650. serialize(): any;
  79651. /**
  79652. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  79653. * @param parsedTexture defines parsed texture data
  79654. * @param scene defines the current scene
  79655. * @param rootUrl defines the root URL containing cloud procedural texture information
  79656. * @returns a parsed Cloud Procedural BABYLON.Texture
  79657. */
  79658. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  79659. }
  79660. }
  79661. declare module BABYLON {
  79662. /** @hidden */
  79663. export var fireProceduralTexturePixelShader: {
  79664. name: string;
  79665. shader: string;
  79666. };
  79667. }
  79668. declare module BABYLON {
  79669. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  79670. private _time;
  79671. private _speed;
  79672. private _autoGenerateTime;
  79673. private _fireColors;
  79674. private _alphaThreshold;
  79675. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  79676. updateShaderUniforms(): void;
  79677. render(useCameraPostProcess?: boolean): void;
  79678. static get PurpleFireColors(): BABYLON.Color3[];
  79679. static get GreenFireColors(): BABYLON.Color3[];
  79680. static get RedFireColors(): BABYLON.Color3[];
  79681. static get BlueFireColors(): BABYLON.Color3[];
  79682. get autoGenerateTime(): boolean;
  79683. set autoGenerateTime(value: boolean);
  79684. get fireColors(): BABYLON.Color3[];
  79685. set fireColors(value: BABYLON.Color3[]);
  79686. get time(): number;
  79687. set time(value: number);
  79688. get speed(): BABYLON.Vector2;
  79689. set speed(value: BABYLON.Vector2);
  79690. get alphaThreshold(): number;
  79691. set alphaThreshold(value: number);
  79692. /**
  79693. * Serializes this fire procedural texture
  79694. * @returns a serialized fire procedural texture object
  79695. */
  79696. serialize(): any;
  79697. /**
  79698. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  79699. * @param parsedTexture defines parsed texture data
  79700. * @param scene defines the current scene
  79701. * @param rootUrl defines the root URL containing fire procedural texture information
  79702. * @returns a parsed Fire Procedural BABYLON.Texture
  79703. */
  79704. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  79705. }
  79706. }
  79707. declare module BABYLON {
  79708. /** @hidden */
  79709. export var grassProceduralTexturePixelShader: {
  79710. name: string;
  79711. shader: string;
  79712. };
  79713. }
  79714. declare module BABYLON {
  79715. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  79716. private _grassColors;
  79717. private _groundColor;
  79718. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  79719. updateShaderUniforms(): void;
  79720. get grassColors(): BABYLON.Color3[];
  79721. set grassColors(value: BABYLON.Color3[]);
  79722. get groundColor(): BABYLON.Color3;
  79723. set groundColor(value: BABYLON.Color3);
  79724. /**
  79725. * Serializes this grass procedural texture
  79726. * @returns a serialized grass procedural texture object
  79727. */
  79728. serialize(): any;
  79729. /**
  79730. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  79731. * @param parsedTexture defines parsed texture data
  79732. * @param scene defines the current scene
  79733. * @param rootUrl defines the root URL containing grass procedural texture information
  79734. * @returns a parsed Grass Procedural BABYLON.Texture
  79735. */
  79736. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  79737. }
  79738. }
  79739. declare module BABYLON {
  79740. /** @hidden */
  79741. export var marbleProceduralTexturePixelShader: {
  79742. name: string;
  79743. shader: string;
  79744. };
  79745. }
  79746. declare module BABYLON {
  79747. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  79748. private _numberOfTilesHeight;
  79749. private _numberOfTilesWidth;
  79750. private _amplitude;
  79751. private _jointColor;
  79752. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  79753. updateShaderUniforms(): void;
  79754. get numberOfTilesHeight(): number;
  79755. set numberOfTilesHeight(value: number);
  79756. get amplitude(): number;
  79757. set amplitude(value: number);
  79758. get numberOfTilesWidth(): number;
  79759. set numberOfTilesWidth(value: number);
  79760. get jointColor(): BABYLON.Color3;
  79761. set jointColor(value: BABYLON.Color3);
  79762. /**
  79763. * Serializes this marble procedural texture
  79764. * @returns a serialized marble procedural texture object
  79765. */
  79766. serialize(): any;
  79767. /**
  79768. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  79769. * @param parsedTexture defines parsed texture data
  79770. * @param scene defines the current scene
  79771. * @param rootUrl defines the root URL containing marble procedural texture information
  79772. * @returns a parsed Marble Procedural BABYLON.Texture
  79773. */
  79774. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  79775. }
  79776. }
  79777. declare module BABYLON {
  79778. /** @hidden */
  79779. export var normalMapProceduralTexturePixelShader: {
  79780. name: string;
  79781. shader: string;
  79782. };
  79783. }
  79784. declare module BABYLON {
  79785. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  79786. private _baseTexture;
  79787. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  79788. updateShaderUniforms(): void;
  79789. render(useCameraPostProcess?: boolean): void;
  79790. resize(size: any, generateMipMaps: any): void;
  79791. get baseTexture(): BABYLON.Texture;
  79792. set baseTexture(texture: BABYLON.Texture);
  79793. /**
  79794. * Serializes this normal map procedural texture
  79795. * @returns a serialized normal map procedural texture object
  79796. */
  79797. serialize(): any;
  79798. /**
  79799. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  79800. * @param parsedTexture defines parsed texture data
  79801. * @param scene defines the current scene
  79802. * @param rootUrl defines the root URL containing normal map procedural texture information
  79803. * @returns a parsed Normal Map Procedural BABYLON.Texture
  79804. */
  79805. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  79806. }
  79807. }
  79808. declare module BABYLON {
  79809. /** @hidden */
  79810. export var perlinNoiseProceduralTexturePixelShader: {
  79811. name: string;
  79812. shader: string;
  79813. };
  79814. }
  79815. declare module BABYLON {
  79816. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  79817. time: number;
  79818. timeScale: number;
  79819. translationSpeed: number;
  79820. private _currentTranslation;
  79821. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  79822. updateShaderUniforms(): void;
  79823. render(useCameraPostProcess?: boolean): void;
  79824. resize(size: any, generateMipMaps: any): void;
  79825. /**
  79826. * Serializes this perlin noise procedural texture
  79827. * @returns a serialized perlin noise procedural texture object
  79828. */
  79829. serialize(): any;
  79830. /**
  79831. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  79832. * @param parsedTexture defines parsed texture data
  79833. * @param scene defines the current scene
  79834. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  79835. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  79836. */
  79837. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  79838. }
  79839. }
  79840. declare module BABYLON {
  79841. /** @hidden */
  79842. export var roadProceduralTexturePixelShader: {
  79843. name: string;
  79844. shader: string;
  79845. };
  79846. }
  79847. declare module BABYLON {
  79848. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  79849. private _roadColor;
  79850. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  79851. updateShaderUniforms(): void;
  79852. get roadColor(): BABYLON.Color3;
  79853. set roadColor(value: BABYLON.Color3);
  79854. /**
  79855. * Serializes this road procedural texture
  79856. * @returns a serialized road procedural texture object
  79857. */
  79858. serialize(): any;
  79859. /**
  79860. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  79861. * @param parsedTexture defines parsed texture data
  79862. * @param scene defines the current scene
  79863. * @param rootUrl defines the root URL containing road procedural texture information
  79864. * @returns a parsed Road Procedural BABYLON.Texture
  79865. */
  79866. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  79867. }
  79868. }
  79869. declare module BABYLON {
  79870. /** @hidden */
  79871. export var starfieldProceduralTexturePixelShader: {
  79872. name: string;
  79873. shader: string;
  79874. };
  79875. }
  79876. declare module BABYLON {
  79877. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  79878. private _time;
  79879. private _alpha;
  79880. private _beta;
  79881. private _zoom;
  79882. private _formuparam;
  79883. private _stepsize;
  79884. private _tile;
  79885. private _brightness;
  79886. private _darkmatter;
  79887. private _distfading;
  79888. private _saturation;
  79889. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  79890. updateShaderUniforms(): void;
  79891. get time(): number;
  79892. set time(value: number);
  79893. get alpha(): number;
  79894. set alpha(value: number);
  79895. get beta(): number;
  79896. set beta(value: number);
  79897. get formuparam(): number;
  79898. set formuparam(value: number);
  79899. get stepsize(): number;
  79900. set stepsize(value: number);
  79901. get zoom(): number;
  79902. set zoom(value: number);
  79903. get tile(): number;
  79904. set tile(value: number);
  79905. get brightness(): number;
  79906. set brightness(value: number);
  79907. get darkmatter(): number;
  79908. set darkmatter(value: number);
  79909. get distfading(): number;
  79910. set distfading(value: number);
  79911. get saturation(): number;
  79912. set saturation(value: number);
  79913. /**
  79914. * Serializes this starfield procedural texture
  79915. * @returns a serialized starfield procedural texture object
  79916. */
  79917. serialize(): any;
  79918. /**
  79919. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  79920. * @param parsedTexture defines parsed texture data
  79921. * @param scene defines the current scene
  79922. * @param rootUrl defines the root URL containing startfield procedural texture information
  79923. * @returns a parsed Starfield Procedural BABYLON.Texture
  79924. */
  79925. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  79926. }
  79927. }
  79928. declare module BABYLON {
  79929. /** @hidden */
  79930. export var woodProceduralTexturePixelShader: {
  79931. name: string;
  79932. shader: string;
  79933. };
  79934. }
  79935. declare module BABYLON {
  79936. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  79937. private _ampScale;
  79938. private _woodColor;
  79939. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  79940. updateShaderUniforms(): void;
  79941. get ampScale(): number;
  79942. set ampScale(value: number);
  79943. get woodColor(): BABYLON.Color3;
  79944. set woodColor(value: BABYLON.Color3);
  79945. /**
  79946. * Serializes this wood procedural texture
  79947. * @returns a serialized wood procedural texture object
  79948. */
  79949. serialize(): any;
  79950. /**
  79951. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  79952. * @param parsedTexture defines parsed texture data
  79953. * @param scene defines the current scene
  79954. * @param rootUrl defines the root URL containing wood procedural texture information
  79955. * @returns a parsed Wood Procedural BABYLON.Texture
  79956. */
  79957. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  79958. }
  79959. }